gdal icon indicating copy to clipboard operation
gdal copied to clipboard

gml writer: FeatureCollection's envelope SRS (3.9.1 regression)

Open cyril1929 opened this issue 1 year ago • 2 comments

What is the bug?

When we produce a GML from a GeoJson with a SQL dialect, the gml:Envelope in the response no longer contains SRS.

The srs is however always present if no sql query is put.

By the way, not having srs reverses the axes.

I don't think this change in behavior was intentional?

Steps to reproduce the issue

ogr2ogr -sql "SELECT * FROM input" -dialect sqlite -f GML output.gml input.json

return :

...
<gml:boundedBy>
    <gml:Envelope>
        <gml:lowerCorner>0 -1369</gml:lowerCorner>
        <gml:upperCorner>1138 -1</gml:upperCorner>
    </gml:Envelope>
</gml:boundedBy>
...

while :

ogr2ogr -sql "" -dialect sqlite -f GML output.gml input.json

return :

...
<gml:boundedBy>
    <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326">
        <gml:lowerCorner>-1369 0</gml:lowerCorner>
        <gml:upperCorner>-1 1138</gml:upperCorner>
    </gml:Envelope>
</gml:boundedBy>
...

Versions and provenance

The regression appeared in version 3.9.1. No worries in version 3.9.0 and earlier.

Additional context

No response

cyril1929 avatar Jun 27 '24 18:06 cyril1929

I can confirm with GDAL 3.10.0dev-a44e40295c, released 2024/06/21 (OSGeo4W).

Also the name of the geometry has changed. Was: <ogr:geometryProperty> Is now: <ogr:GEOMETRY>

This srsName drop affects the FeatureCollection level Envelope. The featureMembers still have Envelopes with srsName - and with Lat-Lon axis order.

<ogr:FeatureCollection
     gml:id="aFeatureCollection"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://ogr.maptools.org/ srs3.xsd"
     xmlns:ogr="http://ogr.maptools.org/"
     xmlns:gml="http://www.opengis.net/gml/3.2">
  <gml:boundedBy><gml:Envelope><gml:lowerCorner>23.5343338 63.1870744</gml:lowerCorner><gml:upperCorner>23.5511729 63.1915115</gml:upperCorner></gml:Envelope></gml:boundedBy>
                                                                                                                                                                              
  <ogr:featureMember>
    <ogr:SELECT gml:id="SELECT.0">
      <gml:boundedBy><gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326"><gml:lowerCorner>63.1870744 23.5454641</gml:lowerCorner><gml:upperCorner>63.1871252 23.5455768</gml:upperCorner></gml:Envelope></gml:boundedBy>

jratike80 avatar Jun 27 '24 19:06 jratike80

Also the name of the geometry has changed.

That's expected ant not an issue, and not a new behaviour. This is due to SQL SQLite layer reporting a name GEOMETRY geometry field. Direct translation from GeoJSON which has a unnamed/empty geometry field fallbacks to using "geometryProperty" in the GML writer.

For the SRS issue, fix in #10334

A workaround is to do a ogr2ogr to a format like GeoJSON (or shapefile, but not GeoPackage, PostGIS, etc) that has not a named geometry field using the -sql clause, and then ogr2ogr that temporary GeoJSON file to GML

rouault avatar Jun 27 '24 20:06 rouault

Thanks !

cyril1929 avatar Jul 06 '24 10:07 cyril1929