Fixed #12101 -- `OGRGeometry` does not need to create a clone of the `SpatialReference` object upon assignment.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11707 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5dfed1b24a
commit
8287c27b18
|
@ -256,11 +256,15 @@ class OGRGeometry(GDALBase):
|
||||||
|
|
||||||
def _set_srs(self, srs):
|
def _set_srs(self, srs):
|
||||||
"Sets the SpatialReference for this geometry."
|
"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):
|
if isinstance(srs, SpatialReference):
|
||||||
srs_ptr = srs_api.clone_srs(srs.ptr)
|
srs_ptr = srs.ptr
|
||||||
elif isinstance(srs, (int, long, basestring)):
|
elif isinstance(srs, (int, long, basestring)):
|
||||||
sr = SpatialReference(srs)
|
sr = SpatialReference(srs)
|
||||||
srs_ptr = srs_api.clone_srs(sr.ptr)
|
srs_ptr = sr.ptr
|
||||||
else:
|
else:
|
||||||
raise TypeError('Cannot assign spatial reference with object of type: %s' % type(srs))
|
raise TypeError('Cannot assign spatial reference with object of type: %s' % type(srs))
|
||||||
capi.assign_srs(self.ptr, srs_ptr)
|
capi.assign_srs(self.ptr, srs_ptr)
|
||||||
|
|
Loading…
Reference in New Issue