Skip to content

failure to print WMTS background layers coming from non-geoserver services #7705

@landryb

Description

@landryb

Description

this is extracted from georchestra/mapstore2-georchestra#399 as it's not georchestra-project specific and can be easily reproduced on non-georchestra instances such as https://mapstore.geosolutionsgroup.com/mapstore/#/

How to reproduce

Expected Result
we should get a pdf

Current Result
java traceback coming from mapfishprint

Error on printing: Error while generating PDF:
org.mapfish.print.JsonMissingException: attribute [spec.layers[1].style] missing
    at org.mapfish.print.utils.PJsonObject.getString(PJsonObject.java:56)
    at org.mapfish.print.map.readers.WMTSMapReader.<init>(WMTSMapReader.java:78)

the error is slightly different if the WMTS layer is configured as a background layer in the map loaded at startup, reproduced with https://wxs.ign.fr/essentiels/geoportail/wmts?SERVICE=WMTS&REQUEST=GetCapabilities which chokes on missing requestEncoding parameter because there's not default to KVP.

Error while generating PDF:
org.mapfish.print.JsonMissingException: attribute [spec.layers[0].requestEncoding] missing
	at org.mapfish.print.utils.PJsonObject.getString(PJsonObject.java:56)
	at org.mapfish.print.map.readers.WMTSMapReader.<init>(WMTSMapReader.java:75)
  • Not browser related

Other useful information

most of my findings/time spent analysing it is in georchestra/mapstore2-georchestra#399

a potential fix (to be improved) is this:

--- a/web/client/utils/PrintUtils.js
+++ b/web/client/utils/PrintUtils.js
@@ -460,9 +460,9 @@ export const specCreators = {
                 ...dimensionParams,
                 "matrixIds": matrixIds,
                 "matrixSet": tileMatrixSetName,
-                "style": layer.style,
+                "style": layer.style || 'default',
                 "name": layer.name,
-                "requestEncoding": layer.requestEncoding === "RESTful" ? "REST" : layer.requestEncoding,
+                "requestEncoding": layer.requestEncoding === "RESTful" ? "REST" : layer.requestEncoding || 'KVP',
                 "opacity": getOpacity(layer),
                 "version": layer.version || "1.0.0"
             };

it would be much better if the only style found in getcapabilities could be considered the default style instead of only looking for isDefault attribute which isnt mandated by the OGC WMTS spec.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions