summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2016-11-30 18:39:03 +0600
committerTim Graham <timograham@gmail.com>2016-11-30 07:39:03 -0500
commit21322f92710a447708409f1fce52ee9d18752eaf (patch)
tree5549bc48f1a80d9b47d98ec8a9c1213ac1ae96ec
parent8eb56f3c786b4dd7f78a60145ae2e483e24b62c1 (diff)
Fixed #27552 -- Added docs/test for GEOSGeometry.normalize().
-rw-r--r--django/contrib/gis/geos/geometry.py2
-rw-r--r--docs/ref/contrib/gis/geos.txt11
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py5
3 files changed, 17 insertions, 1 deletions
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 7467a9c879..1a13cdbbc8 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -259,7 +259,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
def normalize(self):
"Converts this Geometry to normal form (or canonical form)."
- return capi.geos_normalize(self.ptr)
+ capi.geos_normalize(self.ptr)
# #### Unary predicates ####
@property
diff --git a/docs/ref/contrib/gis/geos.txt b/docs/ref/contrib/gis/geos.txt
index 55bd5a3744..165f3c0754 100644
--- a/docs/ref/contrib/gis/geos.txt
+++ b/docs/ref/contrib/gis/geos.txt
@@ -652,6 +652,17 @@ Other Properties & Methods
positive integer even if it was called with a
:class:`~django.contrib.gis.gdal.CoordTransform` object.
+.. method:: GEOSGeometry.normalize()
+
+ Converts this geometry to canonical form::
+
+ >>> g = MultiPoint(Point(0, 0), Point(2, 2), Point(1, 1))
+ >>> print(g)
+ MULTIPOINT (0 0, 2 2, 1 1)
+ >>> g.normalize()
+ >>> print(g)
+ MULTIPOINT (2 2, 1 1, 0 0)
+
``Point``
---------
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index 8a82c16170..544bd3f48f 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -1331,6 +1331,11 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
),
)
+ def test_normalize(self):
+ g = MultiPoint(Point(0, 0), Point(2, 2), Point(1, 1))
+ self.assertIsNone(g.normalize())
+ self.assertTrue(g.equals_exact(MultiPoint(Point(2, 2), Point(1, 1), Point(0, 0))))
+
@ignore_warnings(category=RemovedInDjango20Warning)
def test_deprecated_srid_getters_setters(self):
p = Point(1, 2, srid=123)