[Django] #35783: Add the ability to natively filter geometries by the number of dimensions used by a Geometry.

9 views
Skip to first unread message

Django

unread,
Sep 23, 2024, 1:18:51 PM9/23/24
to django-...@googlegroups.com
#35783: Add the ability to natively filter geometries by the number of dimensions
used by a Geometry.
---------------------------------------+-----------------------------
Reporter: David Smith | Owner: David Smith
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-----------------------------
[https://postgis.net/docs/ST_NDims.html PostGIS] and [https://www.gaia-
gis.it/gaia-sins/spatialite-sql-4.2.0.html SpatiaLite] have a `ST_NDims`
function which returns the number of dimensions a geometry. I propose to
add a function similar to what is proposed for `GeometryType` in #28696.

Support for Oracle should also be possible with its `GET_DIMS( )` function
see
[https://docs.oracle.com/cd/B10500_01/appdev.920/a96630/sdo_meth.htm#BABDEBJA
docs ]. However, I couldn't find a similar function on MySQL/MariaDB.

An implementation for PostGIS/SpatiaLite would look something like this.

{{{
class NumDimensions(GeoFunc):
function = "ST_NDims"
output_field = IntegerField()
arity = 1
}}}

Which would allow this to be used in QuerySets such as annotating the
number of dimensions in a geometry.

{{{Country.objects.annotate(num_dims=functions.NumDimensions("geom"))}}}

I'll prepare a patch if accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/35783>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 24, 2024, 2:13:32 PM9/24/24
to django-...@googlegroups.com
#35783: Add the ability to natively filter geometries by the number of dimensions
used by a Geometry.
-----------------------------+---------------------------------------
Reporter: David Smith | Owner: David Smith
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by Claude Paroz):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/35783#comment:1>

Django

unread,
Sep 29, 2024, 12:03:37 PM9/29/24
to django-...@googlegroups.com
#35783: Add the ability to natively filter geometries by the number of dimensions
used by a Geometry.
-----------------------------+---------------------------------------
Reporter: David Smith | Owner: David Smith
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by David Smith):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35783#comment:2>

Django

unread,
Oct 1, 2024, 12:32:06 PM10/1/24
to django-...@googlegroups.com
#35783: Add the ability to natively filter geometries by the number of dimensions
used by a Geometry.
-----------------------------+---------------------------------------
Reporter: David Smith | Owner: David Smith
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1

Comment:

PR has a an approval from Claude, but I'm setting the flag "patch needs
improvement" until we clarify next steps for Oracle and potentially
[https://dev.mysql.com/doc/refman/8.4/en/gis-general-property-
functions.html#function_st-dimension MySQL].
--
Ticket URL: <https://code.djangoproject.com/ticket/35783#comment:3>
Reply all
Reply to author
Forward
0 new messages