1DROP TABLE IF EXISTS t1;
2select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))'));
31	ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))'))
41	1
5select 0, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))'));
60	ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))'))
70	0
8select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)'));
91	ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)'))
101	1
11select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
121	ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
131	1
14select 0, ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
150	ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
160	0
17select 1, ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))'));
181	ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))'))
191	1
20create table t1 (g point)engine=innodb;
21insert into t1 values
22(ST_GeomFromText('POINT(2 2)')), (ST_GeomFromText('POINT(2 4)')), (ST_GeomFromText('POINT(2 6)')), (ST_GeomFromText('POINT(2 8)')),
23(ST_GeomFromText('POINT(4 2)')), (ST_GeomFromText('POINT(4 4)')), (ST_GeomFromText('POINT(4 6)')), (ST_GeomFromText('POINT(4 8)')),
24(ST_GeomFromText('POINT(6 2)')), (ST_GeomFromText('POINT(6 4)')), (ST_GeomFromText('POINT(6 6)')), (ST_GeomFromText('POINT(6 8)')),
25(ST_GeomFromText('POINT(8 2)')), (ST_GeomFromText('POINT(8 4)')), (ST_GeomFromText('POINT(8 6)')), (ST_GeomFromText('POINT(8 8)'));
26select ST_astext(g) from t1 where ST_Within(g, ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'));
27ST_astext(g)
28POINT(4 4)
29POINT(6 2)
30POINT(6 4)
31POINT(6 6)
32select 'Contains';
33Contains
34Contains
35select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
36ST_astext(g)
37POINT(4 4)
38POINT(6 2)
39POINT(6 4)
40POINT(6 6)
41select 'Intersects';
42Intersects
43Intersects
44select ST_astext(g) from t1 where ST_Intersects(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
45ST_astext(g)
46POINT(4 4)
47POINT(6 2)
48POINT(6 4)
49POINT(6 6)
50select 'Contains';
51Contains
52Contains
53select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
54ST_astext(g)
55POINT(4 4)
56POINT(6 2)
57POINT(6 4)
58POINT(6 6)
59select 'Contains2';
60Contains2
61Contains2
62select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1), (5.01 3.01, 6 5, 9 5, 8 3, 5.01 3.01))'), g);
63ST_astext(g)
64POINT(4 4)
65POINT(6 2)
66POINT(6 6)
67POINT(8 4)
68DROP TABLE t1;
69select 0, ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
700	ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
710	0
72select 1, ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
731	ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
741	1
75select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)'));
761	ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)'))
771	1
78select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)'));
791	ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)'))
801	1
81select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
821	ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))
831	1
84select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
85ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')))
86POLYGON((0 0,1 2,2 0,0 0))
87select ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
88ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')))
89POINT(1 1)
90select ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
91ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))
921
93select ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)'));
94ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)'))
950
96select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'));
97ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'))
981
99select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
100ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'))
1010
102select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
103ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'))
1041
105select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'));
106ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'))
1070
108select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
109ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
1100.7071067811865475
111select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)'));
112ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)'))
1130
114select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
115ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
1160
117select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)'));
118ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)'))
1190.4472135954999579
120select ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
121ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
1220.8944271909999159
123select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')));
124ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')))
125POLYGON((26.47058823529412 23.823529411764707,21.951219512195124 27.439024390243905,23.855421686746986 29.819277108433734,29.289940828402365 26.36094674556213,26.47058823529412 23.823529411764707))
126select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')));
127ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')))
128MULTIPOINT(26.47058823529412 23.823529411764707,29.289940828402365 26.36094674556213,21.951219512195124 27.439024390243905,23.855421686746986 29.819277108433734)
129select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
130ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)')))
131POINT(29.289940828402365 26.36094674556213)
132select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)')));
133ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)')))
134POINT(20 20)
135select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)')));
136ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)')))
137LINESTRING(0 0,46.666666666666664 46.666666666666664)
138select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
139ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
140MULTILINESTRING((0 0,46.666666666666664 46.666666666666664),(8 10,45.33333333333333 47.33333333333333))
141select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
142ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
143GEOMETRYCOLLECTION(LINESTRING(-10 -10,0 0),LINESTRING(-11 -9,8 10),POLYGON((0 0,40 50,50 45,0 0)),LINESTRING(46.666666666666664 46.666666666666664,200 200,199 201,45.33333333333333 47.33333333333333))
144select ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
145ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')))
146POLYGON((0 0,0 1,0.5 0.5,0 0))
147select ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
148ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')))
149MULTIPOLYGON(((0 0,0.5 0.5,1 0,0 0)),((0.5 0.5,0 1,0 2,1 1,0.5 0.5)))
150select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
151ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
152GEOMETRYCOLLECTION(LINESTRING(-10 -10,0 0),LINESTRING(-11 -9,8 10),POLYGON((0 0,40 50,50 45,0 0)),LINESTRING(46.666666666666664 46.666666666666664,200 200,199 201,45.33333333333333 47.33333333333333))
153select ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1));
154ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1))
155POLYGON((1 0,0.9509 0.0012,0.9019 0.0048,0.8532 0.0108,0.8049 0.0192,0.7570 0.0299,0.7097 0.0430,0.6631 0.0584,0.6173 0.0761,0.5724 0.0960,0.5286 0.1180,0.4858 0.1422,0.4444 0.1685,0.4043 0.1967,0.3656 0.2269,0.3284 0.2590,0.2928 0.2928,0.2590 0.3284,0.2269 0.3656,0.1967 0.4043,0.1685 0.4444,0.1422 0.4858,0.1180 0.5286,0.0960 0.5724,0.0761 0.6173,0.0584 0.6631,0.0430 0.7097,0.0299 0.7570,0.0192 0.8049,0.0108 0.8532,0.0048 0.9019,0.0012 0.9509,0 1,0.0048 1.0980,0.0108 1.1467,0.0192 1.1950,0.0299 1.2429,0.0430 1.2902,0.0584 1.3368,0.0761 1.3826,0.0960 1.4275,0.1180 1.4713,0.1422 1.5141,0.1685 1.5555,0.1967 1.5956,0.2269 1.6343,0.2590 1.6715,0.2928 1.7071,0.3284 1.7409,0.3656 1.7730,0.4043 1.8032,0.4444 1.8314,0.4858 1.8577,0.5286 1.8819,0.5724 1.9039,0.6173 1.9238,0.6631 1.9415,0.7097 1.9569,0.7570 1.9700,0.8049 1.9807,0.8532 1.9891,0.9019 1.9951,0.9509 1.9987,1 2,1.0490 1.9987,1.0980 1.9951,1.1467 1.9891,1.1950 1.9807,1.2429 1.9700,1.2902 1.9569,1.3368 1.9415,1.3826 1.9238,1.4275 1.9039,1.4713 1.8819,1.5141 1.8577,1.5555 1.8314,1.5956 1.8032,1.6343 1.7730,1.6715 1.7409,1.7071 1.7071,1.7409 1.6715,1.7730 1.6343,1.8032 1.5956,1.8314 1.5555,1.8577 1.5141,1.8819 1.4713,1.9039 1.4275,1.9238 1.3826,1.9415 1.3368,1.9569 1.2902,1.9700 1.2429,1.9807 1.1950,1.9891 1.1467,1.9951 1.0980,1.9987 1.0490,2 1,1.9951 0.9019,1.9891 0.8532,1.9807 0.8049,1.9700 0.7570,1.9569 0.7097,1.9415 0.6631,1.9238 0.6173,1.9039 0.5724,1.8819 0.5286,1.8577 0.4858,1.8314 0.4444,1.8032 0.4043,1.7730 0.3656,1.7409 0.3284,1.7071 0.2928,1.6715 0.2590,1.6343 0.2269,1.5956 0.1967,1.5555 0.1685,1.5141 0.1422,1.4713 0.1180,1.4275 0.0960,1.3826 0.0761,1.3368 0.0584,1.2902 0.0430,1.2429 0.0299,1.1950 0.0192,1.1467 0.0108,1.0980 0.0048,1.0490 0.0012,1 0))
156create table t1(geom geometrycollection)engine=innodb;
157select ST_astext(geom), ST_area(geom),ST_area(ST_buffer(geom,2)) from t1;
158ST_astext(geom)	ST_area(geom)	ST_area(ST_buffer(geom,2))
159select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1;
160ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2)))
161set @geom=ST_geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
162set @buff=ST_buffer(@geom,1);
163select ST_NUMPOINTS(ST_EXTERIORRING(@buff)) from t1;
164ST_NUMPOINTS(ST_EXTERIORRING(@buff))
165DROP TABLE t1;
166select st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)'));
167st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)'))
1680
169select st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)'));
170st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)'))
1710
172select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)'));
173st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)'))
1741
175select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)'));
176st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)'))
1770
178select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)'));
179st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)'))
1800
181select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'));
182st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'))
1830
184select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'));
185st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'))
1861
187SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 19, 59 13, 59 13, 67 13) )')) as result;
188result
1890
190SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )')) as result;
191result
1921
193SELECT ST_Equals(ST_PointFromText('POINT (12 13)'),ST_PointFromText('POINT (12 13)')) as result;
194result
1951
196#
197# BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD
198# BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL
199#
200SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('POLYGON((525000 183300,525400
201183300,525400 18370, 525000 183700,525000 183300))'),
202ST_geomfromtext('POLYGON((525298.67 183511.53,525296.57
203183510.39,525296.42 183510.31,525289.11 183506.62,525283.17
204183503.47,525280.98 183502.26,525278.63 183500.97,525278.39
205183500.84,525276.79 183500,525260.7 183491.55,525263.95
206183484.75,525265.58 183481.95,525278.97 183488.73,525276.5
207183493.45,525275.5 183495.7,525280.35 183498.2,525282.3
208183499.1,525282.2 183499.3,525283.55 183500,525301.75
209183509.35,525304.45 183504.25,525307.85 183504.95,525304.5
210183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06
211183489.89,525272.06 183488.37,525268.94 183494.51,525271.94
212183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15
213183493.04,525269.88 183485.82,525266.99 183484.33,525263.26
214183491.55))'))) st_u;
215st_u
216MULTIPOLYGON(((525400 18370,525000.9677614468 183300,525400 183300,525400 18370)),((525000 183300,525000 183700,525000.9677614468 183300,525000 183300)),((525265.58 183481.95,525263.95 183484.75,525260.7 183491.55,525276.79 183500,525278.39 183500.84,525278.63 183500.97,525280.98 183502.26,525283.17 183503.47,525289.11 183506.62,525296.42 183510.31,525296.57 183510.39,525298.67 183511.53,525302.81 183513.8,525304.5 183510.83,525307.85 183504.95,525304.45 183504.25,525301.75 183509.35,525283.55 183500,525282.2 183499.3,525282.3 183499.1,525280.35 183498.2,525275.5 183495.7,525276.5 183493.45,525278.97 183488.73,525265.58 183481.95),(525266.99 183484.33,525263.26 183491.55,525266.15 183493.04,525269.88 183485.82,525266.99 183484.33),(525272.06 183488.37,525268.94 183494.51,525271.94 183496.03,525275.06 183489.89,525272.06 183488.37)))
217SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
218SELECT ST_ASTEXT(ST_TOUCHES(@a, ST_GEOMFROMTEXT('point(0 0)'))) t;
219ERROR HY000: Illegal parameter data type int for operation 'st_astext'
220DROP TABLE IF EXISTS p1;
221CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
222BEGIN
223DECLARE g GEOMETRY;
224SET g=GeomFromText(geom);
225SELECT geom AS `-----`;
226SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
227END|
228#
229# Testing ST_BUFFER with positive distance
230#
231-----
232POINT(0 0))
233dist	buffer	buf_area
2341	POLYGON	3.14
235-----
236LineString(0 1, 1 1))
237dist	buffer	buf_area
2381	POLYGON	5.14
239-----
240LineString(9 9,8 1,1 5,0 0)
241dist	buffer	buf_area
2421	POLYGON	44.63
243-----
244Polygon((2 2,2 8,8 8,8 2,2 2))
245dist	buffer	buf_area
2461	POLYGON	63.14
247-----
248Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
249dist	buffer	buf_area
2501	POLYGON	95.14
251-----
252Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
253dist	buffer	buf_area
2541	POLYGON	174.93
255-----
256MultiPoint(9 9,8 1,1 5)
257dist	buffer	buf_area
2581	MULTIPOLYGON	9.42
259-----
260MultiLineString((0 0,2 2))
261dist	buffer	buf_area
2621	POLYGON	8.80
263-----
264MultiLineString((0 0,2 2,0 4))
265dist	buffer	buf_area
2661	POLYGON	14.24
267-----
268MultiLineString((0 0,2 2),(0 2,2 0))
269dist	buffer	buf_area
2701	POLYGON	13.59
271-----
272MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
273dist	buffer	buf_area
2741	MULTIPOLYGON	70.06
275-----
276MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
277dist	buffer	buf_area
2781	POLYGON	73.18
279-----
280MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
281dist	buffer	buf_area
2821	POLYGON	73.18
283-----
284GeometryCollection(Point(0 0))
285dist	buffer	buf_area
2861	POLYGON	3.14
287-----
288GeometryCollection(LineString(0 0, 2 2)))
289dist	buffer	buf_area
2901	POLYGON	8.80
291-----
292GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
293dist	buffer	buf_area
2941	POLYGON	63.14
295-----
296GeometryCollection(MultiPoint(9 9,8 1,1 5))
297dist	buffer	buf_area
2981	MULTIPOLYGON	9.42
299-----
300GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
301dist	buffer	buf_area
3021	MULTIPOLYGON	10.28
303-----
304GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
305dist	buffer	buf_area
3061	MULTIPOLYGON	48.28
307-----
308GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
309dist	buffer	buf_area
3101	POLYGON	75.92
311#
312# Testing ST_BUFFER with zero distance
313#
314-----
315POINT(0 0))
316dist	buffer	buf_area
3170	POINT	0.00
318-----
319LineString(0 1, 1 1))
320dist	buffer	buf_area
3210	LINESTRING	0.00
322-----
323LineString(9 9,8 1,1 5,0 0)
324dist	buffer	buf_area
3250	LINESTRING	0.00
326-----
327Polygon((2 2,2 8,8 8,8 2,2 2))
328dist	buffer	buf_area
3290	POLYGON	36.00
330-----
331Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
332dist	buffer	buf_area
3330	POLYGON	48.00
334-----
335Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
336dist	buffer	buf_area
3370	POLYGON	116.00
338-----
339MultiPoint(9 9,8 1,1 5)
340dist	buffer	buf_area
3410	MULTIPOINT	NULL
342-----
343MultiLineString((0 0,2 2))
344dist	buffer	buf_area
3450	MULTILINESTRING	NULL
346-----
347MultiLineString((0 0,2 2,0 4))
348dist	buffer	buf_area
3490	MULTILINESTRING	NULL
350-----
351MultiLineString((0 0,2 2),(0 2,2 0))
352dist	buffer	buf_area
3530	MULTILINESTRING	NULL
354-----
355MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
356dist	buffer	buf_area
3570	MULTILINESTRING	NULL
358-----
359MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
360dist	buffer	buf_area
3610	MULTIPOLYGON	66.00
362-----
363MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
364dist	buffer	buf_area
3650	MULTIPOLYGON	62.00
366-----
367GeometryCollection(Point(0 0))
368dist	buffer	buf_area
3690	GEOMETRYCOLLECTION	0.00
370-----
371GeometryCollection(LineString(0 0, 2 2)))
372dist	buffer	buf_area
3730	GEOMETRYCOLLECTION	0.00
374-----
375GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
376dist	buffer	buf_area
3770	GEOMETRYCOLLECTION	36.00
378-----
379GeometryCollection(MultiPoint(9 9,8 1,1 5))
380dist	buffer	buf_area
3810	GEOMETRYCOLLECTION	NULL
382-----
383GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
384dist	buffer	buf_area
3850	GEOMETRYCOLLECTION	NULL
386-----
387GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
388dist	buffer	buf_area
3890	GEOMETRYCOLLECTION	18.00
390-----
391GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
392dist	buffer	buf_area
3930	GEOMETRYCOLLECTION	36.00
394#
395# Testing ST_BUFFER with negative distance
396#
397-----
398POINT(0 0))
399dist	buffer	buf_area
400-1	GEOMETRYCOLLECTION	0.00
401-----
402LineString(0 1, 1 1))
403dist	buffer	buf_area
404-1	GEOMETRYCOLLECTION	0.00
405-----
406LineString(9 9,8 1,1 5,0 0)
407dist	buffer	buf_area
408-1	GEOMETRYCOLLECTION	0.00
409-----
410Polygon((2 2,2 8,8 8,8 2,2 2))
411dist	buffer	buf_area
412-1	POLYGON	16.00
413-----
414MultiPoint(9 9,8 1,1 5)
415dist	buffer	buf_area
416-1	GEOMETRYCOLLECTION	0.00
417-----
418MultiLineString((0 0,2 2))
419dist	buffer	buf_area
420-1	GEOMETRYCOLLECTION	0.00
421-----
422MultiLineString((0 0,2 2,0 4))
423dist	buffer	buf_area
424-1	GEOMETRYCOLLECTION	0.00
425-----
426MultiLineString((0 0,2 2),(0 2,2 0))
427dist	buffer	buf_area
428-1	GEOMETRYCOLLECTION	0.00
429-----
430MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
431dist	buffer	buf_area
432-1	GEOMETRYCOLLECTION	0.00
433-----
434GeometryCollection(Point(0 0))
435dist	buffer	buf_area
436-1	GEOMETRYCOLLECTION	0.00
437-----
438GeometryCollection(LineString(0 0, 2 2)))
439dist	buffer	buf_area
440-1	GEOMETRYCOLLECTION	0.00
441-----
442GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
443dist	buffer	buf_area
444-1	POLYGON	16.00
445-----
446GeometryCollection(MultiPoint(9 9,8 1,1 5))
447dist	buffer	buf_area
448-1	GEOMETRYCOLLECTION	0.00
449-----
450GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
451dist	buffer	buf_area
452-1	GEOMETRYCOLLECTION	0.00
453-----
454GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
455dist	buffer	buf_area
456-1	POLYGON	16.00
457SELECT ST_CONTAINS(
458GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
459GeomFromText('POINT(5 10)'));
460ST_CONTAINS(
461GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
462GeomFromText('POINT(5 10)'))
4630
464SELECT AsText(ST_UNION(
465GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
466GeomFromText('POINT(5 10)')));
467AsText(ST_UNION(
468GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
469GeomFromText('POINT(5 10)')))
470GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)),POLYGON((6 6,6 11,11 11,11 6,6 6)),POINT(5 10))
471DROP PROCEDURE p1;
472#
473# Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
474#
475SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
476GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3))
477POLYGON
478#
479# Bug #13832749 	HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
480#
481SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
482GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1))
483POLYGON
484#
485# Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
486#
487DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
488Warnings:
489Warning	1292	Truncated incorrect DOUBLE value: ''
490SELECT ST_WITHIN(
491LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
492ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((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 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
493ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
494ST_WITHIN(
495LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
496ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((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 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) ')
4970
498SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
499ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
500ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
501ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))))
5022
503SELECT ST_NUMINTERIORRINGS(
504ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
505SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
506ST_NUMINTERIORRINGS(
507ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
508SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))))
5090
510SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
511SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
512ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
513SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))))
514POLYGON((9 9,5 2,4 5,9 9))
515