Skip to content

Commit b616f65

Browse files
authored
Added missing support for PointOnSurface function on MariaDB.
1 parent 198a0ad commit b616f65

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

django/contrib/gis/db/backends/mysql/operations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def unsupported_functions(self):
5959
'Scale', 'SnapToGrid', 'Transform', 'Translate',
6060
}
6161
if self.connection.mysql_is_mariadb:
62+
unsupported.remove('PointOnSurface')
6263
unsupported.update({'GeoHash', 'IsValid'})
6364
if self.connection.mysql_version < (10, 2, 4):
6465
unsupported.add('AsGeoJSON')

docs/ref/contrib/gis/functions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ geometry field as a :class:`~django.contrib.gis.measure.Distance` object.
446446
.. class:: PointOnSurface(expression, **extra)
447447

448448
*Availability*: `PostGIS <https://postgis.net/docs/ST_PointOnSurface.html>`__,
449-
Oracle, SpatiaLite
449+
MariaDB, Oracle, SpatiaLite
450450

451451
Accepts a single geographic field or expression and returns a ``Point`` geometry
452452
guaranteed to lie on the surface of the field; otherwise returns ``None``.

tests/gis_tests/geoapp/test_functions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ def test_point_on_surface(self):
370370
'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326),
371371
'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326),
372372
}
373+
elif mysql:
374+
ref = {
375+
'New Zealand': fromstr('POINT (169.030131 -46.678612)', srid=4326),
376+
'Texas': fromstr('POINT (-97.383730 25.840117)', srid=4326),
377+
}
373378
else:
374379
# Using GEOSGeometry to compute the reference point on surface values
375380
# -- since PostGIS also uses GEOS these should be the same.

0 commit comments

Comments
 (0)