geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
515 stars 403 forks source link

wmts getfeatureinfo also requires format parameter.. #10595

Closed landryb closed 1 month ago

landryb commented 1 month ago

Description

WMTS GetFeatureInfo against the national OGC services at https://data.geopf.fr/wmts fail because apparently it expects the FORMAT parameter, which according to my reading of the WMTS spec is mandatory.

How to reproduce

Expected Result we should get a valid return value/feedback

Current Result

a 400 code with this ExceptionReport about missing FORMAT:

<ExceptionReport xmlns="http://www.opengis.net/ows/1.1">
<Exception exceptionCode="MissingParameterValue" >
  Parametre FORMAT absent.
</Exception>
</ExceptionReport>

adding a FORMAT=application/json parameter results in another ExceptionReport:

<ExceptionReport xmlns="http://www.opengis.net/ows/1.1">
<Exception exceptionCode="InvalidParameterValue" >
  Le format application/json n'est pas gere pour la couche ADMINEXPRESS-COG-CARTO.LATEST
</Exception>
</ExceptionReport>

which is another issue and blatantly wrong serverside, since this format is listed in the values for infoformat in https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities

i'll bring up that last bit to the service admins, but in my opinion and interpretation of the spec mapstore should also send the format parameter here: https://github.com/geosolutions-it/MapStore2/blob/master/web/client/utils/mapinfo/wmts.js#L97

landryb commented 1 month ago

after discussing with the data.geopf.fr service admins, the service has a spec-compliant behaviour:

eg https://data.geopf.fr/wmts?service=WMTS&request=GetFeatureInfo&layer=ACCES.BIOMETHANE&infoformat=text/plain&style=ACCES.BIOMETHANE&tilecol=260&tilerow=182&tilematrix=9&tilematrixset=PM_6_16&i=227&j=236&format=image/png and https://data.geopf.fr/wmts?service=WMTS&request=GetFeatureInfo&layer=ACCES.BIOMETHANE&infoformat=application/json&style=ACCES.BIOMETHANE&tilecol=260&tilerow=182&tilematrix=9&tilematrixset=PM_6_16&i=227&j=236&format=image/png

both work, first one as plain text, second one as json.. so mapstore should send the format parameter with the same value as used for a gettile request, dunno if that is accessible in that scope.

the request currently done by mapstore: https://data.geopf.fr/wmts?service=WMTS&request=GetFeatureInfo&layer=ACCES.BIOMETHANE&infoformat=application%2Fjson&style=ACCES.BIOMETHANE&tilecol=260&tilerow=182&tilematrix=9&tilematrixset=PM_6_16&i=204&j=98

a corresponding working request: https://data.geopf.fr/wmts?service=WMTS&request=GetFeatureInfo&layer=ACCES.BIOMETHANE&infoformat=application%2Fjson&style=ACCES.BIOMETHANE&tilecol=260&tilerow=182&tilematrix=9&tilematrixset=PM_6_16&i=204&j=98&format=image%2Fpng

landryb commented 1 month ago

it's as simple as this:

--- a/web/client/utils/mapinfo/wmts.js
+++ b/web/client/utils/mapinfo/wmts.js
@@ -95,6 +95,7 @@ export default {
                 request: 'GetFeatureInfo',
                 layer: layer.name,
                 infoformat: props.format,
+                format: layer.format,
                 style: layer.style || '',
                 ...assign({}, params),
                 tilecol: tileCol,

but in my real testing i only get a 404 and

<ExceptionReport xmlns="http://www.opengis.net/ows/1.1">
<Exception exceptionCode="Not Found" >
  No data found
</Exception>
</ExceptionReport>

which is .. unexpected. But still, progress.

landryb commented 1 month ago

Image

finally, it worked on the ACCES.BIOMETHANE layer. guess i needed to properly click on an existing object..

also tried with the HTML and PROPERTIES formats, all three works.