Opened 3 hours ago

#35783 assigned New feature

Add the ability to natively filter geometries by the number of dimensions used by a Geometry.

Reported by: David Smith Owned by: David Smith
Component: GIS Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

PostGIS and 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 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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top