Skip to content

Commit

Permalink
Merge pull request #9835 from rldhont/backport-9827-to-release-3_4
Browse files Browse the repository at this point in the history
[Backport release-3_4] [Bugfix][Server] WMTS: CRS can have axis inverted
  • Loading branch information
rldhont committed Apr 20, 2019
2 parents 525e414 + d770525 commit dbdd6b5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
12 changes: 10 additions & 2 deletions src/server/services/wmts/qgswmtsgetcapabilities.cpp
Expand Up @@ -540,8 +540,16 @@ namespace QgsWmts
tmElement.appendChild( tmScaleDenomElem );

QDomElement tmTopLeftCornerElem = doc.createElement( QStringLiteral( "TopLeftCorner" ) );
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.left, 6 ) + ' ' + qgsDoubleToString( tm.top, 6 ) );
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
if ( tms.hasAxisInverted )
{
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.top, 6 ) + ' ' + qgsDoubleToString( tm.left, 6 ) );
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
}
else
{
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.left, 6 ) + ' ' + qgsDoubleToString( tm.top, 6 ) );
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
}
tmElement.appendChild( tmTopLeftCornerElem );

QDomElement tmTileWidthElem = doc.createElement( QStringLiteral( "TileWidth" ) );
Expand Down
5 changes: 4 additions & 1 deletion src/server/services/wmts/qgswmtsutils.cpp
Expand Up @@ -96,6 +96,7 @@ namespace QgsWmts
}

tmi.unit = crs.mapUnits();
tmi.hasAxisInverted = crs.hasAxisInverted();

// calculate tile matrix scale denominator
double scaleDenominator = 0.0;
Expand Down Expand Up @@ -183,6 +184,7 @@ namespace QgsWmts
tms.ref = tmi.ref;
tms.extent = extent;
tms.unit = unit;
tms.hasAxisInverted = tmi.hasAxisInverted;
tms.tileMatrixList = tileMatrixList;

return tms;
Expand Down Expand Up @@ -641,7 +643,7 @@ namespace QgsWmts
double maxx = tm.left + ( tc + 1 ) * ( tileSize * res );
double maxy = tm.top - tr * ( tileSize * res );
QString bbox;
if ( tms.ref == "EPSG:4326" )
if ( tms.hasAxisInverted )
{
bbox = qgsDoubleToString( miny, 6 ) + ',' +
qgsDoubleToString( minx, 6 ) + ',' +
Expand Down Expand Up @@ -702,6 +704,7 @@ namespace QgsWmts
tmi4326.extent = QgsRectangle( -180, -90, 180, 90 );
tmi4326.scaleDenominator = 279541132.0143588675418869;
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
tmi4326.hasAxisInverted = true;
m[tmi4326.ref] = tmi4326;

return m;
Expand Down
4 changes: 4 additions & 0 deletions src/server/services/wmts/qgswmtsutils.h
Expand Up @@ -43,6 +43,8 @@ namespace QgsWmts

QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;

bool hasAxisInverted = false;

double scaleDenominator = 0.0;
};

Expand All @@ -69,6 +71,8 @@ namespace QgsWmts

QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;

bool hasAxisInverted = false;

QList< tileMatrixDef > tileMatrixList;
};

Expand Down
40 changes: 20 additions & 20 deletions tests/testdata/qgis_server/wmts_getcapabilities.txt
Expand Up @@ -1191,7 +1191,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>0</ows:Identifier>
<ScaleDenominator>279541132.014359</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2</MatrixWidth>
Expand All @@ -1200,7 +1200,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>1</ows:Identifier>
<ScaleDenominator>139770566.007179</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>4</MatrixWidth>
Expand All @@ -1209,7 +1209,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>2</ows:Identifier>
<ScaleDenominator>69885283.00359</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>8</MatrixWidth>
Expand All @@ -1218,7 +1218,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>3</ows:Identifier>
<ScaleDenominator>34942641.501795</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>16</MatrixWidth>
Expand All @@ -1227,7 +1227,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>4</ows:Identifier>
<ScaleDenominator>17471320.750897</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>32</MatrixWidth>
Expand All @@ -1236,7 +1236,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>5</ows:Identifier>
<ScaleDenominator>8735660.375449</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>64</MatrixWidth>
Expand All @@ -1245,7 +1245,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>6</ows:Identifier>
<ScaleDenominator>4367830.187724</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>128</MatrixWidth>
Expand All @@ -1254,7 +1254,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>7</ows:Identifier>
<ScaleDenominator>2183915.093862</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>256</MatrixWidth>
Expand All @@ -1263,7 +1263,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>8</ows:Identifier>
<ScaleDenominator>1091957.546931</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>512</MatrixWidth>
Expand All @@ -1272,7 +1272,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>9</ows:Identifier>
<ScaleDenominator>545978.773466</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1024</MatrixWidth>
Expand All @@ -1281,7 +1281,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>10</ows:Identifier>
<ScaleDenominator>272989.386733</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2048</MatrixWidth>
Expand All @@ -1290,7 +1290,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>11</ows:Identifier>
<ScaleDenominator>136494.693366</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>4096</MatrixWidth>
Expand All @@ -1299,7 +1299,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>12</ows:Identifier>
<ScaleDenominator>68247.346683</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>8192</MatrixWidth>
Expand All @@ -1308,7 +1308,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>13</ows:Identifier>
<ScaleDenominator>34123.673342</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>16384</MatrixWidth>
Expand All @@ -1317,7 +1317,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>14</ows:Identifier>
<ScaleDenominator>17061.836671</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>32768</MatrixWidth>
Expand All @@ -1326,7 +1326,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>15</ows:Identifier>
<ScaleDenominator>8530.918335</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>65536</MatrixWidth>
Expand All @@ -1335,7 +1335,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>16</ows:Identifier>
<ScaleDenominator>4265.459168</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>131072</MatrixWidth>
Expand All @@ -1344,7 +1344,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>17</ows:Identifier>
<ScaleDenominator>2132.729584</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>262144</MatrixWidth>
Expand All @@ -1353,7 +1353,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>18</ows:Identifier>
<ScaleDenominator>1066.364792</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>524288</MatrixWidth>
Expand All @@ -1362,7 +1362,7 @@ Content-Type: text/xml; charset=utf-8
<TileMatrix>
<ows:Identifier>19</ows:Identifier>
<ScaleDenominator>533.182396</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TopLeftCorner>90 -180</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1048576</MatrixWidth>
Expand Down

0 comments on commit dbdd6b5

Please sign in to comment.