-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e4bddc
commit e83b909
Showing
6 changed files
with
151 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from webmap_lib import * | ||
import argparse | ||
|
||
# create a --development flag: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--development', action='store_true') | ||
args = parser.parse_args() | ||
|
||
in_dev = args.development | ||
|
||
# first, reading the parameters | ||
params = read_json(webmap_params_original_path) | ||
|
||
# then override: (TODO) | ||
|
||
# # generating the "sources" and layernames: | ||
params.update(get_sources(only_urls=True)) | ||
sources = get_sources()['sources'] | ||
|
||
|
||
# reading the base html | ||
webmap_html = file_as_string(webmap_base_path) | ||
|
||
# doing other stuff like insertions and nasty things (TODO): | ||
|
||
# finally generate the files: | ||
str_to_file(webmap_html,webmap_path) | ||
dump_json(params,webmap_params_path) | ||
|
||
# if we are in dev mode, also dump the original params: | ||
if in_dev: | ||
dump_json(params,webmap_params_original_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sys | ||
sys.path.append('oswm_codebase') | ||
from functions import * | ||
|
||
# mapping geometry types to maplibre style | ||
map_geom_type_mapping = { | ||
'Polygon':'fill', | ||
'LineString':'line', | ||
'Point':'circle', | ||
'MultiPolygon':'fill', | ||
'MultiLineString':'line', | ||
'MultiPoint':'circle' | ||
} | ||
layertypes_dict = { k: map_geom_type_mapping[v] for k,v in all_layers_geom_types.items() } | ||
|
||
def get_sources(terrain_url=None,only_urls=False): | ||
ret = {} | ||
ret['sources'] = {} | ||
|
||
for layername in paths_dict['map_layers']: | ||
ret[f'{layername}_url'] = f'{node_homepage_url}data/tiles/{layername}.pmtiles' | ||
|
||
ret['sources'][f'oswm_pmtiles_{layername}'] = { | ||
"type": "vector", | ||
"url": f"pmtiles://{ret[f'{layername}_url']}", | ||
"promoteId":"id", | ||
"attribution": '© <a href="https://openstreetmap.org">OpenStreetMap Contributors</a>'} | ||
|
||
ret['boundaries_url'] = f'{node_homepage_url}data/boundaries.geojson' | ||
|
||
|
||
# basemap: | ||
ret['sources']['osm'] = { | ||
"type": "raster", | ||
"tiles": [BASEMAP_URL], | ||
} | ||
|
||
# boundaries: | ||
ret['sources']['boundaries'] = { | ||
"type": "geojson", | ||
"data": ret['boundaries_url'] | ||
} | ||
|
||
if terrain_url: | ||
# # # terrain: | ||
ret['sources']['terrain'] = { | ||
"type": "raster-dem", | ||
"url": terrain_url, | ||
"tileSize": 256 | ||
} | ||
|
||
if only_urls: | ||
del ret['sources'] | ||
return ret | ||
else: | ||
return ret |