1
0
mirror of https://github.com/django/django.git synced 2025-06-07 04:29:12 +00:00

Refs #35058 -- Removed OGRGeometry.coord_dim setter per deprecation timeline.

This commit is contained in:
Sarah Boyce 2024-12-13 09:19:12 +01:00
parent d5fec03dad
commit 4968f0012e
4 changed files with 2 additions and 32 deletions

View File

@ -40,7 +40,6 @@
""" """
import sys import sys
import warnings
from binascii import b2a_hex from binascii import b2a_hex
from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at
@ -52,7 +51,6 @@ 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.prototypes import srs as srs_api
from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference
from django.contrib.gis.geometry import hex_regex, json_regex, wkt_regex 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 from django.utils.encoding import force_bytes
@ -215,16 +213,6 @@ class OGRGeometry(GDALBase):
"Return the coordinate dimension of the Geometry." "Return the coordinate dimension of the Geometry."
return capi.get_coord_dim(self.ptr) return capi.get_coord_dim(self.ptr)
# 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)
@property @property
def geom_count(self): def geom_count(self):
"Return the number of elements in this Geometry." "Return the number of elements in this Geometry."

View File

@ -551,15 +551,6 @@ coordinate transformation:
>>> polygon.dimension >>> polygon.dimension
2 2
.. attribute:: coord_dim
Returns the coordinate dimension of this geometry. For example, the value
would be 2 for two-dimensional geometries.
.. deprecated:: 5.1
The ``coord_dim`` setter is deprecated. Use :meth:`.set_3d` instead.
.. attribute:: is_3d .. attribute:: is_3d
A boolean indicating if this geometry has Z coordinates. A boolean indicating if this geometry has Z coordinates.

View File

@ -312,3 +312,5 @@ to remove usage of these features.
* Support for passing positional arguments to ``Model.save()`` and * Support for passing positional arguments to ``Model.save()`` and
``Model.asave()`` is removed. ``Model.asave()`` is removed.
* The setter for ``django.contrib.gis.gdal.OGRGeometry.coord_dim`` is removed.

View File

@ -13,7 +13,6 @@ from django.contrib.gis.geos import GEOSException
from django.template import Context from django.template import Context
from django.template.engine import Engine from django.template.engine import Engine
from django.test import SimpleTestCase from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango60Warning
from ..test_data import TestDataMixin from ..test_data import TestDataMixin
@ -1063,13 +1062,3 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
) )
self.assertIsInstance(geom, CurvePolygon) self.assertIsInstance(geom, CurvePolygon)
self.assertIsInstance(geom.shell, CircularString) self.assertIsInstance(geom.shell, CircularString)
class DeprecationTests(SimpleTestCase):
def test_coord_setter_deprecation(self):
geom = OGRGeometry("POINT (1 2)")
msg = "coord_dim setter is deprecated. Use set_3d() instead."
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
geom.coord_dim = 3
self.assertEqual(geom.coord_dim, 3)
self.assertEqual(ctx.filename, __file__)