Skip to content
Permalink
Browse files
Inverting axis in bounding box for CRSes that requires it
  • Loading branch information
leojth authored and pblottiere committed May 18, 2021
1 parent 18dd2c4 commit 3738a644f3e16521444a12a71ce9136093c9e435
Showing with 22 additions and 4 deletions.
  1. +22 −4 src/server/services/wmts/qgswmtsgetcapabilities.cpp
@@ -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 );
}

0 comments on commit 3738a64

Please sign in to comment.