Support WMTS services that omit the optional ows:OperationsMetadata - #12866
Open
eastagiletracker wants to merge 1 commit into
Open
Conversation
getOperations dereferenced Capabilities["ows:OperationsMetadata"]["ows:Operation"] unconditionally, so a WMTS GetCapabilities document without that optional section made the catalog search throw a TypeError and list no layers at all. getOperations now returns an empty array when the section is absent, and getRequestEncoding falls back to RESTful when the layers declare a tile ResourceURL, keeping the previous KVP default otherwise.
|
In order to contribute to the MapStore project, the CLA (Contributor License agreement) should be sent signed to GeoSolutions. Please consult contributing rules at: https://github.com/geosolutions-it/MapStore2/wiki/Contributing-to-MapStore#contributing-code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes support for WMTS services that omit the optional
ows:OperationsMetadatasection, so their layers are listed and can be added from the Catalog instead of the search failing outright (Fixes #6763). We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/511. You can sign in with your GitHub ID to claim ownership of the project.What is wrong
getOperationsinweb/client/utils/WMTSUtils.jsdereferences the capabilities document unconditionally:ows:OperationsMetadatais optional in WMTS 1.0.0, and RESTful services routinely leave it out. When it is absent,searchAndPaginateinweb/client/api/WMTS.jscallsgetOperationson its first line and throws, so the promise returned byWMTS.getRecordsrejects and the Catalog lists nothing at all for the service.Both public services named in the two open issues still omit the section today, so the failure is live on current master:
Running the five new cases against master (this branch with
web/client/utils/WMTSUtils.jsreverted) reproduces it exactly at the line issue #6763 points to:What changed
getOperationsnow reads the optional section defensively and returns an empty array when it is missing, which is enough on its own to stop the throw —getOperationalready handles an empty operations array and simply returnsundefined, soqueryableandGetTileURLcome out false and undefined rather than crashing.getRequestEncodingthen has to answer a question the document no longer answers directly. When there are no operations it falls back to the layers, via a newhasTileResourceURLhelper: aResourceURLwithresourceType="tile"is exactly what a RESTful service advertises in place of the operations section, so that meansRESTful, and anything else keeps the previous KVP default thatrecordToLayeralready documents. This is the first two items of the checklist in issue #4496; the third item there (an explicit KVP/RESTful selector in the catalog UI) is a separate change and is not included here.Nothing changes for a service that does publish
ows:OperationsMetadata: the fallback is only reached when the operations array is empty, so KVP services, RESTful services and the GeoServer 2.15 mixed case all take the same path as before. The existingwmts kvp,wmts rest,GetRecords KVP,GetRecords RESTfulandGetRecords KVP for GeoServer 2.15cases were kept untouched and stay green.How it was verified
Five cases were added, covering the fix at three levels:
WMTSUtilsdirectly (operations parsing, encoding fallback, and a control asserting a document with neither operations nor a tileResourceURLstill resolves to KVP),WMTS.getRecordsfor the record shape, andapi/catalog/WMTSend to end, asserting the layer built from the record carriesrequestEncoding: 'RESTful'and a usable tile template as its URL. All five fail on master with theTypeErrorquoted above and pass with the change. The new fixtureGetCapabilities-rest-no-operations-metadata.xmlfollows the anonymised style of the existing WMTS fixtures.The specs for these two modules and for every other file that imports them —
PrintUtils,WMSCacheOptions, thecatalog,backgroundselectorandlayerinfoepics, the leaflet and mapinfo WMTS utils and the OpenLayersLayerspec — were run with karma before and after: 276 passing before, 281 passing after, nothing newly red.eslinton the four touched JS files andprettier --checkon the fixture are both clean.As a last check the same catalog path was pointed at the two real capabilities documents linked above. On master both throw; with the change EMODnet Bathymetry resolves 20 layers and topplus_open resolves 6, each with
requestEncoding: 'RESTful'and a tile template that survives into the layer:How this was managed
This work was tracked as a single story, WMTS catalog fails if OperationMetadata is missing, but it is optional, on a board imported from this repository's own issues, pull requests and milestones — the same board linked at the top: https://eastagiletracker.com/projects/511
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com