Skip to content
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

Fix WMTS wrapX detection if WGS84BoundingBox is not set #12409

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

M393
Copy link
Contributor

@M393 M393 commented Jun 17, 2021

There is an error thrown in optionsFromCapabilities when WGS84BoundingBox is not set in the layer config.
This sets wrapX to true in this case.

@M393
Copy link
Contributor Author

M393 commented Jun 17, 2021

Here's the xml I'm parsing:

File content
<?xml version="1.0" encoding="UTF-8"?>\n<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
    <ows:ServiceIdentification>
        <ows:ServiceType>OGC WMTS</ows:ServiceType>
        <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
    </ows:ServiceIdentification>
    <ows:ServiceProvider>
        <ows:ServiceContact>
            <ows:ContactInfo/>
        </ows:ServiceContact>
    </ows:ServiceProvider>
    <ows:OperationsMetadata>
        <ows:Operation name="GetCapabilities">
            <ows:DCP>
                <ows:HTTP>
                    <ows:Get xlink:href="http://localhost/services/wmts?">
                        <ows:Constraint name="GetEncoding">
                            <ows:AllowedValues>
                                <ows:Value>KVP</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Get>
                </ows:HTTP>
            </ows:DCP>
        </ows:Operation>
        <ows:Operation name="GetTile">
            <ows:DCP>
                <ows:HTTP>
                    <ows:Get xlink:href="http://localhost/services/wmts?">
                        <ows:Constraint name="GetEncoding">
                            <ows:AllowedValues>
                                <ows:Value>KVP</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Get>
                </ows:HTTP>
            </ows:DCP>
        </ows:Operation>
        <ows:Operation name="GetFeatureInfo">
            <ows:DCP>
                <ows:HTTP>
                    <ows:Get xlink:href="http://localhost/services/wmts?">
                        <ows:Constraint name="GetEncoding">
                            <ows:AllowedValues>
                                <ows:Value>KVP</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Get>
                </ows:HTTP>
            </ows:DCP>
        </ows:Operation>
    </ows:OperationsMetadata>
    <Contents>
        <Layer>
            <ows:Title>streets</ows:Title>
            <ows:Identifier>streets</ows:Identifier>
            <Style isDefault="true">
                <ows:Identifier>default</ows:Identifier>
            </Style>
            <Format>image/png; mode=8bit</Format>
            <TileMatrixSetLink>
                <TileMatrixSet>1x</TileMatrixSet>
                <TileMatrixSetLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:0</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>0</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>0</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:1</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>1</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>1</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:2</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>3</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>3</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:3</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>7</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>7</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:4</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>15</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>15</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:5</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>31</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>31</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:6</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>63</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>63</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:7</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>127</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>127</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:8</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>255</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>255</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:9</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>511</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>511</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:10</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>1023</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>1023</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:11</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>2047</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>2047</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:12</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>4095</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>4095</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:13</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>8191</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>8191</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:14</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>16383</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>16383</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:15</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>32767</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>32767</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:16</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>65535</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>65535</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:17</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>131071</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>131071</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:18</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>262143</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>262143</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:19</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>524287</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>524287</MaxTileCol>
                    </TileMatrixLimits>
                    <TileMatrixLimits>
                        <TileMatrix>1x:20</TileMatrix>
                        <MinTileRow>0</MinTileRow>
                        <MaxTileRow>1048575</MaxTileRow>
                        <MinTileCol>0</MinTileCol>
                        <MaxTileCol>1048575</MaxTileCol>
                    </TileMatrixLimits>
                </TileMatrixSetLimits>
            </TileMatrixSetLink>
            <ResourceURL format="image/png; mode=8bit" resourceType="tile" template="http://localhost/services/wmts/1.0.0/streets/default/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png"/>
        </Layer>
        <TileMatrixSet>
            <ows:Identifier>1x</ows:Identifier>
            <ows:BoundingBox crs="urn:ogc:def:crs:EPSG:6.3:3857">
                <ows:LowerCorner>-20037508.342789 -20037508.342789</ows:LowerCorner>
                <ows:UpperCorner>20037508.342789 20037508.342789</ows:UpperCorner>
            </ows:BoundingBox>
            <ows:SupportedCRS>urn:ogc:def:crs:EPSG:6.3:3857</ows:SupportedCRS>
            <TileMatrix>
                <ows:Identifier>0</ows:Identifier>
                <ScaleDenominator>559082264.02871787548065185547</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>1</MatrixWidth>
                <MatrixHeight>1</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>1</ows:Identifier>
                <ScaleDenominator>279541132.01435893774032592773</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>2</MatrixWidth>
                <MatrixHeight>2</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>2</ows:Identifier>
                <ScaleDenominator>139770566.00717946887016296387</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>4</MatrixWidth>
                <MatrixHeight>4</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>3</ows:Identifier>
                <ScaleDenominator>69885283.00358973443508148193</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>8</MatrixWidth>
                <MatrixHeight>8</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>4</ows:Identifier>
                <ScaleDenominator>34942641.50179486721754074097</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>16</MatrixWidth>
                <MatrixHeight>16</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>5</ows:Identifier>
                <ScaleDenominator>17471320.75089743360877037048</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>32</MatrixWidth>
                <MatrixHeight>32</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>6</ows:Identifier>
                <ScaleDenominator>8735660.37544871680438518524</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>64</MatrixWidth>
                <MatrixHeight>64</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>7</ows:Identifier>
                <ScaleDenominator>4367830.18772435840219259262</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>128</MatrixWidth>
                <MatrixHeight>128</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>8</ows:Identifier>
                <ScaleDenominator>2183915.09386217920109629631</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>256</MatrixWidth>
                <MatrixHeight>256</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>9</ows:Identifier>
                <ScaleDenominator>1091957.54693108960054814816</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>512</MatrixWidth>
                <MatrixHeight>512</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>10</ows:Identifier>
                <ScaleDenominator>545978.77346554480027407408</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>1024</MatrixWidth>
                <MatrixHeight>1024</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>11</ows:Identifier>
                <ScaleDenominator>272989.38673277240013703704</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>2048</MatrixWidth>
                <MatrixHeight>2048</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>12</ows:Identifier>
                <ScaleDenominator>136494.69336638620006851852</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>4096</MatrixWidth>
                <MatrixHeight>4096</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>13</ows:Identifier>
                <ScaleDenominator>68247.34668319310003425926</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>8192</MatrixWidth>
                <MatrixHeight>8192</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>14</ows:Identifier>
                <ScaleDenominator>34123.67334159655001712963</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>16384</MatrixWidth>
                <MatrixHeight>16384</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>15</ows:Identifier>
                <ScaleDenominator>17061.83667079827500856481</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>32768</MatrixWidth>
                <MatrixHeight>32768</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>16</ows:Identifier>
                <ScaleDenominator>8530.91833539913750428241</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>65536</MatrixWidth>
                <MatrixHeight>65536</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>17</ows:Identifier>
                <ScaleDenominator>4265.45916769956875214120</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>131072</MatrixWidth>
                <MatrixHeight>131072</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>18</ows:Identifier>
                <ScaleDenominator>2132.72958384978437607060</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>262144</MatrixWidth>
                <MatrixHeight>262144</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>19</ows:Identifier>
                <ScaleDenominator>1066.36479192489218803530</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>524288</MatrixWidth>
                <MatrixHeight>524288</MatrixHeight>
            </TileMatrix>
            <TileMatrix>
                <ows:Identifier>20</ows:Identifier>
                <ScaleDenominator>533.18239596244609401765</ScaleDenominator>
                <TopLeftCorner>-20037508.342789 20037508.342789</TopLeftCorner>
                <TileWidth>256</TileWidth>
                <TileHeight>256</TileHeight>
                <MatrixWidth>1048576</MatrixWidth>
                <MatrixHeight>1048576</MatrixHeight>
            </TileMatrix>
        </TileMatrixSet>
    </Contents>
</Capabilities>

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change sets wrapX to true too aggressively. In the absence of a wgs84BoundingBox, you would have to make the same check with the ows:BoundingBox of the TileMatrixSet. Otherwise you could have a TileMatrixSet of a small region, and because of wgs84BoundigBox missing you would incorrectly assumewrapX.

src/ol/source/WMTS.js Outdated Show resolved Hide resolved
Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Would you be able to add a test for this?

@ahocevar ahocevar dismissed their stale review June 18, 2021 12:25

Addressed.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @M393

@ahocevar ahocevar merged commit b7585e7 into openlayers:main Jun 21, 2021
@M393 M393 deleted the wmts-bounding-box branch June 21, 2021 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants