1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

splash page update, iiab-make-maps a wip

This commit is contained in:
George Hunt 2019-03-18 21:36:23 -07:00
parent 29096b09d7
commit 6b9b895a9e
3 changed files with 83 additions and 32 deletions

View file

@ -3,11 +3,16 @@
url: "{{ iiab_maps_url }}/map.js" url: "{{ iiab_maps_url }}/map.js"
dest: "{{ doc_root }}/common/assets/" dest: "{{ doc_root }}/common/assets/"
- name: Fetch the bounding box description for maps - name: Fetch the catalog for maps
get_url: get_url:
url: "{{ iiab_maps_url }}/regions.json" url: "{{ iiab_maps_url }}/regions.json"
dest: "{{ iiab_dir }}/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 - name: Install the script to update maps from map catalog
template: template:
src: iiab-update-maps src: iiab-update-maps
@ -56,10 +61,10 @@
- name: Copy the javascript for the splash page to assets - name: Copy the javascript for the splash page to assets
template: template:
src: main.js src: main.js
dest: "{{ osm_vector_path }}/splash/" dest: "{{ doc_root }}/common/assets/"
- name: Copy the php redirect to the splash page - name: Copy the php redirect to the splash page
template: copy:
src: splash-index.html src: splash-index.redirect
dest: "{{ osm_vector_path }}/index.html" dest: "{{ osm_vector_path }}/index.html"

View file

@ -1,33 +1,67 @@
#!/usr/bin/env python #!/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 from geojson import Feature, Point, FeatureCollection, Polygon
import geojson import geojson
import json import json
import os 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(): def main():
features = [] global map_menu_defs
input_json = "{{ iiab_dir }}" + '/regions.json' 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: with open(input_json,'r') as regions:
reg_str = regions.read() reg_str = regions.read()
info = json.loads(reg_str) map_catalog = json.loads(reg_str)
#print(json.dumps(info,indent=2)) #print(json.dumps(map_catalog,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}))
collection = FeatureCollection(features) def get_menu_def_names(intended_use='map'):
bboxes = "{{ doc_root }}/common/assets/bboxes.geojson" menu_def_dict = {}
with open(bboxes,"w") as bounding_geojson: os.chdir(menuDefs)
outstr = geojson.dumps(collection, indent=2) for filename in os.listdir('.'):
bounding_geojson.write(outstr) 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__': if __name__ == '__main__':
main() main()

View file

@ -1,23 +1,21 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Bootstrap Example</title> <title>Osm-Vector Splash Page</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <link rel="stylesheet" href="/common/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="/common/js/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <script src="/common/js/bootstrap.min.js"></script>
<script src="js/admin_console.js"></script>
</head> </head>
<body> <body>
<h2>Install World Map, Select Region</h2> <h2>Vector Maps Test Page -- Use The Admin Console to Download a Selected Region</h2>
<p>The World Map is based upon OpenStreetMap Data. It includes regional views of the whole world and details of a region you can select.</p> <p>The IIAB vector maps are based upon OpenStreetMap Data. Each map has general geographic information that covers the <b>whole world </b>with a resolution of about 5 KM. The detailed regions provide data about items that are 5 meters apart. </p>
<div class="row"> <div class="row">
<div class="col-sm-4"><span >Disk Space: <span id="osmDiskSpace"></span> </span></div> <div class="col-sm-12"><a href="/admin"><button id="INST-MODS" type="button" class="btn btn-lg btn-primary">Go To Admin Console</button></a></div>
<div class="col-sm-2"><button id="INST-MODS" type="button" class="btn btn-lg btn-primary">Install Detailed Region</button></div>
</div> </div>
<div id="osmRegionSelection" > <div id="osmRegionSelection" >
@ -29,13 +27,27 @@
right: 10px; right: 10px;
height: 500px; height: 500px;
} }
body {
padding: 40px;
}
</style> </style>
<div id="map-container"></div> <div id="map-container"></div>
</div> </div>
<div id='regionlist'>placeholdr</div> <div id='regionlist'>placeholdr</div>
</div> <!-- End instOsmRegion Submenu Option Pane --> </div> <!-- End instOsmRegion Submenu Option Pane -->
<script src="js/map_functions.js"></script> <script>
function readableSize(kbytes) {
if (kbytes == 0)
return "0";
var bytes = 1024 * kbytes;
var s = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, e)).toFixed(2) + " " + s[e];
}
</script>
<script src="/admin/js/map_functions.js"></script>
<script src="/common/assets/map.js"></script> <script src="/common/assets/map.js"></script>
</body> </body>
</html> </html>