1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00

more changes due to move of map root

This commit is contained in:
George Hunt 2019-04-08 23:39:17 +01:00
parent 591ad02d5f
commit a1f5dab6ce
3 changed files with 25 additions and 10 deletions

View file

@ -4,7 +4,7 @@
"automatically_generated": "true", "automatically_generated": "true",
"title": "OpenStreetMap Test Page", "title": "OpenStreetMap Test Page",
"extra_html": "", "extra_html": "",
"start_url": "assets", "start_url": "maplist",
"menu_item_name": "en-map_test.json", "menu_item_name": "en-map_test.json",
"map_name": "en-map_test", "map_name": "en-map_test",
"logo_url": "osm.jpg", "logo_url": "osm.jpg",

View file

@ -82,9 +82,15 @@
src: test-index.redirect src: test-index.redirect
dest: "{{ osm_vector_path }}/index.html" dest: "{{ osm_vector_path }}/index.html"
- name: Create a directory for map menu-def
file:
path: '{{ menu_def_dir }}'
state: directory
- name: Determine status of splash menu def - name: Determine status of splash menu def
stat: stat:
path: '{{ menu_def_dir }}/en-map_test.json' path: '{{ menu_def_dir }}/en-map_test.json'
ignore_errors: True
register: menu_def register: menu_def
- name: Do not overwrite if it already exists - name: Do not overwrite if it already exists

View file

@ -17,7 +17,11 @@ from iiab_env import get_iiab_env
SCRIPT_DIR = '/opt/admin/cmdsrv/scripts' SCRIPT_DIR = '/opt/admin/cmdsrv/scripts'
if not SCRIPT_DIR in sys.path: if not SCRIPT_DIR in sys.path:
sys.path.append(SCRIPT_DIR) sys.path.append(SCRIPT_DIR)
import iiab_update_menus as menus if os.path.exists(os.path.join(SCRIPT_DIR,'iiab_update_menus.py')):
import iiab_update_menus as menus
console_installed = True
else:
console_installed = False
doc_root = get_iiab_env('WWWROOT') doc_root = get_iiab_env('WWWROOT')
menuDefs = doc_root + "/js-menu/menu-files/menu-defs/" menuDefs = doc_root + "/js-menu/menu-files/menu-defs/"
@ -29,22 +33,26 @@ map_catalog = {}
map_menu_def_list = [] map_menu_def_list = []
def main(): def main():
global map_menu_defs global map_menu_def_list
get_map_catalog() get_map_catalog()
#print(json.dumps(map_catalog,indent=2)) #print(json.dumps(map_catalog,indent=2))
map_menu_def_list = get_menu_def_names() map_menu_def_list = get_menu_def_names()
#print(json.dumps(map_menu_defs,indent=2)) print(json.dumps(map_menu_def_list,indent=2))
installed_maps = get_installed_regions() installed_maps = get_installed_regions()
print(installed_maps) print(installed_maps)
write_osm_vector_idx(installed_maps) write_osm_vector_idx(installed_maps)
for region in installed_maps: for region in installed_maps:
#print('checking for %s region'%region) print('checking for %s region'%region)
if region != 'assets': if region != 'maplist':
item = map_catalog['regions'][region] item = map_catalog['regions'][region]
menu_ref = item['perma_ref'] menu_ref = item['perma_ref']
else: else:
menu_ref = 'en-map_test' menu_ref = 'en-map_test'
if region != 'assets' and not (region in map_menu_def_list): item = { "perma_ref" : "en-map_test" }
if region != 'maplist' and not (region in map_menu_def_list):
print('creating menu def for %s'%item['perma_ref']) print('creating menu def for %s'%item['perma_ref'])
create_menu_def(region,item['perma_ref'] + '.json') create_menu_def(region,item['perma_ref'] + '.json')
if fetch_menu_json_value('autoupdate_menu'): if fetch_menu_json_value('autoupdate_menu'):
@ -90,14 +98,14 @@ def get_installed_regions():
installed.append(region) installed.append(region)
# add the splash page if no other maps are present # add the splash page if no other maps are present
if len(installed) == 0: if len(installed) == 0:
installed.append('assets') installed.append('maplist')
return installed return installed
def write_osm_vector_idx(installed_maps): def write_osm_vector_idx(installed_maps):
map_dict ={} map_dict ={}
map_dict['regions'] = {} map_dict['regions'] = {}
for map in installed_maps: for map in installed_maps:
if map == 'assets': continue # not a real region if map == 'maplist': continue # not a real region
data_dict = map_catalog['regions'].get(map,'') data_dict = map_catalog['regions'].get(map,'')
map_dict['regions'][map] = data_dict map_dict['regions'][map] = data_dict
with open(osm_vector_idx_dir + '/osm-vector-idx.json','w') as idx: with open(osm_vector_idx_dir + '/osm-vector-idx.json','w') as idx:
@ -150,4 +158,5 @@ def fetch_menu_json_value(key):
if __name__ == '__main__': if __name__ == '__main__':
if console_installed:
main() main()