[MDEV-7514] GIS: PointOnSurface returns NULL instead of the point Created: 2015-01-27  Updated: 2020-11-09  Resolved: 2015-03-15

Status: Closed
Project: MariaDB Server
Component/s: GIS
Affects Version/s: N/A
Fix Version/s: 10.1.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: gis

Attachments: PNG File gis1.png    
Issue Links:
Relates
relates to MDEV-7509 Testing for GIS extensions Closed

 Description   

10.1 tree

MariaDB [test]> SELECT ST_AsText(ST_PointOnSurface(ST_PolyFromText('POLYGON((-70.916 42.1002,-70.9468 42.0946,-70.9754 42.0875,-70.9749 42.0879,-70.9759 42.0897,-70.916 42.1002))')));
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_PointOnSurface(ST_PolyFromText('POLYGON((-70.916 42.1002,-70.9468 42.0946,-70.9754 42.0875,-70.9749 42.0879,-70.9759 42.0897,-70.916 42.1002))'))) |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| NULL                                                                                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

PostGIS

pgis=# SELECT ST_AsText(ST_PointOnSurface(ST_PolyFromText('POLYGON((-70.916 42.1002,-70.9468 42.0946,-70.9754 42.0875,-70.9749 42.0879,-70.9759 42.0897,-70.916 42.1002))')));
             st_astext             
-----------------------------------
 POINT(-70.9510231824279 42.09385)
(1 row)

The shape is rather simple (see the picture).



 Comments   
Comment by Ian Gilfillan [ 2015-02-05 ]

The function doesn't seem to return a point under any circumstances. It even fails for a single point:

SET @g = ST_GEOMFROMTEXT('Point(0 5)');
 
SELECT ST_ASTEXT(ST_POINTONSURFACE(@g));
+----------------------------------+
| ST_ASTEXT(ST_POINTONSURFACE(@g)) |
+----------------------------------+
| NULL                             |
+----------------------------------+

Comment by Alexey Botchkov [ 2015-03-15 ]

Fixing patch: http://lists.askmonty.org/pipermail/commits/2015-March/007595.html

Comment by Deepak Vohra [ 2020-11-09 ]

The function still returns

NULL

in version 10.5.

SELECT ST_AsText(ST_PointOnSurface(ST_PolyFromText('POLYGON((-70.916 42.1002,-70.9468 42.0946,-70.9754 42.0875,-70.9749 42.0879,-70.9759 42.0897,-70.916 42.1002))')));
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | ST_AsText(ST_PointOnSurface(ST_PolyFromText('POLYGON((-70.916 42.1002,-70.9468 42.0946,-70.9754 42.0875,-70.9749 42.0879,-70.9759 42.0897,-70.916 42.1002))'))) |
   +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | NULL                                                                                                                                                            |
   +-----------------------------------------------------------------------------------------------------------------------------------------------------------------+

Generated at Thu Feb 08 07:20:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.