Commit ccc8f67b authored by Sergey Fedoseev's avatar Sergey Fedoseev Committed by Tim Graham
Browse files

Fixed #25722 -- Added the GEOSGeometry.covers() method.

parent 73a6ab63
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -294,6 +294,14 @@ class GEOSGeometry(GEOSBase, ListMixin):
        "Returns true if other.within(this) returns true."
        return capi.geos_contains(self.ptr, other.ptr)

    def covers(self, other):
        """
        Return True if the DE-9IM Intersection Matrix for the two geometries is
        T*****FF*, *T****FF*, ***T**FF*, or ****T*FF*. If either geometry is
        empty, return False.
        """
        return capi.geos_covers(self.ptr, other.ptr)

    def crosses(self, other):
        """
        Returns true if the DE-9IM intersection matrix for the two Geometries
+4 −3
Original line number Diff line number Diff line
@@ -17,8 +17,9 @@ from django.contrib.gis.geos.prototypes.geom import ( # NOQA
)
from django.contrib.gis.geos.prototypes.misc import *  # NOQA
from django.contrib.gis.geos.prototypes.predicates import (  # NOQA
    geos_contains, geos_crosses, geos_disjoint, geos_equals, geos_equalsexact,
    geos_hasz, geos_intersects, geos_isempty, geos_isring, geos_issimple,
    geos_isvalid, geos_overlaps, geos_relatepattern, geos_touches, geos_within,
    geos_contains, geos_covers, geos_crosses, geos_disjoint, geos_equals,
    geos_equalsexact, geos_hasz, geos_intersects, geos_isempty, geos_isring,
    geos_issimple, geos_isvalid, geos_overlaps, geos_relatepattern,
    geos_touches, geos_within,
)
from django.contrib.gis.geos.prototypes.topology import *  # NOQA
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ geos_isvalid = UnaryPredicate('GEOSisValid')

# ## Binary Predicates ##
geos_contains = BinaryPredicate('GEOSContains')
geos_covers = BinaryPredicate('GEOSCovers')
geos_crosses = BinaryPredicate('GEOSCrosses')
geos_disjoint = BinaryPredicate('GEOSDisjoint')
geos_equals = BinaryPredicate('GEOSEquals')
+22 −0
Original line number Diff line number Diff line
@@ -349,6 +349,28 @@ return a boolean.
Returns ``True`` if :meth:`other.within(this) <GEOSGeometry.within>` returns
``True``.

.. method:: GEOSGeometry.covers(other)

.. versionadded:: 1.10

Returns ``True`` if this geometry covers the specified geometry.

The ``covers`` predicate has the following equivalent definitions:

* Every point of the other geometry is a point of this geometry.
* The DE-9IM Intersection Matrix for the two geometries is
  ``T*****FF*``, ``*T****FF*``, ``***T**FF*``, or ``****T*FF*``.

If either geometry is empty, returns ``False``.

This predicate is similar to :meth:`GEOSGeometry.contains`, but is more
inclusive (i.e. returns ``True`` for more cases). In particular, unlike
:meth:`~GEOSGeometry.contains` it does not distinguish between points in the
boundary and in the interior of geometries. For most situations, ``covers()``
should be preferred to :meth:`~GEOSGeometry.contains`. As an added benefit,
``covers()`` is more amenable to optimization and hence should outperform
:meth:`~GEOSGeometry.contains`.

.. method:: GEOSGeometry.crosses(other)

Returns ``True`` if the DE-9IM intersection matrix for the two Geometries
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ Minor features
  <django.contrib.gis.geos.GEOSGeometry.unary_union>` property computes the
  union of all the elements of this geometry.

* Added the :meth:`GEOSGeometry.covers()
  <django.contrib.gis.geos.GEOSGeometry.covers>` binary predicate.

:mod:`django.contrib.messages`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Loading