Added missing support for PointOnSurface function on MariaDB.

This commit is contained in:
Mariusz Felisiak 2019-06-12 10:51:43 +02:00 committed by GitHub
parent 198a0adef2
commit b616f65855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -59,6 +59,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
'Scale', 'SnapToGrid', 'Transform', 'Translate', 'Scale', 'SnapToGrid', 'Transform', 'Translate',
} }
if self.connection.mysql_is_mariadb: if self.connection.mysql_is_mariadb:
unsupported.remove('PointOnSurface')
unsupported.update({'GeoHash', 'IsValid'}) unsupported.update({'GeoHash', 'IsValid'})
if self.connection.mysql_version < (10, 2, 4): if self.connection.mysql_version < (10, 2, 4):
unsupported.add('AsGeoJSON') unsupported.add('AsGeoJSON')

View File

@ -446,7 +446,7 @@ geometry field as a :class:`~django.contrib.gis.measure.Distance` object.
.. class:: PointOnSurface(expression, **extra) .. class:: PointOnSurface(expression, **extra)
*Availability*: `PostGIS <https://postgis.net/docs/ST_PointOnSurface.html>`__, *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 Accepts a single geographic field or expression and returns a ``Point`` geometry
guaranteed to lie on the surface of the field; otherwise returns ``None``. guaranteed to lie on the surface of the field; otherwise returns ``None``.

View File

@ -370,6 +370,11 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), 'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326),
'Texas': fromstr('POINT (-103.002434 36.500397)', 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: else:
# Using GEOSGeometry to compute the reference point on surface values # Using GEOSGeometry to compute the reference point on surface values
# -- since PostGIS also uses GEOS these should be the same. # -- since PostGIS also uses GEOS these should be the same.