Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #12101 -- `OGRGeometry` does not need to create a clone of the …

…`SpatialReference` object upon assignment.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8287c27b1895ba56c6680295ff3d202fc7a4b64e 1 parent 5dfed1b
@jbronn jbronn authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 django/contrib/gis/gdal/
8 django/contrib/gis/gdal/
@@ -256,11 +256,15 @@ def _get_srs(self):
def _set_srs(self, srs):
"Sets the SpatialReference for this geometry."
+ # Do not have to clone the `SpatialReference` object pointer because
+ # when it is assigned to this `OGRGeometry` it's internal OGR
+ # reference count is incremented, and will likewise be released
+ # (decremented) when this geometry's destructor is called.
if isinstance(srs, SpatialReference):
- srs_ptr = srs_api.clone_srs(srs.ptr)
+ srs_ptr = srs.ptr
elif isinstance(srs, (int, long, basestring)):
sr = SpatialReference(srs)
- srs_ptr = srs_api.clone_srs(sr.ptr)
+ srs_ptr = sr.ptr
raise TypeError('Cannot assign spatial reference with object of type: %s' % type(srs))
capi.assign_srs(self.ptr, srs_ptr)

0 comments on commit 8287c27

Please sign in to comment.
Something went wrong with that request. Please try again.