Add raster view for raster data

This commit is contained in:
Petr Sloup 2016-05-04 13:53:47 +02:00
parent daa94dc806
commit 187da7bb58
6 changed files with 32 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>{{name}} - TileServer GL</title>
{{#is_vector}}
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css" />
<script src="/mapbox-gl.js"></script>
<style>
@ -13,7 +14,19 @@
#layerList div div {width:15px;height:15px;display:inline-block;}
#propertyList {position:absolute;top:40%;bottom:0;right:0;width:240px;overflow:auto;color:#fff;}
</style>
{{/is_vector}}
{{^is_vector}}
<link rel="stylesheet" type="text/css" href="/mapbox.css" />
<script src="/mapbox.js"></script>
<script src="/leaflet-hash.js"></script>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
{{/is_vector}}
</head>
<body>
{{#is_vector}}
<h1>{{name}}</h1>
<div id="map"></div>
<div id="layerList"></div>
@ -98,5 +111,17 @@
});
});
</script>
{{/is_vector}}
{{^is_vector}}
<h1 style="display:none;">{{name}}</h1>
<div id='map'></div>
<script>
var map = L.mapbox.map('map', '/data/{{id}}.json', { zoomControl: false });
new L.Control.Zoom({ position: 'topright' }).addTo(map);
setTimeout(function() {
new L.Hash(map);
}, 0);
</script>
{{/is_vector}}
</body>
</html>

View file

@ -49,9 +49,10 @@
<h3>{{name}}</h3>
<p>Id: {{@key}} |{{#if formatted_filesize}} {{formatted_filesize}} |{{/if}} {{#is_vector}}Vector{{/is_vector}}{{^is_vector}}Raster{{/is_vector}} data | <a href="/data/{{@key}}.json">TileJSON</a></p>
{{#is_vector}}
<a class="btn" href="/data/{{@key}}/{{viewer_hash}}">X-Ray viewer</a>
<a class="btn" href="/data/{{@key}}/{{viewer_hash}}">X-Ray view</a>
{{/is_vector}}
{{^is_vector}}
<a class="btn" href="/data/{{@key}}/{{viewer_hash}}">Raster view</a>
{{/is_vector}}
</div>
{{/each}}

View file

@ -12,6 +12,7 @@
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<h1 style="display:none;">{{name}}</h1>
<div id='map'></div>

View file

@ -30,6 +30,7 @@ module.exports = function(options, repo, params, id) {
tileJSON['tilejson'] = '2.0.0';
tileJSON['basename'] = id;
tileJSON['filesize'] = fs.statSync(mbtilesFile)['size'];
delete tileJSON['scheme'];
Object.assign(tileJSON, params.tilejson || {});
utils.fixTileJSONCenter(tileJSON);

View file

@ -253,13 +253,14 @@ module.exports = function(opts, callback) {
});
*/
serveTemplate('/data/:id/$', 'xray', function(params) {
serveTemplate('/data/:id/$', 'data', function(params) {
var id = params.id;
var data = serving.data[id];
var data = clone(serving.data[id]);
if (!data) {
return null;
}
data.id = id;
data.is_vector = data.format == 'pbf';
return data;
});