mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #25773 -- Deprecated the geos.MultiPolygon.cascaded_union property.
This commit is contained in:
parent
0cfe589f95
commit
f920be7c32
@ -3,6 +3,7 @@
|
|||||||
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
|
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
import warnings
|
||||||
from ctypes import byref, c_int, c_uint
|
from ctypes import byref, c_int, c_uint
|
||||||
|
|
||||||
from django.contrib.gis.geos import prototypes as capi
|
from django.contrib.gis.geos import prototypes as capi
|
||||||
@ -13,6 +14,7 @@ from django.contrib.gis.geos.libgeos import get_pointer_arr
|
|||||||
from django.contrib.gis.geos.linestring import LinearRing, LineString
|
from django.contrib.gis.geos.linestring import LinearRing, LineString
|
||||||
from django.contrib.gis.geos.point import Point
|
from django.contrib.gis.geos.point import Point
|
||||||
from django.contrib.gis.geos.polygon import Polygon
|
from django.contrib.gis.geos.polygon import Polygon
|
||||||
|
from django.utils.deprecation import RemovedInDjango20Warning
|
||||||
from django.utils.six.moves import range
|
from django.utils.six.moves import range
|
||||||
|
|
||||||
|
|
||||||
@ -135,6 +137,10 @@ class MultiPolygon(GeometryCollection):
|
|||||||
@property
|
@property
|
||||||
def cascaded_union(self):
|
def cascaded_union(self):
|
||||||
"Returns a cascaded union of this MultiPolygon."
|
"Returns a cascaded union of this MultiPolygon."
|
||||||
|
warnings.warn(
|
||||||
|
"`cascaded_union` is deprecated, use the `unary_union` property instead.",
|
||||||
|
RemovedInDjango20Warning, 2
|
||||||
|
)
|
||||||
return GEOSGeometry(capi.geos_cascaded_union(self.ptr), self.srid)
|
return GEOSGeometry(capi.geos_cascaded_union(self.ptr), self.srid)
|
||||||
|
|
||||||
# Setting the allowed types here since GeometryCollection is defined before
|
# Setting the allowed types here since GeometryCollection is defined before
|
||||||
|
@ -121,6 +121,9 @@ details on these changes.
|
|||||||
* The ``get_coords()`` and ``set_coords()`` methods of
|
* The ``get_coords()`` and ``set_coords()`` methods of
|
||||||
``django.contrib.gis.geos.Point`` will be removed.
|
``django.contrib.gis.geos.Point`` will be removed.
|
||||||
|
|
||||||
|
* The ``cascaded_union`` property of ``django.contrib.gis.geos.MultiPolygon``
|
||||||
|
will be removed.
|
||||||
|
|
||||||
.. _deprecation-removed-in-1.10:
|
.. _deprecation-removed-in-1.10:
|
||||||
|
|
||||||
1.10
|
1.10
|
||||||
|
@ -746,6 +746,10 @@ Geometry Collections
|
|||||||
|
|
||||||
.. attribute:: cascaded_union
|
.. attribute:: cascaded_union
|
||||||
|
|
||||||
|
.. deprecated:: 1.10
|
||||||
|
|
||||||
|
Use the :attr:`GEOSGeometry.unary_union` property instead.
|
||||||
|
|
||||||
Returns a :class:`Polygon` that is the union of all of the component
|
Returns a :class:`Polygon` that is the union of all of the component
|
||||||
polygons in this collection. The algorithm employed is significantly
|
polygons in this collection. The algorithm employed is significantly
|
||||||
more efficient (faster) than trying to union the geometries together
|
more efficient (faster) than trying to union the geometries together
|
||||||
|
@ -361,6 +361,10 @@ This prevents confusion about an assignment resulting in an implicit save.
|
|||||||
:class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
|
:class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
|
||||||
``tuple`` property.
|
``tuple`` property.
|
||||||
|
|
||||||
|
* The ``cascaded_union`` property of
|
||||||
|
:class:`~django.contrib.gis.geos.MultiPolygon` is deprecated in favor of the
|
||||||
|
:attr:`~django.contrib.gis.geos.GEOSGeometry.unary_union` property.
|
||||||
|
|
||||||
Miscellaneous
|
Miscellaneous
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -1203,3 +1203,9 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
|
|||||||
|
|
||||||
p.set_coords((3, 2, 1))
|
p.set_coords((3, 2, 1))
|
||||||
self.assertEqual(p.get_coords(), (3, 2, 1))
|
self.assertEqual(p.get_coords(), (3, 2, 1))
|
||||||
|
|
||||||
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||||
|
def test_deprecated_cascaded_union(self):
|
||||||
|
for geom in self.geometries.multipolygons:
|
||||||
|
mpoly = GEOSGeometry(geom.wkt)
|
||||||
|
self.assertEqual(mpoly.cascaded_union, mpoly.unary_union)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user