[Commits] ca30418: MDEV-7514 GIS: PointOnSurface returns NULL instead of the point.

holyfoot at askmonty.org holyfoot at askmonty.org
Sun Mar 15 09:20:24 EET 2015


revision-id: ca3041883725393baa6c645050ef926d782eb3a8
parent(s): a21ef88d2a358904f0cdf9cadc701cb263b5e317
committer: Alexey Botchkov
branch nick: 10.1
timestamp: 2015-03-15 11:17:50 +0400
message:

MDEV-7514 GIS: PointOnSurface returns NULL instead of the point.
Need to take into account cases of a polygon shaped as a very thin line.

---
 mysql-test/r/gis.result | 6 ++++++
 mysql-test/t/gis.test   | 5 +++++
 sql/item_geofunc.cc     | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index f696466..c3d9fa3 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -1774,3 +1774,9 @@ ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,0 0)'))
 select ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,-10 -10, 0 -10, 0 0)'));
 ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,-10 -10, 0 -10, 0 0)'))
 0
+#
+# MDEV-7514 GIS: PointOnSurface returns NULL instead of the point.
+#
+SELECT ST_GEOMETRYTYPE(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_GEOMETRYTYPE(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))')))
+POINT
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 888ee68..9c84848 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -1492,3 +1492,8 @@ drop table t1;
 select ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,0 0)'));
 select ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,-10 -10, 0 -10, 0 0)'));
 
+--echo #
+--echo # MDEV-7514 GIS: PointOnSurface returns NULL instead of the point.
+--echo #
+SELECT ST_GEOMETRYTYPE(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))')));
+
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 7f63388..753bae8 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -2346,7 +2346,7 @@ String *Item_func_pointonsurface::val_str(String *str)
     }
     x0= scan_it.get_sp_x(pprev);
     px= scan_it.get_sp_x(pit.point());
-    if (px - x0 > GIS_ZERO)
+    if (fabs(px - x0) > GIS_ZERO)
     {
       if (scan_it.get_h() > GIS_ZERO)
       {


More information about the commits mailing list