Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Added vector layers to webmercator sample endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrodjpl committed Jan 9, 2017
1 parent af86112 commit 4690fbd
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 29 deletions.
4 changes: 2 additions & 2 deletions bootstrap-vagrant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ done
mkdir -p /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/{2016,YYYY}
/bin/cp /home/vagrant/resources/mrfs/ASCATA-L2-25km/ASCATA-L2-25km2016188010000_.* /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016/
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25km2016188010000*' -type f -exec bash -c 'ln -s "$1" "${1/2016188010000/TTTTTTTTTTTTT}"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25kmTTTTTTTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG4326/ASCATA-L2-25km/YYYY/"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25kmTTTTTTTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/YYYY/"' -- {} \;
/bin/cp /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016/ASCATA-L2-25km2016188010000_.mrf /etc/onearth/config/headers/ASCATA-L2-25kmTTTTTTTTTTTTT_.mrf

#OSCAR
mkdir -p /usr/share/onearth/demo/data/EPSG3857/oscar/{2016,YYYY}
/bin/cp /home/vagrant/resources/mrfs/oscar/oscar2016189_.* /usr/share/onearth/demo/data/EPSG3857/oscar/2016/
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscar2016189*' -type f -exec bash -c 'ln -s "$1" "${1/2016189/TTTTTTT}"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscarTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG4326/oscar/YYYY/"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscarTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG3857/oscar/YYYY/"' -- {} \;
/bin/cp /usr/share/onearth/demo/data/EPSG3857/oscar/2016/oscar2016189_.mrf /etc/onearth/config/headers/oscarTTTTTTT_.mrf

#Install and copy the Mapserver config files and endpoints
Expand Down
4 changes: 2 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ done
mkdir -p /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/{2016,YYYY}
/bin/cp /home/onearth/resources/mrfs/ASCATA-L2-25km/ASCATA-L2-25km2016188010000_.* /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016/
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25km2016188010000*' -type f -exec bash -c 'ln -s "$1" "${1/2016188010000/TTTTTTTTTTTTT}"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25kmTTTTTTTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG4326/ASCATA-L2-25km/YYYY/"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016 -name 'ASCATA-L2-25kmTTTTTTTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/YYYY/"' -- {} \;
/bin/cp /usr/share/onearth/demo/data/EPSG3857/ASCATA-L2-25km/2016/ASCATA-L2-25km2016188010000_.mrf /etc/onearth/config/headers/ASCATA-L2-25kmTTTTTTTTTTTTT_.mrf

#OSCAR
mkdir -p /usr/share/onearth/demo/data/EPSG3857/oscar/{2016,YYYY}
/bin/cp /home/onearth/resources/mrfs/oscar/oscar2016189_.* /usr/share/onearth/demo/data/EPSG3857/oscar/2016/
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscar2016189*' -type f -exec bash -c 'ln -s "$1" "${1/2016189/TTTTTTT}"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscarTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG4326/oscar/YYYY/"' -- {} \;
find /usr/share/onearth/demo/data/EPSG3857/oscar/2016 -name 'oscarTTTTTTT*' -type l -exec bash -c 'mv "$1" "/usr/share/onearth/demo/data/EPSG3857/oscar/YYYY/"' -- {} \;
/bin/cp /usr/share/onearth/demo/data/EPSG3857/oscar/2016/oscar2016189_.mrf /etc/onearth/config/headers/oscarTTTTTTT_.mrf

#Install and copy the Mapserver config files and endpoints
Expand Down
4 changes: 2 additions & 2 deletions resources/endpoint_configs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="container">
<div class="row">
<h1>Welcome to OnEarth!</h1>
<p>This Vagrant VM is customized with pre-confgured endpoints and sample imagery. For more information, visit (github URL)</p>
<p>This VM is customized with pre-confgured endpoints and sample imagery. For more information, visit (github URL)</p>

<h2>Endpoint Configuration</h2>
<p>This package has 4 endpoints configured for the following EPSG projections: 4326 (geographic), 3857 (webmercator), 3413 (arctic), and 3857 (antarctic).</p>
Expand All @@ -31,7 +31,7 @@ <h3>WMTS endpoints with OpenLayers</h3>

<p><strong>Sample WMTS tile request: </strong><a href="/onearth/demo/wmts/geo/wmts.cgi?layer=blue_marble&tilematrixset=EPSG4326_1km&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix=2&TileCol=1&TileRow=1">/onearth/demo/wmts/geo/wmts.cgi?layer=blue_marble&tilematrixset=EPSG4326_1km&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix=2&TileCol=1&TileRow=1</a></p>

<p><strong>Sample WMTS vector tile request: </strong><a href="/onearth/demo/wmts/webmerc/wmts.cgi?layer=oscar&tilematrixset=GoogleMapsCompatible_Level3&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix=1&TileCol=0&TileRow=1&time=2016-07-07">/onearth/demo/wmts/webmerc/wmts.cgi?layer=oscar&tilematrixset=GoogleMapsCompatible_Level3&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix=1&TileCol=0&TileRow=1&time=2016-07-07</a></p>
<p><strong>Sample WMTS vector tile request: </strong><a href="/onearth/demo/wmts/webmerc/wmts.cgi?layer=oscar&tilematrixset=GoogleMapsCompatible_Level6&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix=1&TileCol=0&TileRow=1&time=2016-07-07">/onearth/demo/wmts/webmerc/wmts.cgi?layer=oscar&tilematrixset=GoogleMapsCompatible_Level6&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix=1&TileCol=0&TileRow=1&time=2016-07-07</a></p>

<p><strong>Sample WMTS getCapabilities request: </strong><a href="/onearth/demo/wmts/arctic/getCapabilities.xml">/onearth/demo/wmts/arctic/getCapabilities.xml</a>

Expand Down
5 changes: 2 additions & 3 deletions resources/endpoint_configs/wmts-webmerc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
<head>
<title>GIBS OpenLayers Example - Web Mercator (EPSG:3857)</title>

<link rel="stylesheet" href="/onearth/demo/lib/ol.css"/>
<link rel="stylesheet" href="/onearth/demo/lib/example.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/onearth/demo/lib/ol.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js"></script>
<script src="webmercator-epsg3857.js"></script>
</head>

Expand Down
70 changes: 54 additions & 16 deletions resources/endpoint_configs/wmts-webmerc/webmercator-epsg3857.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ window.onload = function() {
//Set the maximum number of zoom levels. This will depend on the average number of TileMatrixSets for each layer at this endpoint.
var maxZoomLevels = 7;

//If using vector tiles, specify their identifiers
var vectorLayers = ["MODIS_C5_fires", "oscar", "ASCATA-L2-25km", "Terra_Orbit_Dsc_Dots"];

//Set locations for endpoint and getCapabilities
var endpointUrl = "./wmts.cgi?";
var getCapabilitiesLocation = "./getCapabilities.xml";
Expand All @@ -42,6 +45,26 @@ window.onload = function() {
var mapProjection = ol.proj.get(EPSGProjection);
var maxRes;
var extents;

var testVectorLayerStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: 'blue'
}),
stroke: new ol.style.Stroke({
color: 'blue',
width: 1
}),
image: new ol.style.Circle({
radius: 1,
fill: new ol.style.Fill({
color: 'blue'
}),
stroke: new ol.style.Stroke({
color: 'blue',
width: 1
})
})
});

//Extents and resolution info from: https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers
switch (EPSGProjection) {
Expand Down Expand Up @@ -102,7 +125,21 @@ window.onload = function() {
}
}
}
var newLayerSource = new ol.source.WMTS({

if(vectorLayers.includes(layerName)) {
var tms = layers[i].TileMatrixSetLink[0].TileMatrixSet;
var source = new ol.source.VectorTile({
format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ({maxZoom: parseInt(tms.match(/^GoogleMapsCompatible_Level(\d)/)[1]) - 1}),
tilePixelRatio: 16,
url: `/onearth/demo/wmts/webmerc/wmts.cgi?layer=${layerName}&tilematrixset=${tms}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix={z}&TileCol={x}&TileRow={y}`
});
var newLayer = new ol.layer.VectorTile({
source,
style: testVectorLayerStyle,
});
} else {
var source = new ol.source.WMTS({
url: endpointUrl,
layer: layerName,
format: layers[i].Format[0],
Expand All @@ -113,11 +150,13 @@ window.onload = function() {
tileSize: tileMatrixSet.TileMatrix[0].TileHeight,
resolutions: resolutions
})
});
var newLayer = new ol.layer.Tile({
source: newLayerSource,
visible: false
});
});
var newLayer = new ol.layer.Tile({
source,
});
}
newLayer.set('id', layerName);
newLayer.setVisible(false);
map.addLayer(newLayer);
var dropDown = document.getElementById("layer-select");
//Add string for new checkbox to dropdown div
Expand All @@ -138,16 +177,15 @@ window.onload = function() {
//For a layer that is selected, remove it and then put it at the highest index. If deselected, just make it invisible.
for(var i=0; i<layerCollection.getLength(); i++) {
var layer = layerCollection.item(i);
var layerName = layer.Hd.B.source.C;
if(layerName == pickedLayerName) {
if(evt.target.checked) {
map.getLayers().removeAt(i);
map.getLayers().insertAt(1, layer);
layer.setVisible(true);
} else {
layer.setVisible(false);
}
}
var layerName = layer.get('id');
if(layerName !== pickedLayerName) continue;
if(evt.target.checked) {
map.getLayers().removeAt(i);
map.getLayers().insertAt(layerCollection.getLength(), layer);
layer.setVisible(true);
} else {
layer.setVisible(false);
}
}
});
};
2 changes: 1 addition & 1 deletion resources/layer_configs/oscar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<FileNamePrefix>oscar</FileNamePrefix>
<HeaderFileName>/etc/onearth/config/headers/oscarTTTTTTT_.mrf</HeaderFileName>
<Compression>PBF</Compression>
<TileMatrixSet>GoogleMapsCompatible_Level3</TileMatrixSet>
<TileMatrixSet>GoogleMapsCompatible_Level6</TileMatrixSet>
<EmptyTileSize offset="0">0</EmptyTileSize>
<Projection>EPSG:3857</Projection>
<EnvironmentConfig>/etc/onearth/config/conf/environment_webmercator.xml</EnvironmentConfig>
Expand Down
Binary file modified resources/mrfs/oscar/oscar2016189_.idx
Binary file not shown.
10 changes: 7 additions & 3 deletions resources/mrfs/oscar/oscar2016189_.mrf
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<MRF_META>
<Raster>
<Size x="2048" y="2048"/>
<Size x="16384" y="16384"/>
<PageSize x="256" y="256"/>
<Compression>PBF</Compression>
<Compression>
PBF
</Compression>
<DataValues NoData="0"/>
</Raster>
<Rsets model="uniform"/>
<GeoTags>
<BoundingBox maxx="20037508.3428" maxy="20037508.3428" minx="-20037508.3428" miny="-20037508.3428"/>
<Projection>PROJCS[&quot;WGS 84 / Pseudo-Mercator&quot;,GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]],PROJECTION[&quot;Mercator_1SP&quot;],PARAMETER[&quot;central_meridian&quot;,0],PARAMETER[&quot;scale_factor&quot;,1],PARAMETER[&quot;false_easting&quot;,0],PARAMETER[&quot;false_northing&quot;,0],UNIT[&quot;metre&quot;,1,AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]],AXIS[&quot;X&quot;,EAST],AXIS[&quot;Y&quot;,NORTH],EXTENSION[&quot;PROJ4&quot;,&quot;+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs&quot;],AUTHORITY[&quot;EPSG&quot;,&quot;3857&quot;]]</Projection>
<Projection>
PROJCS[&quot;WGS 84 / Pseudo-Mercator&quot;,GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]],PROJECTION[&quot;Mercator_1SP&quot;],PARAMETER[&quot;central_meridian&quot;,0],PARAMETER[&quot;scale_factor&quot;,1],PARAMETER[&quot;false_easting&quot;,0],PARAMETER[&quot;false_northing&quot;,0],UNIT[&quot;metre&quot;,1,AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]],AXIS[&quot;X&quot;,EAST],AXIS[&quot;Y&quot;,NORTH],EXTENSION[&quot;PROJ4&quot;,&quot;+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs&quot;],AUTHORITY[&quot;EPSG&quot;,&quot;3857&quot;]]
</Projection>
</GeoTags>
</MRF_META>
Binary file modified resources/mrfs/oscar/oscar2016189_.pvt
Binary file not shown.

0 comments on commit 4690fbd

Please sign in to comment.