summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2024-01-22 17:55:40 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-01-23 05:37:59 +0100
commitf4c597346453c44769726d2ac061fbc028b2fd5b (patch)
tree643d315a856a875df5977b2ec769b7782db58812 /django
parent8570e091d025c4aacc6b76597a3322030c2f8162 (diff)
Refs #35058 -- Deprecated OGRGeometry.coord_dim setter.
Reflecting a change in the underlying GDAL library (since GDAL 2.1) using coord_dim to set a geometries dimensions is deprecated in favor of set_3d().
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/gdal/geometries.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 516c6c7113..57f81ca476 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -39,6 +39,7 @@
True True
"""
import sys
+import warnings
from binascii import b2a_hex
from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at
@@ -50,6 +51,7 @@ from django.contrib.gis.gdal.prototypes import geom as capi
from django.contrib.gis.gdal.prototypes import srs as srs_api
from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference
from django.contrib.gis.geometry import hex_regex, json_regex, wkt_regex
+from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.encoding import force_bytes
@@ -206,18 +208,21 @@ class OGRGeometry(GDALBase):
"Return 0 for points, 1 for lines, and 2 for surfaces."
return capi.get_dims(self.ptr)
- def _get_coord_dim(self):
+ @property
+ def coord_dim(self):
"Return the coordinate dimension of the Geometry."
return capi.get_coord_dim(self.ptr)
- def _set_coord_dim(self, dim):
+ # RemovedInDjango60Warning
+ @coord_dim.setter
+ def coord_dim(self, dim):
"Set the coordinate dimension of this Geometry."
+ msg = "coord_dim setter is deprecated. Use set_3d() instead."
+ warnings.warn(msg, RemovedInDjango60Warning, stacklevel=2)
if dim not in (2, 3):
raise ValueError("Geometry dimension must be either 2 or 3")
capi.set_coord_dim(self.ptr, dim)
- coord_dim = property(_get_coord_dim, _set_coord_dim)
-
@property
def geom_count(self):
"Return the number of elements in this Geometry."