#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 |
Cc: |
Description
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 https://3d.bk.tudelft.nl/download/3dfier/Delft.gml.zip
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.
I believe this is a behaviour you'd got with any driver that returns a geometry collection.