Skip to content

Commit 48f1f2c

Browse files
slarosanyalldawson
authored andcommitted
fix: replace comma with point in wms boundingBox
1 parent 0929919 commit 48f1f2c

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/providers/wms/qgswmscapabilities.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,11 +1234,13 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
12341234
}
12351235
else if ( tagName == QLatin1String( "LatLonBoundingBox" ) ) // legacy from earlier versions of WMS
12361236
{
1237+
// boundingBox element can conatain comma as decimal separator and layer extent is not
1238+
// calculated at all. Fixing by replacing comma with point.
12371239
layerProperty.ex_GeographicBoundingBox = QgsRectangle(
1238-
nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
1239-
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
1240-
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
1241-
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
1240+
nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
1241+
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
1242+
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
1243+
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
12421244
);
12431245

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

12781280
double wBLong, eBLong, sBLat, nBLat;
12791281
bool wBOk, eBOk, sBOk, nBOk;
1280-
wBLong = wBoundLongitudeElem.text().toDouble( &wBOk );
1281-
eBLong = eBoundLongitudeElem.text().toDouble( &eBOk );
1282-
sBLat = sBoundLatitudeElem.text().toDouble( &sBOk );
1283-
nBLat = nBoundLatitudeElem.text().toDouble( &nBOk );
1282+
// boundingBox element can conatain comma as decimal separator and layer extent is not
1283+
// calculated at all. Fixing by replacing comma with point.
1284+
wBLong = wBoundLongitudeElem.text().replace( ',', '.' ).toDouble( &wBOk );
1285+
eBLong = eBoundLongitudeElem.text().replace( ',', '.' ).toDouble( &eBOk );
1286+
sBLat = sBoundLatitudeElem.text().replace( ',', '.' ).toDouble( &sBOk );
1287+
nBLat = nBoundLatitudeElem.text().replace( ',', '.' ).toDouble( &nBOk );
12841288
if ( wBOk && eBOk && sBOk && nBOk )
12851289
{
12861290
layerProperty.ex_GeographicBoundingBox = QgsRectangle( wBLong, sBLat, eBLong, nBLat );
@@ -1289,10 +1293,10 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
12891293
else if ( tagName == QLatin1String( "BoundingBox" ) )
12901294
{
12911295
QgsWmsBoundingBoxProperty bbox;
1292-
bbox.box = QgsRectangle( nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
1293-
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
1294-
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
1295-
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
1296+
bbox.box = QgsRectangle( nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
1297+
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
1298+
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
1299+
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
12961300
);
12971301
if ( nodeElement.hasAttribute( QStringLiteral( "CRS" ) ) || nodeElement.hasAttribute( QStringLiteral( "SRS" ) ) )
12981302
{
@@ -1640,11 +1644,13 @@ void QgsWmsCapabilities::parseTileSetProfile( const QDomElement &element )
16401644
else if ( tagName == QLatin1String( "BoundingBox" ) )
16411645
{
16421646
QgsWmsBoundingBoxProperty boundingBoxProperty;
1647+
// boundingBox element can conatain comma as decimal separator and layer extent is not
1648+
// calculated at all. Fixing by replacing comma with point.
16431649
boundingBoxProperty.box = QgsRectangle(
1644-
nodeElement.attribute( QStringLiteral( "minx" ) ).toDouble(),
1645-
nodeElement.attribute( QStringLiteral( "miny" ) ).toDouble(),
1646-
nodeElement.attribute( QStringLiteral( "maxx" ) ).toDouble(),
1647-
nodeElement.attribute( QStringLiteral( "maxy" ) ).toDouble()
1650+
nodeElement.attribute( QStringLiteral( "minx" ) ).replace( ',', '.' ).toDouble(),
1651+
nodeElement.attribute( QStringLiteral( "miny" ) ).replace( ',', '.' ).toDouble(),
1652+
nodeElement.attribute( QStringLiteral( "maxx" ) ).replace( ',', '.' ).toDouble(),
1653+
nodeElement.attribute( QStringLiteral( "maxy" ) ).replace( ',', '.' ).toDouble()
16481654
);
16491655
if ( nodeElement.hasAttribute( QStringLiteral( "SRS" ) ) )
16501656
boundingBoxProperty.crs = nodeElement.attribute( QStringLiteral( "SRS" ) );

0 commit comments

Comments
 (0)