Skip to content

Commit dbdd6b5

Browse files
authored
Merge pull request #9835 from rldhont/backport-9827-to-release-3_4
[Backport release-3_4] [Bugfix][Server] WMTS: CRS can have axis inverted
2 parents 525e414 + d770525 commit dbdd6b5

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

src/server/services/wmts/qgswmtsgetcapabilities.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,16 @@ namespace QgsWmts
540540
tmElement.appendChild( tmScaleDenomElem );
541541

542542
QDomElement tmTopLeftCornerElem = doc.createElement( QStringLiteral( "TopLeftCorner" ) );
543-
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.left, 6 ) + ' ' + qgsDoubleToString( tm.top, 6 ) );
544-
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
543+
if ( tms.hasAxisInverted )
544+
{
545+
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.top, 6 ) + ' ' + qgsDoubleToString( tm.left, 6 ) );
546+
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
547+
}
548+
else
549+
{
550+
QDomText tmTopLeftCornerText = doc.createTextNode( qgsDoubleToString( tm.left, 6 ) + ' ' + qgsDoubleToString( tm.top, 6 ) );
551+
tmTopLeftCornerElem.appendChild( tmTopLeftCornerText );
552+
}
545553
tmElement.appendChild( tmTopLeftCornerElem );
546554

547555
QDomElement tmTileWidthElem = doc.createElement( QStringLiteral( "TileWidth" ) );

src/server/services/wmts/qgswmtsutils.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ namespace QgsWmts
9696
}
9797

9898
tmi.unit = crs.mapUnits();
99+
tmi.hasAxisInverted = crs.hasAxisInverted();
99100

100101
// calculate tile matrix scale denominator
101102
double scaleDenominator = 0.0;
@@ -183,6 +184,7 @@ namespace QgsWmts
183184
tms.ref = tmi.ref;
184185
tms.extent = extent;
185186
tms.unit = unit;
187+
tms.hasAxisInverted = tmi.hasAxisInverted;
186188
tms.tileMatrixList = tileMatrixList;
187189

188190
return tms;
@@ -641,7 +643,7 @@ namespace QgsWmts
641643
double maxx = tm.left + ( tc + 1 ) * ( tileSize * res );
642644
double maxy = tm.top - tr * ( tileSize * res );
643645
QString bbox;
644-
if ( tms.ref == "EPSG:4326" )
646+
if ( tms.hasAxisInverted )
645647
{
646648
bbox = qgsDoubleToString( miny, 6 ) + ',' +
647649
qgsDoubleToString( minx, 6 ) + ',' +
@@ -702,6 +704,7 @@ namespace QgsWmts
702704
tmi4326.extent = QgsRectangle( -180, -90, 180, 90 );
703705
tmi4326.scaleDenominator = 279541132.0143588675418869;
704706
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
707+
tmi4326.hasAxisInverted = true;
705708
m[tmi4326.ref] = tmi4326;
706709

707710
return m;

src/server/services/wmts/qgswmtsutils.h

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ namespace QgsWmts
4343

4444
QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;
4545

46+
bool hasAxisInverted = false;
47+
4648
double scaleDenominator = 0.0;
4749
};
4850

@@ -69,6 +71,8 @@ namespace QgsWmts
6971

7072
QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;
7173

74+
bool hasAxisInverted = false;
75+
7276
QList< tileMatrixDef > tileMatrixList;
7377
};
7478

tests/testdata/qgis_server/wmts_getcapabilities.txt

+20-20
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ Content-Type: text/xml; charset=utf-8
11911191
<TileMatrix>
11921192
<ows:Identifier>0</ows:Identifier>
11931193
<ScaleDenominator>279541132.014359</ScaleDenominator>
1194-
<TopLeftCorner>-180 90</TopLeftCorner>
1194+
<TopLeftCorner>90 -180</TopLeftCorner>
11951195
<TileWidth>256</TileWidth>
11961196
<TileHeight>256</TileHeight>
11971197
<MatrixWidth>2</MatrixWidth>
@@ -1200,7 +1200,7 @@ Content-Type: text/xml; charset=utf-8
12001200
<TileMatrix>
12011201
<ows:Identifier>1</ows:Identifier>
12021202
<ScaleDenominator>139770566.007179</ScaleDenominator>
1203-
<TopLeftCorner>-180 90</TopLeftCorner>
1203+
<TopLeftCorner>90 -180</TopLeftCorner>
12041204
<TileWidth>256</TileWidth>
12051205
<TileHeight>256</TileHeight>
12061206
<MatrixWidth>4</MatrixWidth>
@@ -1209,7 +1209,7 @@ Content-Type: text/xml; charset=utf-8
12091209
<TileMatrix>
12101210
<ows:Identifier>2</ows:Identifier>
12111211
<ScaleDenominator>69885283.00359</ScaleDenominator>
1212-
<TopLeftCorner>-180 90</TopLeftCorner>
1212+
<TopLeftCorner>90 -180</TopLeftCorner>
12131213
<TileWidth>256</TileWidth>
12141214
<TileHeight>256</TileHeight>
12151215
<MatrixWidth>8</MatrixWidth>
@@ -1218,7 +1218,7 @@ Content-Type: text/xml; charset=utf-8
12181218
<TileMatrix>
12191219
<ows:Identifier>3</ows:Identifier>
12201220
<ScaleDenominator>34942641.501795</ScaleDenominator>
1221-
<TopLeftCorner>-180 90</TopLeftCorner>
1221+
<TopLeftCorner>90 -180</TopLeftCorner>
12221222
<TileWidth>256</TileWidth>
12231223
<TileHeight>256</TileHeight>
12241224
<MatrixWidth>16</MatrixWidth>
@@ -1227,7 +1227,7 @@ Content-Type: text/xml; charset=utf-8
12271227
<TileMatrix>
12281228
<ows:Identifier>4</ows:Identifier>
12291229
<ScaleDenominator>17471320.750897</ScaleDenominator>
1230-
<TopLeftCorner>-180 90</TopLeftCorner>
1230+
<TopLeftCorner>90 -180</TopLeftCorner>
12311231
<TileWidth>256</TileWidth>
12321232
<TileHeight>256</TileHeight>
12331233
<MatrixWidth>32</MatrixWidth>
@@ -1236,7 +1236,7 @@ Content-Type: text/xml; charset=utf-8
12361236
<TileMatrix>
12371237
<ows:Identifier>5</ows:Identifier>
12381238
<ScaleDenominator>8735660.375449</ScaleDenominator>
1239-
<TopLeftCorner>-180 90</TopLeftCorner>
1239+
<TopLeftCorner>90 -180</TopLeftCorner>
12401240
<TileWidth>256</TileWidth>
12411241
<TileHeight>256</TileHeight>
12421242
<MatrixWidth>64</MatrixWidth>
@@ -1245,7 +1245,7 @@ Content-Type: text/xml; charset=utf-8
12451245
<TileMatrix>
12461246
<ows:Identifier>6</ows:Identifier>
12471247
<ScaleDenominator>4367830.187724</ScaleDenominator>
1248-
<TopLeftCorner>-180 90</TopLeftCorner>
1248+
<TopLeftCorner>90 -180</TopLeftCorner>
12491249
<TileWidth>256</TileWidth>
12501250
<TileHeight>256</TileHeight>
12511251
<MatrixWidth>128</MatrixWidth>
@@ -1254,7 +1254,7 @@ Content-Type: text/xml; charset=utf-8
12541254
<TileMatrix>
12551255
<ows:Identifier>7</ows:Identifier>
12561256
<ScaleDenominator>2183915.093862</ScaleDenominator>
1257-
<TopLeftCorner>-180 90</TopLeftCorner>
1257+
<TopLeftCorner>90 -180</TopLeftCorner>
12581258
<TileWidth>256</TileWidth>
12591259
<TileHeight>256</TileHeight>
12601260
<MatrixWidth>256</MatrixWidth>
@@ -1263,7 +1263,7 @@ Content-Type: text/xml; charset=utf-8
12631263
<TileMatrix>
12641264
<ows:Identifier>8</ows:Identifier>
12651265
<ScaleDenominator>1091957.546931</ScaleDenominator>
1266-
<TopLeftCorner>-180 90</TopLeftCorner>
1266+
<TopLeftCorner>90 -180</TopLeftCorner>
12671267
<TileWidth>256</TileWidth>
12681268
<TileHeight>256</TileHeight>
12691269
<MatrixWidth>512</MatrixWidth>
@@ -1272,7 +1272,7 @@ Content-Type: text/xml; charset=utf-8
12721272
<TileMatrix>
12731273
<ows:Identifier>9</ows:Identifier>
12741274
<ScaleDenominator>545978.773466</ScaleDenominator>
1275-
<TopLeftCorner>-180 90</TopLeftCorner>
1275+
<TopLeftCorner>90 -180</TopLeftCorner>
12761276
<TileWidth>256</TileWidth>
12771277
<TileHeight>256</TileHeight>
12781278
<MatrixWidth>1024</MatrixWidth>
@@ -1281,7 +1281,7 @@ Content-Type: text/xml; charset=utf-8
12811281
<TileMatrix>
12821282
<ows:Identifier>10</ows:Identifier>
12831283
<ScaleDenominator>272989.386733</ScaleDenominator>
1284-
<TopLeftCorner>-180 90</TopLeftCorner>
1284+
<TopLeftCorner>90 -180</TopLeftCorner>
12851285
<TileWidth>256</TileWidth>
12861286
<TileHeight>256</TileHeight>
12871287
<MatrixWidth>2048</MatrixWidth>
@@ -1290,7 +1290,7 @@ Content-Type: text/xml; charset=utf-8
12901290
<TileMatrix>
12911291
<ows:Identifier>11</ows:Identifier>
12921292
<ScaleDenominator>136494.693366</ScaleDenominator>
1293-
<TopLeftCorner>-180 90</TopLeftCorner>
1293+
<TopLeftCorner>90 -180</TopLeftCorner>
12941294
<TileWidth>256</TileWidth>
12951295
<TileHeight>256</TileHeight>
12961296
<MatrixWidth>4096</MatrixWidth>
@@ -1299,7 +1299,7 @@ Content-Type: text/xml; charset=utf-8
12991299
<TileMatrix>
13001300
<ows:Identifier>12</ows:Identifier>
13011301
<ScaleDenominator>68247.346683</ScaleDenominator>
1302-
<TopLeftCorner>-180 90</TopLeftCorner>
1302+
<TopLeftCorner>90 -180</TopLeftCorner>
13031303
<TileWidth>256</TileWidth>
13041304
<TileHeight>256</TileHeight>
13051305
<MatrixWidth>8192</MatrixWidth>
@@ -1308,7 +1308,7 @@ Content-Type: text/xml; charset=utf-8
13081308
<TileMatrix>
13091309
<ows:Identifier>13</ows:Identifier>
13101310
<ScaleDenominator>34123.673342</ScaleDenominator>
1311-
<TopLeftCorner>-180 90</TopLeftCorner>
1311+
<TopLeftCorner>90 -180</TopLeftCorner>
13121312
<TileWidth>256</TileWidth>
13131313
<TileHeight>256</TileHeight>
13141314
<MatrixWidth>16384</MatrixWidth>
@@ -1317,7 +1317,7 @@ Content-Type: text/xml; charset=utf-8
13171317
<TileMatrix>
13181318
<ows:Identifier>14</ows:Identifier>
13191319
<ScaleDenominator>17061.836671</ScaleDenominator>
1320-
<TopLeftCorner>-180 90</TopLeftCorner>
1320+
<TopLeftCorner>90 -180</TopLeftCorner>
13211321
<TileWidth>256</TileWidth>
13221322
<TileHeight>256</TileHeight>
13231323
<MatrixWidth>32768</MatrixWidth>
@@ -1326,7 +1326,7 @@ Content-Type: text/xml; charset=utf-8
13261326
<TileMatrix>
13271327
<ows:Identifier>15</ows:Identifier>
13281328
<ScaleDenominator>8530.918335</ScaleDenominator>
1329-
<TopLeftCorner>-180 90</TopLeftCorner>
1329+
<TopLeftCorner>90 -180</TopLeftCorner>
13301330
<TileWidth>256</TileWidth>
13311331
<TileHeight>256</TileHeight>
13321332
<MatrixWidth>65536</MatrixWidth>
@@ -1335,7 +1335,7 @@ Content-Type: text/xml; charset=utf-8
13351335
<TileMatrix>
13361336
<ows:Identifier>16</ows:Identifier>
13371337
<ScaleDenominator>4265.459168</ScaleDenominator>
1338-
<TopLeftCorner>-180 90</TopLeftCorner>
1338+
<TopLeftCorner>90 -180</TopLeftCorner>
13391339
<TileWidth>256</TileWidth>
13401340
<TileHeight>256</TileHeight>
13411341
<MatrixWidth>131072</MatrixWidth>
@@ -1344,7 +1344,7 @@ Content-Type: text/xml; charset=utf-8
13441344
<TileMatrix>
13451345
<ows:Identifier>17</ows:Identifier>
13461346
<ScaleDenominator>2132.729584</ScaleDenominator>
1347-
<TopLeftCorner>-180 90</TopLeftCorner>
1347+
<TopLeftCorner>90 -180</TopLeftCorner>
13481348
<TileWidth>256</TileWidth>
13491349
<TileHeight>256</TileHeight>
13501350
<MatrixWidth>262144</MatrixWidth>
@@ -1353,7 +1353,7 @@ Content-Type: text/xml; charset=utf-8
13531353
<TileMatrix>
13541354
<ows:Identifier>18</ows:Identifier>
13551355
<ScaleDenominator>1066.364792</ScaleDenominator>
1356-
<TopLeftCorner>-180 90</TopLeftCorner>
1356+
<TopLeftCorner>90 -180</TopLeftCorner>
13571357
<TileWidth>256</TileWidth>
13581358
<TileHeight>256</TileHeight>
13591359
<MatrixWidth>524288</MatrixWidth>
@@ -1362,7 +1362,7 @@ Content-Type: text/xml; charset=utf-8
13621362
<TileMatrix>
13631363
<ows:Identifier>19</ows:Identifier>
13641364
<ScaleDenominator>533.182396</ScaleDenominator>
1365-
<TopLeftCorner>-180 90</TopLeftCorner>
1365+
<TopLeftCorner>90 -180</TopLeftCorner>
13661366
<TileWidth>256</TileWidth>
13671367
<TileHeight>256</TileHeight>
13681368
<MatrixWidth>1048576</MatrixWidth>

0 commit comments

Comments
 (0)