Skip to content

Commit

Permalink
MDEV-7514 GIS: PointOnSurface returns NULL instead of the point.
Browse files Browse the repository at this point in the history
Need to take into account cases of a polygon shaped as a very thin line.
  • Loading branch information
Alexey Botchkov committed Mar 15, 2015
1 parent a21ef88 commit ca30418
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mysql-test/r/gis.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions mysql-test/t/gis.test
Original file line number Diff line number Diff line change
Expand Up @@ -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))')));

2 changes: 1 addition & 1 deletion sql/item_geofunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit ca30418

Please sign in to comment.