Browse Source

Added missing support for PointOnSurface function on MariaDB.

Mariusz Felisiak 5 years ago
parent
commit
b616f65855

+ 1 - 0
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')

+ 1 - 1
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 <https://postgis.net/docs/ST_PointOnSurface.html>`__,
-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``.

+ 5 - 0
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.