1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #28696 -- Added GeometryType GIS database function and __geom_type lookup.

Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
Ahmed Ibrahim
2025-07-17 09:50:39 +03:00
committed by Mariusz Felisiak
parent 6aa05fd232
commit a5b0a618c3
9 changed files with 192 additions and 54 deletions

View File

@@ -339,42 +339,43 @@ divided into the three categories described in the :ref:`raster lookup details
<spatial-lookup-raster>`: native support ``N``, bilateral native support ``B``,
and geometry conversion support ``C``.
================================= ========= ======== ============ ============ ========== ========
Lookup Type PostGIS Oracle MariaDB MySQL [#]_ SpatiaLite PGRaster
================================= ========= ======== ============ ============ ========== ========
:lookup:`bbcontains` X X X X N
:lookup:`bboverlaps` X X X X N
:lookup:`contained` X X X X N
:lookup:`contains <gis-contains>` X X X X X B
:lookup:`contains_properly` X B
:lookup:`coveredby` X X X (≥ 12.0.1) X X B
:lookup:`covers` X X X X B
:lookup:`crosses` X X X X C
:lookup:`disjoint` X X X X X B
:lookup:`distance_gt` X X X X X N
:lookup:`distance_gte` X X X X X N
:lookup:`distance_lt` X X X X X N
:lookup:`distance_lte` X X X X X N
:lookup:`dwithin` X X X B
:lookup:`equals` X X X X X C
:lookup:`exact <same_as>` X X X X X B
:lookup:`intersects` X X X X X B
================================= ========= ========= ============ ============ ========== ========
Lookup Type PostGIS Oracle MariaDB MySQL [#]_ SpatiaLite PGRaster
================================= ========= ========= ============ ============ ========== ========
:lookup:`bbcontains` X X X X N
:lookup:`bboverlaps` X X X X N
:lookup:`contained` X X X X N
:lookup:`contains <gis-contains>` X X X X X B
:lookup:`contains_properly` X B
:lookup:`coveredby` X X X (≥ 12.0.1) X X B
:lookup:`covers` X X X X B
:lookup:`crosses` X X X X C
:lookup:`disjoint` X X X X X B
:lookup:`distance_gt` X X X X X N
:lookup:`distance_gte` X X X X X N
:lookup:`distance_lt` X X X X X N
:lookup:`distance_lte` X X X X X N
:lookup:`dwithin` X X X B
:lookup:`equals` X X X X X C
:lookup:`exact <same_as>` X X X X X B
:lookup:`geom_type` X X (≥ 23c) X X X
:lookup:`intersects` X X X X X B
:lookup:`isempty` X
:lookup:`isvalid` X X X (≥ 12.0.1) X X
:lookup:`overlaps` X X X X X B
:lookup:`relate` X X X X C
:lookup:`same_as` X X X X X B
:lookup:`touches` X X X X X B
:lookup:`within` X X X X X B
:lookup:`left` X C
:lookup:`right` X C
:lookup:`overlaps_left` X B
:lookup:`overlaps_right` X B
:lookup:`overlaps_above` X C
:lookup:`overlaps_below` X C
:lookup:`strictly_above` X C
:lookup:`strictly_below` X C
================================= ========= ======== ============ ============ ========== ========
:lookup:`isvalid` X X X (≥ 12.0.1) X X
:lookup:`overlaps` X X X X X B
:lookup:`relate` X X X X C
:lookup:`same_as` X X X X X B
:lookup:`touches` X X X X X B
:lookup:`within` X X X X X B
:lookup:`left` X C
:lookup:`right` X C
:lookup:`overlaps_left` X B
:lookup:`overlaps_right` X B
:lookup:`overlaps_above` X C
:lookup:`overlaps_below` X C
:lookup:`strictly_above` X C
:lookup:`strictly_below` X C
================================= ========= ========= ============ ============ ========== ========
.. _database-functions-compatibility:
@@ -408,6 +409,7 @@ Function PostGIS Oracle MariaDB MySQL
:class:`FromWKT` X X X X X
:class:`GeoHash` X X (≥ 12.0.1) X X (LWGEOM/RTTOPO)
:class:`GeometryDistance` X
:class:`GeometryType` X X (≥ 23c) X X X
:class:`Intersection` X X X X X
:class:`IsEmpty` X
:class:`IsValid` X X X (≥ 12.0.1) X X

View File

@@ -635,6 +635,18 @@ Returns ``True`` if its value is a valid geometry and ``False`` otherwise.
MariaDB 12.0.1+ support was added.
``GeometryType``
----------------
.. versionadded:: 6.0
.. class:: GeometryType(expr)
*Availability*: `PostGIS <https://postgis.net/docs/GeometryType.html>`__,
Oracle 23c+, MariaDB, MySQL, SpatiaLite
Accepts a geographic field or expression and returns its geometry type.
``MemSize``
-----------

View File

@@ -399,6 +399,32 @@ Oracle ``SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(p
MariaDB 12.0.1+ support was added.
.. fieldlookup:: geom_type
``geom_type``
-------------
.. versionadded:: 6.0
*Availability*: `PostGIS <https://postgis.net/docs/GeometryType.html>`__,
Oracle 23c+, MariaDB, MySQL, SpatiaLite
Returns the geometry type of the geometry field.
Example::
Zipcode.objects.filter(poly__geom_type="POLYGON")
========== ==========================
Backend SQL Equivalent
========== ==========================
PostGIS ``GeometryType(geom)``
MariaDB ``ST_GeometryType(geom)``
MySQL ``ST_GeometryType(geom)``
Oracle ``SDO_GEOMETRY.GET_GTYPE(geom)``
SpatiaLite ``GeometryType(geom)``
========== ==========================
.. fieldlookup:: overlaps
``overlaps``