optionsFromCapabilities from 'ol/source/WMTS' does not parse resolutions/scale denominators
See original GitHub issueDescribe the bug When parsing a GetCapabilities XML document from a standard WMTS MapServer implementation, the resolutions do not get inferred. I have to manually provide several parameters to a WMTS source to get things working. Since WMTS is a standard, either MapServer is not following the standard correctly or OpenLayers does not parse the document correctly in every case.
import {optionsFromCapabilities} from 'ol/source/WMTS'
To Reproduce
Note that I cannot provide complete steps at the moment, but I do not want this to be forgotten. So, I am leaving this issue slightly incomplete. This issue tripped me up at least 3 times now, which is why I find it very important. I may be able to fix it myself, but the person who did the initial implementation will probably be faster to do so.
Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- See error
Expected behavior Any WMTS XML capabilities document can be parsed by OpenLayers and the layer used easily.
Please see https://gis.stackexchange.com/questions/29671/mathematics-behind-converting-scale-to-resolution to know how to convert the scale denominators to resolutions.
I was using the NZTM (EPSG:2193) projection. We always work around this issue thus far, but every time we need a New Zealand map of our own with WMTS, this trips us up.
Started something here: https://codepen.io/geekdenz/pen/eYJYgQV
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
If anyone has a fix, please submit a pull request.
This is caused by the coordinates being in the wrong order in the origin. NZTM uses neu.
This is already fixed in master: https://github.com/openlayers/openlayers/blob/1ef103ed6/src/ol/source/WMTS.js#L475 https://github.com/openlayers/openlayers/blob/master/src/ol/source/WMTS.js#L476
The bug still exists in production here: https://github.com/openlayers/openlayers/blob/v6.3.1/src/ol/source/WMTS.js#L383
A work-around that works is:
let options = optionsFromCapabilities(capabilities, wmtsOptions); options.tileGrid['extent_'] = [274000, 3087000, 3327000, 7173000];
for the NZTM (EPSG:2193) projection in 6.3.1.