MCPcopy
hub / github.com/django/django / _set_srs

Method _set_srs

django/contrib/gis/gdal/geometries.py:327–344  ·  view source on GitHub ↗

Set the SpatialReference for this geometry.

(self, srs)

Source from the content-addressed store, hash-verified

325 return None
326
327 def _set_srs(self, srs):
328 "Set the SpatialReference for this geometry."
329 # Do not have to clone the `SpatialReference` object pointer because
330 # when it is assigned to this `OGRGeometry` it's internal OGR
331 # reference count is incremented, and will likewise be released
332 # (decremented) when this geometry's destructor is called.
333 if isinstance(srs, SpatialReference):
334 srs_ptr = srs.ptr
335 elif isinstance(srs, (int, str)):
336 sr = SpatialReference(srs)
337 srs_ptr = sr.ptr
338 elif srs is None:
339 srs_ptr = None
340 else:
341 raise TypeError(
342 "Cannot assign spatial reference with object of type: %s" % type(srs)
343 )
344 capi.assign_srs(self.ptr, srs_ptr)
345
346 srs = property(_get_srs, _set_srs)
347

Callers

nothing calls this directly

Calls 1

SpatialReferenceClass · 0.90

Tested by

no test coverage detected