From 8e667369559fdd37dcf8d95958fa0cba6f0c6fec Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Thu, 21 Jun 2018 19:00:10 +0200 Subject: [PATCH 1/4] Fix typo --- docs/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index 15f7db1..6d6f99f 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -173,7 +173,7 @@ Sprites If your style requires any sprites, make sure the style JSON contains proper path in the ``sprite`` property. -It can be a local path (e.g. ``my-style/sprite``) or remove http(s) location (e.g. ``https://mycdn.com/my-style/sprite``). Several possible extension are added to this path, so the following files should be present: +It can be a local path (e.g. ``my-style/sprite``) or remote http(s) location (e.g. ``https://mycdn.com/my-style/sprite``). Several possible extension are added to this path, so the following files should be present: * ``sprite.json`` * ``sprite.png`` From baf01a117b76bde0b7182f641c8ae08efb06c3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=8Ans=20Beckman?= Date: Fri, 17 Aug 2018 13:11:19 +0200 Subject: [PATCH 2/4] Add support for WMTS capabilites https://github.com/klokantech/tileserver-gl/issues/274 --- docs/endpoints.rst | 4 + public/templates/index.tmpl | 6 +- public/templates/wmts.tmpl | 407 ++++++++++++++++++++++++++++++++++++ src/server.js | 20 +- 4 files changed, 429 insertions(+), 8 deletions(-) create mode 100644 public/templates/wmts.tmpl diff --git a/docs/endpoints.rst b/docs/endpoints.rst index 0672f25..b6d3bbd 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 ``/wmts/{id}/`` + Static images ============= * Several endpoints: diff --git a/public/templates/index.tmpl b/public/templates/index.tmpl index 8b37ed1..3dcef0d 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 0000000..f0570c6 --- /dev/null +++ b/public/templates/wmts.tmpl @@ -0,0 +1,407 @@ + + + + + WMTSGate + OGC WMTS + 1.0.0 + + + + + + + + + + RESTful + + + + + + + + + + + + + RESTful + + + + + + + + + + localhost + localhost + + -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 db67be4..8d8ac3b 100644 --- a/src/server.js +++ b/src/server.js @@ -325,11 +325,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 +369,21 @@ function start(opts) { return res.redirect(301, '/styles/' + req.params.id + '/'); }); */ + serveTemplate('/wmts/:id/$', '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'); + console.log(wmts) + return wmts; + }); serveTemplate('/data/:id/$', 'data', function(req) { var id = req.params.id; From 5d5ed1153fda3c9386bf19e22e6fbba63496c8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=8Ans=20Beckman?= Date: Fri, 17 Aug 2018 15:48:35 +0200 Subject: [PATCH 3/4] Clean up wmts template with correct syntax --- public/templates/wmts.tmpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/public/templates/wmts.tmpl b/public/templates/wmts.tmpl index f0570c6..29ab3e6 100644 --- a/public/templates/wmts.tmpl +++ b/public/templates/wmts.tmpl @@ -2,7 +2,7 @@ - WMTSGate + TileServer GL OGC WMTS 1.0.0 @@ -11,7 +11,7 @@ - + RESTful @@ -24,7 +24,7 @@ - + RESTful @@ -37,8 +37,8 @@ - localhost - localhost + {{name}} + {{id}} -180 -85.051128779807 180 85.051128779807 @@ -50,7 +50,7 @@ GoogleMapsCompatible - + GoogleMapsCompatible GoogleMapsCompatible EPSG:3857 @@ -403,5 +403,5 @@ 262144 - + \ No newline at end of file From 6e24f6ec8e16d9cd8bab530884bbedd9e23b39a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=8Ans=20Beckman?= Date: Sat, 18 Aug 2018 12:02:54 +0200 Subject: [PATCH 4/4] Update endpoint URL and change content type After a good nights sleep I considered the structure of the endpoint link for WMTS, at the same time I cleaned up the code and added the correct content type for the response. --- docs/endpoints.rst | 2 +- public/templates/index.tmpl | 2 +- src/server.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/endpoints.rst b/docs/endpoints.rst index b6d3bbd..b3a5fa0 100644 --- a/docs/endpoints.rst +++ b/docs/endpoints.rst @@ -23,7 +23,7 @@ Rendered tiles WMTS Capabilities ============== -* WMTS Capabilities are served at ``/wmts/{id}/`` +* WMTS Capabilities are served at ``/styles/{id}/wmts.xml`` Static images ============= diff --git a/public/templates/index.tmpl b/public/templates/index.tmpl index 3dcef0d..2c61428 100644 --- a/public/templates/index.tmpl +++ b/public/templates/index.tmpl @@ -41,7 +41,7 @@ {{#if serving_data}}| {{/if}}TileJSON {{/if}} {{#if serving_rendered}} - | WMTS + | WMTS {{/if}} {{#if xyz_link}} | XYZ diff --git a/src/server.js b/src/server.js index 8d8ac3b..70edfe8 100644 --- a/src/server.js +++ b/src/server.js @@ -269,6 +269,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(); @@ -369,7 +370,7 @@ function start(opts) { return res.redirect(301, '/styles/' + req.params.id + '/'); }); */ - serveTemplate('/wmts/:id/$', 'wmts', function(req) { + serveTemplate('/styles/:id/wmts.xml', 'wmts', function(req) { var id = req.params.id; var wmts = clone((config.styles || {})[id]); if (!wmts) { @@ -381,7 +382,6 @@ function start(opts) { 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'); - console.log(wmts) return wmts; });