diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 6aa2c279dd..5209648098 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -47,6 +47,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): 'contains': SpatialiteNullCheckOperator(func='Contains'), 'intersects': SpatialiteNullCheckOperator(func='Intersects'), 'relate': SpatialiteNullCheckOperator(func='Relate'), + 'coveredby': SpatialiteNullCheckOperator(func='CoveredBy'), + 'covers': SpatialiteNullCheckOperator(func='Covers'), # Returns true if B's bounding box completely contains A's bounding box. 'contained': SpatialOperator(func='MbrWithin'), # Returns true if A's bounding box completely contains B's bounding box. diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt index 89ac85ac46..b70ae11067 100644 --- a/docs/ref/contrib/gis/db-api.txt +++ b/docs/ref/contrib/gis/db-api.txt @@ -329,8 +329,8 @@ Lookup Type PostGIS Oracle MySQL [#]_ SpatiaLite :lookup:`contained` X X X N :lookup:`contains ` X X X X B :lookup:`contains_properly` X B -:lookup:`coveredby` X X B -:lookup:`covers` X X B +:lookup:`coveredby` X X X B +:lookup:`covers` X X X B :lookup:`crosses` X X C :lookup:`disjoint` X X X X B :lookup:`distance_gt` X X X N diff --git a/docs/ref/contrib/gis/geoquerysets.txt b/docs/ref/contrib/gis/geoquerysets.txt index a8f7e27277..b7bd83b3a3 100644 --- a/docs/ref/contrib/gis/geoquerysets.txt +++ b/docs/ref/contrib/gis/geoquerysets.txt @@ -179,7 +179,7 @@ PostGIS ``ST_ContainsProperly(poly, geom)`` ------------- *Availability*: `PostGIS `__, -Oracle, PGRaster (Bilateral) +Oracle, PGRaster (Bilateral), SpatiaLite Tests if no point in the geometry field is outside the lookup geometry. [#fncovers]_ @@ -188,11 +188,16 @@ Example:: Zipcode.objects.filter(poly__coveredby=geom) +.. versionchanged:: 2.2 + + SpatiaLite support was added. + ========== ============================= Backend SQL Equivalent ========== ============================= PostGIS ``ST_CoveredBy(poly, geom)`` Oracle ``SDO_COVEREDBY(poly, geom)`` +SpatiaLite ``CoveredBy(poly, geom)`` ========== ============================= .. fieldlookup:: covers @@ -201,7 +206,7 @@ Oracle ``SDO_COVEREDBY(poly, geom)`` ---------- *Availability*: `PostGIS `__, -Oracle, PGRaster (Bilateral) +Oracle, PGRaster (Bilateral), SpatiaLite Tests if no point in the lookup geometry is outside the geometry field. [#fncovers]_ @@ -210,11 +215,16 @@ Example:: Zipcode.objects.filter(poly__covers=geom) +.. versionchanged:: 2.2 + + SpatiaLite support was added. + ========== ========================== Backend SQL Equivalent ========== ========================== PostGIS ``ST_Covers(poly, geom)`` Oracle ``SDO_COVERS(poly, geom)`` +SpatiaLite ``Covers(poly, geom)`` ========== ========================== .. fieldlookup:: crosses diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index a968ffa53c..8bcb3a113a 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -59,6 +59,9 @@ Minor features * Added Oracle support for the :class:`~django.contrib.gis.db.models.functions.Envelope` function. +* Added SpatiaLite support for the :lookup:`coveredby` and :lookup:`covers` + lookups. + :mod:`django.contrib.messages` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py index cfc6829fff..7859adf219 100644 --- a/tests/gis_tests/geoapp/tests.py +++ b/tests/gis_tests/geoapp/tests.py @@ -421,6 +421,8 @@ class GeoLookupTest(TestCase): ('relate', (Point(1, 1), 'T*T***FF*')), ('same_as', Point(1, 1)), ('exact', Point(1, 1)), + ('coveredby', Point(1, 1)), + ('covers', Point(1, 1)), ] for lookup, geom in queries: with self.subTest(lookup=lookup):