Commit 152f3c5e authored by Alexey Botchkov's avatar Alexey Botchkov

PostGIS-style 'same point' handling.

parent 90c4df7a
......@@ -392,10 +392,10 @@ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 0 0 0 1 0 1 1 0
120 120 1 1 0 1 0 1 1 1
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 0 0 0 1 0 1 1 0
121 121 1 1 0 1 0 1 1 1
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
......@@ -494,12 +494,13 @@ mbroverlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrtouches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
......@@ -514,9 +515,10 @@ overlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
touches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
......
......@@ -79,7 +79,7 @@ select 1, ST_Intersects(GeomFromText('LINESTRING(15 15, 50 50)'), GeomFromText('
1 1
select 0, ST_Intersects(GeomFromText('LINESTRING(15 15, 50 50)'), GeomFromText('LINESTRING(16 16, 51 51)'));
0 ST_Intersects(GeomFromText('LINESTRING(15 15, 50 50)'), GeomFromText('LINESTRING(16 16, 51 51)'))
0 0
0 1
select 1, ST_Intersects(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
1 ST_Intersects(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))
1 1
......@@ -127,10 +127,10 @@ astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFr
POLYGON((26.4705882352941 23.8235294117647,21.9512195121951 27.4390243902439,23.855421686747 29.8192771084337,29.2899408284024 26.3609467455621,26.4705882352941 23.8235294117647))
select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')));
astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')))
MULTIPOINT(26.4705882352941 23.8235294117647,29.2899408284024 26.3609467455621,21.9512195121951 27.4390243902439,23.855421686747 29.8192771084337)
MULTIPOINT(23.8235294117647 26.4705882352941,26.3609467455621 29.2899408284024,27.4390243902439 21.9512195121951,29.8192771084337 23.855421686747)
select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45)')))
POINT(29.2899408284024 26.3609467455621)
POINT(26.3609467455621 29.2899408284024)
select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POINT(20 20)')));
astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POINT(20 20)')))
POINT(20 20)
......@@ -148,7 +148,7 @@ astext(ST_intersection(geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), geomfromte
POLYGON((0 0,0 1,0.5 0.5,0 0))
select astext(ST_symdifference(geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
astext(ST_symdifference(geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')))
MULTIPOLYGON(((0 0,0 1,0 0,0.5 0.5,1 0,0 0)),((0.5 0.5,0 1,0 2,1 1,0.5 0.5)))
MULTIPOLYGON(((0 0,0.5 0.5,1 0,0 0)),((0.5 0.5,0 1,0 2,1 1,0.5 0.5)))
select astext(ST_UNION(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
astext(ST_UNION(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
GEOMETRYCOLLECTION(LINESTRING(-10 -10,0 0),LINESTRING(-11 -9,8 10),POLYGON((0 0,40 50,50 45,0 0)),LINESTRING(46.6666666666667 46.6666666666667,200 200,199 201,45.3333333333333 47.3333333333333))
......@@ -189,7 +189,7 @@ st_touches(geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), geomfromtext('point(1
0
select st_touches(geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'));
st_touches(geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'))
0
1
select st_touches(geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'));
st_touches(geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'))
1
......@@ -208,13 +208,13 @@ ExteriorRing( Envelope( MultiLineStringFromText('MULTILINESTRING((3 4,5 3),(3 0,
astext(ST_UNION (
PolyFromText('POLYGON(( 2 2 ,3 2,2 7,2 2),( 0 0,8 2,1 9,0 0))'),
ExteriorRing( Envelope( MultiLineStringFromText('MULTILINESTRING((3 4,5 3),(3 0,0 5))')))))
GEOMETRYCOLLECTION(POLYGON((0 0,1 9,8 2,0 0),(2 2,2 7,3 2,2 2)),LINESTRING(0 0,5 0,5 1.25),LINESTRING(0 0,0 5,0.555555555555556 5),LINESTRING(2.4 5,2 5))
GEOMETRYCOLLECTION(POLYGON((0 0,1 9,8 2,0 0),(2 2,2 7,3 2,2 2)),LINESTRING(0.555555555555556 5,0 5,0 0,5 0,5 1.25),LINESTRING(2 5,2.4 5))
SELECT astext(ST_BUFFER(LineStringFromText('LINESTRING(0 0,1 1)'),0));
astext(ST_BUFFER(LineStringFromText('LINESTRING(0 0,1 1)'),0))
LINESTRING(0 0,1 1)
SELECT Round(ST_Area(ST_BUFFER(MultipointFromText('MULTIPOINT(7 7,3 7,7 2,7 4 ,7 7)'), 3)), 5);
Round(ST_Area(ST_BUFFER(MultipointFromText('MULTIPOINT(7 7,3 7,7 2,7 4 ,7 7)'), 3)), 5)
78.68426
78.68303
SELECT ST_INTERSECTION(NULL, NULL);
ST_INTERSECTION(NULL, NULL)
NULL
......@@ -231,7 +231,7 @@ MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4))
((0 5,3 5,3 0,0 0,0 1,2 1,2 2,0 2,0 5), (1 3,2 3,2 4,1 4,1 3)),
((2 2,5 2,4 4,2 8,2 2)))'),
MULTIPOLY
MULTIPOLYGON(((2 2,3 2,2 2)),((5 2,0 2,5 2)),((2 2,0 2,1.5 5,2 5,2 2),(1 3,1 4,2 4,2 3,1 3)),((2 2,2 8,8 8,8 2,5 2,2 2),(6 4,4 4,4 6,6 6,6 4)))
POLYGON((0 2,1 4,1 3,2 3,2 4,1 4,1.5 5,2 5,2 8,8 8,8 2,0 2),(4 4,4 6,6 6,6 4,4 4))
SELECT ASTEXT(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
(8 2,1 3,9 0,4 4))'),
......@@ -240,7 +240,7 @@ ASTEXT(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
(8 2,1 3,9 0,4 4))'),
MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))')))
MULTILINESTRING((8 2,1 3,9 0,4 4),(5 0,2 9,8 4,3 7,0 7,3 9,6 4,4 3,3 6,3 5,4 0,6 2),(3 6,1 6,5 2,9 7,6 7,2 5))
MULTILINESTRING((3.59459459459459 2.02702702702703,4 0,4.75 0.75),(5 0,4.75 0.75),(5.36363636363636 1.36363636363636,9 0,6.17391304347826 2.26086956521739),(4.75 0.75,4.42857142857143 1.71428571428571),(4.75 0.75,5.36363636363636 1.36363636363636),(5.36363636363636 1.36363636363636,4.42857142857143 1.71428571428571),(5.36363636363636 1.36363636363636,6 2),(4.42857142857143 1.71428571428571,3.59459459459459 2.02702702702703),(4.42857142857143 1.71428571428571,4.15 2.55),(4.5 2.5,5 2,5.30769230769231 2.38461538461538),(8 2,6.17391304347826 2.26086956521739),(3.59459459459459 2.02702702702703,1 3,3.47058823529412 2.64705882352941),(3.59459459459459 2.02702702702703,3.47058823529412 2.64705882352941),(6.17391304347826 2.26086956521739,5.30769230769231 2.38461538461538),(6.17391304347826 2.26086956521739,5.58536585365854 2.73170731707317),(5.30769230769231 2.38461538461538,4.5 2.5),(5.30769230769231 2.38461538461538,5.58536585365854 2.73170731707317),(4.5 2.5,4.15 2.55),(4.5 2.5,4 3),(4.15 2.55,3.47058823529412 2.64705882352941),(4.15 2.55,4 3),(3.47058823529412 2.64705882352941,3.25 3.75),(5.58536585365854 2.73170731707317,4.76923076923077 3.38461538461538),(5.58536585365854 2.73170731707317,7.05405405405405 4.56756756756757),(4 3,3.25 3.75),(4 3,3.14285714285714 5.57142857142857),(4 3,4.76923076923077 3.38461538461538),(4.76923076923077 3.38461538461538,4 4),(4.76923076923077 3.38461538461538,6 4,4.875 5.875),(3.25 3.75,2 5),(3.25 3.75,3 5,3 5.5),(7.05405405405405 4.56756756756757,8 4,7.16 4.7),(7.05405405405405 4.56756756756757,4.875 5.875),(7.05405405405405 4.56756756756757,7.16 4.7),(7.16 4.7,5 6.5),(7.16 4.7,9 7,6 7,5 6.5),(2 5,1 6,3 6),(2 5,3 5.5),(3 5.5,3 6),(3 5.5,3.14285714285714 5.57142857142857),(3.14285714285714 5.57142857142857,3 6),(3.14285714285714 5.57142857142857,4.36363636363636 6.18181818181818),(4.875 5.875,4.36363636363636 6.18181818181818),(4.875 5.875,4.61538461538461 6.30769230769231),(3 6,2.66666666666667 7),(4.36363636363636 6.18181818181818,3 7,2.66666666666667 7),(4.36363636363636 6.18181818181818,4.61538461538461 6.30769230769231),(4.61538461538461 6.30769230769231,4 7.33333333333333),(4.61538461538461 6.30769230769231,5 6.5),(5 6.5,4 7.33333333333333),(2.18181818181818 8.45454545454546,0 7,2.66666666666667 7),(2.66666666666667 7,2.18181818181818 8.45454545454546),(4 7.33333333333333,2.44444444444444 8.62962962962963),(4 7.33333333333333,3 9,2.44444444444444 8.62962962962963),(2.18181818181818 8.45454545454546,2 9,2.44444444444444 8.62962962962963),(2.18181818181818 8.45454545454546,2.44444444444444 8.62962962962963))
SELECT ST_NUMGEOMETRIES((ST_UNION(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 0,4 2,0 2,1 5,0 3,7 0,8 5,5 8),
(6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
......@@ -257,14 +257,14 @@ ST_NUMGEOMETRIES((ST_UNION(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 0,4 2,0 2,1 5,0 3,7 0,8 5,5 8),
(6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
32
183
SELECT Round(ST_AREA(ST_BUFFER( ST_UNION(
POLYGONFROMTEXT('POLYGON((7 7, 7 7, 7 4, 7 7, 7 7))'),
POLYGONFROMTEXT('POLYGON((7 7, 4 7, 2 9, 7 6, 7 7))')), 1)), 6);
Round(ST_AREA(ST_BUFFER( ST_UNION(
POLYGONFROMTEXT('POLYGON((7 7, 7 7, 7 4, 7 7, 7 7))'),
POLYGONFROMTEXT('POLYGON((7 7, 4 7, 2 9, 7 6, 7 7))')), 1)), 6)
21.901403
21.901344
SELECT AsText(ST_UNION(MultiPolygonFromText('
MULTIPOLYGON(((2 2, 2 8, 8 8, 8 2, 2 2), (4 4, 4 6, 6 6, 6 4, 4 4)),
((0 0, 8 3, 7 4, 0 0)),
......@@ -278,7 +278,7 @@ AsText(ST_UNION(MultiPolygonFromText('
((0 0, 8 3, 7 4, 0 0)),
((2 2, 2 8, 8 8, 8 2, 2 2), (4 4, 4 6, 6 6, 6 4, 4 4)))'),
MultiPolygonFr
POLYGON((0 0,0 5,0.555555555555556 5,1 9,2 8,8 8,8 2,7 2,5.33333333333333 2,3 1.125,3 0,0 0),(1 1,1 1.5,1.33333333333333 2,1 2,2 2,2 1.14285714285714,1.75 1,1 1),(3 1.71428571428571,3 2,3.5 2,3 1.71428571428571),(4 4,4 6,4.5 6,5.5 4,4 4))
POLYGON((0 0,0 5,0.555555555555556 5,1 9,2 8,8 8,8 2,5.33333333333333 2,3 1.125,3 0,0 0),(1 1,1 1.5,1.33333333333333 2,2 2,2 1.14285714285714,1.75 1,1 1),(3 1.71428571428571,3 2,3.5 2,3 1.71428571428571),(4 4,4 6,4.5 6,5.5 4,4 4))
SELECT AsText(ST_SYMDIFFERENCE(
MultiLineStringFromText('MULTILINESTRING((7 7, 1 7, 8 5, 7 8, 7 7),
(6 3, 3 4, 1 1, 9 9, 9 0, 8 4, 9 9))'),
......@@ -287,7 +287,7 @@ AsText(ST_SYMDIFFERENCE(
MultiLineStringFromText('MULTILINESTRING((7 7, 1 7, 8 5, 7 8, 7 7),
(6 3, 3 4, 1 1, 9 9, 9 0, 8 4, 9 9))'),
Envelope(GeometryFromText('MULTIPOINT(7 9, 0 0, 3 7, 1 6, 0 0)'))))
GEOMETRYCOLLECTION(LINESTRING(9 9,8 4,9 0,9 9,7 7),POLYGON((0 0,0 9,7 9,7 0,0 0)),LINESTRING(7 5.28571428571429,8 5,7 8))
GEOMETRYCOLLECTION(POLYGON((0 0,0 9,7 9,7 0,0 0)),LINESTRING(9 9,8 4,9 0,9 9),LINESTRING(7 5.28571428571429,8 5,7.25 7.25),LINESTRING(7 7,7.25 7.25),LINESTRING(7.25 7.25,7 8),LINESTRING(7.25 7.25,9 9))
SELECT AsText(ST_UNION(
MultiPolygonFromText('MULTIPOLYGON(((9 9, 7 9, 1 1, 9 9)),
((2 2, 1 2, 3 3, 2 2, 2 2)),
......
......@@ -170,6 +170,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
......
......@@ -384,10 +384,10 @@ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 0 0 0 1 0 1 1 0
120 120 1 1 0 1 0 1 1 1
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 0 0 0 1 0 1 1 0
121 121 1 1 0 1 0 1 1 1
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
......@@ -835,12 +835,13 @@ mbroverlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrtouches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
......@@ -855,9 +856,10 @@ overlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
touches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
......@@ -1410,7 +1412,7 @@ FROM lakes, named_places
WHERE lakes.name = 'Blue Lake'
AND named_places.name = 'Ashton';
AsText(ST_SymDifference(shore, boundary))
MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(67 13,59 13,59 18,67 18,67 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(59 13,59 18,67 18,67 13,59 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
# Conformance Item T51
SELECT count(*)
FROM buildings, bridges
......
......@@ -392,10 +392,10 @@ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 0 0 0 1 0 1 1 0
120 120 1 1 0 1 0 1 1 1
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 0 0 0 1 0 1 1 0
121 121 1 1 0 1 0 1 1 1
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
......@@ -494,12 +494,13 @@ mbroverlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrtouches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
......@@ -514,9 +515,10 @@ overlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
touches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
......
......@@ -392,10 +392,10 @@ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 0 0 0 1 0 1 1 0
120 120 1 1 0 1 0 1 1 1
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 0 0 0 1 0 1 1 0
121 121 1 1 0 1 0 1 1 1
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
......@@ -494,12 +494,13 @@ mbroverlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrtouches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
......@@ -514,9 +515,10 @@ overlaps
down,left,right,up
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
touches
down2,left2,right2,up2
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
......
......@@ -181,6 +181,7 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
......@@ -308,403 +309,403 @@ fid AsText(g)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
99
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
98
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
97
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
96
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
95
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
94
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
93
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
92
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
91
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
90
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
89
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
88
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
87
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
86
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
85
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
84
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
83
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
82
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
81
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
80
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
79
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
78
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
77
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
76
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
75
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
74
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
73
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
72
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
71
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
70
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
69
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
68
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
67
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
66
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
65
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
64
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
63
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
62
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
61
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
60
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
59
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
58
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
57
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
56
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
55
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
54
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
53
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
52
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
51
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
50
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
49
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
48
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
47
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
46
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
45
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
44
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
43
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
42
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
41
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
40
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
39
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
38
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
37
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
36
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
35
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
34
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
33
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
32
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
31
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
30
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
29
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
28
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
27
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
26
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
25
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
24
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
23
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
22
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
21
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
20
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
19
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
18
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
17
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
16
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
15
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
14
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
13
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
12
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
11
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
10
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
9
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
8
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
7
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
6
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
5
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
4
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
3
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
2
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
1
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
0
DROP TABLE t2;
drop table if exists t1;
Warnings:
......
......@@ -181,6 +181,7 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
......@@ -308,403 +309,403 @@ fid AsText(g)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
99
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
98
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
97
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
96
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
95
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
94
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
93
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
92
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
91
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
90
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
89
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
88
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
87
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
86
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
85
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
84
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
83
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
82
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
81
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
80
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
79
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
78
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
77
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
76
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
75
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
74
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
73
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
72
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
71
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
70
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
69
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
68
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
67
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
66
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
65
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
64
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
63
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
62
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
61
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
60
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
59
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
58
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
57
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
56
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
55
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
54
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
53
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
52
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
51
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
50
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
49
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
48
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
47
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
46
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
45
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
44
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
43
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
42
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
41
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
40
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
39
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
38
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
37
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
36
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
35
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
34
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
33
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
32
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
31
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
30
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
29
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
28
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
27
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
26
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
25
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
24
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
23
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
22
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
21
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
20
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
19
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
18
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
17
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
16
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
15
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
14
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
13
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
12
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
11
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
10
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
9
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
8
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
7
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
6
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
5
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
4
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
3
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
2
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
1
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
0
DROP TABLE t2;
drop table if exists t1;
Warnings:
......
......@@ -181,6 +181,7 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
......@@ -308,403 +309,403 @@ fid AsText(g)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
99
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
98
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
97
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
96
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
95
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
94
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
93
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
92
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
91
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
90
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
89
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
88
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
87
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
86
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
85
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
84
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
83
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
82
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
81
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
80
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
79
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
78
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
77
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
76
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
75
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
74
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
73
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
72
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
71
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
70
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
69
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
68
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
67
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
66
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
65
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
64
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
63
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
62
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
61
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
60
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
59
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
58
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
57
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
56
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
55
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
54
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
53
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
52
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
51
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
50
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
49
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
48
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
47
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
46
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
45
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
44
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
43
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
42
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
41
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
40
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
39
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
38
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
37
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
36
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
35
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
34
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
33
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
32
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
31
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
30
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
29
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
28
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
27
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
26
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
25
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
24
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
23
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
22
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
21
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
20
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
19
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
18
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
17
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
16
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
15
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
14
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
13
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
12
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
11
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
10
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
9
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
8
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
7
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
6
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
5
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
4
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
3
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
2
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
1
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
100
0
DROP TABLE t2;
drop table if exists t1;
Warnings:
......
......@@ -23,6 +23,7 @@
#define PH_DATA_OFFSET 8
#define coord_to_float(d) ((double) d)
#define coord_eq(a, b) (a == b)
typedef int (*sc_compare_func)(const void*, const void*);
......@@ -126,28 +127,13 @@ static inline void trim_node(Gcalc_heap::Info *node, Gcalc_heap::Info *prev_node
}
static double find_first_different(const Gcalc_heap::Info *p)
{
if (p->left && (p->left->y != p->y))
return p->left->y;
if (p->right && (p->right->y != p->y))
return p->right->y;
if (p->left && p->left->left && (p->left->left->y != p->y))
return p->left->left->y;
if (p->right && p->right->right && (p->right->right->y != p->y))
return p->right->right->y;
return p->y;
}
static int compare_point_info(const void *e0, const void *e1)
{
const Gcalc_heap::Info *i0= (const Gcalc_heap::Info *)e0;
const Gcalc_heap::Info *i1= (const Gcalc_heap::Info *)e1;
if (i0->y != i1->y)
if (!coord_eq(i0->y, i1->y))
return i0->y > i1->y;
return find_first_different(i0) > find_first_different(i1);
return i0->x > i1->x;
}
......@@ -197,6 +183,8 @@ int Gcalc_shape_transporter::int_add_point(gcalc_shape_info Info,
double x, double y)
{
Gcalc_heap::Info *point;
DBUG_ASSERT(!m_prev || m_prev->x != x || m_prev->y != y);
if (!(point= m_heap->new_point_info(x, y, Info)))
return 1;
if (m_first)
......@@ -234,6 +222,7 @@ void Gcalc_shape_transporter::int_complete()
return;
}
DBUG_ASSERT(m_prev->x != m_first->x || m_prev->y != m_first->y);
/* polygon */
m_first->right= m_prev;
m_prev->left= m_first;
......@@ -253,15 +242,14 @@ inline int GET_DX_DY(double *dxdy,
Gcalc_scan_iterator::Gcalc_scan_iterator(size_t blk_size) :
Gcalc_dyn_list(blk_size,
(sizeof(point) > sizeof(intersection)) ?
sizeof(point) : sizeof(intersection)),
m_slice0(NULL), m_slice1(NULL)
sizeof(point) : sizeof(intersection))
{}
Gcalc_scan_iterator::point
*Gcalc_scan_iterator::new_slice(Gcalc_scan_iterator::point *example)
{
point *result= NULL;
Gcalc_dyn_list::Item **result_hook= (Gcalc_dyn_list::Item **)&result;
Gcalc_dyn_list::Item **result_hook= (Gcalc_dyn_list::Item **) &result;
while (example)
{
*result_hook= new_slice_point();
......@@ -276,55 +264,156 @@ Gcalc_scan_iterator::point
void Gcalc_scan_iterator::init(Gcalc_heap *points)
{
DBUG_ASSERT(points->ready());
DBUG_ASSERT(!m_slice0 && !m_slice1);
DBUG_ASSERT(!state0.slice && !state1.slice);
if (!(m_cur_pi= points->get_first()))
return;
m_cur_thread= 0;
m_sav_slice= NULL;
m_intersections= NULL;
m_cur_intersection= NULL;
m_y1= m_cur_pi->y;
m_next_is_top_point= true;
m_bottom_points_count= 0;
m_events= NULL;
current_state= &state0;
next_state= &state1;
saved_state= &state_s;
next_state->y= m_cur_pi->y;
}
void Gcalc_scan_iterator::reset()
{
if (m_slice0)
free_list(m_slice0);
if (m_slice1)
free_list(m_slice1);
m_slice0= m_slice1= NULL;
state0.slice= state1.slice= m_events= state_s.slice= NULL;
m_intersections= NULL;
Gcalc_dyn_list::reset();
}
static bool slice_first_equal_x(const Gcalc_scan_iterator::point *p0,
const Gcalc_scan_iterator::point *p1)
void Gcalc_scan_iterator::point::copy_core(point *from)
{
dx_dy= from->dx_dy;
horiz_dir= from->horiz_dir;
pi= from->pi;
next_pi= from->next_pi;
thread= from->thread;
#ifdef TO_REMOVE
from->next_link= this;
#endif /*TO_REMOVE*/
}
int Gcalc_scan_iterator::point::compare_dx_dy(int horiz_dir_a, double dx_dy_a,
int horiz_dir_b, double dx_dy_b)
{
if (p0->horiz_dir == p1->horiz_dir)
return p0->dx_dy <= p1->dx_dy;
if (p0->horiz_dir)
return p0->dx_dy < 0;
return p1->dx_dy > 0; /* p1->horiz_dir case */
if (!horiz_dir_a && !horiz_dir_b)
{
if (coord_eq(dx_dy_a, dx_dy_b))
return 0;
return dx_dy_a < dx_dy_b ? -1 : 1;
}
if (!horiz_dir_a)
return -1;
if (!horiz_dir_b)
return 1;
return 0;
}
static inline bool slice_first(const Gcalc_scan_iterator::point *p0,
const Gcalc_scan_iterator::point *p1)
int Gcalc_scan_iterator::point::cmp_dx_dy(const point *p) const
{
if (p0->x != p1->x)
return p0->x < p1->x;
return slice_first_equal_x(p0, p1);
if (is_bottom())
return p->is_bottom() ? 0 : -1;
if (p->is_bottom())
return 1;
return compare_dx_dy(horiz_dir, dx_dy, p->horiz_dir, p->dx_dy);
}
void Gcalc_scan_iterator::mark_event_position1(
point *ep, Gcalc_dyn_list::Item **ep_hook)
{
if (!next_state->event_position)
{
next_state->event_position= ep;
next_state->event_position_hook= ep_hook;
}
next_state->event_end_hook= &ep->next;
}
static int compare_events(const void *e0, const void *e1)
{
const Gcalc_scan_iterator::point *p0= (const Gcalc_scan_iterator::point *)e0;
const Gcalc_scan_iterator::point *p1= (const Gcalc_scan_iterator::point *)e1;
return p0->cmp_dx_dy(p1) > 0;
}
int Gcalc_scan_iterator::arrange_event()
{
int ev_counter;
point *sp, *new_sp;
point *after_event;
Gcalc_dyn_list::Item **ae_hook= (Gcalc_dyn_list::Item **) &after_event;
if (m_events)
free_list(m_events);
ev_counter= 0;
DBUG_ASSERT(current_state->event_position ==
*current_state->event_position_hook);
for (sp= current_state->event_position;
sp != *current_state->event_end_hook; sp= sp->get_next())
{
if (sp->is_bottom())
continue;
if (!(new_sp= new_slice_point()))
return 1;
*new_sp= *sp;
*ae_hook= new_sp;
ae_hook= &new_sp->next;
#ifdef TO_REMOVE
sp->intersection_link= new_sp;
#endif /*TO_REMOVE*/
ev_counter++;
}
*ae_hook= NULL;
m_events= current_state->event_position;
if (after_event)
{
if (after_event->get_next())
{
point *cur_p;
after_event= (point *) sort_list(compare_events, after_event, ev_counter);
/* Find last item in the list, ae_hook can change after the sorting */
for (cur_p= after_event->get_next(); cur_p->get_next();
cur_p= cur_p->get_next());
ae_hook= &cur_p->next;
}
*ae_hook= *current_state->event_end_hook;
*current_state->event_end_hook= NULL;
*current_state->event_position_hook= after_event;
current_state->event_end_hook= ae_hook;
current_state->event_position= after_event;
}
else
{
*current_state->event_position_hook= *current_state->event_end_hook;
*current_state->event_end_hook= NULL;
current_state->event_position= sp;
current_state->event_end_hook= current_state->event_position_hook;
}
return 0;
}
int Gcalc_scan_iterator::insert_top_point()
{
point *sp= m_slice1;
Gcalc_dyn_list::Item **prev_hook= (Gcalc_dyn_list::Item **)&m_slice1;
point *sp= next_state->slice;
Gcalc_dyn_list::Item **prev_hook=
(Gcalc_dyn_list::Item **) &next_state->slice;
point *sp1;
point *sp0= new_slice_point();
point *sp_inc;
if (!sp0)
return 1;
......@@ -335,116 +424,182 @@ int Gcalc_scan_iterator::insert_top_point()
if (m_cur_pi->left)
{
sp0->horiz_dir= GET_DX_DY(&sp0->dx_dy, m_cur_pi, m_cur_pi->left);
m_event1= scev_thread;
sp0->event= scev_thread;
/*Now just to increase the size of m_slice0 to be same*/
if (!(sp1= new_slice_point()))
if (!(sp_inc= new_slice_point()))
return 1;
sp1->next= m_slice0;
m_slice0= sp1;
}
else
{
m_event1= scev_single_point;
sp0->horiz_dir= 0;
sp0->dx_dy= 0.0;
}
/* First we need to find the place to insert.
Binary search could probably make things faster here,
but structures used aren't suitable, and the
scan is usually not really long */
for (; sp && slice_first(sp, sp0);
prev_hook= &sp->next, sp=sp->get_next())
{}
sp_inc->next= current_state->slice;
current_state->slice= sp_inc;
if (m_cur_pi->right)
{
m_event1= scev_two_threads;
/*We have two threads so should decide which one will be first*/
sp1= new_slice_point();
if (!sp1)
if (!(sp1= new_slice_point()))
return 1;
sp1->event= sp0->event= scev_two_threads;
#ifdef TO_REMOVE
sp1->event_pair= sp0;
sp0->event_pair= sp1;
#endif /*TO_REMOVE*/
sp1->pi= m_cur_pi;
sp1->next_pi= m_cur_pi->right;
sp1->thread= m_cur_thread++;
sp1->x= sp0->x;
sp1->horiz_dir= GET_DX_DY(&sp1->dx_dy, m_cur_pi, m_cur_pi->right);
if (slice_first_equal_x(sp1, sp0))
/* We have two threads so should decide which one will be first */
if (sp0->cmp_dx_dy(sp1)>0)
{
point *tmp= sp0;
sp0= sp1;
sp1= tmp;
}
sp1->next= sp;
sp0->next= sp1;
/*Now just to increase the size of m_slice0 to be same*/
if (!(sp1= new_slice_point()))
if (!(sp_inc= new_slice_point()))
return 1;
sp1->next= m_slice0;
m_slice0= sp1;
sp_inc->next= current_state->slice;
current_state->slice= sp_inc;
}
}
else
sp0->next= sp;
*prev_hook= sp0;
m_event_position1= sp0;
{
sp0->event= scev_single_point;
sp0->horiz_dir= 0;
sp0->dx_dy= 0.0;
}
return 0;
}
enum
{
intersection_normal= 1,
intersection_forced= 2
};
/* We need to find the place to insert. */
for (; sp && (sp->x < sp0->x); prev_hook= &sp->next, sp=sp->get_next())
{}
next_state->event_position_hook= prev_hook;
if (sp && coord_eq(sp->x, sp0->x))
{
next_state->event_position= sp;
do
{
if (!sp->event)
sp->event= scev_intersection;
prev_hook= &sp->next;
sp= sp->get_next();
} while (sp && coord_eq(sp->x, sp0->x));
}
else
next_state->event_position= sp0;
static int intersection_found(const Gcalc_scan_iterator::point *sp0,
const Gcalc_scan_iterator::point *sp1,
unsigned int bottom_points_count)
{
if (sp1->x < sp0->x)
return intersection_normal;
if (sp1->is_bottom() && !sp0->is_bottom() &&
(bottom_points_count > 1))
return intersection_forced;
*prev_hook= sp0;
if (sp0->event == scev_two_threads)
{
sp1->next= sp;
sp0->next= sp1;
next_state->event_end_hook= &sp1->next;
}
else
{
sp0->next= sp;
next_state->event_end_hook= &sp0->next;
}
return 0;
}
int Gcalc_scan_iterator::normal_scan()
{
if (m_next_is_top_point)
if (insert_top_point())
point *sp;
Gcalc_dyn_list::Item **sp_hook;
Gcalc_heap::Info *next_pi;
point *first_bottom_point= NULL;
if (m_next_is_top_point && insert_top_point())
return 1;
for (next_pi= m_cur_pi->get_next();
next_pi &&
coord_eq(m_cur_pi->x, next_pi->x) &&
coord_eq(m_cur_pi->y, next_pi->y);
next_pi= next_pi->get_next())
{
DBUG_ASSERT(coord_eq(next_state->event_position->x, next_pi->x));
next_state->clear_event_position();
m_next_is_top_point= true;
for (sp= next_state->slice,
sp_hook= (Gcalc_dyn_list::Item **) &next_state->slice; sp;
sp_hook= &sp->next, sp= sp->get_next())
{
if (sp->next_pi == next_pi) /* End of the segment */
{
sp->x= coord_to_float(next_pi->x);
sp->pi= next_pi;
sp->next_pi= next_pi->left;
m_next_is_top_point= false;
if (next_pi->is_bottom())
{
if (first_bottom_point)
{
first_bottom_point->event= sp->event= scev_two_ends;
#ifdef TO_REMOVE
first_bottom_point->event_pair= sp;
sp->event_pair= first_bottom_point;
#endif /*TO_REMOVE*/
}
else
{
first_bottom_point= sp;
sp->event= scev_end;
}
}
else
{
sp->event= scev_point;
sp->horiz_dir= GET_DX_DY(&sp->dx_dy, next_pi, next_pi->left);
}
mark_event_position1(sp, sp_hook);
}
else if (coord_eq(sp->x, next_pi->x))
{
if (!sp->event)
sp->event= scev_intersection;
mark_event_position1(sp, sp_hook);
}
}
m_cur_pi= next_pi;
if (m_next_is_top_point && insert_top_point())
return 1;
}
point *tmp= m_slice0;
m_slice0= m_slice1;
m_slice1= tmp;
m_event0= m_event1;
m_event_position0= m_event_position1;
m_y0= m_y1;
/* Swap current <-> next */
{
slice_state *tmp= current_state;
current_state= next_state;
next_state= tmp;
}
if (!(m_cur_pi= m_cur_pi->get_next()))
if (arrange_event())
return 1;
point *sp0= current_state->slice;
point *sp1= next_state->slice;
point *prev_sp1= NULL;
if (!(m_cur_pi= next_pi))
{
free_list(m_slice1);
m_slice1= NULL;
free_list(sp1);
next_state->slice= NULL;
#ifdef TO_REMOVE
for (; sp0; sp0= sp0->get_next())
sp0->next_link= NULL;
#endif /*TO_REMOVE*/
return 0;
}
Gcalc_heap::Info *cur_pi= m_cur_pi;
m_y1= coord_to_float(cur_pi->y);
m_h= m_y1 - m_y0;
next_state->y= coord_to_float(cur_pi->y);
point *sp0= m_slice0;
point *sp1= m_slice1;
point *prev_sp1= NULL;
m_bottom_points_count= 0;
first_bottom_point= NULL;
m_next_is_top_point= true;
bool intersections_found= false;
next_state->clear_event_position();
for (; sp0; sp0= sp0->get_next())
{
......@@ -454,41 +609,57 @@ int Gcalc_scan_iterator::normal_scan()
sp1->pi= cur_pi;
sp1->thread= sp0->thread;
sp1->next_pi= cur_pi->left;
if (cur_pi->left)
sp1->horiz_dir= GET_DX_DY(&sp1->dx_dy, m_cur_pi, m_cur_pi->left);
#ifdef TO_REMOVE
sp0->next_link= sp1;
#endif /*TO_REMOVE*/
m_next_is_top_point= false;
if (sp1->is_bottom())
{
++m_bottom_points_count;
if (m_bottom_points_count == 1)
if (!first_bottom_point)
{
m_event1= scev_end;
m_event_position1= sp1;
sp1->event= scev_end;
first_bottom_point= sp1;
}
else
m_event1= scev_two_ends;
{
first_bottom_point->event= sp1->event= scev_two_ends;
#ifdef TO_REMOVE
sp1->event_pair= first_bottom_point;
first_bottom_point->event_pair= sp1;
#endif /*TO_REMOVE*/
}
}
else
{
m_event1= scev_point;
m_event_position1= sp1;
sp1->event= scev_point;
sp1->horiz_dir= GET_DX_DY(&sp1->dx_dy, m_cur_pi, m_cur_pi->left);
}
mark_event_position1(sp1,
prev_sp1 ? &prev_sp1->next :
(Gcalc_dyn_list::Item **) &next_state->slice);
}
else if (!sp0->is_bottom())
else
{
/* Cut current string with the height of the new point*/
sp1->copy_core(sp0);
sp1->x= sp1->horiz_dir ? sp0->x :
sp1->x= sp1->horiz_dir ? coord_to_float(cur_pi->x) :
(coord_to_float(sp1->pi->x) +
(m_y1-coord_to_float(sp1->pi->y)) * sp1->dx_dy);
(next_state->y-coord_to_float(sp1->pi->y)) * sp1->dx_dy);
if (coord_eq(sp1->x, cur_pi->x))
{
mark_event_position1(sp1,
prev_sp1 ? &prev_sp1->next :
(Gcalc_dyn_list::Item **) &next_state->slice);
sp1->event= scev_intersection;
}
else
sp1->event= scev_none;
}
else /* Skip the bottom point in slice0 */
continue;
intersections_found= intersections_found ||
(prev_sp1 && intersection_found(prev_sp1, sp1, m_bottom_points_count));
(prev_sp1 && prev_sp1->x > sp1->x);
prev_sp1= sp1;
sp1= sp1->get_next();
......@@ -499,7 +670,7 @@ int Gcalc_scan_iterator::normal_scan()
if (prev_sp1)
prev_sp1->next= NULL;
else
m_slice1= NULL;
next_state->slice= NULL;
free_list(sp1);
}
......@@ -513,7 +684,7 @@ int Gcalc_scan_iterator::normal_scan()
#define INTERSECTION_ZERO 0.000000000001
int Gcalc_scan_iterator::add_intersection(const point *a, const point *b,
int isc_kind, Gcalc_dyn_list::Item ***p_hook)
Gcalc_dyn_list::Item ***p_hook)
{
intersection *isc= new_intersection();
......@@ -524,16 +695,12 @@ int Gcalc_scan_iterator::add_intersection(const point *a, const point *b,
*p_hook= &isc->next;
isc->thread_a= a->thread;
isc->thread_b= b->thread;
if (isc_kind == intersection_forced)
{
isc->y= m_y1;
isc->x= a->x;
return 0;
}
/* intersection_normal */
const point *a0= a->precursor;
const point *b0= b->precursor;
const point *a0= a->intersection_link;
const point *b0= b->intersection_link;
DBUG_ASSERT(!a0->horiz_dir || !b0->horiz_dir);
if (!a0->horiz_dir && !b0->horiz_dir)
{
double dk= a0->dx_dy - b0->dx_dy;
......@@ -541,11 +708,11 @@ int Gcalc_scan_iterator::add_intersection(const point *a, const point *b,
if (fabs(dk) < INTERSECTION_ZERO)
dy= 0.0;
isc->y= m_y0 + dy;
isc->y= current_state->y + dy;
isc->x= a0->x + dy*a0->dx_dy;
return 0;
}
isc->y= m_y1;
isc->y= next_state->y;
isc->x= a0->horiz_dir ? b->x : a->x;
return 0;
}
......@@ -553,19 +720,18 @@ int Gcalc_scan_iterator::add_intersection(const point *a, const point *b,
int Gcalc_scan_iterator::find_intersections()
{
point *sp1= m_slice1;
point *sp1= next_state->slice;
Gcalc_dyn_list::Item **hook;
m_n_intersections= 0;
{
/* Set links between slicepoints */
point *sp0= m_slice0;
point *sp0= current_state->slice;
for (; sp1; sp0= sp0->get_next(),sp1= sp1->get_next())
{
while (sp0->is_bottom())
sp0= sp0->get_next();
DBUG_ASSERT(!sp0->is_bottom());
DBUG_ASSERT(sp0->thread == sp1->thread);
sp1->precursor= sp0;
sp1->intersection_link= sp0;
}
}
......@@ -575,23 +741,18 @@ int Gcalc_scan_iterator::find_intersections()
point *last_possible_isc= NULL;
do
{
sp1= m_slice1;
point **pprev_s1= &m_slice1;
point **pprev_s1= &next_state->slice;
intersections_found= false;
unsigned int bottom_points_count= sp1->is_bottom() ? 1:0;
sp1= m_slice1->get_next();
int isc_kind;
sp1= next_state->slice->get_next();
point *cur_possible_isc= NULL;
for (; sp1 != last_possible_isc;
pprev_s1= (point **)(&(*pprev_s1)->next), sp1= sp1->get_next())
{
if (sp1->is_bottom())
++bottom_points_count;
if (!(isc_kind=intersection_found(*pprev_s1, sp1, bottom_points_count)))
continue;
point *prev_s1= *pprev_s1;
if (prev_s1->x <= sp1->x)
continue;
intersections_found= true;
if (add_intersection(prev_s1, sp1, isc_kind, &hook))
if (add_intersection(prev_s1, sp1, &hook))
return 1;
*pprev_s1= sp1;
prev_s1->next= sp1->next;
......@@ -611,7 +772,9 @@ static int compare_intersections(const void *e0, const void *e1)
{
Gcalc_scan_iterator::intersection *i0= (Gcalc_scan_iterator::intersection *)e0;
Gcalc_scan_iterator::intersection *i1= (Gcalc_scan_iterator::intersection *)e1;
if (i0->y != i1->y)
return i0->y > i1->y;
return i0->x > i1->x;
}
......@@ -624,144 +787,131 @@ inline void Gcalc_scan_iterator::sort_intersections()
int Gcalc_scan_iterator::handle_intersections()
{
DBUG_ASSERT(m_slice1->next);
DBUG_ASSERT(next_state->slice->next);
if (find_intersections())
return 1;
sort_intersections();
m_sav_slice= m_slice1;
m_sav_y= m_y1;
m_slice1= new_slice(m_sav_slice);
/* Swap saved <-> next */
{
slice_state *tmp= next_state;
next_state= saved_state;
saved_state= tmp;
}
/* We need the next slice to be just equal */
next_state->slice= new_slice(saved_state->slice);
m_cur_intersection= m_intersections;
m_pre_intersection_hook= NULL;
return intersection_scan();
}
void Gcalc_scan_iterator::pop_suitable_intersection()
int Gcalc_scan_iterator::intersection_scan()
{
intersection *prev_i= m_cur_intersection;
intersection *cur_i= prev_i->get_next();
for (; cur_i; prev_i= cur_i, cur_i= cur_i->get_next())
point *sp0, *sp1;
Gcalc_dyn_list::Item **hook;
intersection *next_intersection;
if (m_cur_intersection != m_intersections)
{
point *prev_p= m_slice0;
point *sp= prev_p->get_next();
for (; sp; prev_p= sp, sp= sp->get_next())
/* Swap current <-> next */
{
if ((prev_p->thread == cur_i->thread_a) &&
(sp->thread == cur_i->thread_b))
slice_state *tmp= current_state;
current_state= next_state;
next_state= tmp;
}
if (arrange_event())
return 1;
if (!m_cur_intersection)
{
/* Move cur_t on the top of the list */
if (prev_i == m_cur_intersection)
saved_state->event_position_hook=
(Gcalc_dyn_list::Item **) &saved_state->slice;
#ifdef TO_REMOVE
for (sp0= current_state->slice, sp1= saved_state->slice;
sp0;
sp0= sp0->get_next(), sp1= sp1->get_next())
{
m_cur_intersection->next= cur_i->next;
cur_i->next= m_cur_intersection;
m_cur_intersection= cur_i;
sp0->next_link= sp1;
if (sp1->get_next() == saved_state->event_position)
saved_state->event_position_hook= &sp1->next;
}
else
#endif /*TO_REMOVE*/
for (sp1= saved_state->slice; sp1; sp1= sp1->get_next())
{
Gcalc_dyn_list::Item *tmp= m_cur_intersection->next;
m_cur_intersection->next= cur_i->next;
prev_i->next= m_cur_intersection;
m_cur_intersection= cur_i;
cur_i->next= tmp;
}
return;
}
if (sp1->get_next() == saved_state->event_position)
saved_state->event_position_hook= &sp1->next;
}
/* Swap saved <-> next */
{
slice_state *tmp= next_state;
next_state= saved_state;
saved_state= tmp;
}
DBUG_ASSERT(0);
}
free_list(saved_state->slice);
saved_state->slice= NULL;
int Gcalc_scan_iterator::intersection_scan()
{
if (m_pre_intersection_hook) /*Skip the first point*/
{
point *next= (*m_pre_intersection_hook)->get_next();
(*m_pre_intersection_hook)->next= next->next;
next->next= *m_pre_intersection_hook;
*m_pre_intersection_hook= next;
m_event0= scev_intersection;
m_event_position0= next;
point *tmp= m_slice1;
m_slice1= m_slice0;
m_slice0= tmp;
m_y0= m_y1;
m_cur_intersection= m_cur_intersection->get_next();
if (!m_cur_intersection)
{
m_h= m_sav_y - m_y1;
m_y1= m_sav_y;
free_list(m_slice1);
m_slice1= m_sav_slice;
free_list(m_intersections);
m_intersections= NULL;
return 0;
}
}
m_y1= m_cur_intersection->y;
m_h= m_y1 - m_y0;
next_state->y= m_cur_intersection->y;
point *sp0;
point **psp1;
found_equal_intersection:
sp0= current_state->slice;
hook= (Gcalc_dyn_list::Item **) &next_state->slice;
sp1= next_state->slice;
next_state->clear_event_position();
redo_loop:
sp0= m_slice0;
psp1= &m_slice1;
for (; sp0; sp0= sp0->get_next())
for (; sp0;
hook= &sp1->next, sp1= sp1->get_next(), sp0= sp0->get_next())
{
point *sp1= *psp1;
if (sp0->thread == m_cur_intersection->thread_a)
if (sp0->thread == m_cur_intersection->thread_a ||
sp0->thread == m_cur_intersection->thread_b)
{
point *next_s0= sp0;
/* Skip Bottom points */
do
next_s0= next_s0->get_next();
while(next_s0->is_bottom()); /* We always find nonbottom point here*/
/* If the next point's thread isn't the thread of intersection,
we try to find suitable intersection */
if (next_s0->thread != m_cur_intersection->thread_b)
{
/* It's really rare case - sometimes happen when
there's two intersections with the same Y
Move suitable one to the beginning of the list
*/
pop_suitable_intersection();
goto redo_loop;
}
m_pre_intersection_hook= psp1;
sp1->copy_core(sp0);
sp1->x= m_cur_intersection->x;
sp0= next_s0;
sp1= sp1->get_next();
sp1->copy_core(sp0);
sp1->x= m_cur_intersection->x;
psp1= (point **)&sp1->next;
continue;
sp1->event= scev_intersection;
mark_event_position1(sp1, hook);
}
if (!sp0->is_bottom())
else
{
sp1->copy_core(sp0);
sp1->x= sp1->horiz_dir ? sp0->x :
(coord_to_float(sp1->pi->x) +
(m_y1-coord_to_float(sp1->pi->y)) * sp1->dx_dy);
sp1->x= sp1->horiz_dir ?
m_cur_intersection->x :
coord_to_float(sp1->pi->x) +
(next_state->y-coord_to_float(sp1->pi->y)) * sp1->dx_dy;
if (coord_eq(sp1->x, m_cur_intersection->x))
{
sp1->event= scev_intersection;
mark_event_position1(sp1, hook);
}
else
/* Skip bottom point */
continue;
psp1= (point **)&sp1->next;
sp1->event= scev_none;
}
}
if (sp1)
{
free_list(sp1);
*hook= NULL;
}
if (*psp1)
next_intersection= m_cur_intersection->get_next();
if (next_intersection &&
coord_eq(next_intersection->x, m_cur_intersection->x) &&
coord_eq(next_intersection->y, m_cur_intersection->y))
{
free_list(*psp1);
*psp1= NULL;
m_cur_intersection= next_intersection;
goto found_equal_intersection;
}
m_cur_intersection= next_intersection;
return 0;
}
#endif /* HAVE_SPATIAL */
......@@ -236,6 +236,7 @@ class Gcalc_shape_transporter
enum Gcalc_scan_events
{
scev_none= 0,
scev_point= 1, /* Just a new point in thread */
scev_thread= 2, /* Start of the new thread */
scev_two_threads= 4, /* A couple of new threads started */
......@@ -268,7 +269,13 @@ class Gcalc_scan_iterator : public Gcalc_dyn_list
Gcalc_heap::Info *pi;
Gcalc_heap::Info *next_pi;
sc_thread_id thread;
const point *precursor; /* used as a temporary field */
const point *intersection_link;
Gcalc_scan_events event;
#ifdef TO_REMOVE
const point *event_pair;
point *next_link;
#endif /*TO_REMOVE*/
inline const point *c_get_next() const
{ return (const point *)next; }
......@@ -276,15 +283,17 @@ class Gcalc_scan_iterator : public Gcalc_dyn_list
gcalc_shape_info get_shape() const { return pi->shape; }
inline point *get_next() { return (point *)next; }
inline const point *get_next() const { return (const point *)next; }
/* copies all but 'next' 'x' and 'precursor' */
void copy_core(const point *from)
void copy_core(point *from);
/* Compare the dx_dy parameters regarding the horiz_dir */
/* returns -1 if less, 0 if equal, 1 if bigger */
static int compare_dx_dy(int horiz_dir_a, double dx_dy_a,
int horiz_dir_b, double dx_dy_b);
int cmp_dx_dy(const point *p) const;
int simple_event() const
{
dx_dy= from->dx_dy;
horiz_dir= from->horiz_dir;
pi= from->pi;
next_pi= from->next_pi;
thread= from->thread;
return !next ? (event & (scev_point | scev_end)) :
(!next->next && event == scev_two_ends);
}
#ifndef DBUG_OFF
void dbug_print();
......@@ -301,6 +310,22 @@ class Gcalc_scan_iterator : public Gcalc_dyn_list
inline intersection *get_next() { return (intersection *)next; }
};
class slice_state
{
public:
point *slice;
point *event_position;
Gcalc_dyn_list::Item **event_position_hook;
Gcalc_dyn_list::Item **event_end_hook;
double y;
slice_state() : slice(NULL) {}
void clear_event_position()
{
event_position= NULL;
event_end_hook= (Gcalc_dyn_list::Item **) &event_position;
}
};
public:
Gcalc_scan_iterator(size_t blk_size= 8192);
......@@ -309,50 +334,46 @@ class Gcalc_scan_iterator : public Gcalc_dyn_list
int step()
{
DBUG_ASSERT(more_points());
return m_cur_intersection ? intersection_scan() : normal_scan();
return m_intersections ? intersection_scan() : normal_scan();
}
inline Gcalc_heap::Info *more_points() { return m_cur_pi; }
inline bool more_trapezoids()
{ return m_cur_pi && m_cur_pi->next; }
inline Gcalc_scan_events get_event() const { return m_event0; }
inline const point *get_events() const
{ return m_events; }
inline const point *get_event_position() const
{ return m_event_position0; }
inline const point *get_b_slice() const { return m_slice0; }
inline const point *get_t_slice() const { return m_slice1; }
inline double get_h() const { return m_h; }
inline double get_y() const { return m_y0; }
{ return current_state->event_position; }
inline const point *get_event_end() const
{ return (point *) *current_state->event_end_hook; }
inline const point *get_b_slice() const { return current_state->slice; }
inline const point *get_t_slice() const { return next_state->slice; }
inline double get_h() const { return current_state->y - next_state->y; }
inline double get_y() const { return current_state->y; }
private:
Gcalc_heap::Info *m_cur_pi;
point *m_slice0;
point *m_slice1;
point *m_sav_slice;
slice_state state0, state1, state_s;
slice_state *current_state;
slice_state *next_state;
slice_state *saved_state;
intersection *m_intersections;
int m_n_intersections;
intersection *m_cur_intersection;
point **m_pre_intersection_hook;
double m_h;
double m_y0;
double m_y1;
double m_sav_y;
bool m_next_is_top_point;
unsigned int m_bottom_points_count;
sc_thread_id m_cur_thread;
Gcalc_scan_events m_event0, m_event1;
point *m_event_position0;
point *m_event_position1;
point *m_events;
int normal_scan();
int intersection_scan();
void sort_intersections();
int handle_intersections();
int insert_top_point();
int add_intersection(const point *a, const point *b,
int isc_kind, Gcalc_dyn_list::Item ***p_hook);
Gcalc_dyn_list::Item ***p_hook);
int find_intersections();
void pop_suitable_intersection();
intersection *new_intersection()
{
......@@ -363,6 +384,8 @@ class Gcalc_scan_iterator : public Gcalc_dyn_list
return (point *)new_item();
}
point *new_slice(point *example);
int arrange_event();
void mark_event_position1(point *ep, Gcalc_dyn_list::Item **ep_hook);
};
......@@ -427,6 +450,8 @@ class Gcalc_point_iterator
inline const Gcalc_heap::Info *get_pi() const { return sp->pi; }
inline gcalc_shape_info get_shape() const { return sp->get_shape(); }
inline double get_x() const { return sp->x; }
inline void restart(const Gcalc_scan_iterator *scan_i)
{ sp= scan_i->get_b_slice(); }
};
#endif /*GCALC_SLICESCAN_INCLUDED*/
......
......@@ -106,13 +106,26 @@ int Gcalc_function::reserve_op_buffer(uint n_ops)
int Gcalc_function::alloc_states()
{
if (function_buffer.reserve((n_shapes+1) * sizeof(int)))
if (function_buffer.reserve((n_shapes+1) * 2 * sizeof(int)))
return 1;
i_states= (int *) (function_buffer.ptr() + ALIGN_SIZE(function_buffer.length()));
saved_i_states= i_states + (n_shapes + 1);
return 0;
}
void Gcalc_function::save_states()
{
memcpy(saved_i_states, i_states, (n_shapes+1) * sizeof(int));
}
void Gcalc_function::restore_states()
{
memcpy(i_states, saved_i_states, (n_shapes+1) * sizeof(int));
}
int Gcalc_function::count_internal()
{
int c_op= uint4korr(cur_func);
......@@ -170,36 +183,64 @@ void Gcalc_function::reset()
int Gcalc_function::find_function(Gcalc_scan_iterator &scan_it)
{
const Gcalc_scan_iterator::point *eq_start, *cur_eq, *events;
while (scan_it.more_points())
{
if (scan_it.step())
return -1;
Gcalc_scan_events ev= scan_it.get_event();
const Gcalc_scan_iterator::point *evpos= scan_it.get_event_position();
if (ev & (scev_point | scev_end | scev_two_ends))
events= scan_it.get_events();
/* these kinds of events don't change the function */
if (events->simple_event())
continue;
Gcalc_point_iterator pit(&scan_it);
clear_state();
for (Gcalc_point_iterator pit(&scan_it); pit.point() != evpos; ++pit)
/* Walk to the event, marking polygons we met */
for (; pit.point() != scan_it.get_event_position(); ++pit)
{
gcalc_shape_info si= pit.point()->get_shape();
if ((get_shape_kind(si) == Gcalc_function::shape_polygon))
invert_state(si);
}
invert_state(evpos->get_shape());
save_states();
/* Check the status of the event point */
for (; events; events= events->get_next())
set_on_state(events->get_shape());
if (ev == scev_intersection)
if (count())
return 1;
if (scan_it.get_event_position() == scan_it.get_event_end())
continue;
/* Check the status after the event */
restore_states();
eq_start= pit.point();
do
{
const Gcalc_scan_iterator::point *evnext= evpos->c_get_next();
if ((get_shape_kind(evpos->get_shape()) !=
Gcalc_function::shape_polygon) ||
(get_shape_kind(evnext->get_shape()) !=
Gcalc_function::shape_polygon))
invert_state(evnext->get_shape());
++pit;
if (pit.point() != scan_it.get_event_end() &&
eq_start->cmp_dx_dy(pit.point()) == 0)
continue;
save_states();
for (cur_eq= eq_start; cur_eq != pit.point();
cur_eq= cur_eq->get_next())
set_on_state(cur_eq->get_shape());
if (count())
return 1;
restore_states();
for (cur_eq= eq_start; cur_eq != pit.point(); cur_eq= cur_eq->get_next())
{
gcalc_shape_info si= cur_eq->get_shape();
if ((get_shape_kind(si) == Gcalc_function::shape_polygon))
invert_state(si);
}
if (count())
return 1;
eq_start= pit.point();
} while (pit.point() != scan_it.get_event_end());
}
return 0;
}
......@@ -457,6 +498,10 @@ void Gcalc_operation_reducer::init(Gcalc_function *fn, modes mode)
m_fn= fn;
m_mode= mode;
m_first_active_thread= NULL;
m_lines= NULL;
m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines;
m_poly_borders= NULL;
m_poly_borders_hook= (Gcalc_dyn_list::Item **) &m_poly_borders;
}
......@@ -470,10 +515,10 @@ Gcalc_operation_reducer(Gcalc_function *fn, modes mode, size_t blk_size) :
inline int Gcalc_operation_reducer::continue_range(active_thread *t,
const Gcalc_heap::Info *p)
const Gcalc_heap::Info *p,
int horiz_dir, double dx_dy)
{
DBUG_ASSERT(t->result_range);
res_point *rp= add_res_point();
res_point *rp= add_res_point(t->rp->type);
if (!rp)
return 1;
rp->glue= NULL;
......@@ -482,16 +527,17 @@ inline int Gcalc_operation_reducer::continue_range(active_thread *t,
rp->intersection_point= false;
rp->pi= p;
t->rp= rp;
t->horiz_dir= horiz_dir;
t->dx_dy= dx_dy;
return 0;
}
inline int Gcalc_operation_reducer::continue_i_range(active_thread *t,
const Gcalc_heap::Info *p,
double x, double y)
double x, double y,
int horiz_dir, double dx_dy)
{
DBUG_ASSERT(t->result_range);
res_point *rp= add_res_point();
res_point *rp= add_res_point(t->rp->type);
if (!rp)
return 1;
rp->glue= NULL;
......@@ -499,487 +545,516 @@ inline int Gcalc_operation_reducer::continue_i_range(active_thread *t,
t->rp->up= rp;
rp->intersection_point= true;
rp->x= x;
rp->pi= p;
rp->y= y;
t->rp= rp;
t->horiz_dir= horiz_dir;
t->dx_dy= dx_dy;
return 0;
}
inline int Gcalc_operation_reducer::start_range(active_thread *t,
int Gcalc_operation_reducer::end_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p)
{
res_point *rp= add_res_point();
if (!rp)
res_point *rp0, *rp1;
DBUG_ASSERT(t0->rp->type == t1->rp->type);
if (!(rp0= add_res_point(t0->rp->type)) ||
!(rp1= add_res_point(t0->rp->type)))
return 1;
rp->glue= rp->down= NULL;
rp->intersection_point= false;
rp->pi= p;
t->result_range= 1;
t->rp= rp;
rp0->down= t0->rp;
rp1->down= t1->rp;
rp1->glue= rp0;
rp0->glue= rp1;
rp0->up= rp1->up= NULL;
t0->rp->up= rp0;
t1->rp->up= rp1;
rp0->intersection_point= rp1->intersection_point= false;
rp0->pi= rp1->pi= p;
return 0;
}
inline int Gcalc_operation_reducer::start_i_range(active_thread *t,
const Gcalc_heap::Info *p,
double x, double y)
{
res_point *rp= add_res_point();
if (!rp)
return 1;
rp->glue= rp->down= NULL;
rp->intersection_point= true;
rp->x= x;
rp->y= y;
rp->pi= p;
t->result_range= 1;
t->rp= rp;
return 0;
}
inline int Gcalc_operation_reducer::end_range(active_thread *t,
const Gcalc_heap::Info *p)
int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
{
res_point *rp= add_res_point();
if (!rp)
return 1;
rp->glue= rp->up= NULL;
rp->down= t->rp;
rp->intersection_point= false;
rp->pi= p;
t->rp->up= rp;
t->result_range= 0;
return 0;
}
Gcalc_point_iterator pi(si);
const Gcalc_heap::Info *event_point= NULL;
int prev_state= 0;
int sav_prev_state;
active_thread *prev_range= NULL;
const Gcalc_scan_iterator::point *events;
const Gcalc_scan_iterator::point *eq_start;
active_thread **cur_t_hook= &m_first_active_thread;
active_thread **starting_t_hook;
active_thread *bottom_threads= NULL;
active_thread *eq_thread, *point_thread;;
inline int Gcalc_operation_reducer::end_i_range(active_thread *t,
const Gcalc_heap::Info *p,
double x, double y)
{
res_point *rp= add_res_point();
if (!rp)
return 1;
rp->glue= rp->up= NULL;
rp->down= t->rp;
rp->intersection_point= true;
rp->x= x;
rp->pi= p;
rp->y= y;
t->rp->up= rp;
t->result_range= 0;
return 0;
}
m_fn->clear_state();
/* Walk to the event, remembering what is needed. */
for (; pi.point() != si->get_event_position();
++pi, cur_t_hook= (active_thread **) &(*cur_t_hook)->next)
{
active_thread *cur_t= *cur_t_hook;
if (cur_t->enabled() &&
cur_t->rp->type == Gcalc_function::shape_polygon)
{
prev_state^= 1;
prev_range= prev_state ? cur_t : 0;
}
if (m_fn->get_shape_kind(pi.get_shape()) == Gcalc_function::shape_polygon)
m_fn->invert_state(pi.get_shape());
}
int Gcalc_operation_reducer::start_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p,
const active_thread *prev_range)
{
res_point *rp0, *rp1;
if (!(rp0= add_res_point()) || !(rp1= add_res_point()))
events= si->get_events();
if (events->simple_event())
{
active_thread *cur_t= *cur_t_hook;
switch (events->event)
{
case scev_point:
{
if (cur_t->enabled() &&
continue_range(cur_t, events->pi, events->horiz_dir, events->dx_dy))
return 1;
rp0->glue= rp1;
rp1->glue= rp0;
rp0->intersection_point= rp1->intersection_point= false;
rp0->down= rp1->down= NULL;
rp0->pi= rp1->pi= p;
t0->rp= rp0;
t1->rp= rp1;
if (prev_range)
break;
}
case scev_end:
{
rp0->outer_poly= prev_range->thread_start;
t1->thread_start= prev_range->thread_start;
if (cur_t->enabled() && end_line(cur_t, events->pi, si))
return 1;
*cur_t_hook= cur_t->get_next();
free_item(cur_t);
break;
}
else
case scev_two_ends:
{
rp0->outer_poly= 0;
t0->thread_start= rp0;
if (cur_t->enabled() &&
end_couple(cur_t, cur_t->get_next(), events->pi))
return 1;
*cur_t_hook= cur_t->get_next()->get_next();
free_item(cur_t->next);
free_item(cur_t);
break;
}
default:
DBUG_ASSERT(0);
}
return 0;
}
}
int Gcalc_operation_reducer::start_i_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
double x, double y,
const active_thread *prev_range)
{
res_point *rp0, *rp1;
if (!(rp0= add_res_point()) || !(rp1= add_res_point()))
starting_t_hook= cur_t_hook;
sav_prev_state= prev_state;
/* Walk through the event, collecting all the 'incoming' threads */
for (; events; events= events->get_next())
{
active_thread *cur_t= *cur_t_hook;
if (!event_point && events->event != scev_intersection)
event_point= events->pi;
if (events->event == scev_single_point)
continue;
if (events->event == scev_thread ||
events->event == scev_two_threads)
{
active_thread *new_t= new_active_thread();
if (!new_t)
return 1;
rp0->glue= rp1;
rp1->glue= rp0;
rp0->pi= p0;
rp1->pi= p1;
rp0->intersection_point= rp1->intersection_point= true;
rp0->down= rp1->down= NULL;
rp0->x= rp1->x= x;
rp0->y= rp1->y= y;
t0->result_range= t1->result_range= 1;
t0->rp= rp0;
t1->rp= rp1;
if (prev_range)
new_t->rp= NULL;
/* Insert into the main thread list before the current */
new_t->next= cur_t;
*cur_t_hook= new_t;
cur_t_hook= (active_thread **) &new_t->next;
}
else
{
rp0->outer_poly= prev_range->thread_start;
t1->thread_start= prev_range->thread_start;
if (events->is_bottom())
{
/* Move thread from the main list to the bottom_threads. */
*cur_t_hook= cur_t->get_next();
cur_t->next= bottom_threads;
bottom_threads= cur_t;
}
if (cur_t->enabled())
{
if (cur_t->rp->type == Gcalc_function::shape_line)
{
DBUG_ASSERT(!prev_state);
add_line(1, cur_t, events);
}
else
{
rp0->outer_poly= 0;
t0->thread_start= rp0;
add_poly_border(1, cur_t, prev_state, events);
prev_state^= 1;
}
return 0;
}
int Gcalc_operation_reducer::end_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p)
{
res_point *rp0, *rp1;
DBUG_ASSERT(t1->result_range);
if (!(rp0= add_res_point()) || !(rp1= add_res_point()))
return 1;
rp0->down= t0->rp;
rp1->down= t1->rp;
rp1->glue= rp0;
rp0->glue= rp1;
rp0->up= rp1->up= NULL;
t0->rp->up= rp0;
t1->rp->up= rp1;
rp0->intersection_point= rp1->intersection_point= false;
rp0->pi= rp1->pi= p;
t0->result_range= t1->result_range= 0;
return 0;
}
int Gcalc_operation_reducer::end_i_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
double x, double y)
{
res_point *rp0, *rp1;
if (!(rp0= add_res_point()) || !(rp1= add_res_point()))
if (!events->is_bottom())
{
active_thread *new_t= new_active_thread();
if (!new_t)
return 1;
rp0->down= t0->rp;
rp1->down= t1->rp;
rp0->pi= p0;
rp1->pi= p1;
rp1->glue= rp0;
rp0->glue= rp1;
rp0->up= rp1->up= NULL;
rp0->intersection_point= rp1->intersection_point= true;
rp0->x= rp1->x= x;
rp0->y= rp1->y= y;
t0->result_range= t1->result_range= 0;
t0->rp->up= rp0;
t1->rp->up= rp1;
return 0;
}
new_t->rp= NULL;
/* Replace the current thread with the new. */
new_t->next= cur_t->next;
*cur_t_hook= new_t;
cur_t_hook= (active_thread **) &new_t->next;
/* And move old to the bottom list */
cur_t->next= bottom_threads;
bottom_threads= cur_t;
}
}
else if (!events->is_bottom())
cur_t_hook= (active_thread **) &cur_t->next;
}
}
prev_state= sav_prev_state;
cur_t_hook= starting_t_hook;
int Gcalc_operation_reducer::add_single_point(const Gcalc_heap::Info *p)
{
res_point *rp= add_res_point();
if (!rp)
return 1;
rp->glue= rp->up= rp->down= NULL;
rp->intersection_point= false;
rp->pi= p;
rp->x= p->x;
rp->y= p->y;
return 0;
}
eq_start= pi.point();
eq_thread= point_thread= *starting_t_hook;
while (eq_start != si->get_event_end())
{
const Gcalc_scan_iterator::point *cur_eq;
int in_state, after_state;
int Gcalc_operation_reducer::add_i_single_point(const Gcalc_heap::Info *p,
double x, double y)
{
res_point *rp= add_res_point();
if (!rp)
return 1;
rp->glue= rp->up= rp->down= NULL;
rp->intersection_point= true;
rp->x= x;
rp->pi= p;
rp->y= y;
return 0;
}
++pi;
point_thread= point_thread->get_next();
int Gcalc_operation_reducer::
handle_lines_intersection(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0, const Gcalc_heap::Info *p1,
double x, double y)
{
m_fn->invert_state(p0->shape);
if (p0->shape != p1->shape)
m_fn->invert_state(p1->shape);
int intersection_state= m_fn->count();
if ((t0->result_range | t1->result_range) == intersection_state)
return 0;
if (pi.point() != si->get_event_end() &&
eq_start->cmp_dx_dy(pi.point()) == 0)
continue;
if (t0->result_range &&
(end_i_range(t0, p1, x, y) || start_i_range(t0, p1, x, y)))
return 1;
m_fn->save_states();
for (cur_eq= eq_start; cur_eq != pi.point(); cur_eq= cur_eq->get_next())
m_fn->set_on_state(cur_eq->get_shape());
in_state= m_fn->count();
if (t1->result_range &&
(end_i_range(t1, p0, x, y) || start_i_range(t1, p0, x, y)))
m_fn->restore_states();
for (cur_eq= eq_start; cur_eq != pi.point(); cur_eq= cur_eq->get_next())
{
gcalc_shape_info si= cur_eq->get_shape();
if ((m_fn->get_shape_kind(si) == Gcalc_function::shape_polygon))
m_fn->invert_state(si);
}
after_state= m_fn->count();
if (prev_state != after_state)
{
if (add_poly_border(0, eq_thread, prev_state, eq_start))
return 1;
if (intersection_state &&
add_i_single_point(p0, x, y))
}
else if (!prev_state /* &&!after_state */ && in_state)
{
if (add_line(0, eq_thread, eq_start))
return 1;
}
return 0;
}
prev_state= after_state;
eq_start= pi.point();
eq_thread= point_thread;
}
inline int Gcalc_operation_reducer::
handle_line_polygon_intersection(active_thread *l, const Gcalc_heap::Info *pl,
int line_state, int poly_state,
double x, double y)
{
int range_after= ~poly_state & line_state;
if (l->result_range == range_after)
return 0;
return range_after ? start_i_range(l, pl, x, y) : end_i_range(l, pl, x, y);
}
if (!sav_prev_state && !m_poly_borders && !m_lines)
{
/* Check if we need to add the event point itself */
m_fn->clear_state();
for (pi.restart(si); pi.point() != si->get_event_position(); ++pi)
{
if (m_fn->get_shape_kind(pi.get_shape()) == Gcalc_function::shape_polygon)
m_fn->invert_state(pi.get_shape());
}
for (events= si->get_events(); events; events= events->get_next())
m_fn->set_on_state(events->get_shape());
static inline void switch_athreads(Gcalc_operation_reducer::active_thread *t0,
Gcalc_operation_reducer::active_thread *t1,
Gcalc_dyn_list::Item **hook)
{
*hook= t1;
t0->next= t1->next;
t1->next= t0;
}
return m_fn->count() ? add_single_point(event_point, si) : 0;
}
inline int Gcalc_operation_reducer::
handle_polygons_intersection(active_thread *t0, active_thread *t1,
Gcalc_dyn_list::Item **t_hook,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
int prev_state, double x, double y,
const active_thread *prev_range)
{
m_fn->invert_state(p0->shape);
int state_11= m_fn->count();
m_fn->invert_state(p1->shape);
int state_2= m_fn->count();
int state_01= prev_state ^ t0->result_range;
if ((prev_state == state_01) && (prev_state == state_2))
if (m_poly_borders)
{
if (state_11 == prev_state)
*m_poly_borders_hook= NULL;
while (m_poly_borders)
{
switch_athreads(t0, t1, t_hook);
return 0;
poly_border *pb1, *pb2;
pb1= m_poly_borders;
DBUG_ASSERT(m_poly_borders->next);
pb2= get_pair_border(pb1);
/* Remove pb1 from the list. The pb2 already removed in get_pair_border. */
m_poly_borders= pb1->get_next();
if (connect_threads(pb1->incoming, pb2->incoming,
pb1->t, pb2->t, pb1->p, pb2->p,
prev_range, event_point, si,
Gcalc_function::shape_polygon))
return 1;
free_item(pb1);
free_item(pb2);
}
return start_i_couple(t0, t1, p0, p1, x, y, prev_range);
m_poly_borders_hook= (Gcalc_dyn_list::Item **) &m_poly_borders;
m_poly_borders= NULL;
}
if (prev_state == state_2)
{
if (state_01 == state_11)
if (m_lines)
{
if (m_mode & polygon_selfintersections_allowed)
*m_lines_hook= NULL;
if (m_lines->get_next() &&
!m_lines->get_next()->get_next())
{
switch_athreads(t0, t1, t_hook);
return 0;
if (connect_threads(m_lines->incoming, m_lines->get_next()->incoming,
m_lines->t, m_lines->get_next()->t,
m_lines->p, m_lines->get_next()->p, NULL,
event_point, si, Gcalc_function::shape_line))
return 1;
}
if (prev_state != (m_mode & prefer_big_with_holes))
return continue_i_range(t0, p0, x, y) || continue_i_range(t1, p1, x, y);
return end_i_couple(t0, t1, p0, p1, x, y) ||
start_i_couple(t0, t1, p0, p1, x, y, prev_range);
else
{
for (line *cur_line= m_lines; cur_line; cur_line= cur_line->get_next())
{
if (cur_line->incoming)
{
if (end_line(cur_line->t, event_point, si))
return 1;
}
else
return end_i_couple(t0, t1, p0, p1, x, y);
start_line(cur_line->t, cur_line->p, event_point, si);
}
if (state_01 ^ state_11)
{
switch_athreads(t0, t1, t_hook);
return 0;
}
free_list(m_lines);
m_lines= NULL;
m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines;
}
if (bottom_threads)
free_list(bottom_threads);
return 0;
}
active_thread *thread_to_continue;
const Gcalc_heap::Info *way_to_go;
if (prev_state == state_01)
int Gcalc_operation_reducer::add_single_point(const Gcalc_heap::Info *p,
const Gcalc_scan_iterator *si)
{
res_point *rp= add_res_point(Gcalc_function::shape_point);
if (!rp)
return 1;
rp->glue= rp->up= rp->down= NULL;
if (p)
{
thread_to_continue= t1;
way_to_go= p1;
rp->intersection_point= false;
rp->pi= p;
}
else
{
thread_to_continue= t0;
way_to_go= p0;
rp->intersection_point= true;
rp->x= si->get_y();
rp->y= si->get_events()->x;
}
return continue_i_range(thread_to_continue, way_to_go, x, y);
return 0;
}
int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
{
Gcalc_point_iterator pi(si);
active_thread *cur_t= m_first_active_thread;
Gcalc_dyn_list::Item **at_hook= (Gcalc_dyn_list::Item **)&m_first_active_thread;
const active_thread *prev_range;
int prev_state;
if (si->get_event() & (scev_point | scev_end | scev_two_ends))
Gcalc_operation_reducer::poly_border
*Gcalc_operation_reducer::get_pair_border(poly_border *b1)
{
poly_border *prev_b= b1;
poly_border *result= b1->get_next();
if (b1->prev_state)
{
for (; pi.point() != si->get_event_position(); ++pi, cur_t= cur_t->get_next())
at_hook= &cur_t->next;
switch (si->get_event())
if (b1->incoming)
{
case scev_point:
/* Find the first outgoing, otherwise the last one. */
while (result->incoming && result->get_next())
{
if (cur_t->result_range &&
continue_range(cur_t, pi.get_pi()))
return 1;
break;
prev_b= result;
result= result->get_next();
}
case scev_end:
{
if (cur_t->result_range &&
end_range(cur_t, pi.get_pi()))
return 1;
*at_hook= cur_t->next;
free_item(cur_t);
break;
}
case scev_two_ends:
else
{
active_thread *cur_t1= cur_t->get_next();
if (cur_t->result_range &&
end_couple(cur_t, cur_t1, pi.get_pi()))
return 1;
*at_hook= cur_t1->next;
free_list(cur_t, &cur_t1->next);
break;
/* Get the last one */
while (result->get_next())
{
prev_b= result;
result= result->get_next();
}
default:
DBUG_ASSERT(0);
}
return 0;
}
prev_state= 0;
prev_range= 0;
m_fn->clear_state();
for (; pi.point() != si->get_event_position(); ++pi, cur_t= cur_t->get_next())
else /* !b1->prev_state */
{
if (m_fn->get_shape_kind(pi.get_shape()) == Gcalc_function::shape_polygon)
if (b1->incoming)
{
m_fn->invert_state(pi.get_shape());
prev_state^= cur_t->result_range;
/* Get the next incoming, otherwise the last one. */
while (!result->incoming && result->get_next())
{
prev_b= result;
result= result->get_next();
}
at_hook= &cur_t->next;
if (cur_t->result_range)
prev_range= prev_state ? cur_t : 0;
}
switch (si->get_event())
else
{
case scev_thread:
/* Just pick the next one */
}
}
/* Delete the result from the list. */
prev_b->next= result->next;
return result;
}
int Gcalc_operation_reducer::connect_threads(
int incoming_a, int incoming_b,
active_thread *ta, active_thread *tb,
const Gcalc_scan_iterator::point *pa, const Gcalc_scan_iterator::point *pb,
active_thread *prev_range, const Gcalc_heap::Info *ev_p,
const Gcalc_scan_iterator *si, Gcalc_function::shape_type s_t)
{
if (incoming_a && incoming_b)
{
active_thread *new_t= new_active_thread();
if (!new_t)
return 1;
m_fn->invert_state(pi.get_shape());
new_t->result_range= ~prev_state & m_fn->count();
new_t->next= *at_hook;
*at_hook= new_t;
if (new_t->result_range &&
start_range(new_t, pi.get_pi()))
res_point *rpa, *rpb;
DBUG_ASSERT(ta->rp->type == tb->rp->type);
if (!(rpa= add_res_point(ta->rp->type)) ||
!(rpb= add_res_point(ta->rp->type)))
return 1;
break;
rpa->down= ta->rp;
rpb->down= tb->rp;
rpb->glue= rpa;
rpa->glue= rpb;
rpa->up= rpb->up= NULL;
ta->rp->up= rpa;
tb->rp->up= rpb;
if (ev_p)
{
rpa->intersection_point= rpb->intersection_point= false;
rpa->pi= rpb->pi= ev_p;
}
case scev_two_threads:
else
{
active_thread *new_t0, *new_t1;
int fn_result;
const Gcalc_heap::Info *p= pi.get_pi();
bool line= m_fn->get_shape_kind(p->shape) == Gcalc_function::shape_line;
if (!(new_t0= new_active_thread()) || !(new_t1= new_active_thread()))
return 1;
rpa->intersection_point= rpb->intersection_point= true;
rpa->x= rpb->x= si->get_events()->x;
rpa->y= rpb->y= si->get_y();
}
m_fn->invert_state(pi.get_shape());
fn_result= m_fn->count();
if (line)
new_t0->result_range= new_t1->result_range= ~prev_state & fn_result;
else
new_t0->result_range= new_t1->result_range= prev_state ^ fn_result;
new_t1->next= *at_hook;
new_t0->next= new_t1;
*at_hook= new_t0;
if (new_t0->result_range &&
start_couple(new_t0, new_t1, pi.get_pi(), prev_range))
return 1;
break;
ta->rp= tb->rp= NULL;
return 0;
}
case scev_intersection:
if (!incoming_a)
{
active_thread *cur_t1= cur_t->get_next();
const Gcalc_heap::Info *p0, *p1;
p0= pi.get_pi();
++pi;
p1= pi.get_pi();
bool line0= m_fn->get_shape_kind(p0->shape) == Gcalc_function::shape_line;
bool line1= m_fn->get_shape_kind(p1->shape) == Gcalc_function::shape_line;
DBUG_ASSERT(!incoming_b);
if (!line0 && !line1) /* two polygons*/
{
if (handle_polygons_intersection(cur_t, cur_t1, at_hook, p0, p1,
prev_state, pi.get_x(), si->get_y(),
prev_range))
res_point *rp0, *rp1;
if (!(rp0= add_res_point(s_t)) || !(rp1= add_res_point(s_t)))
return 1;
}
else if (line0 && line1)
rp0->glue= rp1;
rp1->glue= rp0;
if (ev_p)
{
if (!prev_state &&
handle_lines_intersection(cur_t, cur_t1,
p0, p1, pi.get_x(), si->get_y()))
return 1;
switch_athreads(cur_t, cur_t1, at_hook);
rp0->intersection_point= rp1->intersection_point= false;
rp0->pi= rp1->pi= ev_p;
}
else
{
int poly_state;
int line_state;
const Gcalc_heap::Info *line;
active_thread *line_t;
m_fn->invert_state(p0->shape);
if (line0)
rp0->intersection_point= rp1->intersection_point= true;
rp0->x= rp1->x= si->get_events()->x;
rp0->y= rp1->y= si->get_y();
}
rp0->down= rp1->down= NULL;
ta->rp= rp0;
tb->rp= rp1;
ta->horiz_dir= pa->horiz_dir;
ta->dx_dy= pa->dx_dy;
tb->horiz_dir= pb->horiz_dir;
tb->dx_dy= pb->dx_dy;
if (prev_range)
{
line_state= m_fn->count();
poly_state= prev_state;
line= p0;
line_t= cur_t1;
rp0->outer_poly= prev_range->thread_start;
tb->thread_start= prev_range->thread_start;
}
else
{
poly_state= m_fn->count();
m_fn->invert_state(p1->shape);
line_state= m_fn->count();
line= p1;
line_t= cur_t;
rp0->outer_poly= 0;
ta->thread_start= rp0;
}
return 0;
}
if (handle_line_polygon_intersection(line_t, line,
line_state, poly_state,
pi.get_x(), si->get_y()))
/* else, if only ta is incoming */
DBUG_ASSERT(tb != ta);
tb->rp= ta->rp;
tb->thread_start= ta->thread_start;
if (Gcalc_scan_iterator::point::
compare_dx_dy(ta->horiz_dir, ta->dx_dy,
pb->horiz_dir, pb->dx_dy) != 0)
{
if (ev_p ? continue_range(tb, ev_p, pb->horiz_dir, pb->dx_dy):
continue_i_range(tb,
si->get_events()->x, si->get_y(),
pb->horiz_dir, pb->dx_dy))
return 1;
switch_athreads(cur_t, cur_t1, at_hook);
}
break;
else
{
tb->horiz_dir= pb->horiz_dir;
tb->dx_dy= pb->dx_dy;
}
case scev_single_point:
return 0;
}
int Gcalc_operation_reducer::start_line(active_thread *t,
const Gcalc_scan_iterator::point *p,
const Gcalc_heap::Info *ev_p,
const Gcalc_scan_iterator *si)
{
res_point *rp= add_res_point(Gcalc_function::shape_line);
if (!rp)
return 1;
rp->glue= rp->down= NULL;
if (ev_p)
{
m_fn->invert_state(pi.get_shape());
if ((prev_state ^ m_fn->count()) &&
add_single_point(pi.get_pi()))
rp->intersection_point= false;
rp->pi= ev_p;
}
else
{
rp->intersection_point= true;
rp->x= si->get_events()->x;
rp->y= si->get_y();
}
t->rp= rp;
t->horiz_dir= p->horiz_dir;
t->dx_dy= p->dx_dy;
return 0;
}
int Gcalc_operation_reducer::end_line(active_thread *t,
const Gcalc_heap::Info *ev_p,
const Gcalc_scan_iterator *si)
{
DBUG_ASSERT(t->rp->type == Gcalc_function::shape_line);
res_point *rp= add_res_point(Gcalc_function::shape_line);
if (!rp)
return 1;
break;
rp->glue= rp->up= NULL;
rp->down= t->rp;
if (ev_p)
{
rp->intersection_point= false;
rp->pi= ev_p;
}
default:
DBUG_ASSERT(0);
else
{
rp->intersection_point= true;
rp->x= si->get_events()->x;
rp->y= si->get_y();
}
t->rp->up= rp;
t->rp= NULL;
return 0;
}
int Gcalc_operation_reducer::count_all(Gcalc_heap *hp)
{
Gcalc_scan_iterator si;
......@@ -1014,7 +1089,7 @@ inline int Gcalc_operation_reducer::get_single_result(res_point *res,
return 1;
}
else
if (storage->single_point(res->x, res->y))
if (storage->single_point(res->pi->x, res->pi->y))
return 1;
free_result(res);
return 0;
......@@ -1113,13 +1188,13 @@ int Gcalc_operation_reducer::get_result(Gcalc_result_receiver *storage)
*m_res_hook= NULL;
while (m_result)
{
if (!m_result->up)
Gcalc_function::shape_type shape= m_result->type;
if (shape == Gcalc_function::shape_point)
{
if (get_single_result(m_result, storage))
return 1;
continue;
}
Gcalc_function::shape_type shape= m_fn->get_shape_kind(m_result->pi->shape);
if (shape == Gcalc_function::shape_polygon)
{
if (m_result->outer_poly)
......
......@@ -45,6 +45,7 @@ class Gcalc_function
String function_buffer;
const char *cur_func;
int *i_states;
int *saved_i_states;
uint32 cur_object_id;
uint n_shapes;
int count_internal();
......@@ -90,7 +91,10 @@ class Gcalc_function
void set_states(int *shape_states) { i_states= shape_states; }
int alloc_states();
void invert_state(gcalc_shape_info shape) { i_states[shape]^= 1; }
void set_on_state(gcalc_shape_info shape) { i_states[shape]= 1; }
int get_state(gcalc_shape_info shape) { return i_states[shape]; }
void save_states();
void restore_states();
int count()
{
cur_func= function_buffer.ptr();
......@@ -210,6 +214,7 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list
res_point *up;
res_point *down;
res_point *glue;
Gcalc_function::shape_type type;
union
{
const Gcalc_heap::Info *pi;
......@@ -228,8 +233,10 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list
{
public:
res_point *rp;
int result_range;
int horiz_dir;
double dx_dy;
res_point *thread_start;
res_point *enabled() { return rp; }
active_thread *get_next() { return (active_thread *)next; }
};
......@@ -240,6 +247,60 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list
poly_instance *get_next() { return (poly_instance *)next; }
};
class line : public Gcalc_dyn_list::Item
{
public:
active_thread *t;
int incoming;
const Gcalc_scan_iterator::point *p;
line *get_next() { return (line *)next; }
};
class poly_border : public Gcalc_dyn_list::Item
{
public:
active_thread *t;
int incoming;
int prev_state;
const Gcalc_scan_iterator::point *p;
poly_border *get_next() { return (poly_border *)next; }
};
line *m_lines;
Gcalc_dyn_list::Item **m_lines_hook;
poly_border *m_poly_borders;
Gcalc_dyn_list::Item **m_poly_borders_hook;
line *new_line() { return (line *) new_item(); }
poly_border *new_poly_border() { return (poly_border *) new_item(); }
int add_line(int incoming, active_thread *t,
const Gcalc_scan_iterator::point *p)
{
line *l= new_line();
if (!l)
return 1;
l->incoming= incoming;
l->t= t;
l->p= p;
*m_lines_hook= l;
m_lines_hook= &l->next;
return 0;
}
int add_poly_border(int incoming, active_thread *t, int prev_state,
const Gcalc_scan_iterator::point *p)
{
poly_border *b= new_poly_border();
if (!b)
return 1;
b->incoming= incoming;
b->t= t;
b->prev_state= prev_state;
b->p= p;
*m_poly_borders_hook= b;
m_poly_borders_hook= &b->next;
return 0;
}
protected:
Gcalc_function *m_fn;
Gcalc_dyn_list::Item **m_res_hook;
......@@ -249,12 +310,13 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list
res_point *result_heap;
active_thread *m_first_active_thread;
res_point *add_res_point()
res_point *add_res_point(Gcalc_function::shape_type type)
{
res_point *result= (res_point *)new_item();
*m_res_hook= result;
result->prev_hook= m_res_hook;
m_res_hook= &result->next;
result->type= type;
return result;
}
......@@ -263,44 +325,27 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list
poly_instance *new_poly() { return (poly_instance *) new_item(); }
private:
int continue_range(active_thread *t, const Gcalc_heap::Info *p);
int continue_i_range(active_thread *t, const Gcalc_heap::Info *p,
double x, double y);
int start_range(active_thread *t, const Gcalc_heap::Info *p);
int start_i_range(active_thread *t, const Gcalc_heap::Info *p,
double x, double y);
int end_range(active_thread *t, const Gcalc_heap::Info *p);
int end_i_range(active_thread *t, const Gcalc_heap::Info *p,
double x, double y);
int start_couple(active_thread *t0, active_thread *t1,const Gcalc_heap::Info *p,
const active_thread *prev_range);
int start_i_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
double x, double y,
const active_thread *prev_range);
int start_line(active_thread *t, const Gcalc_scan_iterator::point *p,
const Gcalc_heap::Info *ev_p, const Gcalc_scan_iterator *si);
int end_line(active_thread *t, const Gcalc_heap::Info *ev_p,
const Gcalc_scan_iterator *si);
int connect_threads(int incoming_a, int incoming_b,
active_thread *ta, active_thread *tb,
const Gcalc_scan_iterator::point *pa,
const Gcalc_scan_iterator::point *pb,
active_thread *prev_range,
const Gcalc_heap::Info *ev_p,
const Gcalc_scan_iterator *si,
Gcalc_function::shape_type s_t);
int add_single_point(const Gcalc_heap::Info *p,
const Gcalc_scan_iterator *si);
poly_border *get_pair_border(poly_border *b1);
int continue_range(active_thread *t, const Gcalc_heap::Info *p,
int horiz_dir, double dx_dy);
int continue_i_range(active_thread *t, double x, double y,
int horiz_dir, double dx_dy);
int end_couple(active_thread *t0, active_thread *t1, const Gcalc_heap::Info *p);
int end_i_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
double x, double y);
int add_single_point(const Gcalc_heap::Info *p);
int add_i_single_point(const Gcalc_heap::Info *p, double x, double y);
int handle_lines_intersection(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
double x, double y);
int handle_polygons_intersection(active_thread *t0, active_thread *t1,
Gcalc_dyn_list::Item **t_hook,
const Gcalc_heap::Info *p0,
const Gcalc_heap::Info *p1,
int prev_state, double x, double y,
const active_thread *prev_range);
int handle_line_polygon_intersection(active_thread *l,
const Gcalc_heap::Info *pl,
int line_state, int poly_state,
double x, double y);
int get_single_result(res_point *res, Gcalc_result_receiver *storage);
int get_result_thread(res_point *cur, Gcalc_result_receiver *storage,
......
......@@ -665,10 +665,12 @@ static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
{
bool above_cur_point, cur_point_edge;
const Gcalc_scan_iterator::point *evpos;
const Gcalc_heap::Info *cur_point, *dist_point;
Gcalc_scan_events ev;
const Gcalc_heap::Info *cur_point= NULL;
const Gcalc_heap::Info *dist_point;
const Gcalc_scan_iterator::point *ev;
double t, distance, cur_distance;
double ex, ey, vx, vy, e_sqrlen;
int o1, o2;
DBUG_ENTER("calc_distance");
......@@ -680,32 +682,39 @@ static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
if (scan_it->step())
goto mem_error;
evpos= scan_it->get_event_position();
ev= scan_it->get_event();
cur_point= evpos->pi;
ev= scan_it->get_events();
cur_point= NULL;
if (ev->simple_event())
{
cur_point= ev->pi;
goto calculate_distance;
}
/*
handling intersection we only need to check if it's the intersecion
of objects 1 and 2. In this case distance is 0
*/
if (ev == scev_intersection)
o1= 0;
o2= 0;
for (; ev; ev= ev->get_next())
{
if ((evpos->get_next()->pi->shape >= obj2_si) !=
(cur_point->shape >= obj2_si))
if (ev->event != scev_intersection)
cur_point= ev->pi;
if (ev->pi->shape >= obj2_si)
o2= 1;
else
o1= 1;
if (o1 && o2)
{
distance= 0;
goto exit;
}
continue;
}
if (!cur_point)
continue;
/*
if we get 'scev_point | scev_end | scev_two_ends' we don't need
to check for intersection of objects.
Though we need to calculate distances.
*/
if (ev & (scev_point | scev_end | scev_two_ends))
goto calculate_distance;
#ifdef TO_REMOVE
goto calculate_distance;
/*
having these events we need to check for possible intersection
......@@ -728,7 +737,7 @@ static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
distance= 0;
goto exit;
}
#endif /*TO_REMOVE*/
calculate_distance:
if (cur_point->shape >= obj2_si)
......@@ -1516,6 +1525,7 @@ longlong Item_func_issimple::val_int()
Gcalc_operation_transporter trn(&func, &collector);
Geometry *g;
int result= 1;
const Gcalc_scan_iterator::point *ev;
DBUG_ENTER("Item_func_issimple::val_int");
DBUG_ASSERT(fixed == 1);
......@@ -1539,12 +1549,20 @@ longlong Item_func_issimple::val_int()
if (scan_it.step())
goto mem_error;
if (scan_it.get_event() == scev_intersection)
{
ev= scan_it.get_events();
if (ev->simple_event())
continue;
if ((ev->event == scev_thread || ev->event == scev_single_point) &&
!ev->get_next())
continue;
if (ev->event == scev_two_threads && !ev->get_next()->get_next())
continue;
result= 0;
break;
}
}
collector.reset();
func.reset();
......@@ -1553,7 +1571,6 @@ longlong Item_func_issimple::val_int()
mem_error:
null_value= 1;
DBUG_RETURN(0);
return 0;
}
......@@ -1731,7 +1748,7 @@ double Item_func_distance::val_real()
bool above_cur_point, cur_point_edge;
const Gcalc_scan_iterator::point *evpos;
const Gcalc_heap::Info *cur_point, *dist_point;
Gcalc_scan_events ev;
const Gcalc_scan_iterator::point *ev;
double t, distance, cur_distance;
double x1, x2, y1, y2;
double ex, ey, vx, vy, e_sqrlen;
......@@ -1782,39 +1799,24 @@ double Item_func_distance::val_real()
if (scan_it.step())
goto mem_error;
evpos= scan_it.get_event_position();
ev= scan_it.get_event();
cur_point= evpos->pi;
ev= scan_it.get_events();
/*
handling intersection we only need to check if it's the intersecion
of objects 1 and 2. In this case distance is 0
*/
if (ev == scev_intersection)
{
if ((evpos->get_next()->pi->shape >= obj2_si) !=
(cur_point->shape >= obj2_si))
if (ev->simple_event())
{
distance= 0;
goto exit;
}
continue;
cur_point= ev->pi;
goto count_distance;
}
/*
if we get 'scev_point | scev_end | scev_two_ends' we don't need
to check for intersection of objects.
Though we need to calculate distances.
handling intersection we only need to check if it's the intersecion
of objects 1 and 2. In this case distance is 0
*/
if (ev & (scev_point | scev_end | scev_two_ends))
goto count_distance;
cur_point= NULL;
/*
having these events we need to check for possible intersection
of objects
scev_thread | scev_two_threads | scev_single_point
*/
DBUG_ASSERT(ev & (scev_thread | scev_two_threads | scev_single_point));
func.clear_state();
for (Gcalc_point_iterator pit(&scan_it); pit.point() != evpos; ++pit)
{
......@@ -1822,14 +1824,22 @@ double Item_func_distance::val_real()
if ((func.get_shape_kind(si) == Gcalc_function::shape_polygon))
func.invert_state(si);
}
func.invert_state(evpos->get_shape());
for (; ev; ev= ev->get_next())
{
if (ev->event != scev_intersection)
cur_point= ev->pi;
func.set_on_state(evpos->get_shape());
if (func.count())
{
/* Point of one object is inside the other - intersection found */
distance= 0;
goto exit;
}
}
if (!cur_point)
continue;
count_distance:
if (cur_point->shape >= obj2_si)
......
......@@ -705,6 +705,8 @@ int Gis_line_string::store_shapes(Gcalc_shape_transporter *trn) const
{
uint32 n_points;
double x, y;
double prev_x, prev_y;
int first_point= 1;
const char *data= m_data;
if (no_data(m_data, 4))
......@@ -720,8 +722,13 @@ int Gis_line_string::store_shapes(Gcalc_shape_transporter *trn) const
{
get_point(&x, &y, data);
data+= POINT_DATA_SIZE;
if (!first_point && x == prev_x && y == prev_y)
continue;
if (trn->add_point(x, y))
return 1;
first_point= 0;
prev_x= x;
prev_y= y;
}
return trn->complete_line();
......@@ -1119,6 +1126,9 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const
{
uint32 n_linear_rings;
const char *data= m_data;
double first_x, first_y;
double prev_x, prev_y;
int was_equal_first= 0;
if (trn->start_poly())
return 1;
......@@ -1140,11 +1150,33 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const
return 1;
trn->start_ring();
get_point(&first_x, &first_y, data);
data+= POINT_DATA_SIZE;
n_points--;
prev_x= first_x;
prev_y= first_y;
if (trn->add_point(first_x, first_y))
return 1;
while (--n_points)
{
double x, y;
get_point(&x, &y, data);
data+= POINT_DATA_SIZE;
if (x == prev_x && y == prev_y)
continue;
prev_x= x;
prev_y= y;
if (was_equal_first)
{
if (trn->add_point(first_x, first_y))
return 1;
was_equal_first= 0;
}
if (x == first_x && y == first_y)
{
was_equal_first= 1;
continue;
}
if (trn->add_point(x, y))
return 1;
}
......
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