TerriaJS / terriajs

A library for building rich, web-based geospatial data platforms.
https://terria.io
Apache License 2.0
1.18k stars 362 forks source link

Support RESTful access to WMTS servers #2927

Open kring opened 6 years ago

kring commented 6 years ago

TerriaJS currently only requests tiles from WMTS servers using KVP (query parameter) encoding. Unfortunately, some servers don't support this encoding and require the use of RESTful (URL) encoding. Here's an example of such a server: https://tiles.openaerialmap.org/5abae68e65bd8f00110f3e42/0/5abae68e65bd8f00110f3e43/wmts

This may also be the reason for the problem described in #1573.

stevenjh commented 5 years ago

I think this is another example of this use case, WMTS served from the https://koordinates.com/ data sharing platform.

New Zealand LINZ data service (note you'll need a free api key) https://data.linz.govt.nz/services;key=YOUR_API_TOKEN/wmts/1.0.0/layer/95497/WMTSCapabilities.xml

returns

<ResourceURL format="image/png" resourceType="tile" template="https://tiles-a.data-cdn.linz.govt.nz/services;key=YOUR_API_TOKEN/tiles/v4/layer=95497,{style}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png"/>

The service will add, but tile requests fail. Does this suggest approaching WMTS as outlined in issue 1371 is required?

kring commented 5 years ago

Definitely looks like an example of this issue, at least. Terria is ignoring the ResourceURL and instead constructing KVP GetTile requests manually. So if the server doesn't support that (I haven't checked), it's not going to work. But do check that that's really the issue. It could be something simpler, like the key isn't being included in the GetTile requests. It looks like Terria doesn't currently support the parameters property for WMTS that it does for WMS, so there's not a built-in way to add that key. But it'd be easy to add it.

stevenjh commented 5 years ago

Thanks for the reply, the key was being carried across into the requests just as part of the base url in the KVP requests.

Imagine supporting REST would involve refactoring /lib/Models/WebMapTileServiceCatalogItem.js and the cesium WebMapTileServiceImageryProvider instances that are created, as well as the leaflet instances which I couldn't spot where that was. Is there more to this that I'm overlooking?

kring commented 5 years ago

Yep that's right. You shouldn't need to do anything special for Leaflet because, in TerriaJS, Leaflet knows how to render Cesium imagery providers directly.

stevenjh commented 5 years ago

ahh, that's neat re the TerraJS and Leaflet setup!