Skip to content

Commit

Permalink
qgswfsgetfeature: Do not invert axis if no SRSNAME is passed
Browse files Browse the repository at this point in the history
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:

<gml:Envelope srsName="EPSG:4326">
  <gml:lowerCorner>2.358 48.865</gml:lowerCorner>
  <gml:upperCorner>2.37 48.876</gml:upperCorner>
</gml:Envelope>

However, the same request without a SRSNAME parameter inverts the axis
and returns the the coordinates in the LAT/LON order:

<gml:Envelope srsName="EPSG:4326">
  <gml:lowerCorner>48.865 2.358</gml:lowerCorner>
  <gml:upperCorner>48.876 2.37</gml:upperCorner>
</gml:Envelope>

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.
  • Loading branch information
ptitjano committed Apr 2, 2024
1 parent 4b30849 commit 73e0559
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/etienne/dev/qgis/qgis-master/tests/testdata/qgis_server/test_project_wfs.qgs&amp;SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=testlayer&amp;OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:4326">
<gml:lowerCorner>44.90139484 8.20345931</gml:lowerCorner>
<gml:upperCorner>44.90148253 8.20354699</gml:upperCorner>
<gml:lowerCorner>8.20345931 44.90139484</gml:lowerCorner>
<gml:upperCorner>8.20354699 44.90148253</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
Expand All @@ -13,11 +13,13 @@ Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
<gml:Envelope srsName="EPSG:4326">
<gml:lowerCorner>44.90148253 8.20349634</gml:lowerCorner>
<gml:upperCorner>44.90148253 8.20349634</gml:upperCorner>
<gml:lowerCorner>8.20349634 44.90148253</gml:lowerCorner>
<gml:upperCorner>8.20349634 44.90148253</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<pos xmlns="http://www.opengis.net/gml" srsDimension="2">44.90148253 8.20349634</pos>
<pos xmlns="http://www.opengis.net/gml" srsDimension="2">8.20349634 44.90148253</pos>
</Point>
</qgs:geometry>
<qgs:id>1</qgs:id>
Expand Down

0 comments on commit 73e0559

Please sign in to comment.