mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
splash page update, iiab-make-maps a wip
This commit is contained in:
parent
29096b09d7
commit
6b9b895a9e
3 changed files with 83 additions and 32 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Bootstrap Example</title>
|
||||
<title>Osm-Vector Splash Page</title>
|
||||
<meta charset="utf-8">
|
||||
<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">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
|
||||
<script src="js/admin_console.js"></script>
|
||||
<link rel="stylesheet" href="/common/css/bootstrap.min.css">
|
||||
<script src="/common/js/jquery.min.js"></script>
|
||||
<script src="/common/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<h2>Install World Map, Select 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>
|
||||
<h2>Vector Maps Test Page -- Use The Admin Console to Download a Selected Region</h2>
|
||||
<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="col-sm-4"><span >Disk Space: <span id="osmDiskSpace"></span> </span></div>
|
||||
<div class="col-sm-2"><button id="INST-MODS" type="button" class="btn btn-lg btn-primary">Install Detailed Region</button></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>
|
||||
|
||||
<div id="osmRegionSelection" >
|
||||
|
@ -29,13 +27,27 @@
|
|||
right: 10px;
|
||||
height: 500px;
|
||||
}
|
||||
body {
|
||||
padding: 40px;
|
||||
}
|
||||
</style>
|
||||
<div id="map-container"></div>
|
||||
|
||||
</div>
|
||||
<div id='regionlist'>placeholdr</div>
|
||||
</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>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue