Opened 6 years ago

Closed 6 years ago

Last modified 6 years 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
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.

Change History (6)

comment:1 by Even Rouault, 6 years ago

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

comment:2 by Even Rouault, 6 years ago

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 by Even Rouault, 6 years ago

In 40827:

Update test for refs #7126

comment:4 by Even Rouault, 6 years ago

In 40829:

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

comment:5 by Even Rouault, 6 years ago

In 40830:

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

comment:6 by Even Rouault, 6 years ago

In 40831:

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

Note: See TracTickets for help on using tickets.