Commit 702fba15 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-7510 GIS: IsRing returns false for a primitive triangle.

The problem is in the IsSimple function. If the first and the last points
of a curve coincide it's and exception and the line is still 'simple'.
parent 75d65b5f
......@@ -1378,7 +1378,7 @@ SELECT IsRing(LineFromWKB(AsBinary(Boundary(boundary)),SRID(boundary)))
FROM named_places
WHERE name = 'Goose Island';
IsRing(LineFromWKB(AsBinary(Boundary(boundary)),SRID(boundary)))
0
1
# Conformance Item T21
SELECT GLength(centerline)
FROM road_segments
......@@ -1765,3 +1765,12 @@ SRID
0
0
drop table t1;
#
# MDEV-7510 GIS: IsRing returns false for a primitive triangle.
#
select ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,0 0)'));
ST_IsRing(ST_LineFromText('LINESTRING(0 0,0 10,10 10,0 0)'))
1
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
......@@ -1486,3 +1486,9 @@ ALTER TABLE t1 ADD fid INT NOT NULL;
select SRID from information_schema.geometry_columns where F_TABLE_NAME='t1';
drop table t1;
--echo #
--echo # MDEV-7510 GIS: IsRing returns false for a primitive triangle.
--echo #
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)'));
......@@ -1867,7 +1867,6 @@ longlong Item_func_issimple::val_int()
Gcalc_operation_transporter trn(&func, &collector);
Geometry *g;
int result= 1;
const Gcalc_scan_iterator::event_point *ev;
MBR mbr;
const char *c_end;
......@@ -1892,6 +1891,8 @@ longlong Item_func_issimple::val_int()
while (scan_it.more_points())
{
const Gcalc_scan_iterator::event_point *ev, *next_ev;
if (scan_it.step())
goto mem_error;
......@@ -1899,11 +1900,18 @@ longlong Item_func_issimple::val_int()
if (ev->simple_event())
continue;
if ((ev->event == scev_thread || ev->event == scev_single_point) &&
!ev->get_next())
next_ev= ev->get_next();
if ((ev->event & (scev_thread | scev_single_point)) && !next_ev)
continue;
if ((ev->event == scev_two_threads) && !next_ev->get_next())
continue;
if (ev->event == scev_two_threads && !ev->get_next()->get_next())
/* If the first and last points of a curve coincide - that is */
/* an exception to the rule and the line is considered as simple. */
if ((next_ev && !next_ev->get_next()) &&
(ev->event & (scev_thread | scev_end)) &&
(next_ev->event & (scev_thread | scev_end)))
continue;
result= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment