Loading docs/ref/contrib/gis/geos.txt +29 −0 Original line number Diff line number Diff line Loading @@ -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 ================ Loading Loading
docs/ref/contrib/gis/geos.txt +29 −0 Original line number Diff line number Diff line Loading @@ -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 ================ Loading