Skip to content

Commit

Permalink
Inverting axis in bounding box for CRSes that requires it
Browse files Browse the repository at this point in the history
  • Loading branch information
leojth authored and pblottiere committed May 18, 2021
1 parent 18dd2c4 commit 3738a64
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/server/services/wmts/qgswmtsgetcapabilities.cpp
Expand Up @@ -412,15 +412,33 @@ namespace QgsWmts
precision = 6;
}

bool invert = crs.hasAxisInverted();

QDomElement bboxElement = doc.createElement( QStringLiteral( "ows:BoundingBox" ) );
bboxElement.setAttribute( QStringLiteral( "crs" ), tms.ref );
QDomElement lowerCornerElement = doc.createElement( QStringLiteral( "ows:LowerCorner" ) );
QDomText lowerCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.xMinimum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.yMinimum(), precision ), precision ) );
lowerCornerElement.appendChild( lowerCornerText );
if (invert)
{
QDomText lowerCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.yMinimum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.xMinimum(), precision ), precision ));
lowerCornerElement.appendChild( lowerCornerText );
}
else
{
QDomText lowerCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.xMinimum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.yMinimum(), precision ), precision ));
lowerCornerElement.appendChild( lowerCornerText );
}
bboxElement.appendChild( lowerCornerElement );
QDomElement upperCornerElement = doc.createElement( QStringLiteral( "ows:UpperCorner" ) );
QDomText upperCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.xMaximum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.yMaximum(), precision ), precision ) );
upperCornerElement.appendChild( upperCornerText );
if (invert)
{
QDomText upperCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.yMaximum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.xMaximum(), precision ), precision ));
upperCornerElement.appendChild( upperCornerText );
}
else
{
QDomText upperCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.xMaximum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.yMaximum(), precision ), precision ));
upperCornerElement.appendChild( upperCornerText );
}
bboxElement.appendChild( upperCornerElement );
layerElem.appendChild( bboxElement );
}
Expand Down

0 comments on commit 3738a64

Please sign in to comment.