Skip to content
Permalink
Browse files
Clean
  • Loading branch information
pblottiere committed May 19, 2021
1 parent 6f620bb commit 81e61fa7aa73b07c24cd658e85b4a6c076fa3b06
Showing with 30 additions and 20 deletions.
  1. +30 −20 src/server/services/wmts/qgswmtsgetcapabilities.cpp
@@ -412,34 +412,44 @@ 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" ) );
if ( invert )
{
QDomText lowerCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.yMinimum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.xMinimum(), precision ), precision ) );
lowerCornerElement.appendChild( lowerCornerText );
}
else

// lower corner
double firstCoord = rect.xMinimum();
double secondCoord = rect.yMinimum();

if ( crs.hasAxisInverted() )
{
QDomText lowerCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.xMinimum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( rect.yMinimum(), precision ), precision ) );
lowerCornerElement.appendChild( lowerCornerText );
std::swap( firstCoord, secondCoord );
}

QString firstCoordStr = qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( firstCoord, precision ), precision );
QString secondCoordStr = qgsDoubleToString( QgsServerProjectUtils::floorWithPrecision( secondCoord, precision ), precision );
const QDomText lowerCornerText = doc.createTextNode( QString( "%1 %2" ).arg( firstCoordStr, secondCoordStr ) );

QDomElement lowerCornerElement = doc.createElement( QStringLiteral( "ows:LowerCorner" ) );
lowerCornerElement.appendChild( lowerCornerText );
bboxElement.appendChild( lowerCornerElement );
QDomElement upperCornerElement = doc.createElement( QStringLiteral( "ows:UpperCorner" ) );
if ( invert )
{
QDomText upperCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.yMaximum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.xMaximum(), precision ), precision ) );
upperCornerElement.appendChild( upperCornerText );
}
else

// upper corner
firstCoord = rect.xMaximum();
secondCoord = rect.yMaximum();

if ( crs.hasAxisInverted() )
{
QDomText upperCornerText = doc.createTextNode( qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.xMaximum(), precision ), precision ) + ' ' + qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( rect.yMaximum(), precision ), precision ) );
upperCornerElement.appendChild( upperCornerText );
std::swap( firstCoord, secondCoord );
}

firstCoordStr = qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( firstCoord, precision ), precision );
secondCoordStr = qgsDoubleToString( QgsServerProjectUtils::ceilWithPrecision( secondCoord, precision ), precision );
const QDomText upperCornerText = doc.createTextNode( QString( "%1 %2" ).arg( firstCoordStr, secondCoordStr ) );

QDomElement upperCornerElement = doc.createElement( QStringLiteral( "ows:UpperCorner" ) );
upperCornerElement.appendChild( upperCornerText );
bboxElement.appendChild( upperCornerElement );

// update layer element
layerElem.appendChild( bboxElement );
}

0 comments on commit 81e61fa

Please sign in to comment.