Opened 14 months ago

Closed 13 months ago

Last modified 13 months ago

#7126 closed defect (fixed)

In GML, sub-geometries of an OGRGeometryCollection can lose their spatial reference

Reported by: sbarker Owned by: warmerdam
Priority: low Milestone:
Component: OGR_SF Version: 2.2.0
Severity: normal Keywords: GML


Some GML data files only have the spatial reference (srsName) in the gml:Envelope, within the gml:boundedBy section at the start of the file. The spatial references are not specified for each geometry in the file. An example of such a file is

This appears to be valid according to section 9.10 of GML 3.2.1.

Such files need to be opened with "FORCE_SRS_DETECTION=YES" in the GDALOpenEx open options, otherwise the spatial references are not found for any geometries.

With "FORCE_SRS_DETECTION=YES" specified, individual geometries have their spatial reference set correctly. But child geometries of an OGRGeometryCollection, extracted using OGRGeometryCollection::getGeometryRef, do not pick up their parent's spatial reference. Instead, OGRGeometry::getSpatialReference returns a NULL pointer for those child geometries.

A workaround is to find the spatial reference of the geometry collection, and use that when transforming the child geometries.

Change History (6)

comment:1 Changed 14 months ago by Even Rouault

I believe this is a behaviour you'd got with any driver that returns a geometry collection.

comment:2 Changed 13 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 40824:

Make OGRGeometry::assignSpatialReference() a virtual method, and make implementation recursively assign the SR to child geometries (fixes #7126)

comment:3 Changed 13 months ago by Even Rouault

In 40827:

Update test for refs #7126

comment:4 Changed 13 months ago by Even Rouault

In 40829:

GeoJSON: fix failure in ogr_geojson_11 test due to changes of refs #7126

comment:5 Changed 13 months ago by Even Rouault

In 40830:

Doc: document assignSpatialReference() new behaviour (refs #7126)

comment:6 Changed 13 months ago by Even Rouault

In 40831:

GeoJSON: fix OGRGeoJSONReadGeometryCollection() so that it forwards its CRS to its children (refs #7126)

Note: See TracTickets for help on using tickets.