ndb_gis.result 46 KB
Newer Older
1
SET storage_engine=ndbcluster;
2
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
3 4 5 6 7 8 9 10
CREATE TABLE gis_point  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
CREATE TABLE gis_line  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
CREATE TABLE gis_polygon   (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
CREATE TABLE gis_multi_polygon  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
CREATE TABLE gis_geometrycollection  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
11 12 13
SHOW CREATE TABLE gis_point;
Table	Create Table
gis_point	CREATE TABLE `gis_point` (
14 15
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  `g` point DEFAULT NULL,
16
  PRIMARY KEY (`fid`)
17
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
18 19
SHOW FIELDS FROM gis_point;
Field	Type	Null	Key	Default	Extra
20
fid	int(11)	NO	PRI	NULL	auto_increment
21 22 23
g	point	YES		NULL	
SHOW FIELDS FROM gis_line;
Field	Type	Null	Key	Default	Extra
24
fid	int(11)	NO	PRI	NULL	auto_increment
25 26 27
g	linestring	YES		NULL	
SHOW FIELDS FROM gis_polygon;
Field	Type	Null	Key	Default	Extra
28
fid	int(11)	NO	PRI	NULL	auto_increment
29 30 31
g	polygon	YES		NULL	
SHOW FIELDS FROM gis_multi_point;
Field	Type	Null	Key	Default	Extra
32
fid	int(11)	NO	PRI	NULL	auto_increment
33 34 35
g	multipoint	YES		NULL	
SHOW FIELDS FROM gis_multi_line;
Field	Type	Null	Key	Default	Extra
36
fid	int(11)	NO	PRI	NULL	auto_increment
37 38 39
g	multilinestring	YES		NULL	
SHOW FIELDS FROM gis_multi_polygon;
Field	Type	Null	Key	Default	Extra
40
fid	int(11)	NO	PRI	NULL	auto_increment
41 42 43
g	multipolygon	YES		NULL	
SHOW FIELDS FROM gis_geometrycollection;
Field	Type	Null	Key	Default	Extra
44
fid	int(11)	NO	PRI	NULL	auto_increment
45 46 47
g	geometrycollection	YES		NULL	
SHOW FIELDS FROM gis_geometry;
Field	Type	Null	Key	Default	Extra
48
fid	int(11)	NO	PRI	NULL	auto_increment
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
g	geometry	YES		NULL	
INSERT INTO gis_point VALUES 
(101, PointFromText('POINT(10 10)')),
(102, PointFromText('POINT(20 10)')),
(103, PointFromText('POINT(20 20)')),
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
INSERT INTO gis_line VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
INSERT INTO gis_polygon VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
INSERT INTO gis_multi_point VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
INSERT INTO gis_multi_line VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
INSERT INTO gis_multi_polygon VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
INSERT INTO gis_geometrycollection VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
INSERT into gis_geometry SELECT * FROM gis_multi_point;
INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
fid	AsText(g)
101	POINT(10 10)
102	POINT(20 10)
103	POINT(20 20)
104	POINT(10 20)
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
fid	AsText(g)
105	LINESTRING(0 0,0 10,10 0)
106	LINESTRING(10 10,20 10,20 20,10 20,10 10)
107	LINESTRING(10 10,40 10)
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
fid	AsText(g)
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
109	POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110	POLYGON((0 0,30 0,30 30,0 0))
SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid;
fid	AsText(g)
111	MULTIPOINT(0 0,10 10,10 20,20 20)
112	MULTIPOINT(1 1,11 11,11 21,21 21)
113	MULTIPOINT(3 6,4 10)
SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid;
fid	AsText(g)
114	MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115	MULTILINESTRING((10 48,10 21,10 0))
116	MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid;
fid	AsText(g)
117	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119	MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid;
fid	AsText(g)
120	GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121	GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
fid	AsText(g)
101	POINT(10 10)
102	POINT(20 10)
103	POINT(20 20)
104	POINT(10 20)
105	LINESTRING(0 0,0 10,10 0)
106	LINESTRING(10 10,20 10,20 20,10 20,10 10)
107	LINESTRING(10 10,40 10)
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
109	POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110	POLYGON((0 0,30 0,30 30,0 0))
111	MULTIPOINT(0 0,10 10,10 20,20 20)
112	MULTIPOINT(1 1,11 11,11 21,21 21)
113	MULTIPOINT(3 6,4 10)
114	MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115	MULTILINESTRING((10 48,10 21,10 0))
116	MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
117	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119	MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
120	GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121	GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
fid	Dimension(g)
101	0
102	0
103	0
104	0
105	1
106	1
107	1
108	2
109	2
110	2
111	0
112	0
113	0
114	1
115	1
116	1
117	2
118	2
119	2
120	1
121	1
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
fid	GeometryType(g)
101	POINT
102	POINT
103	POINT
104	POINT
105	LINESTRING
106	LINESTRING
107	LINESTRING
108	POLYGON
109	POLYGON
110	POLYGON
111	MULTIPOINT
112	MULTIPOINT
113	MULTIPOINT
114	MULTILINESTRING
115	MULTILINESTRING
116	MULTILINESTRING
117	MULTIPOLYGON
118	MULTIPOLYGON
119	MULTIPOLYGON
120	GEOMETRYCOLLECTION
121	GEOMETRYCOLLECTION
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
fid	IsEmpty(g)
101	0
102	0
103	0
104	0
105	0
106	0
107	0
108	0
109	0
110	0
111	0
112	0
113	0
114	0
115	0
116	0
117	0
118	0
119	0
120	0
121	0
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
fid	AsText(Envelope(g))
101	POLYGON((10 10,10 10,10 10,10 10,10 10))
102	POLYGON((20 10,20 10,20 10,20 10,20 10))
103	POLYGON((20 20,20 20,20 20,20 20,20 20))
104	POLYGON((10 20,10 20,10 20,10 20,10 20))
105	POLYGON((0 0,10 0,10 10,0 10,0 0))
106	POLYGON((10 10,20 10,20 20,10 20,10 10))
107	POLYGON((10 10,40 10,40 10,10 10,10 10))
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
109	POLYGON((0 0,50 0,50 50,0 50,0 0))
110	POLYGON((0 0,30 0,30 30,0 30,0 0))
111	POLYGON((0 0,20 0,20 20,0 20,0 0))
112	POLYGON((1 1,21 1,21 21,1 21,1 1))
113	POLYGON((3 6,4 6,4 10,3 10,3 6))
114	POLYGON((10 0,16 0,16 48,10 48,10 0))
115	POLYGON((10 0,10 0,10 48,10 48,10 0))
116	POLYGON((1 2,21 2,21 8,1 8,1 2))
117	POLYGON((28 0,84 0,84 42,28 42,28 0))
118	POLYGON((28 0,84 0,84 42,28 42,28 0))
119	POLYGON((0 0,3 0,3 3,0 3,0 0))
120	POLYGON((0 0,10 0,10 10,0 10,0 0))
121	POLYGON((3 6,44 6,44 9,3 9,3 6))
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
236 237
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_geometry	ALL	NULL	NULL	NULL	NULL	21	100.00	
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
Warnings:
Note	1003	select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
SELECT fid, X(g) FROM gis_point ORDER by fid;
fid	X(g)
101	10
102	20
103	20
104	10
SELECT fid, Y(g) FROM gis_point ORDER by fid;
fid	Y(g)
101	10
102	10
103	20
104	20
explain extended select X(g),Y(g) FROM gis_point;
253 254
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_point	ALL	NULL	NULL	NULL	NULL	4	100.00	
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
Warnings:
Note	1003	select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
fid	AsText(StartPoint(g))
105	POINT(0 0)
106	POINT(10 10)
107	POINT(10 10)
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
fid	AsText(EndPoint(g))
105	POINT(10 0)
106	POINT(10 10)
107	POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid	GLength(g)
105	24.142135623731
106	40
107	30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
fid	NumPoints(g)
105	3
106	5
107	2
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
fid	AsText(PointN(g, 2))
105	POINT(0 10)
106	POINT(20 10)
107	POINT(40 10)
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
fid	IsClosed(g)
105	0
106	1
107	0
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
288 289
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_line	ALL	NULL	NULL	NULL	NULL	3	100.00	
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
Warnings:
Note	1003	select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid	AsText(Centroid(g))
108	POINT(15 15)
109	POINT(25.416666666667 25.416666666667)
110	POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid	Area(g)
108	100
109	2400
110	450
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
fid	AsText(ExteriorRing(g))
108	LINESTRING(10 10,20 10,20 20,10 20,10 10)
109	LINESTRING(0 0,50 0,50 50,0 50,0 0)
110	LINESTRING(0 0,30 0,30 30,0 0)
SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
fid	NumInteriorRings(g)
108	0
109	1
110	0
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
fid	AsText(InteriorRingN(g, 1))
108	NULL
109	LINESTRING(10 10,20 10,20 20,10 20,10 10)
110	NULL
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
318 319
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_polygon	ALL	NULL	NULL	NULL	NULL	3	100.00	
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
Warnings:
Note	1003	select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
fid	IsClosed(g)
114	0
115	0
116	0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid	AsText(Centroid(g))
117	POINT(55.588527753042 17.426536064114)
118	POINT(55.588527753042 17.426536064114)
119	POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid	Area(g)
117	1684.5
118	1684.5
119	4.5
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
fid	NumGeometries(g)
111	4
112	4
113	2
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
fid	NumGeometries(g)
114	2
115	1
116	2
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
fid	NumGeometries(g)
117	2
118	2
119	1
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
fid	NumGeometries(g)
120	2
121	2
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
357 358
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_multi_point	ALL	NULL	NULL	NULL	NULL	3	100.00	
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
Warnings:
Note	1003	select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
fid	AsText(GeometryN(g, 2))
111	POINT(10 10)
112	POINT(11 11)
113	POINT(4 10)
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
fid	AsText(GeometryN(g, 2))
114	LINESTRING(16 0,16 23,16 48)
115	NULL
116	LINESTRING(2 5,5 8,21 7)
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
fid	AsText(GeometryN(g, 2))
117	POLYGON((59 18,67 18,67 13,59 13,59 18))
118	POLYGON((59 18,67 18,67 13,59 13,59 18))
119	NULL
SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
fid	AsText(GeometryN(g, 2))
120	LINESTRING(0 0,10 10)
121	LINESTRING(3 6,7 9)
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
fid	AsText(GeometryN(g, 1))
120	POINT(0 0)
121	POINT(44 6)
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
385 386
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_multi_point	ALL	NULL	NULL	NULL	NULL	3	100.00	
387 388 389 390 391 392 393 394 395
Warnings:
Note	1003	select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
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,
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	1	1	0	1	0	0	1	0
396
120	121	0	0	1	0	0	0	1	0
397 398 399 400 401 402 403
121	120	0	0	1	0	0	0	1	0
121	121	1	1	0	1	0	0	1	0
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,
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;
404
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
405 406
1	SIMPLE	g1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using temporary; Using filesort
1	SIMPLE	g2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using join buffer
407 408 409 410
Warnings:
Note	1003	select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
411
a INTEGER PRIMARY KEY AUTO_INCREMENT,
412 413 414 415 416 417 418 419 420 421 422
gp  point,
ln  linestring,
pg  polygon,
mp  multipoint,
mln multilinestring,
mpg multipolygon,
gc  geometrycollection,
gm  geometry
);
SHOW FIELDS FROM t1;
Field	Type	Null	Key	Default	Extra
423
a	int(11)	NO	PRI	NULL	auto_increment
424 425 426 427 428 429 430 431 432 433 434
gp	point	YES		NULL	
ln	linestring	YES		NULL	
pg	polygon	YES		NULL	
mp	multipoint	YES		NULL	
mln	multilinestring	YES		NULL	
mpg	multipolygon	YES		NULL	
gc	geometrycollection	YES		NULL	
gm	geometry	YES		NULL	
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field	Type	Null	Key	Default	Extra
435
a	int(11)	NO	PRI	NULL	auto_increment
436 437 438 439 440 441 442 443 444 445
gp	point	YES		NULL	
ln	linestring	YES		NULL	
pg	polygon	YES		NULL	
mp	multipoint	YES		NULL	
mln	multilinestring	YES		NULL	
mpg	multipolygon	YES		NULL	
gc	geometrycollection	YES		NULL	
gm	geometry	YES		NULL	
fid	int(11)	YES		NULL	
DROP TABLE t1;
446 447 448
create table t1 (pk integer primary key auto_increment, a geometry not null);
insert into t1 (a) values (GeomFromText('Point(1 2)'));
insert into t1 (a) values ('Garbage');
449
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
450
insert IGNORE into t1 (a) values ('Garbage');
451 452
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
453
create table t1 (pk integer primary key auto_increment, fl geometry not null);
454
insert into t1 (fl) values (1);
455
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
456
insert into t1 (fl) values (1.11);
457
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
458
insert into t1 (fl) values ("qwerty");
459
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
460
insert into t1 (fl) values (pointfromtext('point(1,1)'));
461
ERROR 23000: Column 'fl' cannot be null
462
drop table t1;
463
End of 4.1 tests
464
CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY);
465
Warnings:
466
Error	1475	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
INSERT INTO t1 VALUES("small",  GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES("big",    GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 VALUES("up",     GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES("up2",    GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
INSERT INTO t1 VALUES("up3",    GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES("down",   GeomFromText('POLYGON (( 0 -1, 0  1, 2  1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES("down2",  GeomFromText('POLYGON (( 0 -2, 0  0, 2  0, 2 -2, 0 -2))'));
INSERT INTO t1 VALUES("down3",  GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES("right",  GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
INSERT INTO t1 VALUES("left",   GeomFromText('POLYGON (( -1 0, -1 2,  1 2,  1 0, -1 0))'));
INSERT INTO t1 VALUES("left2",  GeomFromText('POLYGON (( -2 0, -2 2,  0 2,  0 0, -2 0))'));
INSERT INTO t1 VALUES("left3",  GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains  FROM t1 a1 JOIN t1 a2 ON MBRContains(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrcontains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint  FROM t1 a1 JOIN t1 a2 ON MBRDisjoint(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrdisjoint
down3,left3,right3,up3
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal     FROM t1 a1 JOIN t1 a2 ON MBREqual(      a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrequal
center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrintersect
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps  FROM t1 a1 JOIN t1 a2 ON MBROverlaps(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
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
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
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals       FROM t1 a1 JOIN t1 a2 ON Equals(        a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
equals
center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect    FROM t1 a1 JOIN t1 a2 ON Intersects(    a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
intersect
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps     FROM t1 a1 JOIN t1 a2 ON Overlaps(      a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
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
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))');
SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
SET @point1 = GeomFromText('POLYGON ((0 0))');
SET @point2 = GeomFromText('POLYGON ((-2 0))');
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name;
overlaps
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name;
overlaps
SELECT Overlaps(@horiz1, @vert1) FROM DUAL;
Overlaps(@horiz1, @vert1)
0
SELECT Overlaps(@horiz1, @horiz2) FROM DUAL;
Overlaps(@horiz1, @horiz2)
1
SELECT Overlaps(@horiz1, @horiz3) FROM DUAL;
Overlaps(@horiz1, @horiz3)
0
SELECT Overlaps(@horiz1, @point1) FROM DUAL;
Overlaps(@horiz1, @point1)
0
SELECT Overlaps(@horiz1, @point2) FROM DUAL;
Overlaps(@horiz1, @point2)
0
DROP TABLE t1;
End of 5.0 tests
551
set engine_condition_pushdown = on;
552
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
553 554 555 556 557 558 559 560
CREATE TABLE gis_point  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
CREATE TABLE gis_line  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
CREATE TABLE gis_polygon   (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
CREATE TABLE gis_multi_polygon  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
CREATE TABLE gis_geometrycollection  (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
561 562 563
SHOW CREATE TABLE gis_point;
Table	Create Table
gis_point	CREATE TABLE `gis_point` (
564 565
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  `g` point DEFAULT NULL,
566
  PRIMARY KEY (`fid`)
567
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
568 569
SHOW FIELDS FROM gis_point;
Field	Type	Null	Key	Default	Extra
570
fid	int(11)	NO	PRI	NULL	auto_increment
571 572 573
g	point	YES		NULL	
SHOW FIELDS FROM gis_line;
Field	Type	Null	Key	Default	Extra
574
fid	int(11)	NO	PRI	NULL	auto_increment
575 576 577
g	linestring	YES		NULL	
SHOW FIELDS FROM gis_polygon;
Field	Type	Null	Key	Default	Extra
578
fid	int(11)	NO	PRI	NULL	auto_increment
579 580 581
g	polygon	YES		NULL	
SHOW FIELDS FROM gis_multi_point;
Field	Type	Null	Key	Default	Extra
582
fid	int(11)	NO	PRI	NULL	auto_increment
583 584 585
g	multipoint	YES		NULL	
SHOW FIELDS FROM gis_multi_line;
Field	Type	Null	Key	Default	Extra
586
fid	int(11)	NO	PRI	NULL	auto_increment
587 588 589
g	multilinestring	YES		NULL	
SHOW FIELDS FROM gis_multi_polygon;
Field	Type	Null	Key	Default	Extra
590
fid	int(11)	NO	PRI	NULL	auto_increment
591 592 593
g	multipolygon	YES		NULL	
SHOW FIELDS FROM gis_geometrycollection;
Field	Type	Null	Key	Default	Extra
594
fid	int(11)	NO	PRI	NULL	auto_increment
595 596 597
g	geometrycollection	YES		NULL	
SHOW FIELDS FROM gis_geometry;
Field	Type	Null	Key	Default	Extra
598
fid	int(11)	NO	PRI	NULL	auto_increment
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
g	geometry	YES		NULL	
INSERT INTO gis_point VALUES 
(101, PointFromText('POINT(10 10)')),
(102, PointFromText('POINT(20 10)')),
(103, PointFromText('POINT(20 20)')),
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
INSERT INTO gis_line VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
INSERT INTO gis_polygon VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
INSERT INTO gis_multi_point VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
INSERT INTO gis_multi_line VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
INSERT INTO gis_multi_polygon VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
INSERT INTO gis_geometrycollection VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
INSERT into gis_geometry SELECT * FROM gis_multi_point;
INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
635
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
636
fid	AsText(g)
637
101	POINT(10 10)
638 639 640
102	POINT(20 10)
103	POINT(20 20)
104	POINT(10 20)
641
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
642
fid	AsText(g)
643
105	LINESTRING(0 0,0 10,10 0)
644 645
106	LINESTRING(10 10,20 10,20 20,10 20,10 10)
107	LINESTRING(10 10,40 10)
646
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
647
fid	AsText(g)
648
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
649 650
109	POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110	POLYGON((0 0,30 0,30 30,0 0))
651
SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid;
652
fid	AsText(g)
653
111	MULTIPOINT(0 0,10 10,10 20,20 20)
654 655
112	MULTIPOINT(1 1,11 11,11 21,21 21)
113	MULTIPOINT(3 6,4 10)
656
SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid;
657
fid	AsText(g)
658
114	MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
659 660
115	MULTILINESTRING((10 48,10 21,10 0))
116	MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
661
SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid;
662
fid	AsText(g)
663
117	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
664 665
118	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119	MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
666
SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid;
667 668
fid	AsText(g)
120	GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
669 670
121	GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
671
fid	AsText(g)
672
101	POINT(10 10)
673
102	POINT(20 10)
674 675
103	POINT(20 20)
104	POINT(10 20)
676
105	LINESTRING(0 0,0 10,10 0)
677 678 679
106	LINESTRING(10 10,20 10,20 20,10 20,10 10)
107	LINESTRING(10 10,40 10)
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
680
109	POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
681
110	POLYGON((0 0,30 0,30 30,0 0))
682
111	MULTIPOINT(0 0,10 10,10 20,20 20)
683
112	MULTIPOINT(1 1,11 11,11 21,21 21)
684
113	MULTIPOINT(3 6,4 10)
685 686 687 688 689 690 691 692 693
114	MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115	MULTILINESTRING((10 48,10 21,10 0))
116	MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
117	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118	MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119	MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
120	GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121	GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
694
fid	Dimension(g)
695
101	0
696
102	0
697 698
103	0
104	0
699
105	1
700 701 702
106	1
107	1
108	2
703
109	2
704
110	2
705
111	0
706
112	0
707
113	0
708 709 710 711 712 713 714 715 716
114	1
115	1
116	1
117	2
118	2
119	2
120	1
121	1
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
717
fid	GeometryType(g)
718
101	POINT
719
102	POINT
720 721
103	POINT
104	POINT
722
105	LINESTRING
723 724 725
106	LINESTRING
107	LINESTRING
108	POLYGON
726
109	POLYGON
727
110	POLYGON
728
111	MULTIPOINT
729
112	MULTIPOINT
730
113	MULTIPOINT
731 732 733 734 735 736 737 738 739
114	MULTILINESTRING
115	MULTILINESTRING
116	MULTILINESTRING
117	MULTIPOLYGON
118	MULTIPOLYGON
119	MULTIPOLYGON
120	GEOMETRYCOLLECTION
121	GEOMETRYCOLLECTION
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
740
fid	IsEmpty(g)
741
101	0
742
102	0
743 744
103	0
104	0
745
105	0
746 747 748
106	0
107	0
108	0
749
109	0
750
110	0
751
111	0
752
112	0
753
113	0
754 755 756 757 758 759 760 761 762
114	0
115	0
116	0
117	0
118	0
119	0
120	0
121	0
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
763
fid	AsText(Envelope(g))
764
101	POLYGON((10 10,10 10,10 10,10 10,10 10))
765
102	POLYGON((20 10,20 10,20 10,20 10,20 10))
766 767
103	POLYGON((20 20,20 20,20 20,20 20,20 20))
104	POLYGON((10 20,10 20,10 20,10 20,10 20))
768
105	POLYGON((0 0,10 0,10 10,0 10,0 0))
769 770 771
106	POLYGON((10 10,20 10,20 20,10 20,10 10))
107	POLYGON((10 10,40 10,40 10,10 10,10 10))
108	POLYGON((10 10,20 10,20 20,10 20,10 10))
772
109	POLYGON((0 0,50 0,50 50,0 50,0 0))
773
110	POLYGON((0 0,30 0,30 30,0 30,0 0))
774
111	POLYGON((0 0,20 0,20 20,0 20,0 0))
775
112	POLYGON((1 1,21 1,21 21,1 21,1 1))
776
113	POLYGON((3 6,4 6,4 10,3 10,3 6))
777 778 779 780 781 782 783 784
114	POLYGON((10 0,16 0,16 48,10 48,10 0))
115	POLYGON((10 0,10 0,10 48,10 48,10 0))
116	POLYGON((1 2,21 2,21 8,1 8,1 2))
117	POLYGON((28 0,84 0,84 42,28 42,28 0))
118	POLYGON((28 0,84 0,84 42,28 42,28 0))
119	POLYGON((0 0,3 0,3 3,0 3,0 0))
120	POLYGON((0 0,10 0,10 10,0 10,0 0))
121	POLYGON((3 6,44 6,44 9,3 9,3 6))
785
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
786 787
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_geometry	ALL	NULL	NULL	NULL	NULL	21	100.00	
788 789
Warnings:
Note	1003	select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
790
SELECT fid, X(g) FROM gis_point ORDER by fid;
791
fid	X(g)
792
101	10
793 794 795
102	20
103	20
104	10
796
SELECT fid, Y(g) FROM gis_point ORDER by fid;
797
fid	Y(g)
798
101	10
799 800 801 802
102	10
103	20
104	20
explain extended select X(g),Y(g) FROM gis_point;
803 804
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_point	ALL	NULL	NULL	NULL	NULL	4	100.00	
805 806
Warnings:
Note	1003	select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
807
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
808
fid	AsText(StartPoint(g))
809
105	POINT(0 0)
810 811
106	POINT(10 10)
107	POINT(10 10)
812
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
813
fid	AsText(EndPoint(g))
814
105	POINT(10 0)
815 816
106	POINT(10 10)
107	POINT(40 10)
817
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
818
fid	GLength(g)
819
105	24.142135623731
820 821
106	40
107	30
822
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
823
fid	NumPoints(g)
824
105	3
825 826
106	5
107	2
827
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
828
fid	AsText(PointN(g, 2))
829
105	POINT(0 10)
830 831
106	POINT(20 10)
107	POINT(40 10)
832
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
833
fid	IsClosed(g)
834
105	0
835 836 837
106	1
107	0
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
838 839
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_line	ALL	NULL	NULL	NULL	NULL	3	100.00	
840 841
Warnings:
Note	1003	select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
842
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
843
fid	AsText(Centroid(g))
844
108	POINT(15 15)
845 846
109	POINT(25.416666666667 25.416666666667)
110	POINT(20 10)
847
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
848
fid	Area(g)
849
108	100
850 851
109	2400
110	450
852
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
853
fid	AsText(ExteriorRing(g))
854
108	LINESTRING(10 10,20 10,20 20,10 20,10 10)
855 856
109	LINESTRING(0 0,50 0,50 50,0 50,0 0)
110	LINESTRING(0 0,30 0,30 30,0 0)
857
SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
858
fid	NumInteriorRings(g)
859
108	0
860 861
109	1
110	0
862
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
863
fid	AsText(InteriorRingN(g, 1))
864
108	NULL
865 866 867
109	LINESTRING(10 10,20 10,20 20,10 20,10 10)
110	NULL
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
868 869
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_polygon	ALL	NULL	NULL	NULL	NULL	3	100.00	
870 871
Warnings:
Note	1003	select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
872
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
873
fid	IsClosed(g)
874
114	0
875 876
115	0
116	0
877
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
878
fid	AsText(Centroid(g))
879
117	POINT(55.588527753042 17.426536064114)
880 881
118	POINT(55.588527753042 17.426536064114)
119	POINT(2 2)
882
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
883
fid	Area(g)
884
117	1684.5
885 886
118	1684.5
119	4.5
887
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
888
fid	NumGeometries(g)
889
111	4
890 891
112	4
113	2
892
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
893
fid	NumGeometries(g)
894
114	2
895 896
115	1
116	2
897
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
898
fid	NumGeometries(g)
899
117	2
900 901
118	2
119	1
902
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
903 904
fid	NumGeometries(g)
120	2
905
121	2
906
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
907 908
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_multi_point	ALL	NULL	NULL	NULL	NULL	3	100.00	
909 910
Warnings:
Note	1003	select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
911
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
912
fid	AsText(GeometryN(g, 2))
913
111	POINT(10 10)
914 915
112	POINT(11 11)
113	POINT(4 10)
916
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
917
fid	AsText(GeometryN(g, 2))
918
114	LINESTRING(16 0,16 23,16 48)
919 920
115	NULL
116	LINESTRING(2 5,5 8,21 7)
921
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
922
fid	AsText(GeometryN(g, 2))
923
117	POLYGON((59 18,67 18,67 13,59 13,59 18))
924 925
118	POLYGON((59 18,67 18,67 13,59 13,59 18))
119	NULL
926
SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
927 928
fid	AsText(GeometryN(g, 2))
120	LINESTRING(0 0,10 10)
929 930
121	LINESTRING(3 6,7 9)
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
931 932
fid	AsText(GeometryN(g, 1))
120	POINT(0 0)
933
121	POINT(44 6)
934
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
935 936
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	gis_multi_point	ALL	NULL	NULL	NULL	NULL	3	100.00	
937 938 939 940 941 942 943 944 945
Warnings:
Note	1003	select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
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,
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	1	1	0	1	0	0	1	0
946
120	121	0	0	1	0	0	0	1	0
947 948 949 950 951 952 953
121	120	0	0	1	0	0	0	1	0
121	121	1	1	0	1	0	0	1	0
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,
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;
954
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
955 956
1	SIMPLE	g1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using temporary; Using filesort
1	SIMPLE	g2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using join buffer
957 958 959 960
Warnings:
Note	1003	select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
961
a INTEGER PRIMARY KEY AUTO_INCREMENT,
962 963 964 965 966 967 968 969 970 971 972
gp  point,
ln  linestring,
pg  polygon,
mp  multipoint,
mln multilinestring,
mpg multipolygon,
gc  geometrycollection,
gm  geometry
);
SHOW FIELDS FROM t1;
Field	Type	Null	Key	Default	Extra
973
a	int(11)	NO	PRI	NULL	auto_increment
974 975 976 977 978 979 980 981 982 983 984
gp	point	YES		NULL	
ln	linestring	YES		NULL	
pg	polygon	YES		NULL	
mp	multipoint	YES		NULL	
mln	multilinestring	YES		NULL	
mpg	multipolygon	YES		NULL	
gc	geometrycollection	YES		NULL	
gm	geometry	YES		NULL	
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field	Type	Null	Key	Default	Extra
985
a	int(11)	NO	PRI	NULL	auto_increment
986 987 988 989 990 991 992 993 994 995
gp	point	YES		NULL	
ln	linestring	YES		NULL	
pg	polygon	YES		NULL	
mp	multipoint	YES		NULL	
mln	multilinestring	YES		NULL	
mpg	multipolygon	YES		NULL	
gc	geometrycollection	YES		NULL	
gm	geometry	YES		NULL	
fid	int(11)	YES		NULL	
DROP TABLE t1;
996 997 998
create table t1 (pk integer primary key auto_increment, a geometry not null);
insert into t1 (a) values (GeomFromText('Point(1 2)'));
insert into t1 (a) values ('Garbage');
999
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1000
insert IGNORE into t1 (a) values ('Garbage');
1001 1002
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
1003
create table t1 (pk integer primary key auto_increment, fl geometry not null);
1004
insert into t1 (fl) values (1);
1005
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1006
insert into t1 (fl) values (1.11);
1007
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1008
insert into t1 (fl) values ("qwerty");
1009
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1010
insert into t1 (fl) values (pointfromtext('point(1,1)'));
1011
ERROR 23000: Column 'fl' cannot be null
1012
drop table t1;
1013
End of 4.1 tests
1014
CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY);
1015
Warnings:
1016
Error	1475	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
INSERT INTO t1 VALUES("small",  GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES("big",    GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 VALUES("up",     GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES("up2",    GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
INSERT INTO t1 VALUES("up3",    GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES("down",   GeomFromText('POLYGON (( 0 -1, 0  1, 2  1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES("down2",  GeomFromText('POLYGON (( 0 -2, 0  0, 2  0, 2 -2, 0 -2))'));
INSERT INTO t1 VALUES("down3",  GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES("right",  GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
INSERT INTO t1 VALUES("left",   GeomFromText('POLYGON (( -1 0, -1 2,  1 2,  1 0, -1 0))'));
INSERT INTO t1 VALUES("left2",  GeomFromText('POLYGON (( -2 0, -2 2,  0 2,  0 0, -2 0))'));
INSERT INTO t1 VALUES("left3",  GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains  FROM t1 a1 JOIN t1 a2 ON MBRContains(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrcontains
center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint  FROM t1 a1 JOIN t1 a2 ON MBRDisjoint(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrdisjoint
down3,left3,right3,up3
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal     FROM t1 a1 JOIN t1 a2 ON MBREqual(      a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrequal
center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
mbrintersect
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps  FROM t1 a1 JOIN t1 a2 ON MBROverlaps(   a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
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
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
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals       FROM t1 a1 JOIN t1 a2 ON Equals(        a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
equals
center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect    FROM t1 a1 JOIN t1 a2 ON Intersects(    a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
intersect
big,center,down,down2,left,left2,right,right2,small,up,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps     FROM t1 a1 JOIN t1 a2 ON Overlaps(      a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
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
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))');
SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
SET @point1 = GeomFromText('POLYGON ((0 0))');
SET @point2 = GeomFromText('POLYGON ((-2 0))');
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name;
overlaps
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name;
overlaps
SELECT Overlaps(@horiz1, @vert1) FROM DUAL;
Overlaps(@horiz1, @vert1)
0
SELECT Overlaps(@horiz1, @horiz2) FROM DUAL;
Overlaps(@horiz1, @horiz2)
1
SELECT Overlaps(@horiz1, @horiz3) FROM DUAL;
Overlaps(@horiz1, @horiz3)
0
SELECT Overlaps(@horiz1, @point1) FROM DUAL;
Overlaps(@horiz1, @point1)
0
SELECT Overlaps(@horiz1, @point2) FROM DUAL;
Overlaps(@horiz1, @point2)
0
DROP TABLE t1;
End of 5.0 tests