Skip to content

Commit 8ef5dae

Browse files
committed
[1.1.X] Added another GDAL bug workaround for retrieving the correct coordinate dimension on geometry collections. Refs #12312.
Backport of r12883 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12884 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 08d0094 commit 8ef5dae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

django/contrib/gis/gdal/geometries.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ def dimension(self):
181181

182182
def _get_coord_dim(self):
183183
"Returns the coordinate dimension of the Geometry."
184+
if isinstance(self, GeometryCollection) and GDAL_VERSION < (1, 5, 2):
185+
# On GDAL versions prior to 1.5.2, there exists a bug in which
186+
# the coordinate dimension of geometry collections is always 2:
187+
# http://trac.osgeo.org/gdal/ticket/2334
188+
# Here we workaround by returning the coordinate dimension of the
189+
# first geometry in the collection instead.
190+
if len(self):
191+
return capi.get_coord_dim(capi.get_geom_ref(self.ptr, 0))
184192
return capi.get_coord_dim(self.ptr)
185193

186194
def _set_coord_dim(self, dim):

0 commit comments

Comments
 (0)