Bug report #21575

QGIS doesn't work properly with WFS 2.0.0 combined with OGC HTTP URI srsName style (e.g. http://www.opengis.net/def/crs/EPSG/0/xxxx)

Added by Jonas Pedersen about 5 years ago. Updated almost 5 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Web Services clients/WFS
Affected QGIS version:3.6.0 Regression?:No
Operating System:Windows 10 64bit Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29391

Description

When adding a layer from a Geoserver WFS 2.0.0 serving a layer using the OGC HTTP URI srsName style I get lots and lots of errors.
It looks as if there are more than one problem involved (e.g. QGIS doesn't recognise the CRS and has you choose one).
But after choosing the correct CRS, the problem manifests itself when checking the box "Only request features overlapping the view extent".
When this box is checked QGIS generates a "GetFeature" request containing a malformed BBOX value as can be seen below:
/am/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=am:ManagementRestrictionOrRegulationZone&COUNT=1000000&BBOX=53,6,58,15,

This BBOX value end with a "," where it should end with the srsName to make it valid - like below:
/am/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=am:ManagementRestrictionOrRegulationZone&COUNT=1000000&BBOX=53,6,58,15,http://www.opengis.net/def/crs/EPSG/0/3044
Apart from that it also seems that the BBOX values for the corners themselves are also a little off (although I'm not sure of this).

For reference, I have pasted the corresponding "GetFeature" request, when the layer is served with the OGC URN srsName style (e.g. urn:ogc:def:crs:EPSG::xxxx):
/am/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=am:ManagementRestrictionOrRegulationZone&COUNT=1000000&SRSNAME=urn:ogc:def:crs:EPSG::3044&BBOX=6013288,254451,6430433,1035230,urn:ogc:def:crs:EPSG::3044
Here the BBOX values for the corners are looks more realistic, and this notation works perfectly in QGIS.

Unfortunately I can't provide access to our Geoserver backend, but let me know if any additional information is needed.

regards,
Jonas

choose-CRS-for-layer.PNG - QGIS doesn't recognise the CRS, so you have to select it manuallu (48.9 KB) Jonas Pedersen, 2019-03-13 11:41 AM

connect.PNG - The check box in question "Only request features overlapping the view extent" (55.4 KB) Jonas Pedersen, 2019-03-13 11:41 AM

History

#1 Updated by Jonas Pedersen almost 5 years ago

In have tried to edit the function QgsGmlStreamingParser::readEpsgFromAttribute (line 1207) in qgsgml.cpp. I have edited the first branch, so that instead of filtering on just "http://" it filters on "http://www.opengis.net/gml/srs/" and I have also added a extra branch that handles the OGC HTTP URI style by filtering on "http://www.opengis.net/def/crs/EPSG/", e.g.
else if ( epsgString.startsWith( QLatin1String( "http://www.opengis.net/def/crs/EPSG/" ) ) )

{
bIsUrn = true;
epsgNrString = epsgString.split( '/' ).last();
QgsDebugMsg(QStringLiteral("epsgNrString from new OGC HTTP URI branch is: %1").arg(epsgNrString));
}

This fix seems to as far as the debug output now shows:
C:\Users\b031513\git\QGIS\src\core\qgsgml.cpp(835) : (QgsGmlStreamingParser::startElement) [2ms] mEpsg = 3044
indicating that the epsg code is found and returned.
But I still get the same error as before when adding the WFS, so the BBOX is still malformed and coordinates seems to be in WGS 84 (EPSG:4326) format.
Can anybody point me to where the getfeature string is created and maybe a hint as to how to set a QgsDebugMsg at that point?

PS If a pull request is better, please let me know how to do that,

Regards,
Jonas

#2 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Open to Feedback

#3 Updated by Jonas Pedersen almost 5 years ago

I have created a PR for the issue: https://github.com/qgis/QGIS/pull/9594

#4 Updated by Giovanni Manghi almost 5 years ago

  • Pull Request or Patch supplied changed from No to Yes

#5 Updated by Jonas Pedersen almost 5 years ago

I have now supplied a PR that solves the problem and works with OGC HTTP URI srsName annotation. But my travis build is failing because of code style. I'm on Windows and I can't seem to get the Astyle formatting to function properly (I'm on Visual Studion 2015). Does anyone know how to make it work?
I have tried to edit the code manually so that it looks proper, but it won't validate.
Also if I would love to do this PR the right way, so any exammples of implementing unit test and creating documentation is appreciated.

// Jonas

#6 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Feedback to Open

Jonas Pedersen wrote:

I have now supplied a PR that solves the problem and works with OGC HTTP URI srsName annotation. But my travis build is failing because of code style. I'm on Windows and I can't seem to get the Astyle formatting to function properly (I'm on Visual Studion 2015). Does anyone know how to make it work?
I have tried to edit the code manually so that it looks proper, but it won't validate.
Also if I would love to do this PR the right way, so any exammples of implementing unit test and creating documentation is appreciated.

// Jonas

you should post this question in the qgis developers mailing list.

#7 Updated by Jonas Pedersen almost 5 years ago

Hi,

I don't know the procedure, but are there any other steps I need to take to get the PR associated with this issue accepted? I would love to change whatever needed, but I need some feedback first.

// Jonas

#8 Updated by Giovanni Manghi almost 5 years ago

Jonas Pedersen wrote:

Hi,

I don't know the procedure, but are there any other steps I need to take to get the PR associated with this issue accepted? I would love to change whatever needed, but I need some feedback first.

// Jonas

ask in the PR for a review from other developers.

Also available in: Atom PDF