mirror of
https://github.com/iiab/iiab.git
synced 2025-02-14 20:22:08 +00:00
splash page installed by role
This commit is contained in:
parent
de0d530296
commit
29096b09d7
8 changed files with 429 additions and 0 deletions
182
roles/osm-vector/files/countries.json
Normal file
182
roles/osm-vector/files/countries.json
Normal file
File diff suppressed because one or more lines are too long
5
roles/osm-vector/files/splash-index.redirect
Normal file
5
roles/osm-vector/files/splash-index.redirect
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
header('Location: './splash'L);
|
||||||
|
die();
|
||||||
|
?>
|
||||||
|
|
65
roles/osm-vector/tasks/main.yml
Normal file
65
roles/osm-vector/tasks/main.yml
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
- name: Fetch the javascript bundle with openlayers module, and map.js
|
||||||
|
get_url:
|
||||||
|
url: "{{ iiab_maps_url }}/map.js"
|
||||||
|
dest: "{{ doc_root }}/common/assets/"
|
||||||
|
|
||||||
|
- name: Fetch the bounding box description for maps
|
||||||
|
get_url:
|
||||||
|
url: "{{ iiab_maps_url }}/regions.json"
|
||||||
|
dest: "{{ iiab_dir }}/regions.json"
|
||||||
|
|
||||||
|
- name: Install the script to update maps from map catalog
|
||||||
|
template:
|
||||||
|
src: iiab-update-maps
|
||||||
|
dest: /usr/bin/iiab-update-maps
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Generate the bounding bboxes.geojson file
|
||||||
|
shell: /usr/bin/iiab-update-maps
|
||||||
|
|
||||||
|
- name: Copy the Countries geojson to assets
|
||||||
|
copy:
|
||||||
|
src: countries.json
|
||||||
|
dest: "{{ doc_root }}/common/assets/"
|
||||||
|
|
||||||
|
- name: Install /etc/{{ apache_config_dir }}/osm-vect.conf from template
|
||||||
|
template:
|
||||||
|
src: osm-vector.conf
|
||||||
|
dest: "/etc/{{ apache_config_dir }}/osm-vector.conf"
|
||||||
|
|
||||||
|
- name: Create symlink osm-vector.conf from sites-enabled to sites-available (debuntu, not nec for redhat)
|
||||||
|
file:
|
||||||
|
src: /etc/apache2/sites-available/osm-vector.conf
|
||||||
|
path: /etc/apache2/sites-enabled/osm-vector.conf
|
||||||
|
state: link
|
||||||
|
when: osm_vector_enabled and is_debuntu
|
||||||
|
|
||||||
|
- name: Remove symlink /etc/apache2/sites-enabled/osm-vector.conf (debuntu)
|
||||||
|
file:
|
||||||
|
path: /etc/apache2/sites-enabled/osm-vector.conf
|
||||||
|
state: absent
|
||||||
|
when: not osm_vector_enabled and is_debuntu
|
||||||
|
|
||||||
|
- name: Make sure the osm-vector directory exists
|
||||||
|
file:
|
||||||
|
path: '{{ osm_vector_path }}/splash'
|
||||||
|
state: directory
|
||||||
|
owner: '{{ apache_user }}'
|
||||||
|
group: '{{ apache_user }}'
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Copy the splash page for maps to apache root for maps
|
||||||
|
template:
|
||||||
|
src: splash-index.html
|
||||||
|
dest: "{{ osm_vector_path }}/splash/index.html"
|
||||||
|
|
||||||
|
- name: Copy the javascript for the splash page to assets
|
||||||
|
template:
|
||||||
|
src: main.js
|
||||||
|
dest: "{{ osm_vector_path }}/splash/"
|
||||||
|
|
||||||
|
- name: Copy the php redirect to the splash page
|
||||||
|
template:
|
||||||
|
src: splash-index.html
|
||||||
|
dest: "{{ osm_vector_path }}/index.html"
|
||||||
|
|
33
roles/osm-vector/templates/iiab-update-maps
Executable file
33
roles/osm-vector/templates/iiab-update-maps
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# create spec for bounding boxes used in IIAB vector map subsets
|
||||||
|
|
||||||
|
from geojson import Feature, Point, FeatureCollection, Polygon
|
||||||
|
import geojson
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
features = []
|
||||||
|
input_json = "{{ iiab_dir }}" + '/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}))
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
89
roles/osm-vector/templates/main.js
Normal file
89
roles/osm-vector/templates/main.js
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
import {Fill, Stroke, Style} from 'ol/style';
|
||||||
|
import 'ol/ol.css';
|
||||||
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
|
import Map from 'ol/Map';
|
||||||
|
import VectorLayer from 'ol/layer/Vector';
|
||||||
|
import VectorSource from 'ol/source/Vector';
|
||||||
|
import View from 'ol/View';
|
||||||
|
//import XYZSource from 'ol/source/XYZ';
|
||||||
|
//import MVT from 'ol/format/MVT';
|
||||||
|
|
||||||
|
// a global variable to control which features are shown
|
||||||
|
var show = {};
|
||||||
|
var mapData = "/common/assets";
|
||||||
|
|
||||||
|
|
||||||
|
var map = new Map({
|
||||||
|
target: 'map-container',
|
||||||
|
layers: [
|
||||||
|
new VectorLayer({
|
||||||
|
source: new VectorSource({
|
||||||
|
format: new GeoJSON(),
|
||||||
|
url: mapData + '/countries.json'
|
||||||
|
}),
|
||||||
|
style: new Style({
|
||||||
|
fill: new Fill({
|
||||||
|
color: 'rgb(219, 180, 131)'
|
||||||
|
}),
|
||||||
|
stroke: new Stroke({
|
||||||
|
color: 'white'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
view: new View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 2
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
var setBoxStyle = function(feature) {
|
||||||
|
var name = feature.get("name");
|
||||||
|
//alert(keys+'');
|
||||||
|
if (typeof show !== 'undefined' &&
|
||||||
|
show != null && name == show) {
|
||||||
|
return new Style({
|
||||||
|
fill: new Fill({
|
||||||
|
color: 'rgba(67, 163, 46, 0.2)'
|
||||||
|
}),
|
||||||
|
stroke: new Stroke({
|
||||||
|
color: 'rgba(67, 163, 46, 1)',
|
||||||
|
width: 2
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return new Style({
|
||||||
|
fill: new Fill({
|
||||||
|
color: 'rgba(255,255,255,.10)'
|
||||||
|
}),
|
||||||
|
stroke: new Stroke({
|
||||||
|
color: 'rgba(255,255,255,.3)'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var boxLayer = new VectorLayer({
|
||||||
|
source: new VectorSource({
|
||||||
|
format: new GeoJSON(),
|
||||||
|
url: mapData + '/bboxes.geojson'
|
||||||
|
}),
|
||||||
|
id: 'boxes',
|
||||||
|
style: setBoxStyle
|
||||||
|
});
|
||||||
|
map.addLayer(boxLayer);
|
||||||
|
|
||||||
|
$( document ).on("mouseover",".extract",function(){
|
||||||
|
|
||||||
|
var data = JSON.parse($(this).attr('data-region'));
|
||||||
|
show = data.name;
|
||||||
|
//setBoxStyle();
|
||||||
|
boxLayer.changed();
|
||||||
|
});
|
||||||
|
$( document ).on("mouseout",".extract",function(){
|
||||||
|
var data = JSON.parse($(this).attr('data-region'));
|
||||||
|
show = '';
|
||||||
|
boxLayer.changed();
|
||||||
|
});
|
8
roles/osm-vector/templates/osm-vector.conf
Normal file
8
roles/osm-vector/templates/osm-vector.conf
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# For downloadable regional vector tilesets
|
||||||
|
Alias /maps {{ osm_vector_path }}
|
||||||
|
Alias /osm-vector {{ osm_vector_path }}
|
||||||
|
<Directory {{ osm_vector_path }}>
|
||||||
|
Options Indexes FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
41
roles/osm-vector/templates/splash-index.html
Normal file
41
roles/osm-vector/templates/splash-index.html
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Bootstrap Example</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>
|
||||||
|
</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>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div id="osmRegionSelection" >
|
||||||
|
<style>
|
||||||
|
#map-container{
|
||||||
|
background-color: #b2d3f8;
|
||||||
|
float: right;
|
||||||
|
width: 70%;
|
||||||
|
right: 10px;
|
||||||
|
height: 500px;
|
||||||
|
}
|
||||||
|
</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 src="/common/assets/map.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -15,6 +15,7 @@ pip_packages_dir: "{{ iiab_base }}/pip-packages"
|
||||||
yum_packages_dir: "{{ iiab_base }}/yum-packages"
|
yum_packages_dir: "{{ iiab_base }}/yum-packages"
|
||||||
downloads_dir: "{{ iiab_base }}/downloads"
|
downloads_dir: "{{ iiab_base }}/downloads"
|
||||||
iiab_download_url: http://download.iiab.io/packages
|
iiab_download_url: http://download.iiab.io/packages
|
||||||
|
iiab_maps_url : http://download.iiab.io/content/OSM/vector-tiles
|
||||||
|
|
||||||
content_base: "/library"
|
content_base: "/library"
|
||||||
doc_base: "{{ content_base }}/www"
|
doc_base: "{{ content_base }}/www"
|
||||||
|
@ -350,6 +351,11 @@ mongodb_install: False
|
||||||
mongodb_enabled: False
|
mongodb_enabled: False
|
||||||
mongodb_port: 27018
|
mongodb_port: 27018
|
||||||
|
|
||||||
|
# Regional OSM vector maps take much less disk space than image versions
|
||||||
|
osm_vector_install: True
|
||||||
|
osm_vector_enabled: True
|
||||||
|
osm_vector_path: '{{ content_base }}/osm-vector'
|
||||||
|
|
||||||
# roles/sugarizer/meta/main.yml auto-invokes 2 above prereqs: mongodb & nodejs
|
# roles/sugarizer/meta/main.yml auto-invokes 2 above prereqs: mongodb & nodejs
|
||||||
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
||||||
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
||||||
|
|
Loading…
Reference in a new issue