feat: archive CW-033 deployed sign map prototype v0.1.0
This commit is contained in:
commit
2f1c437a55
17 files changed
+1562
No files matched your search
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render the captured map from validated normalized data. No credentials are bundled by default."""
|
||||
import argparse,json,os,pathlib
|
||||
ROOT=pathlib.Path(__file__).resolve().parents[1]
|
||||
p=argparse.ArgumentParser();p.add_argument('--data',type=pathlib.Path,required=True);p.add_argument('--output',type=pathlib.Path,required=True);p.add_argument('--include-carto-key',action='store_true');a=p.parse_args()
|
||||
s=(ROOT/'templates/map.html').read_text();key=os.environ.get('RTC_CARTO_BASEMAP_KEY','') if a.include_carto_key else ''
|
||||
# Retain the prototype's RTC-specific UI; this renderer does not claim multi-agency support.
|
||||
s=s.replace('const CARTO_BASEMAP_KEY=','let CARTO_BASEMAP_KEY=')
|
||||
s=s.replace("baseMode=mode;$('basemap').value=mode;","if(mode.startsWith('positron')&&!CARTO_BASEMAP_KEY){const k=window.prompt('Enter your CARTO basemap key (kept in this tab only):');if(!k){$('basemap').value=baseMode;return;}CARTO_BASEMAP_KEY=k.trim();}baseMode=mode;$('basemap').value=mode;")
|
||||
if not key:
|
||||
s=s.replace("let savedBase='positron';","let savedBase='esri';").replace("||savedBase}catch{}setBasemap(","||savedBase}catch{}if(savedBase.startsWith('positron')&&!CARTO_BASEMAP_KEY)savedBase='esri';setBasemap(")
|
||||
files={'/*LEAFLET_CSS*/':'leaflet.css','/*MAPLIBRE_CSS*/':'maplibre-gl.css','/*LEAFLET_JS*/':'leaflet.js','/*MAPLIBRE_JS*/':'maplibre-gl.js','/*MAPLIBRE_LEAFLET_JS*/':'leaflet-maplibre-gl.js'}
|
||||
for token,name in files.items():s=s.replace(token,(ROOT/'vendor'/name).read_text().replace('</script>','<\\/script>'))
|
||||
s=s.replace('/*DATA*/',json.dumps(json.loads(a.data.read_text()),separators=(',',':')).replace('</script>','<\\/script>')).replace('/*CARTO_KEY*/',json.dumps(key))
|
||||
a.output.parent.mkdir(parents=True,exist_ok=True);a.output.write_text(s);print('Rendered',a.output,'with embedded CARTO key' if key else 'without embedded credentials')
|
||||
Reference in new issue
Block a user