From 73e0559ab1f8973ace86d943e2f63d28cd395619 Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Thu, 21 Dec 2023 14:47:05 +0100 Subject: [PATCH] qgswfsgetfeature: Do not invert axis if no SRSNAME is passed A WFS request such as `SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&SRSNAME=EPSG:4326` does not invert the axis and return the coordinates in the LON/LAT order. For example: 2.358 48.865 2.37 48.876 However, the same request without a SRSNAME parameter inverts the axis and returns the the coordinates in the LAT/LON order: 48.865 2.358 48.876 2.37 With this change, the axis is not inverted if the SRSNAME parameter is not passed and has the same behavior as `SRSNAME=EPSG:4326`. This is a follow-up of qgis#45270. --- src/server/services/wfs/qgswfsgetfeature.cpp | 6 ++++-- .../wfs_getFeature_1_1_0_featureid_0_1_1_0_srsname.txt | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/server/services/wfs/qgswfsgetfeature.cpp b/src/server/services/wfs/qgswfsgetfeature.cpp index e994491b9e86..c9d014ebbf2e 100644 --- a/src/server/services/wfs/qgswfsgetfeature.cpp +++ b/src/server/services/wfs/qgswfsgetfeature.cpp @@ -464,7 +464,8 @@ namespace QgsWfs const QString srsName {request.serverParameters().value( QStringLiteral( "SRSNAME" ) )}; const bool invertAxis { mWfsParameters.versionAsNumber() >= QgsProjectVersion( 1, 1, 0 ) && outputCrs.hasAxisInverted() && - ! srsName.startsWith( QLatin1String( "EPSG:" ) ) }; + ! srsName.startsWith( QLatin1String( "EPSG:" ) ) && + !srsName.isEmpty() }; const createFeatureParams cfp = { layerPrecision, layerCrs, @@ -1251,7 +1252,8 @@ namespace QgsWfs const QString srsName {request.serverParameters().value( QStringLiteral( "SRSNAME" ) )}; const bool invertAxis { mWfsParameters.versionAsNumber() >= QgsProjectVersion( 1, 1, 0 ) && crs.hasAxisInverted() && - ! srsName.startsWith( QLatin1String( "EPSG:" ) ) }; + ! srsName.startsWith( QLatin1String( "EPSG:" ) ) && + !srsName.isEmpty() }; // If requested SRS (srsName) is different from rect CRS (crs) we need to transform the envelope QgsCoordinateTransform transform; diff --git a/tests/testdata/qgis_server/wfs_getFeature_1_1_0_featureid_0_1_1_0_srsname.txt b/tests/testdata/qgis_server/wfs_getFeature_1_1_0_featureid_0_1_1_0_srsname.txt index ce39f88833d0..cfbe5fd7dde4 100644 --- a/tests/testdata/qgis_server/wfs_getFeature_1_1_0_featureid_0_1_1_0_srsname.txt +++ b/tests/testdata/qgis_server/wfs_getFeature_1_1_0_featureid_0_1_1_0_srsname.txt @@ -3,8 +3,8 @@ Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8 - 44.90139484 8.20345931 - 44.90148253 8.20354699 + 8.20345931 44.90139484 + 8.20354699 44.90148253 @@ -13,11 +13,13 @@ Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8 44.90148253 8.20349634 44.90148253 8.20349634 + 8.20349634 44.90148253 + 8.20349634 44.90148253 - 44.90148253 8.20349634 + 8.20349634 44.90148253 1