summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2015-12-04 12:22:29 +0500
committerTim Graham <timograham@gmail.com>2015-12-04 12:37:33 -0500
commit479ba5add23c119387baa60d5dce3a4e17d1b15b (patch)
tree2e7d7f51bb9857b384db2130474fc7bdbd69a666 /docs/ref
parent8e838d9c869083597dc9e161ae2fe37acaa90de9 (diff)
Fixed #25740 -- Documented GEOSGeometry operators.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/gis/geos.txt29
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/ref/contrib/gis/geos.txt b/docs/ref/contrib/gis/geos.txt
index 8a5810d406..e53acbc99c 100644
--- a/docs/ref/contrib/gis/geos.txt
+++ b/docs/ref/contrib/gis/geos.txt
@@ -141,6 +141,35 @@ just like a Python list::
>>> line.coords
((1.0, 1.0), (0.0, 50.0), (50.0, 50.0), (50.0, 0.0), (1.0, 1.0))
+Geometries support set-like operators::
+
+ >>> from django.contrib.gis.geos import LineString
+ >>> ls1 = LineString((0, 0), (2, 2))
+ >>> ls2 = LineString((1, 1), (3, 3))
+ >>> print(ls1 | ls2) # equivalent to `ls1.union(ls2)`
+ MULTILINESTRING ((0 0, 1 1), (1 1, 2 2), (2 2, 3 3))
+ >>> print(ls1 & ls2) # equivalent to `ls1.intersection(ls2)`
+ LINESTRING (1 1, 2 2)
+ >>> print(ls1 - ls2) # equivalent to `ls1.difference(ls2)`
+ LINESTRING(0 0, 1 1)
+ >>> print(ls1 ^ ls2) # equivalent to `ls1.sym_difference(ls2)`
+ MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))
+
+.. admonition:: Equality operator doesn't check spatial equality
+
+ The :class:`~GEOSGeometry` equality operator uses
+ :meth:`~GEOSGeometry.equals_exact`, not :meth:`~GEOSGeometry.equals`, i.e.
+ it requires the compared geometries to have the same coordinates in the
+ same positions::
+
+ >>> from django.contrib.gis.geos import LineString
+ >>> ls1 = LineString((0, 0), (1, 1))
+ >>> ls2 = LineString((1, 1), (0, 0))
+ >>> ls1.equals(ls2)
+ True
+ >>> ls1 == ls2
+ False
+
Geometry Objects
================