Skip to content

Conversation

@zoran995
Copy link
Collaborator

@zoran995 zoran995 commented Dec 13, 2024

What this PR does

Fixes #7296, #2927, #1573

Extended OWS common interfaces lists and added support for reading the URL from operations metadata.

Test me

Try adding data using the init file https://gist.githubusercontent.com/zoran995/10169b47c7c7191f4795b56878c3d9c4/raw/2a27e2165b43f3e920dbebd181d4f6bd14ae4f4a/terriajs-7296-config.json
I have also tested using New Zealand LINZ data service mentioned in #2927

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

: [layer.ResourceURL];

if (resourceUrls && (this.requestEncoding === "RESTful" || !url)) {
for (let i = 0; i < resourceUrls.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could for (const resourceUrl of resourceUrls) { be used to iterate over the content so the next line can be omitted, or is there some JavaScript-reason to always use index-based iterations in TypeScript?

Same comment for the other for-loops where the index is only used to get the element.

@moosepants
Copy link

moosepants commented May 19, 2025

<Edit: sorry I didn't realise this was an unreleased branch that potentially fixes the below behaviour, I will wait for the final push and retest when released>.

I'm not sure if this is related, or whether this is an adjacent issue, however when I add the NZ LINZ WMTS data (via https://data.linz.govt.nz/services;key=_removed_/wmts/1.0.0/WMTSCapabilities.xml) and add a layer, I don't see the tile data, instead a lot of 400 {Bad Requests} from the tile server.

After some investigation, the issue appears to be URL Encoding of the TileMatrixSet URL parameter. See below (noting EPSG%3A3857 vs EPSG:3857)

Terria does this (and doesn't work): https://tiles-cdn.koordinates.com/services;key=_removed_/tiles/v4/layer=50767,style%3Dauto/EPSG%3A3857/9/497/327.png
I amended the URL and this works: https://tiles-cdn.koordinates.com/services;key=_removed_/tiles/v4/layer=50767,style%3Dauto/EPSG:3857/8/255/162.png

@zoran995
Copy link
Collaborator Author

Hi @moosepants, I just tried loading that dataset using the CI deployment http://ci.terria.io/fix-7296-wmts, but it is still throwing an error due to the encoded tilematrix set value. We are requesting data as
https://tiles-cdn.koordinates.com/services;key=_removed_/tiles/v4/layer=50767,style%3Dauto/EPSG%3A3857/10/999/651.png
and services expects
https://tiles-cdn.koordinates.com/services;key=_removed_/tiles/v4/layer=50767,style%3Dauto/EPSG:3857/10/999/651.png
The difference is only that ESPG:3857 is encoded to EPSG%3A3857, which is a standard method. It would be good to report this to the Koordinates team, as this is an issue on their side (mainly because it won't work even after merging this fix).

@niktayv
Copy link
Collaborator

niktayv commented Aug 21, 2025

I've done some thorough testing both in the local environment and with the CI link.
The examples provided in the description did not work for me.
To get a working WMTS server, I spun up a TiTiler server on localhost:8000, following https://developmentseed.org/titiler/user_guide/getting_started/.
To serve the data, I used a GOG file on my machine, so that my URL looked like

http://127.0.0.1:8000/WebMercatorQuad/WMTSCapabilities.xml?url=file:<path-to-GOG.tif> 

Currently, on the main branch, this layer fails to load tiles as the ResourceURL is ignored.
With the changes from PR, layer loads the tiles successfully.

@niktayv
Copy link
Collaborator

niktayv commented Aug 21, 2025

I also submitted a ticket to Koordinates about the URL-Encoded TileMatrixSet issue, asking them either to adjust their backend or provide an alias so that Cesium could use the ResourceURL without tweaking.

@rsignell
Copy link

Would love to see this merged -- this would fix my issues as well

Copy link
Collaborator

@na9da na9da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @zoran995 - the spec is breaking for invalid tilematrix because previously we defaulted to googlemapscompatible. Should we keep the default?

@zoran995
Copy link
Collaborator Author

zoran995 commented Oct 29, 2025

@na9da, I'm not confident we should define a default tile matrix. WMTS capabilities should advertise all supported CRS/tile matrices, and if we set a default, we’ll likely end up sending requests with a tile matrix that's highly unlikely to work.
I can restore the default, but in 99% of cases, it would be better to improve the actual parsing of tile matrices. The default acts as a glue to make it look like it works, and we don't know if we are missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong WMTS GetTile requests for some WMTS servers

6 participants