Skip to content
Permalink
Browse files

[Bugfix][Server] WMTS: CRS can have axis inverted

The top left element has to respect the axis, like in WMS 1.3.0.
  • Loading branch information
rldhont committed Apr 19, 2019
1 parent dd18e8f commit d7705256f1cb6794a5f6e689c2a1d0c0ba6d81f9
@@ -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" ) );
@@ -96,6 +96,7 @@ namespace QgsWmts
}

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

// calculate tile matrix scale denominator
double scaleDenominator = 0.0;
@@ -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;
@@ -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 ) + ',' +
@@ -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;
@@ -43,6 +43,8 @@ namespace QgsWmts

QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;

bool hasAxisInverted = false;

double scaleDenominator = 0.0;
};

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

QgsUnitTypes::DistanceUnit unit = QgsUnitTypes::DistanceMeters;

bool hasAxisInverted = false;

QList< tileMatrixDef > tileMatrixList;
};

@@ -939,7 +939,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>
@@ -948,7 +948,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>
@@ -957,7 +957,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>
@@ -966,7 +966,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>
@@ -975,7 +975,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>
@@ -984,7 +984,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>
@@ -993,7 +993,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>
@@ -1002,7 +1002,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>
@@ -1011,7 +1011,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>
@@ -1020,7 +1020,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>
@@ -1029,7 +1029,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>
@@ -1038,7 +1038,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>
@@ -1047,7 +1047,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>
@@ -1056,7 +1056,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>
@@ -1065,7 +1065,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>
@@ -1074,7 +1074,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>
@@ -1083,7 +1083,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>
@@ -1092,7 +1092,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>
@@ -1101,7 +1101,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>
@@ -1110,7 +1110,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>

0 comments on commit d770525

Please sign in to comment.
You can’t perform that action at this time.