diff --git a/roles/osm-vector/tasks/main.yml b/roles/osm-vector/tasks/main.yml index 1de06f43a..0351692c9 100644 --- a/roles/osm-vector/tasks/main.yml +++ b/roles/osm-vector/tasks/main.yml @@ -3,11 +3,16 @@ url: "{{ iiab_maps_url }}/map.js" dest: "{{ doc_root }}/common/assets/" -- name: Fetch the bounding box description for maps +- name: Fetch the catalog for maps get_url: url: "{{ iiab_maps_url }}/regions.json" dest: "{{ iiab_dir }}/regions.json" +- name: Fetch the bounding box description for maps + get_url: + url: "{{ iiab_maps_url }}/bboxes.geojson" + dest: "{{ doc_root }}/common/assets/bboxes.geojson" + - name: Install the script to update maps from map catalog template: src: iiab-update-maps @@ -56,10 +61,10 @@ - name: Copy the javascript for the splash page to assets template: src: main.js - dest: "{{ osm_vector_path }}/splash/" + dest: "{{ doc_root }}/common/assets/" - name: Copy the php redirect to the splash page - template: - src: splash-index.html + copy: + src: splash-index.redirect dest: "{{ osm_vector_path }}/index.html" diff --git a/roles/osm-vector/templates/iiab-update-maps b/roles/osm-vector/templates/iiab-update-maps index d9c7b5fca..153eeb40d 100755 --- a/roles/osm-vector/templates/iiab-update-maps +++ b/roles/osm-vector/templates/iiab-update-maps @@ -1,33 +1,67 @@ #!/usr/bin/env python -# create spec for bounding boxes used in IIAB vector map subsets +# Scan the osm-vector directory, update the osm-vector-idx.json, add menu-defs from geojson import Feature, Point, FeatureCollection, Polygon import geojson import json import os +import sys +import fnmatch +IIAB_PATH='/etc/iiab' +if not IIAB_PATH in sys.path: + sys.path.append(IIAB_PATH) +from iiab_env import get_iiab_env +doc_root = get_iiab_env('WWWROOT') +menuDefs = doc_root + "/js-menu/menu-files/menu-defs/" +map_catalog = {} +map_menu_defs ={} def main(): - features = [] - input_json = "{{ iiab_dir }}" + '/regions.json' + global map_menu_defs + get_map_catalog() + map_menu_defs = get_menu_def_names() + +def get_map_catalog(): + global map_catalog + #input_json = "{{ iiab_dir }}" + '/regions.json' + input_json = "/etc/iiab" + '/regions.json' with open(input_json,'r') as regions: reg_str = regions.read() - info = json.loads(reg_str) - #print(json.dumps(info,indent=2)) - for root in info.keys(): - for region in info[root]: - west = float(info[root][region]['west']) - south = float(info[root][region]['south']) - east = float(info[root][region]['east']) - north = float(info[root][region]['north']) - poly = Polygon([[[west,south],[east,south],[east,north],[west,north],[west,south]]]) - features.append(Feature(geometry=poly,properties={"name":region})) + map_catalog = json.loads(reg_str) + #print(json.dumps(map_catalog,indent=2)) - collection = FeatureCollection(features) - bboxes = "{{ doc_root }}/common/assets/bboxes.geojson" - with open(bboxes,"w") as bounding_geojson: - outstr = geojson.dumps(collection, indent=2) - bounding_geojson.write(outstr) +def get_menu_def_names(intended_use='map'): + menu_def_dict = {} + os.chdir(menuDefs) + for filename in os.listdir('.'): + if fnmatch.fnmatch(filename, '*.json'): + try: + with open(filename,'r') as json_file: + readstr = json_file.read() + data = json.loads(readstr) + except: + print("failed to parse %s"%filename) + print(readstr) + if data.get('intended_use','') != intended_use: + continue + mapname = data.get('name','') + if mapname != '': + menu_def_dict[data['map_name']] = menuDefs + filename + return menu_def_dict + +def human_readable(num): + # return 3 significant digits and unit specifier + num = float(num) + units = [ '','K','M','G'] + for i in range(4): + if num<10.0: + return "%.2f%s"%(num,units[i]) + if num<100.0: + return "%.1f%s"%(num,units[i]) + if num < 1000.0: + return "%.0f%s"%(num,units[i]) + num /= 1000.0 if __name__ == '__main__': main() diff --git a/roles/osm-vector/templates/splash-index.html b/roles/osm-vector/templates/splash-index.html index ad8989a86..6f8e135d1 100644 --- a/roles/osm-vector/templates/splash-index.html +++ b/roles/osm-vector/templates/splash-index.html @@ -1,23 +1,21 @@ - Bootstrap Example + Osm-Vector Splash Page - - - - + + + -

Install World Map, Select Region

-

The World Map is based upon OpenStreetMap Data. It includes regional views of the whole world and details of a region you can select.

+

Vector Maps Test Page -- Use The Admin Console to Download a Selected Region

+

The IIAB vector maps are based upon OpenStreetMap Data. Each map has general geographic information that covers the whole world with a resolution of about 5 KM. The detailed regions provide data about items that are 5 meters apart.

-
Disk Space:
-
+
@@ -29,13 +27,27 @@ right: 10px; height: 500px; } + body { + padding: 40px; + }
placeholdr
- + + +