summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2015-03-15 11:17:50 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2015-03-15 11:17:50 +0400
commitca3041883725393baa6c645050ef926d782eb3a8 (patch)
treeeda5c27fd68b48d5f8f41a15a26dc611b1ffbb1a
parenta21ef88d2a358904f0cdf9cadc701cb263b5e317 (diff)
downloadmariadb-git-ca3041883725393baa6c645050ef926d782eb3a8.tar.gz
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.
-rw-r--r--mysql-test/r/gis.result6
-rw-r--r--mysql-test/t/gis.test5
-rw-r--r--sql/item_geofunc.cc2
3 files changed, 12 insertions, 1 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index f696466f38c..c3d9fa39270 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 888ee681eeb..9c84848b979 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 7f63388fc81..753bae89ca4 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)
{