Refs #28841 -- Removed ForceRHR function per deprecation timeline.
This commit is contained in:
parent
1fecde6be9
commit
6f23996a59
|
@ -40,10 +40,10 @@ class BaseSpatialOperations:
|
||||||
unsupported_functions = {
|
unsupported_functions = {
|
||||||
'Area', 'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG', 'Azimuth',
|
'Area', 'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG', 'Azimuth',
|
||||||
'BoundingCircle', 'Centroid', 'Difference', 'Distance', 'Envelope',
|
'BoundingCircle', 'Centroid', 'Difference', 'Distance', 'Envelope',
|
||||||
'ForceRHR', 'GeoHash', 'Intersection', 'IsValid', 'Length',
|
'GeoHash', 'Intersection', 'IsValid', 'Length', 'LineLocatePoint',
|
||||||
'LineLocatePoint', 'MakeValid', 'MemSize', 'NumGeometries',
|
'MakeValid', 'MemSize', 'NumGeometries', 'NumPoints', 'Perimeter',
|
||||||
'NumPoints', 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale',
|
'PointOnSurface', 'Reverse', 'Scale', 'SnapToGrid', 'SymDifference',
|
||||||
'SnapToGrid', 'SymDifference', 'Transform', 'Translate', 'Union',
|
'Transform', 'Translate', 'Union',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Constructors
|
# Constructors
|
||||||
|
|
|
@ -56,9 +56,9 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
def unsupported_functions(self):
|
def unsupported_functions(self):
|
||||||
unsupported = {
|
unsupported = {
|
||||||
'AsGML', 'AsKML', 'AsSVG', 'Azimuth', 'BoundingCircle',
|
'AsGML', 'AsKML', 'AsSVG', 'Azimuth', 'BoundingCircle',
|
||||||
'ForcePolygonCW', 'ForceRHR', 'LineLocatePoint', 'MakeValid',
|
'ForcePolygonCW', 'LineLocatePoint', 'MakeValid', 'MemSize',
|
||||||
'MemSize', 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale',
|
'Perimeter', 'PointOnSurface', 'Reverse', 'Scale', 'SnapToGrid',
|
||||||
'SnapToGrid', 'Transform', 'Translate',
|
'Transform', 'Translate',
|
||||||
}
|
}
|
||||||
if self.connection.mysql_is_mariadb:
|
if self.connection.mysql_is_mariadb:
|
||||||
unsupported.update({'GeoHash', 'IsValid'})
|
unsupported.update({'GeoHash', 'IsValid'})
|
||||||
|
|
|
@ -106,9 +106,9 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
}
|
}
|
||||||
|
|
||||||
unsupported_functions = {
|
unsupported_functions = {
|
||||||
'AsGeoJSON', 'AsKML', 'AsSVG', 'Azimuth',
|
'AsGeoJSON', 'AsKML', 'AsSVG', 'Azimuth', 'ForcePolygonCW', 'GeoHash',
|
||||||
'ForcePolygonCW', 'ForceRHR', 'GeoHash', 'LineLocatePoint',
|
'LineLocatePoint', 'MakeValid', 'MemSize', 'Scale', 'SnapToGrid',
|
||||||
'MakeValid', 'MemSize', 'Scale', 'SnapToGrid', 'Translate',
|
'Translate',
|
||||||
}
|
}
|
||||||
|
|
||||||
def geo_quote_name(self, name):
|
def geo_quote_name(self, name):
|
||||||
|
|
|
@ -81,7 +81,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def unsupported_functions(self):
|
def unsupported_functions(self):
|
||||||
unsupported = {'BoundingCircle', 'ForceRHR', 'MemSize'}
|
unsupported = {'BoundingCircle', 'MemSize'}
|
||||||
if not self.lwgeom_version():
|
if not self.lwgeom_version():
|
||||||
unsupported |= {'Azimuth', 'GeoHash', 'IsValid', 'MakeValid'}
|
unsupported |= {'Azimuth', 'GeoHash', 'IsValid', 'MakeValid'}
|
||||||
return unsupported
|
return unsupported
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import warnings
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
|
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
|
||||||
|
@ -11,7 +10,6 @@ from django.db.models import (
|
||||||
from django.db.models.expressions import Func, Value
|
from django.db.models.expressions import Func, Value
|
||||||
from django.db.models.functions import Cast
|
from django.db.models.functions import Cast
|
||||||
from django.db.utils import NotSupportedError
|
from django.db.utils import NotSupportedError
|
||||||
from django.utils.deprecation import RemovedInDjango30Warning
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
NUMERIC_TYPES = (int, float, Decimal)
|
NUMERIC_TYPES = (int, float, Decimal)
|
||||||
|
@ -284,17 +282,6 @@ class ForcePolygonCW(GeomOutputGeoFunc):
|
||||||
arity = 1
|
arity = 1
|
||||||
|
|
||||||
|
|
||||||
class ForceRHR(GeomOutputGeoFunc):
|
|
||||||
arity = 1
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
warnings.warn(
|
|
||||||
'ForceRHR is deprecated in favor of ForcePolygonCW.',
|
|
||||||
RemovedInDjango30Warning, stacklevel=2,
|
|
||||||
)
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class GeoHash(GeoFunc):
|
class GeoHash(GeoFunc):
|
||||||
output_field = TextField()
|
output_field = TextField()
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,6 @@ Function PostGIS Oracle MySQL Spat
|
||||||
:class:`Distance` X X X X
|
:class:`Distance` X X X X
|
||||||
:class:`Envelope` X X X X
|
:class:`Envelope` X X X X
|
||||||
:class:`ForcePolygonCW` X X
|
:class:`ForcePolygonCW` X X
|
||||||
:class:`ForceRHR` X
|
|
||||||
:class:`GeoHash` X X (≥ 5.7.5) X (LWGEOM)
|
:class:`GeoHash` X X (≥ 5.7.5) X (LWGEOM)
|
||||||
:class:`Intersection` X X X X
|
:class:`Intersection` X X X X
|
||||||
:class:`IsValid` X X X (≥ 5.7.5) X (LWGEOM)
|
:class:`IsValid` X X X (≥ 5.7.5) X (LWGEOM)
|
||||||
|
|
|
@ -24,12 +24,11 @@ Function's summary:
|
||||||
Measurement Relationships Operations Editors Output format Miscellaneous
|
Measurement Relationships Operations Editors Output format Miscellaneous
|
||||||
================== ======================== ====================== ======================= ================== =====================
|
================== ======================== ====================== ======================= ================== =====================
|
||||||
:class:`Area` :class:`Azimuth` :class:`Difference` :class:`ForcePolygonCW` :class:`AsGeoJSON` :class:`IsValid`
|
:class:`Area` :class:`Azimuth` :class:`Difference` :class:`ForcePolygonCW` :class:`AsGeoJSON` :class:`IsValid`
|
||||||
:class:`Distance` :class:`BoundingCircle` :class:`Intersection` :class:`ForceRHR` :class:`AsGML` :class:`MemSize`
|
:class:`Distance` :class:`BoundingCircle` :class:`Intersection` :class:`MakeValid` :class:`AsGML` :class:`MemSize`
|
||||||
:class:`Length` :class:`Centroid` :class:`SymDifference` :class:`MakeValid` :class:`AsKML` :class:`NumGeometries`
|
:class:`Length` :class:`Centroid` :class:`SymDifference` :class:`Reverse` :class:`AsKML` :class:`NumGeometries`
|
||||||
:class:`Perimeter` :class:`Envelope` :class:`Union` :class:`Reverse` :class:`AsSVG` :class:`NumPoints`
|
:class:`Perimeter` :class:`Envelope` :class:`Union` :class:`Scale` :class:`AsSVG` :class:`NumPoints`
|
||||||
.. :class:`LineLocatePoint` :class:`Scale` :class:`GeoHash`
|
.. :class:`LineLocatePoint` :class:`SnapToGrid` :class:`GeoHash`
|
||||||
.. :class:`PointOnSurface` :class:`SnapToGrid`
|
.. :class:`PointOnSurface` :class:`Transform`
|
||||||
.. :class:`Transform`
|
|
||||||
.. :class:`Translate`
|
.. :class:`Translate`
|
||||||
================== ======================== ====================== ======================= ================== =====================
|
================== ======================== ====================== ======================= ================== =====================
|
||||||
|
|
||||||
|
@ -291,21 +290,6 @@ of the polygon/multipolygon in which all exterior rings are oriented clockwise
|
||||||
and all interior rings are oriented counterclockwise. Non-polygonal geometries
|
and all interior rings are oriented counterclockwise. Non-polygonal geometries
|
||||||
are returned unchanged.
|
are returned unchanged.
|
||||||
|
|
||||||
``ForceRHR``
|
|
||||||
============
|
|
||||||
|
|
||||||
.. class:: ForceRHR(expression, **extra)
|
|
||||||
|
|
||||||
.. deprecated:: 2.1
|
|
||||||
|
|
||||||
Use :class:`ForcePolygonCW` instead.
|
|
||||||
|
|
||||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_ForceRHR.html>`__
|
|
||||||
|
|
||||||
Accepts a single geographic field or expression and returns a modified version
|
|
||||||
of the polygon/multipolygon in which all of the vertices follow the
|
|
||||||
right-hand rule.
|
|
||||||
|
|
||||||
``GeoHash``
|
``GeoHash``
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
|
@ -253,4 +253,4 @@ to remove usage of these features.
|
||||||
See :ref:`deprecated-features-2.1` for details on these changes, including how
|
See :ref:`deprecated-features-2.1` for details on these changes, including how
|
||||||
to remove usage of these features.
|
to remove usage of these features.
|
||||||
|
|
||||||
* ...
|
* The ``ForceRHR`` GIS function is removed.
|
||||||
|
|
|
@ -10,8 +10,7 @@ from django.contrib.gis.geos import (
|
||||||
from django.contrib.gis.measure import Area
|
from django.contrib.gis.measure import Area
|
||||||
from django.db import NotSupportedError, connection
|
from django.db import NotSupportedError, connection
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
|
from django.test import TestCase, skipUnlessDBFeature
|
||||||
from django.utils.deprecation import RemovedInDjango30Warning
|
|
||||||
|
|
||||||
from ..utils import FuncTestMixin, mysql, oracle, postgis, spatialite
|
from ..utils import FuncTestMixin, mysql, oracle, postgis, spatialite
|
||||||
from .models import City, Country, CountryWebMercator, State, Track
|
from .models import City, Country, CountryWebMercator, State, Track
|
||||||
|
@ -230,21 +229,6 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
||||||
st = State.objects.annotate(force_polygon_cw=functions.ForcePolygonCW('poly')).get(name='Foo')
|
st = State.objects.annotate(force_polygon_cw=functions.ForcePolygonCW('poly')).get(name='Foo')
|
||||||
self.assertEqual(rhr_rings, st.force_polygon_cw.coords)
|
self.assertEqual(rhr_rings, st.force_polygon_cw.coords)
|
||||||
|
|
||||||
@skipUnlessDBFeature("has_ForceRHR_function")
|
|
||||||
@ignore_warnings(category=RemovedInDjango30Warning)
|
|
||||||
def test_force_rhr(self):
|
|
||||||
rings = (
|
|
||||||
((0, 0), (5, 0), (0, 5), (0, 0)),
|
|
||||||
((1, 1), (1, 3), (3, 1), (1, 1)),
|
|
||||||
)
|
|
||||||
rhr_rings = (
|
|
||||||
((0, 0), (0, 5), (5, 0), (0, 0)),
|
|
||||||
((1, 1), (3, 1), (1, 3), (1, 1)),
|
|
||||||
)
|
|
||||||
State.objects.create(name='Foo', poly=Polygon(*rings))
|
|
||||||
st = State.objects.annotate(force_rhr=functions.ForceRHR('poly')).get(name='Foo')
|
|
||||||
self.assertEqual(rhr_rings, st.force_rhr.coords)
|
|
||||||
|
|
||||||
@skipUnlessDBFeature("has_GeoHash_function")
|
@skipUnlessDBFeature("has_GeoHash_function")
|
||||||
def test_geohash(self):
|
def test_geohash(self):
|
||||||
# Reference query:
|
# Reference query:
|
||||||
|
|
Loading…
Reference in New Issue