Description
Adding the WMTS layer from https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml leads to errors.
In case of Bug (otherwise remove this paragraph)
Browser Affected
(use this site: https://www.whatsmybrowser.org/ for non expert users)
Browser Version Affected
not browser specific
Steps to reproduce
add https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml as a WMTS layer.
Expected Result
WMTS layer is added
Current Result
Parsing errors, WMTS layer is not added.
Other useful information (optional):
It seems there are a number of issues with this WMTS. I was able to fix some of them, but now I am at a point where I am stuck.
The issues arise because the capabilities only include a single TileMatrixSet element. This can be fixed here:
diff --git a/web/client/components/map/openlayers/plugins/WMTSLayer.js b/web/client/components/map/openlayers/plugins/WMTSLayer.js
index 11aeb1d1..f20ae83d 100644
--- a/web/client/components/map/openlayers/plugins/WMTSLayer.js
+++ b/web/client/components/map/openlayers/plugins/WMTSLayer.js
@@ -8,7 +8,7 @@
var Layers = require('../../../../utils/openlayers/Layers');
var ol = require('openlayers');
-const {isArray, head, isEmpty} = require('lodash');
+const {isArray, head, isEmpty, castArray} = require('lodash');
const SecurityUtils = require('../../../../utils/SecurityUtils');
const WMTSUtils = require('../../../../utils/WMTSUtils');
const CoordinatesUtils = require('../../../../utils/CoordinatesUtils');
@@ -24,7 +24,7 @@ const createLayer = options => {
const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
const srs = CoordinatesUtils.normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
const tilMatrixSetName = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS, options.matrixIds);
- const tileMatrixSet = head(options.tileMatrixSet.filter(tM => tM['ows:Identifier'] === tilMatrixSetName));
+ const tileMatrixSet = head(castArray(options.tileMatrixSet).filter(tM => tM['ows:Identifier'] === tilMatrixSetName));
const scales = tileMatrixSet && tileMatrixSet.TileMatrix.map(t => t.ScaleDenominator);
const mapResolutions = options.resolutions || mapUtils.getResolutions();
const matrixResolutions = options.resolutions || scales && mapUtils.getResolutionsForScales(scales, srs, 96) || [];
and here:
diff --git a/web/client/utils/CatalogUtils.js b/web/client/utils/CatalogUtils.js
index b1fdd462..6cf7856f 100644
--- a/web/client/utils/CatalogUtils.js
+++ b/web/client/utils/CatalogUtils.js
@@ -161,7 +161,7 @@ const converters = {
if (records && records.records) {
return records.records.map((record) => {
const matrixIds = castArray(record.TileMatrixSetLink || []).reduce((previous, current) => {
- const tileMatrix = head((record.TileMatrixSet || []).filter((matrix) => matrix["ows:Identifier"] === current.TileMatrixSet));
+ const tileMatrix = head(castArray(record.TileMatrixSet || []).filter((matrix) => matrix["ows:Identifier"] === current.TileMatrixSet));
const tileMatrixSRS = tileMatrix && CoordinatesUtils.getEPSGCode(tileMatrix["ows:SupportedCRS"]);
const levels = current.TileMatrixSetLimits && (current.TileMatrixSetLimits.TileMatrixLimits || []).map((limit) => ({
identifier: limit.TileMatrix,
and here:
diff --git a/web/client/utils/WMTSUtils.js b/web/client/utils/WMTSUtils.js
index 081e0073..e0c72dbd 100644
--- a/web/client/utils/WMTSUtils.js
+++ b/web/client/utils/WMTSUtils.js
@@ -41,7 +41,9 @@ const WMTSUtils = {
const matching = head(tileMatrixSet.filter((matrix) => ((matrix["ows:Identifier"] === current || CoordinatesUtils.getEPSGCode(matrix["ows:SupportedCRS"]) === current) && matrixIds[matrix["ows:Identifier"]])));
return matching && matching["ows:Identifier"] ? matching["ows:Identifier"] : previous;
} else if (isObject(tileMatrixSet)) {
- return tileMatrixSet[current] || previous;
+ return ((tileMatrixSet["ows:Identifier"] === current
+ || CoordinatesUtils.getEPSGCode(tileMatrixSet["ows:SupportedCRS"]) === current)
+ && matrixIds[tileMatrixSet["ows:Identifier"]]) ? tileMatrixSet["ows:Identifier"] : previous;
}
return previous;
}, defaultMatrix);
After these fixes it successfully loads the layer, but then requests the tiles from the wrong URL. Capabilities declare the URLs to be like this:
https://maps1.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png
But it actually requests these:
https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml?layer=geolandbasemap&style=&tilematrixset=google3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=8&TileCol=139&TileRow=90
Description
Adding the WMTS layer from https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml leads to errors.
In case of Bug (otherwise remove this paragraph)
Browser Affected
(use this site: https://www.whatsmybrowser.org/ for non expert users)
Browser Version Affected
not browser specific
Steps to reproduce
add https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml as a WMTS layer.
Expected Result
WMTS layer is added
Current Result
Parsing errors, WMTS layer is not added.
Other useful information (optional):
It seems there are a number of issues with this WMTS. I was able to fix some of them, but now I am at a point where I am stuck.
The issues arise because the capabilities only include a single TileMatrixSet element. This can be fixed here:
and here:
and here:
After these fixes it successfully loads the layer, but then requests the tiles from the wrong URL. Capabilities declare the URLs to be like this:
https://maps1.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png
But it actually requests these:
https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml?layer=geolandbasemap&style=&tilematrixset=google3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=8&TileCol=139&TileRow=90