diff --git a/docs/endpoints.rst b/docs/endpoints.rst index 0672f2515..b3a5fa081 100644 --- a/docs/endpoints.rst +++ b/docs/endpoints.rst @@ -21,6 +21,10 @@ Rendered tiles * The rendered tiles are not available in the ``tileserver-gl-light`` version. +WMTS Capabilities +============== +* WMTS Capabilities are served at ``/styles/{id}/wmts.xml`` + Static images ============= * Several endpoints: diff --git a/package.json b/package.json index 4116d2418..b24927f9a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "@mapbox/sphericalmercator": "1.0.5", "@mapbox/vector-tile": "1.3.0", "advanced-pool": "0.3.3", - "base64url": "2.0.0", "canvas": "1.6.8", "clone": "2.1.1", "color": "1.0.3", diff --git a/public/templates/index.tmpl b/public/templates/index.tmpl index 8b37ed1d6..2c61428e4 100644 --- a/public/templates/index.tmpl +++ b/public/templates/index.tmpl @@ -40,8 +40,8 @@ {{#if serving_rendered}} {{#if serving_data}}| {{/if}}TileJSON {{/if}} - {{#if wmts_link}} - | WMTS + {{#if serving_rendered}} + | WMTS {{/if}} {{#if xyz_link}} | XYZ @@ -110,4 +110,4 @@

- + \ No newline at end of file diff --git a/public/templates/wmts.tmpl b/public/templates/wmts.tmpl new file mode 100644 index 000000000..4fbec0487 --- /dev/null +++ b/public/templates/wmts.tmpl @@ -0,0 +1,407 @@ + + + + + TileServer GL + OGC WMTS + 1.0.0 + + + + + + + + + + RESTful + + + + + + + + + + + + + RESTful + + + + + + + + + + {{name}} + {{id}} + + -180 -85.051128779807 + 180 85.051128779807 + + + image/png + + GoogleMapsCompatible + + + + GoogleMapsCompatible + GoogleMapsCompatible EPSG:3857 + GoogleMapsCompatible + urn:ogc:def:crs:EPSG::3857 + + 0 + 559082264.02872 + -20037508.34 20037508.34 + 256 + 256 + 1 + 1 + + + 1 + 279541132.01436 + -20037508.34 20037508.34 + 256 + 256 + 2 + 2 + + + 2 + 139770566.00718 + -20037508.34 20037508.34 + 256 + 256 + 4 + 4 + + + 3 + 69885283.00359 + -20037508.34 20037508.34 + 256 + 256 + 8 + 8 + + + 4 + 34942641.501795 + -20037508.34 20037508.34 + 256 + 256 + 16 + 16 + + + 5 + 17471320.750897 + -20037508.34 20037508.34 + 256 + 256 + 32 + 32 + + + 6 + 8735660.3754487 + -20037508.34 20037508.34 + 256 + 256 + 64 + 64 + + + 7 + 4367830.1877244 + -20037508.34 20037508.34 + 256 + 256 + 128 + 128 + + + 8 + 2183915.0938622 + -20037508.34 20037508.34 + 256 + 256 + 256 + 256 + + + 9 + 1091957.5469311 + -20037508.34 20037508.34 + 256 + 256 + 512 + 512 + + + 10 + 545978.77346554 + -20037508.34 20037508.34 + 256 + 256 + 1024 + 1024 + + + 11 + 272989.38673277 + -20037508.34 20037508.34 + 256 + 256 + 2048 + 2048 + + + 12 + 136494.69336639 + -20037508.34 20037508.34 + 256 + 256 + 4096 + 4096 + + + 13 + 68247.346683193 + -20037508.34 20037508.34 + 256 + 256 + 8192 + 8192 + + + 14 + 34123.673341597 + -20037508.34 20037508.34 + 256 + 256 + 16384 + 16384 + + + 15 + 17061.836670798 + -20037508.34 20037508.34 + 256 + 256 + 32768 + 32768 + + + 16 + 8530.9183353991 + -20037508.34 20037508.34 + 256 + 256 + 65536 + 65536 + + + 17 + 4265.4591676996 + -20037508.34 20037508.34 + 256 + 256 + 131072 + 131072 + + + 18 + 2132.7295838498 + -20037508.34 20037508.34 + 256 + 256 + 262144 + 262144 + + WGS84 + WGS84 EPSG:4326 + WGS84 + urn:ogc:def:crs:EPSG::4326 + + 0 + 279541132.01436 + 90 -180 + 256 + 256 + 2 + 1 + + + 1 + 139770566.00718 + 90 -180 + 256 + 256 + 4 + 2 + + + 2 + 69885283.00359 + 90 -180 + 256 + 256 + 8 + 4 + + + 3 + 34942641.501795 + 90 -180 + 256 + 256 + 16 + 8 + + + 4 + 17471320.750897 + 90 -180 + 256 + 256 + 32 + 16 + + + 5 + 8735660.3754487 + 90 -180 + 256 + 256 + 64 + 32 + + + 6 + 4367830.1877244 + 90 -180 + 256 + 256 + 128 + 64 + + + 7 + 2183915.0938622 + 90 -180 + 256 + 256 + 256 + 128 + + + 8 + 1091957.5469311 + 90 -180 + 256 + 256 + 512 + 256 + + + 9 + 545978.77346554 + 90 -180 + 256 + 256 + 1024 + 512 + + + 10 + 272989.38673277 + 90 -180 + 256 + 256 + 2048 + 1024 + + + 11 + 136494.69336639 + 90 -180 + 256 + 256 + 4096 + 2048 + + + 12 + 68247.346683193 + 90 -180 + 256 + 256 + 8192 + 4096 + + + 13 + 34123.673341597 + 90 -180 + 256 + 256 + 16384 + 8192 + + + 14 + 17061.836670798 + 90 -180 + 256 + 256 + 32768 + 16384 + + + 15 + 8530.9183353991 + 90 -180 + 256 + 256 + 65536 + 32768 + + + 16 + 4265.4591676996 + 90 -180 + 256 + 256 + 131072 + 65536 + + + 17 + 2132.7295838498 + 90 -180 + 256 + 256 + 262144 + 131072 + + + 18 + + 90 -180 + 256 + 256 + 524288 + 262144 + + + + \ No newline at end of file diff --git a/src/server.js b/src/server.js index db67be470..f89fa783c 100644 --- a/src/server.js +++ b/src/server.js @@ -7,8 +7,7 @@ process.env.UV_THREADPOOL_SIZE = var fs = require('fs'), path = require('path'); -var base64url = require('base64url'), - clone = require('clone'), +var clone = require('clone'), cors = require('cors'), enableShutdown = require('http-shutdown'), express = require('express'), @@ -269,6 +268,7 @@ function start(opts) { data['key_query_part'] = req.query.key ? 'key=' + req.query.key + '&' : ''; data['key_query'] = req.query.key ? '?key=' + req.query.key : ''; + if (template === 'wmts') res.set('Content-Type', 'text/xml'); return res.status(200).send(compiled(data)); }); resolve(); @@ -295,12 +295,7 @@ function start(opts) { Math.floor(centerPx[0] / 256) + '/' + Math.floor(centerPx[1] / 256) + '.png'; } - - var query = req.query.key ? ('?key=' + req.query.key) : ''; - style.wmts_link = 'http://wmts.maptiler.com/' + - base64url('http://' + req.headers.host + - '/styles/' + id + '.json' + query) + '/wmts'; - + var tiles = utils.getTileUrls( req, style.serving_rendered.tiles, 'styles/' + id, style.serving_rendered.format); @@ -325,11 +320,6 @@ function start(opts) { Math.floor(centerPx[1] / 256) + '.' + data_.format; } - var query = req.query.key ? ('?key=' + req.query.key) : ''; - data_.wmts_link = 'http://wmts.maptiler.com/' + - base64url('http://' + req.headers.host + - '/data/' + id + '.json' + query) + '/wmts'; - var tiles = utils.getTileUrls( req, data_.tiles, 'data/' + id, data_.format, { 'pbf': options.pbfAlias @@ -374,6 +364,20 @@ function start(opts) { return res.redirect(301, '/styles/' + req.params.id + '/'); }); */ + serveTemplate('/styles/:id/wmts.xml', 'wmts', function(req) { + var id = req.params.id; + var wmts = clone((config.styles || {})[id]); + if (!wmts) { + return null; + } + if (wmts.hasOwnProperty("serve_rendered") && !wmts.serve_rendered) { + return null; + } + wmts.id = id; + wmts.name = (serving.styles[id] || serving.rendered[id]).name; + wmts.baseUrl = (req.get('X-Forwarded-Protocol')?req.get('X-Forwarded-Protocol'):req.protocol) + '://' + req.get('host'); + return wmts; + }); serveTemplate('/data/:id/$', 'data', function(req) { var id = req.params.id;