Skip to content

Commit

Permalink
fix: replace comma with point in wms boundingBox
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa authored and nyalldawson committed Jan 27, 2021
1 parent 0929919 commit 48f1f2c
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -1234,11 +1234,13 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
}
else if ( tagName == QLatin1String( "LatLonBoundingBox" ) ) // legacy from earlier versions of WMS
{
// boundingBox element can conatain comma as decimal separator and layer extent is not
// calculated at all. Fixing by replacing comma with point.
layerProperty.ex_GeographicBoundingBox = QgsRectangle(
nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
);

if ( nodeElement.hasAttribute( QStringLiteral( "SRS" ) ) && nodeElement.attribute( QStringLiteral( "SRS" ) ) != DEFAULT_LATLON_CRS )
Expand Down Expand Up @@ -1277,10 +1279,12 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp

double wBLong, eBLong, sBLat, nBLat;
bool wBOk, eBOk, sBOk, nBOk;
wBLong = wBoundLongitudeElem.text().toDouble( &wBOk );
eBLong = eBoundLongitudeElem.text().toDouble( &eBOk );
sBLat = sBoundLatitudeElem.text().toDouble( &sBOk );
nBLat = nBoundLatitudeElem.text().toDouble( &nBOk );
// boundingBox element can conatain comma as decimal separator and layer extent is not
// calculated at all. Fixing by replacing comma with point.
wBLong = wBoundLongitudeElem.text().replace( ',', '.' ).toDouble( &wBOk );
eBLong = eBoundLongitudeElem.text().replace( ',', '.' ).toDouble( &eBOk );
sBLat = sBoundLatitudeElem.text().replace( ',', '.' ).toDouble( &sBOk );
nBLat = nBoundLatitudeElem.text().replace( ',', '.' ).toDouble( &nBOk );
if ( wBOk && eBOk && sBOk && nBOk )
{
layerProperty.ex_GeographicBoundingBox = QgsRectangle( wBLong, sBLat, eBLong, nBLat );
Expand All @@ -1289,10 +1293,10 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
else if ( tagName == QLatin1String( "BoundingBox" ) )
{
QgsWmsBoundingBoxProperty bbox;
bbox.box = QgsRectangle( nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
bbox.box = QgsRectangle( nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
);
if ( nodeElement.hasAttribute( QStringLiteral( "CRS" ) ) || nodeElement.hasAttribute( QStringLiteral( "SRS" ) ) )
{
Expand Down Expand Up @@ -1640,11 +1644,13 @@ void QgsWmsCapabilities::parseTileSetProfile( const QDomElement &element )
else if ( tagName == QLatin1String( "BoundingBox" ) )
{
QgsWmsBoundingBoxProperty boundingBoxProperty;
// boundingBox element can conatain comma as decimal separator and layer extent is not
// calculated at all. Fixing by replacing comma with point.
boundingBoxProperty.box = QgsRectangle(
nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
);
if ( nodeElement.hasAttribute( QStringLiteral( "SRS" ) ) )
boundingBoxProperty.crs = nodeElement.attribute( QStringLiteral( "SRS" ) );
Expand Down

0 comments on commit 48f1f2c

Please sign in to comment.