Current Path : /home/usr.opt/mysql57/mysql-test/suite/gis/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/gis/t/geometry_property_functions.test |
############################################################################### # # # This test is aimed to focus on the properties and attributes of the # # following Geometry classes. # # # # 1. Point # # 2. LineString # # 3. Polygon # # 4. MultiPoint # # 5. MultiLineString # # 6. MultiPolygon # # 7. GeometryCollection # # # # Creation Date: 2015-01-13 # # Author : Pavan Naik # # # ############################################################################### --source include/have_geometry.inc ############################################################################################ # Creating the spatial objects # ############################################################################################ --echo # Creating the spatial objects USE test; CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT); CREATE TABLE gis_linestring (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING); CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON); CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT); CREATE TABLE gis_multi_linestring (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING); CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON); CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION); ############################################################################################ # Inserting POINT Geometry values # ############################################################################################ --echo # Inserting POINT Geometry Values INSERT INTO gis_point VALUES (101, ST_POINTFROMTEXT('POINT(0 0)')), (102, ST_POINTFROMTEXT('POINT(1 0)')), (103, ST_POINTFROMTEXT('POINT(0 1)')), (104, ST_POINTFROMTEXT('POINT(1 1)')), (105, ST_POINTFROMTEXT('POINT(-1 1)')); INSERT INTO gis_point VALUES (106, ST_POINTFROMWKB(POINT(0,0))), (107, ST_POINTFROMWKB(POINT(10,0))), (108, ST_POINTFROMWKB(POINT(0,10))), (109, ST_POINTFROMWKB(POINT(-10,0))), (110, ST_POINTFROMWKB(POINT(0,-10))); INSERT INTO gis_point VALUES (111, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1 1)')))), (112, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 1e308)')))), (113, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 -1e308)')))), (114, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 1e308)')))), (115, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 -1e308)')))); --echo # Displaying the inserted POINT Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_point; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_point; SELECT COUNT(ST_ASTEXT(g)) FROM gis_point; SELECT COUNT(DISTINCT(g)) FROM gis_point; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_point; ############################################################################################ # Inserting LINESTRING Geometry values # ############################################################################################ --echo # Inserting LINESTRING Geometry Values INSERT INTO gis_linestring VALUES (201, ST_LINEFROMTEXT('LINESTRING(0 0,5 5)')), (202, ST_LINEFROMTEXT('LINESTRING(0 0,2 2,4 4)')), (203, ST_LINEFROMTEXT('LINESTRING(0 0,5 5,10 10)')); INSERT INTO gis_linestring VALUES (204, ST_LINESTRINGFROMTEXT('LINESTRING(10 10,5 5)')), (205, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,12 12,24 24)')), (206, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,50 50,100 100)')); INSERT INTO gis_linestring VALUES (207, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))), (208, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,10)))), (209, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)))); INSERT INTO gis_linestring VALUES (210, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))), (211, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(-50,-50), POINT(10,-10)))), (212, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(1e308,1e308), POINT(1e308,-1e308)))); INSERT INTO gis_linestring VALUES (213, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1e308 1e308,1e308 -1e308)')))), (214, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1 1,2 2,3 3,4 4,5 5,6 6,7 7,8 8,9 9)')))), (215, ST_LINESTRINGFROMWKB(ST_ASWKB(ST_LINESTRINGFROMTEXT('LINESTRING(10 10,10 -10,-10 -10,-10 10,10 10)')))); --echo # Displaying the inserted LINESTRING Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_linestring; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_linestring; SELECT COUNT(ST_ASTEXT(g)) FROM gis_linestring; SELECT COUNT(DISTINCT(g)) FROM gis_linestring; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_linestring; ############################################################################################ # Inserting POLYGON Geometry values # ############################################################################################ --echo # Inserting POLYGON Geometry Values INSERT INTO gis_polygon VALUES (301, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5, 0 0))')), (302, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')), (303, ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); INSERT INTO gis_polygon VALUES (304, ST_POLYGONFROMTEXT('POLYGON((0 0,0 50,50 50,50 0,0 0))')), (305, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))')), (306, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))')); INSERT INTO gis_polygon VALUES (307, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))), (308, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0))))), (309, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))))); INSERT INTO gis_polygon VALUES (310, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))), (311, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,15), POINT(15,15), POINT(15,10), POINT(10,10))))), (312, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,20), POINT(20,20), POINT(20,10), POINT(10,10)), LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14))))); INSERT INTO gis_polygon VALUES (313, ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,5 5,0 0))')))), (314, ST_POLYFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((10 0,10 10,0 10,-10 10,-10 0,-10 -10,0 10,10 -10,10 0))')))), (315, ST_POLYGONFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))')))); --echo # Displaying the inserted POLYGON Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_polygon; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_polygon; SELECT COUNT(ST_ASTEXT(g)) FROM gis_polygon; SELECT COUNT(DISTINCT(g)) FROM gis_polygon; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_polygon; ############################################################################################ # Inserting MULTIPOINT Geometry values # ############################################################################################ --echo # Inserting MULTIPOINT Geometry Values INSERT INTO gis_multi_point VALUES (401, ST_MPOINTFROMTEXT('MULTIPOINT(0 0)')), (402, ST_MPOINTFROMTEXT('MULTIPOINT(0 0,2 2,4 4)')), (403, ST_MPOINTFROMTEXT('MULTIPOINT(0 0,5 5,10 10)')); INSERT INTO gis_multi_point VALUES (404, ST_MULTIPOINTFROMTEXT('MULTIPOINT(0 0,100 100)')), (405, ST_MULTIPOINTFROMTEXT('MULTIPOINT(0 0,1e308 1e308)')), (406, ST_MULTIPOINTFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308)')); INSERT INTO gis_multi_point VALUES (407, ST_MPOINTFROMWKB(MULTIPOINT(POINT(0,0)))), (408, ST_MPOINTFROMWKB(MULTIPOINT(POINT(0,0), POINT(10,10)))), (409, ST_MPOINTFROMWKB(MULTIPOINT(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6)))); INSERT INTO gis_multi_point VALUES (410, ST_MULTIPOINTFROMWKB(MULTIPOINT(POINT(0,0)))), (411, ST_MULTIPOINTFROMWKB(MULTIPOINT(POINT(0,0), POINT(1e308,1e308)))), (412, ST_MULTIPOINTFROMWKB(MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308), POINT(-1e308,-1e308)))); INSERT INTO gis_multi_point VALUES (413, ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT(0 0)')))), (414, ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT(0 0,1e308 1e308,-1e308 -1e308)')))), (415, ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308,1e308 1e308)')))); --echo # Displaying the inserted MULTIPOINT Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_multi_point; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_multi_point; SELECT COUNT(ST_ASTEXT(g)) FROM gis_multi_point; SELECT COUNT(DISTINCT(g)) FROM gis_multi_point; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_multi_point; ############################################################################################ # Inserting MULTILINESTRING Geometry values # ############################################################################################ --echo # Inserting MULTILINESTRING Geometry Values INSERT INTO gis_multi_linestring VALUES (501, ST_MLINEFROMTEXT('MULTILINESTRING((0 0,2 2))')), (502, ST_MLINEFROMTEXT('MULTILINESTRING((0 0,2 2,4 4))')), (503, ST_MLINEFROMTEXT('MULTILINESTRING((0 0,2 2,4 4),(6 6,8 8,10 10))')); INSERT INTO gis_multi_linestring VALUES (504, ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,100 100,-100 -100))')), (505, ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308))')), (506, ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308),(1e308 -1e308,-1e308 1e308))')); INSERT INTO gis_multi_linestring VALUES (507, ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2))))), (508, ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24))))), (509, ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4)), LINESTRING(POINT(6,6), POINT(8,8), POINT(10,10))))); INSERT INTO gis_multi_linestring VALUES (510, ST_MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4))))), (511, ST_MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1,1), POINT(2,2))))), (512, ST_MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24)), LINESTRING(POINT(36,36), POINT(48,48), POINT(50,50))))); INSERT INTO gis_multi_linestring VALUES (513, ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 10),(0 10,10 0))')))), (514, ST_MLINEFROMWKB(ST_ASWKB(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,10 10,-10 10,0 0),(0 0,-10 -10,10 -10,0 0))')))), (515, ST_MULTILINESTRINGFROMWKB(ST_ASWKB(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,0 100),(0 0,100 0),(0 0,0 -100),(0 0,-100 0))')))); --echo # Displaying the inserted MULTILINESTRING Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_multi_linestring; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_multi_linestring; SELECT COUNT(ST_ASTEXT(g)) FROM gis_multi_linestring; SELECT COUNT(DISTINCT(g)) FROM gis_multi_linestring; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_multi_linestring; ############################################################################################ # Inserting MULTIPOLYGON Geometry values # ############################################################################################ --echo # Inserting MULTIPOLGYON Geometry Values INSERT INTO gis_multi_polygon VALUES (601, ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)))')), (602, ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)),((5 5,5 10,10 10,5 5)))')), (603, ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); INSERT INTO gis_multi_polygon VALUES (604, ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5, 0 0)))')), (605, ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,0 -2,-2 -2, 0 0)))')), (606, ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,5 5,-5 5,0 0)),((0 0,-5 -5,5 -5,0 0)))')); INSERT INTO gis_multi_polygon VALUES (607, ST_MPOLYFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0)))))), (608, ST_MPOLYFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))), (609, ST_MPOLYFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0))), POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0)))))); INSERT INTO gis_multi_polygon VALUES (610, ST_MULTIPOLYGONFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0)))))), (611, ST_MULTIPOLYGONFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(10,10), POINT(20,10), POINT(20,20), POINT(10,20), POINT(10,10)), LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14)))))), (612, ST_MULTIPOLYGONFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0)))))); INSERT INTO gis_multi_polygon VALUES (613, ST_MPOLYFROMWKB(ST_ASWKB(ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,5 5,5 -5,0 0)),((0 0,-5 5,-5 -5,0 0)))')))), (614, ST_MPOLYFROMWKB(ST_ASWKB(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,10 10,-10 10,0 0)),((0 0,-10 -10,10 -10,0 0)))')))), (615, ST_MULTIPOLYGONFROMWKB(ST_ASWKB(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,5 5,10 0,5 -5,0 0)))')))); --echo # Displaying the inserted MULTIPOLYGON Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_multi_polygon; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_multi_polygon; SELECT COUNT(ST_ASTEXT(g)) FROM gis_multi_polygon; SELECT COUNT(DISTINCT(g)) FROM gis_multi_polygon; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_multi_polygon; ############################################################################################ # Inserting GEOMETRYCOLLECTION Geometry values # ############################################################################################ --echo # Inserting GEOMETRYCOLLECTION Geometry Values INSERT INTO gis_geometrycollection VALUES (701, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')), (702, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), (703, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(5 5), POLYGON((0 0,0 10,10 10,10 0,0 0)))')); INSERT INTO gis_geometrycollection VALUES (704, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), (705, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),' 'LINESTRING(0 0,10 10),' 'POLYGON((0 0,0 10,10 10,10 0, 0 0)))')), (706, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(MULTIPOINT(0 0,5 5,10 10),' 'MULTILINESTRING((0 0,10 10),(0 10,10 0)),' 'MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),' '((0 0,-10 0,-10 -10,0 -10,0 0))))')); INSERT INTO gis_geometrycollection VALUES (707, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0)))), (708, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)), POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))), (709, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(0,0), POINT(5,5), POINT(10,10)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)), LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0))))))); INSERT INTO gis_geometrycollection VALUES (710, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(0,0), POINT(100,100))))), (711, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(10,10), LINESTRING(POINT(10,10), POINT(12,12), POINT(14,14), POINT(16,16), POINT(18,18)), POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))), (712, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(10,10), POINT(15,15), POINT(20,20)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)), LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0))))))); INSERT INTO gis_geometrycollection VALUES (713, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,10 10),' 'POLYGON((0 0,0 10,10 10,10 0, 0 0)),' 'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),' 'MULTILINESTRING((0 0,10 10),(0 10,10 0)),' 'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))')))), (714, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION(' 'POINT(0 0)),' 'GEOMETRYCOLLECTION(' 'LINESTRING(0 0,10 10)),' 'GEOMETRYCOLLECTION(' 'POLYGON((0 0,0 10,10 10,10 0, 0 0))),' 'GEOMETRYCOLLECTION(' 'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10)),' 'GEOMETRYCOLLECTION(' 'MULTILINESTRING((0 0,10 10),(0 10,10 0))),' 'GEOMETRYCOLLECTION(' 'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))))')))), (715, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION(),' 'POINT(0 0),' 'GEOMETRYCOLLECTION(' 'LINESTRING(0 0,10 10),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION())),' 'GEOMETRYCOLLECTION(),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION()),' 'POLYGON((0 0,0 10,10 10,10 0, 0 0)),' 'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),' 'MULTILINESTRING((0 0,10 10),(0 10,10 0)),' 'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))')))); --echo # Displaying the inserted GEOMETRYCOLLECTION Geometry Data SELECT fid, ST_ASTEXT(g) FROM gis_geometrycollection; --echo # Checking the integrity of the above insert statements SELECT COUNT(g) FROM gis_geometrycollection; SELECT COUNT(ST_ASTEXT(g)) FROM gis_geometrycollection; SELECT COUNT(DISTINCT(g)) FROM gis_geometrycollection; SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_geometrycollection; ############################################################################################ # POINT geometry property functions # ############################################################################################ --echo #==================================================================================== --echo # ST_X(point) --echo #==================================================================================== SELECT ST_X(ST_POINTFROMTEXT('POINT(0 0)')); SELECT ST_X(ST_POINTFROMTEXT('POINT(10 10)')); SELECT ST_X(ST_POINTFROMTEXT('POINT(1e308 1e308)')); SELECT ST_X(ST_POINTFROMWKB(POINT(1.1111,-1.1111))); SELECT ST_X(ST_POINTFROMWKB(POINT(10.0000,10.0000))); SELECT ST_X(ST_POINTFROMWKB(POINT(-1e308,-1e308))); --echo #==================================================================================== --echo # ST_Y(point) --echo #==================================================================================== SELECT ST_Y(ST_POINTFROMTEXT('POINT(0 0)')); SELECT ST_Y(ST_POINTFROMTEXT('POINT(10 10)')); SELECT ST_Y(ST_POINTFROMTEXT('POINT(1e308 1e308)')); SELECT ST_Y(ST_POINTFROMWKB(POINT(1.1111,-1.1111))); SELECT ST_Y(ST_POINTFROMWKB(POINT(10.0000,10.0000))); SELECT ST_Y(ST_POINTFROMWKB(POINT(-1e308,-1e308))); ############################################################################################ # LINESTRING geometry property functions # ############################################################################################ --echo #==================================================================================== --echo # ST_ISCLOSED(linestring) --echo #==================================================================================== SELECT ST_ISCLOSED(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)')); SELECT ST_ISCLOSED(ST_LINEFROMTEXT('LINESTRING(0 0,2 2,0 0)')); SELECT ST_ISCLOSED(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0)')); SELECT ST_ISCLOSED(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)')); SELECT ST_ISCLOSED(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)))); SELECT ST_ISCLOSED(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10), POINT(0,0)))); SELECT ST_ISCLOSED(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10)))); SELECT ST_ISCLOSED(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0)))); --echo #==================================================================================== --echo # ST_LENGTH(linestring) --echo #==================================================================================== SELECT ST_LENGTH(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)')); SELECT ST_LENGTH(ST_LINEFROMTEXT('LINESTRING(0 0,1e308 1e308)')); SELECT ST_LENGTH(ST_LINESTRINGFROMTEXT('LINESTRING(1e308 1e308,-1e308 -1e308)')); SELECT ST_LENGTH(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)')); SELECT ST_LENGTH(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-10,-10)))); SELECT ST_LENGTH(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-5,5), POINT(0,0)))); SELECT ST_LENGTH(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10)))); SELECT ST_LENGTH(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0)))); --echo #==================================================================================== --echo # ST_NUMPOINTS(linestring) --echo #==================================================================================== SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)')); SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('LINESTRING(0 0,1e308 1e308)')); SELECT ST_NUMPOINTS(ST_LINESTRINGFROMTEXT('LINESTRING(1e308 1e308,-1e308 -1e308)')); SELECT ST_NUMPOINTS(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)')); SELECT ST_NUMPOINTS(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-10,-10)))); SELECT ST_NUMPOINTS(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-5,5), POINT(0,0)))); SELECT ST_NUMPOINTS(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10)))); SELECT ST_NUMPOINTS(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0)))); --echo #==================================================================================== --echo # ST_STARTPOINT(linestring) --echo #==================================================================================== SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)'))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,1e308 1e308)'))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1e308 1e308,-1e308 -1e308)'))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)'))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-10,-10))))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-5,5), POINT(0,0))))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10))))); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0))))); --echo #==================================================================================== --echo # ST_ENDPOINT(linestring) --echo #==================================================================================== SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)'))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,1e308 1e308)'))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1e308 1e308,-1e308 -1e308)'))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)'))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-10,-10))))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-5,5), POINT(0,0))))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10))))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0))))); --echo #==================================================================================== --echo # ST_POINTN(linestring, number) --echo #==================================================================================== SELECT ST_ASTEXT(ST_POINTN(ST_LINEFROMTEXT('LINESTRING(0 0,2 2)'), 1)); SELECT ST_ASTEXT(ST_POINTN(ST_LINEFROMTEXT('LINESTRING(0 0,1e308 1e308)'), 2)); SELECT ST_ASTEXT(ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(1e308 1e308,-1e308 -1e308)'), 2)); SELECT ST_ASTEXT(ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)'), 3)); SELECT ST_ASTEXT(ST_POINTN(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-10,-10))), 3)); SELECT ST_ASTEXT(ST_POINTN(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5), POINT(-5,5), POINT(0,0))), 4)); SELECT ST_ASTEXT(ST_POINTN(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10))), 4)); SELECT ST_ASTEXT(ST_POINTN(ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(10,10), POINT(10,0), POINT(0,10), POINT(0,0))), 4)); ############################################################################################ # POLYGON geometry property functions # ############################################################################################ --echo #==================================================================================== --echo # ST_NUMINTERIORRINGS(polygon) --echo #==================================================================================== SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')); SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))')); SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((0 0,0 -115,-115 -115,-115 0,0 0))')); SELECT ST_NUMINTERIORRINGS(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))); SELECT ST_NUMINTERIORRINGS(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))))); SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)), LINESTRING(POINT(8,8), POINT(8,10), POINT(10,10), POINT(10,8), POINT(8,8))))); SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(110,110), POINT(110,5), POINT(5,5), POINT(110,110))))); --echo #==================================================================================== --echo # ST_EXTERIORRING(polygon) --echo #==================================================================================== SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))'))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))'))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON((0 0,0 -115,-115 -115,-115 0,0 0))'))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0)))))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)), LINESTRING(POINT(8,8), POINT(8,10), POINT(10,10), POINT(10,8), POINT(8,8)))))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(110,110), POINT(110,5), POINT(5,5), POINT(110,110)))))); --echo #==================================================================================== --echo # ST_INTERIORRINGN(polygon, number) --echo #==================================================================================== SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))'), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))'), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'), 2)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 -115,-115 -115,-115 0,0 0))'), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0)))), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)), LINESTRING(POINT(8,8), POINT(8,10), POINT(10,10), POINT(10,8), POINT(8,8)))), 2)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(110,110), POINT(110,5), POINT(5,5), POINT(110,110)))), 2)); ############################################################################################ # MULTULINESTRING geometry property functions # ############################################################################################ --echo #==================================================================================== --echo # ST_ISCLOSED(multilinestring) --echo #==================================================================================== SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 0,0 0))')); SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 0),(0 0,-10 0,0 0))')); SELECT ST_ISCLOSED(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,10 10,0 0),(0 0,-10 -10,0 0))')); SELECT ST_ISCLOSED(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,5 0,0 0),(0 0,0 5),(0 0,-5 0),(0 0,0 -5))')); SELECT ST_ISCLOSED(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(0,0))))); SELECT ST_ISCLOSED(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1e308,1e308))))); SELECT ST_ISCLOSED(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(10,10), POINT(0,0)), LINESTRING(POINT(1e308,1e308), POINT(-1e308,-1e308), POINT(1e308,1e308))))); SELECT ST_ISCLOSED(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1e10,1e10))))); --echo #==================================================================================== --echo # ST_LENGTH(multilinestring) --echo #==================================================================================== SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 0,0 0))')); SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 0,0 0),(0 0,-10 0,0 0))')); SELECT ST_LENGTH(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,10 10,0 0),(0 0,-10 -10,0 0))')); SELECT ST_LENGTH(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((0 0,5 0),(0 0,0 5),(0 0,-5 0),(0 0,0 -5))')); SELECT ST_LENGTH(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(0,0))))); SELECT ST_LENGTH(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1e308,1e308))))); SELECT ST_LENGTH(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(10,10)), LINESTRING(POINT(1e308,1e308), POINT(-1e308,-1e308))))); SELECT ST_LENGTH(ST_MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1e10,1e10))))); ############################################################################################ # GEOMETRYCOLLECTION geometry property functions # ############################################################################################ --echo #==================================================================================== --echo # ST_NUMGEOMETRIES(geometrycollection) --echo #==================================================================================== SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')); SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))')); SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(' 'MULTIPOINT(0 0),' 'MULTILINESTRING((0 0,5 5,10 10),' '(0 0,-5 -5,-10 -10)),' 'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),' '((5 5,5 10,10 10,10 5,5 5))))')); SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'GEOMETRYCOLLECTION(),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION()),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10))')); SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION( POINT(10,10), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))); SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION( MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,13), POINT(13,13), POINT(13,2), POINT(2,2)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))))))); SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION( POINT(0,0), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,3), POINT(3,3), POINT(3,2), POINT(2,2))))))); --echo #==================================================================================== --echo # ST_GEOMETRYN(geometrycollection, number) --echo #==================================================================================== SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))'), 1)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))'), 2)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(' 'MULTIPOINT(0 0),' 'MULTILINESTRING((0 0,5 5,10 10),' '(0 0,-5 -5,-10 -10)),' 'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),' '((5 5,5 10,10 10,10 5,5 5))))'), 3)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'GEOMETRYCOLLECTION(),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION()),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10))'), 2)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION( POINT(10,10), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))))), 2)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION( MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,13), POINT(13,13), POINT(13,2), POINT(2,2)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))), 3)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION( POINT(0,0), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,3), POINT(3,3), POINT(3,2), POINT(2,2)))))), 2)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION( POINT(0,0), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,3), POINT(3,3), POINT(3,2), POINT(2,2)))))), 5)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION( POINT(0,0), LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6)), POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)), LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))), MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308)), MULTILINESTRING(LINESTRING(POINT(0,0), POINT(5,5), POINT(10,10)), LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,-10))), MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(1,0), POINT(0,0))), POLYGON(LINESTRING(POINT(2,2), POINT(2,3), POINT(3,3), POINT(3,2), POINT(2,2)))))), 6)); ############################################################################################ # Invalid functions calls # ############################################################################################ --echo #==================================================================================== --echo # ST_X(point) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_X(); SELECT ST_X(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_X(ST_POINTFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_X(ST_POINTFROMWKB(POINT(0,0)), 2); SELECT ST_X(ST_POINTFROMWKB(NULL)); --error ER_PARSE_ERROR SELECT ST_X(ST_POINTFROMWKB(POINT(1))); --error ER_BAD_FIELD_ERROR SELECT ST_X(ST_POINTFROMWKB(POINT(1,a))); --error ER_BAD_FIELD_ERROR SELECT ST_X(ST_POINTFROMWKB(POINT(a,b))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_X(ST_POINTFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_X(ST_POINTFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_X(ST_POINTFROMTEXT('POINT()')); --error ER_GIS_INVALID_DATA SELECT ST_X(ST_POINTFROMTEXT('POINT(1)')); --error ER_GIS_INVALID_DATA SELECT ST_X(ST_POINTFROMTEXT('POINT(a 1)')); --error ER_GIS_INVALID_DATA SELECT ST_X(ST_POINTFROMTEXT('POINT(1 1,2)')); --error ER_PARSE_ERROR SELECT ST_X(ST_POINTFROMTEXT('POINT('!' 0)')); --echo #==================================================================================== --echo # ST_Y(point) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_Y(); SELECT ST_Y(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_Y(ST_POINTFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_Y(ST_POINTFROMWKB(POINT(0,0)), 2); SELECT ST_Y(ST_POINTFROMWKB(NULL)); --error ER_PARSE_ERROR SELECT ST_Y(ST_POINTFROMWKB(POINT(1))); --error ER_BAD_FIELD_ERROR SELECT ST_Y(ST_POINTFROMWKB(POINT(1,a))); --error ER_BAD_FIELD_ERROR SELECT ST_Y(ST_POINTFROMWKB(POINT(a,b))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_Y(ST_POINTFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_Y(ST_POINTFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_Y(ST_POINTFROMTEXT('POINT()')); --error ER_GIS_INVALID_DATA SELECT ST_Y(ST_POINTFROMTEXT('POINT(1)')); --error ER_GIS_INVALID_DATA SELECT ST_Y(ST_POINTFROMTEXT('POINT(a 1)')); --error ER_GIS_INVALID_DATA SELECT ST_Y(ST_POINTFROMTEXT('POINT(1 1,2)')); --error ER_PARSE_ERROR SELECT ST_Y(ST_POINTFROMTEXT('POINT('!' 0)')); --echo #==================================================================================== --echo # ST_ISCLOSED(linestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(); SELECT ST_ISCLOSED(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2))), 2); --error ER_BAD_FIELD_ERROR SELECT ST_ISCLOSED(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_ISCLOSED(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b)))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(ST_LINEFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_LINEFROMTEXT('LINESTRING()')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_LINEFROMTEXT('LINESTRING(0)')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)')); --error ER_PARSE_ERROR SELECT ST_ISCLOSED(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)')); --echo #==================================================================================== --echo # ST_LENGTH(linestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(); SELECT ST_LENGTH(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2))), 2); --error ER_BAD_FIELD_ERROR SELECT ST_LENGTH(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_LENGTH(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b)))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(ST_LINEFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_LINEFROMTEXT('LINESTRING()')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_LINEFROMTEXT('LINESTRING(0)')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)')); --error ER_PARSE_ERROR SELECT ST_LENGTH(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)')); --echo #==================================================================================== --echo # ST_NUMPOINTS(linestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMPOINTS(); SELECT ST_NUMPOINTS(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMPOINTS(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMPOINTS(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2))), 2); --error ER_BAD_FIELD_ERROR SELECT ST_NUMPOINTS(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_NUMPOINTS(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b)))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMPOINTS(ST_LINEFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('LINESTRING()')); --error ER_GIS_INVALID_DATA SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('LINESTRING(0)')); --error ER_GIS_INVALID_DATA SELECT ST_NUMPOINTS(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1')); --error ER_GIS_INVALID_DATA SELECT ST_NUMPOINTS(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)')); --error ER_PARSE_ERROR SELECT ST_NUMPOINTS(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)')); --echo #==================================================================================== --echo # ST_STARTPOINT(linestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_STARTPOINT(); SELECT ST_STARTPOINT(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_STARTPOINT(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_STARTPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2))), 2); --error ER_BAD_FIELD_ERROR SELECT ST_STARTPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_STARTPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b)))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_STARTPOINT(ST_LINEFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_STARTPOINT(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_STARTPOINT(ST_LINEFROMTEXT('LINESTRING()')); --error ER_GIS_INVALID_DATA SELECT ST_STARTPOINT(ST_LINEFROMTEXT('LINESTRING(0)')); --error ER_GIS_INVALID_DATA SELECT ST_STARTPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1')); --error ER_GIS_INVALID_DATA SELECT ST_STARTPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)')); --error ER_PARSE_ERROR SELECT ST_STARTPOINT(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)')); --echo #==================================================================================== --echo # ST_ENDPOINT(linestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ENDPOINT(); SELECT ST_ENDPOINT(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ENDPOINT(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ENDPOINT(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2))), 2); --error ER_BAD_FIELD_ERROR SELECT ST_ENDPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_ENDPOINT(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b)))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ENDPOINT(ST_LINEFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_ENDPOINT(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_ENDPOINT(ST_LINEFROMTEXT('LINESTRING()')); --error ER_GIS_INVALID_DATA SELECT ST_ENDPOINT(ST_LINEFROMTEXT('LINESTRING(0)')); --error ER_GIS_INVALID_DATA SELECT ST_ENDPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1')); --error ER_GIS_INVALID_DATA SELECT ST_ENDPOINT(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)')); --error ER_PARSE_ERROR SELECT ST_ENDPOINT(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)')); --echo #==================================================================================== --echo # ST_POINTN(linestring, number) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(NULL); SELECT ST_POINTN(NULL, 1); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(ST_LINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2)))); --error ER_BAD_FIELD_ERROR SELECT ST_POINTN(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,2))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_POINTN(ST_LINESTRINGFROMWKB(LINESTRING(POINT(a,1), POINT(2,b))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_POINTN(ST_LINESTRINGFROMWKB(LINESTRING(POINT(1,1), POINT(2,2))), a); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(ST_LINEFROMTEXT()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_POINTN(ST_LINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_POINTN(ST_LINEFROMTEXT('NULL'), 1); --error ER_GIS_INVALID_DATA SELECT ST_POINTN(ST_LINEFROMTEXT('LINESTRING()'), 2); --error ER_GIS_INVALID_DATA SELECT ST_POINTN(ST_LINEFROMTEXT('LINESTRING(0)'), 3); --error ER_GIS_INVALID_DATA SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(1 2,1'), 4); --error ER_GIS_INVALID_DATA SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(1 1,2 2,a 3)'), 5); --error ER_PARSE_ERROR SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING('!' 0,1 1,2 2)'), 6); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), 0); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), -1); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), -1024); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), 10000); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), 1234567890); SELECT ST_POINTN(ST_LINESTRINGFROMTEXT('LINESTRING(0 0,1 1,2 2)'), 'a'); --echo #==================================================================================== --echo # ST_NUMINTERIORRINGS(polygon) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMINTERIORRINGS(); SELECT ST_NUMINTERIORRINGS(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMINTERIORRINGS(ST_POLYFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMINTERIORRINGS(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(0,0)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(0,1), POINT(1,1), POINT(0,0))))); --error ER_BAD_FIELD_ERROR SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(b,1), POINT(1,1), POINT(0,0))))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON(())')); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON((0))')); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((0 0,0 4,4 4,0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((0 0,2 0,2))')); --error ER_GIS_INVALID_DATA SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((0 0,0 5,5 a,0 0))')); --error ER_PARSE_ERROR SELECT ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON(('!' 0,2 0,2 4,0 0))')); --echo #==================================================================================== --echo # ST_EXTERIORRING(polygon) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_EXTERIORRING(); SELECT ST_EXTERIORRING(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_EXTERIORRING(ST_POLYFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_EXTERIORRING(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(0,0)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_EXTERIORRING(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(0,1), POINT(1,1), POINT(0,0))))); --error ER_BAD_FIELD_ERROR SELECT ST_EXTERIORRING(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(b,1), POINT(1,1), POINT(0,0))))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_EXTERIORRING(ST_POLYFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON(())')); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON((0))')); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON((0 0,0 4,4 4,0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON((0 0,2 0,2))')); --error ER_GIS_INVALID_DATA SELECT ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON((0 0,0 5,5 a,0 0))')); --error ER_PARSE_ERROR SELECT ST_EXTERIORRING(ST_POLYGONFROMTEXT('POLYGON(('!' 0,2 0,2 4,0 0))')); --echo #==================================================================================== --echo # ST_INTERIORRINGN(polygon, number) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_INTERIORRINGN(); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_INTERIORRINGN(NULL); SELECT ST_INTERIORRINGN(NULL, 1); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_INTERIORRINGN(ST_POLYFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_INTERIORRINGN(ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(0,0))))); --error ER_BAD_FIELD_ERROR SELECT ST_INTERIORRINGN(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(0,1), POINT(1,1), POINT(0,0)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_INTERIORRINGN(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(a,0), POINT(b,1), POINT(1,1), POINT(0,0)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_INTERIORRINGN(ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,1), POINT(1,1), POINT(0,0)))), a); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_INTERIORRINGN(ST_POLYFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYFROMTEXT('NULL'), 1); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON(())'), 2); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON((0))'), 3); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 4,4 4,0 0)'), 4); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,2 0,2))'), 5); --error ER_GIS_INVALID_DATA SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 5,5 a,0 0))'), 6); --error ER_PARSE_ERROR SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON(('!' 0,2 0,2 4,0 0))'), 7); SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 2,2 2,0 0))'), 0); SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 2,2 2,0 0))'), -1); SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 2,2 2,0 0))'), -1024); SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 2,2 2,0 0))'), 10000); SELECT ST_INTERIORRINGN(ST_POLYGONFROMTEXT('POLYGON((0 0,0 2,2 2,0 0))'), 123456789); --echo #==================================================================================== --echo # ST_ISCLOSED(multilinestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(); SELECT ST_ISCLOSED(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(MLINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_ISCLOSED(MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(a,4))))); --error ER_BAD_FIELD_ERROR SELECT ST_ISCLOSED(MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2)), LINESTRING(POINT(3,3), POINT(a,4))))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_ISCLOSED(ST_POLYFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING(())')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING((1 1,2 2),()')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING((1 1,2 2,3 3)')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1 1,2 3,3 3,4))')); --error ER_GIS_INVALID_DATA SELECT ST_ISCLOSED(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1 1,2 2,3 3,4 a))')); --error ER_PARSE_ERROR SELECT ST_ISCLOSED(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING(('!' 1,2 2,3 3,4 4')); --echo #==================================================================================== --echo # ST_LENGTH(multilinestring) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(); SELECT ST_LENGTH(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(MLINEFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(MLINEFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_LENGTH(MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(a,4))))); --error ER_BAD_FIELD_ERROR SELECT ST_LENGTH(MULTILINESTRINGFROMWKB(MULTILINESTRING(LINESTRING(POINT(1,1), POINT(2,2)), LINESTRING(POINT(3,3), POINT(a,4))))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_LENGTH(ST_POLYFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MLINEFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING(())')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING((1 1,2 2),()')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING((1 1,2 2,3 3)')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1 1,2 3,3 3,4))')); --error ER_GIS_INVALID_DATA SELECT ST_LENGTH(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1 1,2 2,3 3,4 a))')); --error ER_PARSE_ERROR SELECT ST_LENGTH(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING(('!' 1,2 2,3 3,4 4')); --echo #==================================================================================== --echo # ST_NUMGEOMETRIES(geometrycollection) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMGEOMETRIES(); SELECT ST_NUMGEOMETRIES(NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(1,1), POINT(2,2)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(a,1), POINT(2,2))))); --error ER_BAD_FIELD_ERROR SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,b), LINESTRING(POINT(a,1), POINT(2,2))))); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('NULL')); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(1)')); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0))')); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2)')); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2))')); --error ER_GIS_INVALID_DATA SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 a))')); --error ER_PARSE_ERROR SELECT ST_NUMGEOMETRIES(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 '!'))')); --echo #==================================================================================== --echo # ST_GEOMETRYN(geometrycollection, number) --echo #==================================================================================== --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_GEOMETRYN(); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_GEOMETRYN(NULL); SELECT ST_GEOMETRYN(NULL, 1); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMWKB()); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(1,1), POINT(2,2))))); --error ER_BAD_FIELD_ERROR SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(a,1), POINT(2,2)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,b), LINESTRING(POINT(a,1), POINT(2,2)))), 1); --error ER_BAD_FIELD_ERROR SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0), LINESTRING(POINT(1,1), POINT(2,2)))), A); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT()); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('NULL'), 1); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(1)'), 2); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0))'), 3); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2)'), 4); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2))'), 5); --error ER_GIS_INVALID_DATA SELECT ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 a))'), 6); --error ER_PARSE_ERROR SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 '!'))'), 7); SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2))'), 0); SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2))'), -1); SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2))'), -1024); SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2))'), 10000); SELECT ST_GEOMETRYN(ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(1 1,2 2))'), 123456789); ############################################################################################ # Checking the procedure to work with Point and MultiPoint properties # ############################################################################################ --echo # Check procedure to work with Point and MultiPoint properties DELIMITER |; CREATE PROCEDURE point_attri() BEGIN SELECT ST_X(ST_POINTFROMTEXT('POINT(0 0)')); SELECT ST_X(ST_POINTFROMTEXT('POINT(1.1111 -1.1111)')); SELECT ST_X(ST_POINTFROMTEXT('POINT(1e308 1e308)')); SELECT ST_Y(ST_POINTFROMTEXT('POINT(0 0)')); SELECT ST_Y(ST_POINTFROMTEXT('POINT(1.1111 -1.1111)')); SELECT ST_Y(ST_POINTFROMTEXT('POINT(1e308 1e308)')); END | DELIMITER ;| --echo # Call the proc CALL point_attri; --echo # Dropping the created procedure DROP PROCEDURE point_attri; ############################################################################################ # Checking the procedure to work with Linestring and MultiLinestring properties # ############################################################################################ --echo # Check procedure to work with Linestring and MultiLineString properties DELIMITER |; CREATE PROCEDURE line_attri() BEGIN SELECT ST_ISCLOSED(ST_LINEFROMTEXT('LINESTRING(0 0,1 1,2 2,0 0)')); SELECT ST_NUMPOINTS(ST_LINEFROMTEXT('LINESTRING(0 0,1 1,2 2,0 0)')); SELECT ST_LENGTH(ST_LINEFROMTEXT('LINESTRING(0 0,10 0,0 0,-10 0,0 0,0 10,0 0,0 -10,0 0)')); SELECT ST_ASTEXT(ST_STARTPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,1 1,2 2,0 0)'))); SELECT ST_ASTEXT(ST_ENDPOINT(ST_LINEFROMTEXT('LINESTRING(0 0,1 1,2 2,3 3,0 0)'))); SELECT ST_ASTEXT(ST_POINTN(ST_LINEFROMTEXT('LINESTRING(0 0,1 1,2 2,3 3,4 4,5 5,6 6,7 7,8 8,9 9)'), 8)); SELECT ST_ISCLOSED(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,1 1,2 2,0 0),(0 0,-1 -1,-2 -2,0 0))')); SELECT ST_LENGTH(ST_MLINEFROMTEXT('MULTILINESTRING((0 0,10 0),(0 0,0 10),(0 0,-10 0),(0 0,0 -10))')); END | DELIMITER ;| --echo # Call the proc CALL line_attri; --echo # Dropping the created procedure DROP PROCEDURE line_attri; ############################################################################################ # Checking the procedure to work with Polygon and MultiPolygon properties # ############################################################################################ DELIMITER |; CREATE PROCEDURE poly_attri() BEGIN SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_NUMINTERIORRINGS(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))')); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'))); SELECT ST_ASTEXT(ST_EXTERIORRING(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'))); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'), 1)); SELECT ST_ASTEXT(ST_INTERIORRINGN(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'), 2)); END | DELIMITER ;| --echo # Call the proc CALL poly_attri; --echo # Dropping the created procedure DROP PROCEDURE poly_attri; ############################################################################################ # Checking the procedure to work with GeometryCollection properties # ############################################################################################ DELIMITER |; CREATE PROCEDURE geom_coll_attri() BEGIN SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))')); SELECT ST_NUMGEOMETRIES(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION()),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))')); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))'), 3)); SELECT ST_ASTEXT(ST_GEOMETRYN(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(' 'POINT(0 0),' 'LINESTRING(0 0,2 2,4 4,6 6,8 8,10 10),' 'GEOMETRYCOLLECTION(' 'GEOMETRYCOLLECTION()),' 'POLYGON((0 0,0 5,5 5,5 0,0 0)))'), 3)); END | DELIMITER ;| --echo # Call the proc CALL geom_coll_attri; --echo # Dropping the created procedure DROP PROCEDURE geom_coll_attri; ############################################################################################ # Checking the trigger to work with Point and MultiPoint Geometry properties # ############################################################################################ --echo # Checking Point and MultiPoint attributes within a trigger --echo # Create a tigger to insert into gis_multi_point and update gis_point DELIMITER |; CREATE TRIGGER geom_trigger BEFORE UPDATE ON gis_point FOR EACH ROW BEGIN INSERT INTO gis_multi_point SELECT * FROM gis_point; SET New.g = ST_POINTFROMTEXT('POINT(-1e308 1e308)'); END| DELIMITER ;| --echo # Calling the trigger UPDATE gis_point SET fid = 999 WHERE fid = 111; --echo # Checking the table entries SELECT fid, ST_ASTEXT(g) FROM gis_point; SELECT fid, ST_ASTEXT(g) FROM gis_multi_point; --echo # Cleaning up the trigger DROP TRIGGER geom_trigger; ############################################################################################ # Checking the trigger to work with Linestring and MultiLinestring Geometry properties # ############################################################################################ --echo # Checking Linestring and MultiLinestring attributes within a trigger --echo # Create a tigger to insert into gis_multi_linestring and update gis_linestring DELIMITER |; CREATE TRIGGER geom_trigger BEFORE UPDATE ON gis_linestring FOR EACH ROW BEGIN INSERT INTO gis_multi_linestring SELECT * FROM gis_linestring; SET New.g = ST_LINEFROMTEXT('LINESTRING(0 0,10 0,0 0,0 10,0 0,-10 0,0 0,0 10,0 0)'); END| DELIMITER ;| --echo # Calling the trigger UPDATE gis_linestring SET fid = 999 WHERE fid = 211; --echo # Checking the table entries SELECT fid, ST_ASTEXT(g) FROM gis_linestring; SELECT fid, ST_ASTEXT(g) FROM gis_multi_linestring; --echo # Cleaning up the trigger DROP TRIGGER geom_trigger; ############################################################################################ # Checking the trigger to work with Polygon and MultiPolygon Geometry properties # ############################################################################################ --echo # Checking Polygon and MultiPolygon attributes within a trigger --echo # Create a tigger to insert into gis_multi_polygon and update gis_polygon DELIMITER |; CREATE TRIGGER geom_trigger BEFORE UPDATE ON gis_polygon FOR EACH ROW BEGIN INSERT INTO gis_multi_polygon SELECT * FROM gis_polygon; SET New.g = ST_POLYFROMTEXT('POLYGON((0 0,10 0,10 10,0 10,0 0),(3 3,3 7,7 7,7 3,3 3))'); END| DELIMITER ;| --echo # Calling the trigger UPDATE gis_polygon SET fid = 999 WHERE fid = 311; --echo # Checking the table entries SELECT fid, ST_ASTEXT(g) FROM gis_polygon; SELECT fid, ST_ASTEXT(g) FROM gis_multi_polygon; --echo # Cleaning up the trigger DROP TRIGGER geom_trigger; --echo # Final cleanup DROP TABLE gis_point; DROP TABLE gis_linestring; DROP TABLE gis_polygon; DROP TABLE gis_multi_point; DROP TABLE gis_multi_linestring; DROP TABLE gis_multi_polygon; DROP TABLE gis_geometrycollection;