From 875aebdb2c7c26b29b52a2114b4e1a80f6809496 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Fri, 17 Mar 2017 05:29:31 +0500 Subject: [PATCH] Added SpatiaLite NumPoints support for non-LINESTRING geometries. --- django/contrib/gis/db/backends/spatialite/features.py | 2 -- django/contrib/gis/db/backends/spatialite/operations.py | 1 + docs/ref/contrib/gis/functions.txt | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/django/contrib/gis/db/backends/spatialite/features.py b/django/contrib/gis/db/backends/spatialite/features.py index 79517e8190..19235dea95 100644 --- a/django/contrib/gis/db/backends/spatialite/features.py +++ b/django/contrib/gis/db/backends/spatialite/features.py @@ -6,8 +6,6 @@ from django.utils.functional import cached_property class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures): supports_3d_storage = True - # SpatiaLite can only count vertices in LineStrings - supports_num_points_poly = False @cached_property def supports_initspatialmetadata_in_one_transaction(self): diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 9671cf2341..0b71f07b4e 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -83,6 +83,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): def function_names(self): return { 'Length': 'ST_Length', + 'NumPoints': 'ST_NPoints', 'Reverse': 'ST_Reverse', 'Scale': 'ScaleCoords', 'Translate': 'ST_Translate', diff --git a/docs/ref/contrib/gis/functions.txt b/docs/ref/contrib/gis/functions.txt index ca993542b8..1b7a0c39f5 100644 --- a/docs/ref/contrib/gis/functions.txt +++ b/docs/ref/contrib/gis/functions.txt @@ -392,7 +392,13 @@ or ``MULTI*`` field); otherwise returns ``None``. Oracle, SpatiaLite Accepts a single geographic field or expression and returns the number of points -in the first linestring in the geometry field; otherwise returns ``None``. +in a geometry. + +On MySQL, returns ``None`` for any non-``LINESTRING`` geometry. + +.. versionchanged:: 1.11 + + SpatiaLite support for non-``LINESTRING`` geometries was added. ``Perimeter`` =============