1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #25665 -- Deprecated getter/setter of GEOSGeometry.srid.

This commit is contained in:
Sergey Fedoseev
2015-11-04 23:56:14 +05:00
committed by Tim Graham
parent 5f7f3b4685
commit b7177cc2a4
4 changed files with 44 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
from __future__ import unicode_literals
import json
import warnings
from ctypes import addressof, byref, c_double
from django.contrib.gis import gdal
@@ -20,6 +21,7 @@ from django.contrib.gis.geos.prototypes.io import (
ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w,
)
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_bytes, force_text
@@ -356,7 +358,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
return capi.geos_within(self.ptr, other.ptr)
# #### SRID Routines ####
def get_srid(self):
@property
def srid(self):
"Gets the SRID for the geometry, returns None if no SRID is set."
s = capi.geos_get_srid(self.ptr)
if s == 0:
@@ -364,10 +367,24 @@ class GEOSGeometry(GEOSBase, ListMixin):
else:
return s
def set_srid(self, srid):
@srid.setter
def srid(self, srid):
"Sets the SRID for the geometry."
capi.geos_set_srid(self.ptr, 0 if srid is None else srid)
srid = property(get_srid, set_srid)
def get_srid(self):
warnings.warn(
"`get_srid()` is deprecated, use the `srid` property instead.",
RemovedInDjango20Warning, 2
)
return self.srid
def set_srid(self, srid):
warnings.warn(
"`set_srid()` is deprecated, use the `srid` property instead.",
RemovedInDjango20Warning, 2
)
self.srid = srid
# #### Output Routines ####
@property
@@ -375,10 +392,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
"""
Returns the EWKT (SRID + WKT) of the Geometry.
"""
if self.get_srid():
return 'SRID=%s;%s' % (self.srid, self.wkt)
else:
return self.wkt
srid = self.srid
return 'SRID=%s;%s' % (srid, self.wkt) if srid else self.wkt
@property
def wkt(self):