Merge pull request #61963 from elpaso/bugfix-gh61399-wms-getcap-fails-on-split

[wmts] Be nice and accept redundant spaces in coord tuples
This commit is contained in:
Alexander Bruy 2025-05-24 07:27:02 +01:00 committed by GitHub
commit f3a55eb615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 5 deletions

View File

@ -1793,7 +1793,7 @@ void QgsWmsCapabilities::parseWMTSContents( const QDomElement &element )
tileMatrix.scaleDenom = secondChildElement.firstChildElement( QStringLiteral( "ScaleDenominator" ) ).text().toDouble();
QStringList topLeft = secondChildElement.firstChildElement( QStringLiteral( "TopLeftCorner" ) ).text().split( ' ' );
QStringList topLeft = secondChildElement.firstChildElement( QStringLiteral( "TopLeftCorner" ) ).text().split( ' ', Qt::SkipEmptyParts );
if ( topLeft.size() == 2 )
{
if ( invert )
@ -1856,8 +1856,8 @@ void QgsWmsCapabilities::parseWMTSContents( const QDomElement &element )
QDomElement bbox = childElement.firstChildElement( QStringLiteral( "ows:WGS84BoundingBox" ) );
if ( !bbox.isNull() )
{
QStringList ll = bbox.firstChildElement( QStringLiteral( "ows:LowerCorner" ) ).text().split( ' ' );
QStringList ur = bbox.firstChildElement( QStringLiteral( "ows:UpperCorner" ) ).text().split( ' ' );
QStringList ll = bbox.firstChildElement( QStringLiteral( "ows:LowerCorner" ) ).text().split( ' ', Qt::SkipEmptyParts );
QStringList ur = bbox.firstChildElement( QStringLiteral( "ows:UpperCorner" ) ).text().split( ' ', Qt::SkipEmptyParts );
if ( ll.size() == 2 && ur.size() == 2 )
{
@ -1872,8 +1872,8 @@ void QgsWmsCapabilities::parseWMTSContents( const QDomElement &element )
!bbox.isNull();
bbox = bbox.nextSiblingElement( QStringLiteral( "ows:BoundingBox" ) ) )
{
QStringList ll = bbox.firstChildElement( QStringLiteral( "ows:LowerCorner" ) ).text().split( ' ' );
QStringList ur = bbox.firstChildElement( QStringLiteral( "ows:UpperCorner" ) ).text().split( ' ' );
QStringList ll = bbox.firstChildElement( QStringLiteral( "ows:LowerCorner" ) ).text().split( ' ', Qt::SkipEmptyParts );
QStringList ur = bbox.firstChildElement( QStringLiteral( "ows:UpperCorner" ) ).text().split( ' ', Qt::SkipEmptyParts );
if ( ll.size() == 2 && ur.size() == 2 )
{

View File

@ -596,6 +596,44 @@ class TestQgsWmsCapabilities : public QObject
QCOMPARE( res.end(), range.end() );
QCOMPARE( static_cast<int>( resFormat ), format );
}
void wmtsWithRedundantSpaces()
{
QgsWmsCapabilities capabilities;
const QgsWmsParserSettings config;
// Note: Redundant spaces in the coordinate tuples
const QByteArray configData( R"""(<Capabilities>
<Contents>
<Layer>
<ows:Identifier>Layer1</ows:Identifier>
<ows:WGS84BoundingBox>
<ows:LowerCorner>109.999000 -45.081000</ows:LowerCorner>
<ows:UpperCorner>155.005000 -9.978000</ows:UpperCorner>
</ows:WGS84BoundingBox>
</Layer>
<TileMatrixSet>
<ows:Identifier>WholeWorld_CRS_84</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GlobalCRS84Pixel</WellKnownScaleSet>
<TileMatrix>
<ows:Identifier>1g</ows:Identifier>
<ScaleDenominator>397569609.975977</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>320</TileWidth>
<TileHeight>200</TileHeight>
<MatrixWidth>2</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
</Capabilities>)""" );
QVERIFY( capabilities.parseResponse( configData, config ) );
QCOMPARE( capabilities.supportedTileMatrixSets().size(), 1 );
QgsWmtsTileLayer layer = capabilities.supportedTileLayers().at( 0 );
QCOMPARE( layer.boundingBoxes.first().box, QgsRectangle( 109.999, -45.081, 155.005, -9.978 ) );
}
};
QGSTEST_MAIN( TestQgsWmsCapabilities )