diff --git a/src/wmts/capabilities.spec.ts b/src/wmts/capabilities.spec.ts index c6a4f0b..ede9566 100644 --- a/src/wmts/capabilities.spec.ts +++ b/src/wmts/capabilities.spec.ts @@ -614,7 +614,7 @@ describe('WMTS Capabilities', () => { matrixSets: [ { identifier: 'BigWorldPixel', - crs: 'urn:ogc:def:crs:EPSG:6.18:3:3857', + crs: 'urn:ogc:def:crs:OGC:1.3:CRS84', limits: [], }, { @@ -681,7 +681,7 @@ describe('WMTS Capabilities', () => { }, { identifier: 'GoogleMapsCompatible', - crs: 'urn:ogc:def:crs:EPSG::3857', + crs: 'urn:ogc:def:crs:EPSG:6.18.3:3857', limits: [], }, ], diff --git a/src/wmts/capabilities.ts b/src/wmts/capabilities.ts index e00ba91..56d4039 100644 --- a/src/wmts/capabilities.ts +++ b/src/wmts/capabilities.ts @@ -119,13 +119,37 @@ export function readLayersFromCapabilities( ): WmtsLayer[] { const rootEl = getRootElement(capabilitiesDoc); const contentsEl = findChildElement(rootEl, 'Contents'); + + /** + * Get the TileMatrixSet CRS + * @param contentsEl - Contents + * @param identifier - TileMatrixSet identifier + * @returns The SupportedCRS of the TileMatrixSet + */ + function getMatrixSetCrs(contentsEl: XmlElement, identifier: string): string { + const matrixSet = findChildrenElement(contentsEl, 'TileMatrixSet').find( + (matrixSetEl) => { + const identifierEl = findChildElement(matrixSetEl, 'Identifier'); + return getElementText(identifierEl) === identifier; + } + ); + return getElementText(findChildElement(matrixSet, 'SupportedCRS')); + } + + /** + * Get the parameters of the TileMatrixSetLink + * @param element - TileMatrixSetLink + * @returns + */ function parseMatrixSetLink(element: XmlElement): MatrixSetLink { - const fullMatrixSet = findChildrenElement(contentsEl, 'TileMatrixSet').find( - (el) => getElementText(findChildElement(el, 'Identifier')) + const identifier = getElementText( + findChildElement(element, 'TileMatrixSet') ); + const crs = getMatrixSetCrs(contentsEl, identifier); + return { - identifier: getElementText(findChildElement(element, 'TileMatrixSet')), - crs: getElementText(findChildElement(fullMatrixSet, 'SupportedCRS')), + identifier, + crs, limits: findChildrenElement(element, 'TileMatrixLimits', true).map( (element) => ({ tileMatrix: getElementText(findChildElement(element, 'TileMatrix')),