Opened 7 years ago

Closed 5 years ago

#6818 closed defect (wontfix)

WFS/GML: problems with namespaces

Reported by: TobWen Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: 2.1.3
Severity: normal Keywords: wfs, gml, namespace
Cc:

Description (last modified by TobWen)

There seem to be problems with either the WFS or the GML driver concerning the namespace of a web feature service. The following data is released under "CC-BY-SA 4.0, © Metropole Ruhr". It's a mapserver, so the namespace starts with ms, followed by a colon, f.e. ms:poi_hoehlen.

I've got a replace the URLs by $1 since trac interprets my URLs as spam! $1 = "http://geodaten.metropoleruhr.de"

Since I had coordinate precision problems using OGR (I'll create another ticket for this), I've downloaded the GML stream using cURL the same way, OGR does it (for this example, I'll do the first 100 features only):

curl -o curl.gml "$1/poi/poi?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=ms:poi_hoehlen&STARTINDEX=0&COUNT=100"

That's the result I'm getting (I've skipped most of the header and stepped directly to wfs:member):

<wfs:member>
      <ms:poi_hoehlen gml:id="poi_hoehlen.12773">
        <gml:boundedBy>
                <gml:Envelope srsName="urn:ogc:def:crs:EPSG::25832">
                        <gml:lowerCorner>385286.000000 5684446.000000</gml:lowerCorner>
                        <gml:upperCorner>385286.000000 5684446.000000</gml:upperCorner>
                </gml:Envelope>
        </gml:boundedBy>
        <ms:geom>
          <gml:Point gml:id="poi_hoehlen.12773.1" srsName="urn:ogc:def:crs:EPSG::25832">
            <gml:pos>385286.000000 5684446.000000</gml:pos>
          </gml:Point>
        </ms:geom>
        <ms:name>Kluterthöhle</ms:name>

The namespace is ms:, everything looks as expected. But doing the same with OGR, I'll get a different result converning the namespaces. First the command, then the result (only a few lines):

ogr2ogr -f GML ogr.gml "WFS:$1/poi/poi?" "ms:poi_hoehlen"

And the result:

<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://ogr.maptools.org/ .xsd"
     xmlns:ogr="http://ogr.maptools.org/"
     xmlns:gml="http://www.opengis.net/gml">
  <gml:boundedBy><gml:null>missing</gml:null></gml:boundedBy>
  <gml:featureMember>
    <ogr:ms_poi_hoehlen fid="ms_poi_hoehlen.0">
      <ogr:geometryProperty><gml:Point srsName="EPSG:25832"><gml:coordinates>385286,5684446</gml:coordinates></gml:Point></ogr:geometryProperty>
      <ogr:gml_id>poi_hoehlen.12773</ogr:gml_id>
      <ogr:name>Kluterthöhle</ogr:name>

As you can see, the namespace has changed to OGR, f.e. <ogr:name>, but the name of the layer was renamed: ogr:ms_poi_hoehlen. There's also a warning about this to make it XML compatible:

Warning 1: Layer name 'ms:poi_hoehlen' adjusted to 'ms_poi_hoehlen' for XML validity.

I don't think, that's the correct way of changing the namespace from ms to ogr. In my opinion, the layer shold be named ogr:poi_alle_pois (see below). All other fields are renamed correctly. There's never a <ogr:ms_name> coming from <ms:name>.

Another argument, which supports my bug-report is the conversion from cURL's "raw" GML to OGR's GML. Let's have a look at the command first:

ogr2ogr -f GML curl_ogr.gml curl.gml

The result looks WAY better, also there's no XML-warning anymore (since there's no reason for):

<gml:featureMember>
    <ogr:poi_hoehlen fid="poi_hoehlen.0">
      <ogr:geometryProperty><gml:Point srsName="EPSG:25832"><gml:coordinates>385286,5684446</gml:coordinates></gml:Point></ogr:geometryProperty>
      <ogr:gml_id>poi_hoehlen.12773</ogr:gml_id>
      <ogr:name>Kluterthöhle</ogr:name>

The layer name and its namespace got perfectly converted to OGR-namespace. No ms_ messing anymore.

The problem can be tested on other feature providers, like WFS:http://geodienste.hamburg.de/HH_WFS_Strassenbaumkataster using namespace app:

Change History (5)

comment:1 by TobWen, 7 years ago

Description: modified (diff)

comment:2 by TobWen, 7 years ago

Description: modified (diff)

comment:3 by Even Rouault, 7 years ago

The behaviour is somewhat logical, but I can understand it is surprising.

For layer names, the WFS driver is namespace aware, so it will reports layer names with prefix:typename. Whereas the GML driver is namespace unaware (potentially a defect). When converting to GML, there's some laundering name so that the source layer name is compatible with a XML element name, and the ogr: prefix is added. You can workaround by using -nln poi_hoehlen

comment:4 by TobWen, 7 years ago

Is it possible to store the raw GML stream, like I'm doing with cURL? This won't introduce the floating point errors, I've talked about in the other bug report.

Actually, I want to store data as it comes in and I don't want to have it modified.

comment:5 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.