From b616f65855e5658a0272506ded1274516daa908d Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 12 Jun 2019 10:51:43 +0200 Subject: [PATCH] Added missing support for PointOnSurface function on MariaDB. --- django/contrib/gis/db/backends/mysql/operations.py | 1 + docs/ref/contrib/gis/functions.txt | 2 +- tests/gis_tests/geoapp/test_functions.py | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index e765e4d879..e808609802 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -59,6 +59,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): 'Scale', 'SnapToGrid', 'Transform', 'Translate', } if self.connection.mysql_is_mariadb: + unsupported.remove('PointOnSurface') unsupported.update({'GeoHash', 'IsValid'}) if self.connection.mysql_version < (10, 2, 4): unsupported.add('AsGeoJSON') diff --git a/docs/ref/contrib/gis/functions.txt b/docs/ref/contrib/gis/functions.txt index 4a4e1b406b..15434fdd6c 100644 --- a/docs/ref/contrib/gis/functions.txt +++ b/docs/ref/contrib/gis/functions.txt @@ -446,7 +446,7 @@ geometry field as a :class:`~django.contrib.gis.measure.Distance` object. .. class:: PointOnSurface(expression, **extra) *Availability*: `PostGIS `__, -Oracle, SpatiaLite +MariaDB, Oracle, SpatiaLite Accepts a single geographic field or expression and returns a ``Point`` geometry guaranteed to lie on the surface of the field; otherwise returns ``None``. diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 7610a522eb..356f211c86 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -370,6 +370,11 @@ class GISFunctionsTests(FuncTestMixin, TestCase): 'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), } + elif mysql: + ref = { + 'New Zealand': fromstr('POINT (169.030131 -46.678612)', srid=4326), + 'Texas': fromstr('POINT (-97.383730 25.840117)', srid=4326), + } else: # Using GEOSGeometry to compute the reference point on surface values # -- since PostGIS also uses GEOS these should be the same.