-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WMTS backgroudLayer with API key #586
Comments
Can you try whether not truncating the URL here [1] works? Possibly the code should also be adapted to remove know query paramters (REQUEST, VERSION, etc) from the URL and keep the others. |
I am using qwc-docker, how can I find the file? |
You'll need to compile a custom viewer, see https://qwc-services.github.io/master/configuration/ViewerConfiguration/#custom-viewer |
Thank you @manisandro Managed to get it to work by adding function createWMTSSource(options) {
const urls = getWMSURLs(Array.isArray(options.url) ? options.url : [options.url]).map((url) => {
// Initialize the base URL
let updatedUrl = url;
// Append rev parameter if it exists
if (options.rev) {
updatedUrl += `?${options.rev}`; // Start with a question mark for rev
}
// Check if a key is provided and append it to the URL
if (options.key) {
// If rev is present, append key using "&"; otherwise, use "?"
updatedUrl += options.rev ? `&key=${options.key}` : `?key=${options.key}`;
}
return updatedUrl;
}); Had an additional issue with the resolutions, as wmts_config_generator.py could not handle the minimum zoom starting from EPSG:3857:7 instead of EPSG:3857:1. Also removed the high zooms that require subscription. {
"name": "Light_3857",
"type": "wmts",
"url": "https://api.os.uk/maps/raster/v1/wmts?key=xxxxxx&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=Light_3857&STYLE=default&FORMAT=image/png&TILEMATRIXSET={TileMatrixSet}&TILEMATRIX=EPSG:3857:{TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}",
"key": "xxxxxx",
// trimmed for clarity
"resolutions": [
156543.03390334628,
78271.51695167314,
39135.75847583657,
19567.879237918284,
9783.939618959142,
4891.969809479571,
2445.9849047397856,
1222.9924523698928,
611.4962261850814,
305.7481130924087,
152.87405654633633,
76.43702827303586,
38.21851413651793,
19.109257068258966,
9.554628534129483,
4.777314267197037,
2.3886571335985134
],
"thumbnail": "Light_3857.png"
}, Not sure if this can be implemented in https://github.com/qgis/qwc2/ ? |
Can you elaborate on
? |
The Ordnance Survey EPSG:3857 Tile Matrix Set starts at Zoom level 7 and not 0. Attached at the bottom is the relevant snippet from Running: Produces: "resolutions": [
1222.9924523698928,
611.4962261850814,
305.7481130924087,
152.87405654633633,
76.43702827303586,
38.21851413651793,
19.109257068258966,
9.554628534129483,
4.777314267197037,
2.3886571335985134,
1.1943285666669667,
0.5971642834657753,
0.2985821416005962,
0.1492910708002979
], If I use those resolutions in my themesConfig.json as backgroundLayers. All the I need to extrapolate and add additional resolutions for zoom levels 0-6 even if those are not available in "resolutions": [
156543.03390334628,
78271.51695167314,
39135.75847583657,
19567.879237918284,
9783.939618959142,
4891.969809479571,
2445.9849047397856,
1222.9924523698928,
611.4962261850814,
\\ etc... I hope this makes sense. Relevant parts from getcapabilities TileMatrixSet below. TileMatrixSet from getcapabilities <TileMatrixSet>
<ows:Title>TileMatrix for EPSG:3857 using 0.28mm</ows:Title>
<ows:Abstract>The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel).</ows:Abstract>
<ows:Identifier>EPSG:3857</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:EPSG::3857</ows:SupportedCRS>
<ows:BoundingBox crs="urn:ogc:def:crs:EPSG::3857">
<ows:LowerCorner>-1198263.0364071354 6365004.037965424</ows:LowerCorner>
<ows:UpperCorner>213000.0 8702260.01</ows:UpperCorner>
</ows:BoundingBox>
<TileMatrix>
<ows:Identifier>EPSG:3857:7</ows:Identifier>
<ScaleDenominator>4367830.1870353315</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>65</MatrixWidth>
<MatrixHeight>44</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:8</ows:Identifier>
<ScaleDenominator>2183915.0935181477</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>130</MatrixWidth>
<MatrixHeight>88</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:9</ows:Identifier>
<ScaleDenominator>1091957.5467586026</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>260</MatrixWidth>
<MatrixHeight>175</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:10</ows:Identifier>
<ScaleDenominator>545978.7733797727</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>519</MatrixWidth>
<MatrixHeight>350</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:11</ows:Identifier>
<ScaleDenominator>272989.3866894138</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1037</MatrixWidth>
<MatrixHeight>699</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:12</ows:Identifier>
<ScaleDenominator>136494.6933447069</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2073</MatrixWidth>
<MatrixHeight>1398</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:13</ows:Identifier>
<ScaleDenominator>68247.34667235345</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>4145</MatrixWidth>
<MatrixHeight>2795</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:14</ows:Identifier>
<ScaleDenominator>34123.673336176726</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>8290</MatrixWidth>
<MatrixHeight>5590</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:15</ows:Identifier>
<ScaleDenominator>17061.836668560845</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>16580</MatrixWidth>
<MatrixHeight>11180</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:16</ows:Identifier>
<ScaleDenominator>8530.918334280406</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>33159</MatrixWidth>
<MatrixHeight>22360</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:17</ows:Identifier>
<ScaleDenominator>4265.459166667739</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>66317</MatrixWidth>
<MatrixHeight>44719</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:18</ows:Identifier>
<ScaleDenominator>2132.7295838063405</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>132634</MatrixWidth>
<MatrixHeight>89437</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:19</ows:Identifier>
<ScaleDenominator>1066.3647914307007</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>265267</MatrixWidth>
<MatrixHeight>178873</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>EPSG:3857:20</ows:Identifier>
<ScaleDenominator>533.1823957153497</ScaleDenominator>
<TopLeftCorner>-2.0037508342787E7 2.0037508342787E7</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>530533</MatrixWidth>
<MatrixHeight>357746</MatrixHeight>
</TileMatrix>
</TileMatrixSet> |
Could you propose a PR to address this? |
I would like to add UK OS Maps WMTS layer as a background map. However, my request needs to include an API key as documented here.
This is the correct format of the get request that I am trying to achieve
https://api.os.uk/maps/raster/v1/wmts?key=xxxxxx&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=Light_3857&STYLE=default&FORMAT=image/png&TILEMATRIXSET=EPSG:3857&TILEMATRIX=EPSG:3857:16&TILEROW=21779&TILECOL=32721
Instead, I am getting:
https://api.os.uk/maps/raster/v1/wmts?layer=Light_3857&style=default&tilematrixset=EPSG:3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:3857:16&TileCol=32721&TileRow=21779
Is there a way to add another custom parameter to the request URL?
My themesConfig.json backgroundLayers entry:
The text was updated successfully, but these errors were encountered: