config root man

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
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/gis/t/geometry_class_attri_prop.test

###############################################################################
#                                                                             #
# This test is aimed to focus on the properties and attributes of the         #
# geometry class                                                              #
#                                                                             #
# The geometry class has a number of properties that are common to all        #
# geometry values created from any of the Geometry subclasses.                #
#                                                                             #
# Creation Date: 2013-8-1                                                     #
# Author : Tanjot Singh Uppal                                                 #
#                                                                             #
# Description:Test Cases of the geometry base class Properties                #
#                                                                             #
###############################################################################

--source include/have_geometry.inc

############################################################################################
# Creating the spatial objects                                                             #
############################################################################################

--echo # Creating the spatial Geometry object
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);
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);

############################################################################################
# Inserting the values specific to the spatial objects                                     #
############################################################################################

--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(1000 1000)')))),
    (113, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1000 -1000)')))),
    (114, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1000 1000)')))),
    (115, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1000 -1000)'))));

--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(1000,1000), POINT(1000,-1000))));

INSERT INTO gis_linestring VALUES
    (213, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1000 1000,1000 -1000)')))),
    (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 # 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 # 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,1000 1000)')),
    (406, ST_MULTIPOINTFROMTEXT('MULTIPOINT(1000 1000,1000 -1000,-1000 1000,-1000 -1000)'));

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(1000,1000)))),
    (412, ST_MULTIPOINTFROMWKB(MULTIPOINT(POINT(1000,1000), POINT(-1000,1000), POINT(1000,-1000), POINT(-1000,-1000))));

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,1000 1000,-1000 -1000)')))),
    (415, ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT(1000 1000,1000 -1000,-1000 1000,-1000 -1000,1000 1000)'))));

--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((1000 1000,-1000 -1000))')),
    (506, ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((1000 1000,-1000 -1000),(1000 -1000,-1000 1000))'));

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 # 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 # 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))))'))));

############################################################################################
# Inserting the spatial values of all kinds to the parent class                            #
############################################################################################

--echo # Inserting the spatial values of all kinds to the parent class
INSERT INTO gis_geometry SELECT * FROM gis_point;

INSERT INTO gis_geometry SELECT * FROM gis_linestring;

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_linestring;

INSERT INTO gis_geometry SELECT * FROM gis_multi_polygon;

INSERT INTO gis_geometry SELECT * FROM gis_geometrycollection;

--echo # Checking the integrity of the above insert statements 
SELECT COUNT(g) FROM gis_geometry;

SELECT COUNT(ST_ASTEXT(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ASTEXT(g))) FROM gis_geometry;

############################################################################################
# Displaying the spatial data FROM all the spatial objects created                         #
############################################################################################

--echo # Displaying the inserted spatial Data
SELECT fid, ST_ASTEXT(g) FROM gis_point;

SELECT fid, ST_ASTEXT(g) FROM gis_linestring;

SELECT fid, ST_ASTEXT(g) FROM gis_polygon;

SELECT fid, ST_ASTEXT(g) FROM gis_multi_point;

SELECT fid, ST_ASTEXT(g) FROM gis_multi_linestring;

SELECT fid, ST_ASTEXT(g) FROM gis_multi_polygon;

SELECT fid, ST_ASTEXT(g) FROM gis_geometrycollection;

SELECT fid, ST_ASTEXT(g) FROM gis_geometry;

############################################################################################
# Checking the geometry type of the spatial objects inserted into GEOMETRY class           #
############################################################################################

--echo # Checking the geometry type of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_GEOMETRYTYPE(g) FROM gis_geometry;

SELECT COUNT(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_GEOMETRYTYPE(g))) FROM gis_geometry;

############################################################################################
# Checking the SRID of the spatial objects inserted into GEOMETRY class                    #
############################################################################################

--echo # Checking the ST_SRID of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_SRID(g) FROM gis_geometry;

SELECT COUNT(ST_SRID(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_SRID(g))) FROM gis_geometry;

############################################################################################
# Checking the Dimension of the spatial objects inserted into GEOMETRY class               #
############################################################################################

--echo # Checking the Dimension of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_DIMENSION(g) FROM gis_geometry;

SELECT COUNT(ST_DIMENSION(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_DIMENSION(g))) FROM gis_geometry;

############################################################################################
# Checking if the geometries are simple or not                                             #
############################################################################################

--echo # Checking if the geometries are simple or not
SELECT fid, ST_ISSIMPLE(g) FROM gis_geometry;

SELECT COUNT(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ISSIMPLE(g))) FROM gis_geometry;

############################################################################################
# Checking the Envelope of the spatial objects inserted into GEOMETRY class                #
############################################################################################

--echo # Checking the Envelope of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_ASTEXT(ST_ENVELOPE(g)) FROM gis_geometry;

SELECT COUNT(ST_ENVELOPE(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ENVELOPE(g))) FROM gis_geometry;

############################################################################################
# Checking the Area of the spatial objects inserted into GEOMETRY class                    #
############################################################################################

--echo # Checking the Area of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_AREA(g) FROM gis_geometry;

SELECT COUNT(ST_AREA(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_AREA(g))) FROM gis_geometry;

############################################################################################
# Checking the Centroid of the spatial objects inserted into GEOMETRY class                #
############################################################################################

--echo # Checking the Centroid of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_ASTEXT(ST_CENTROID(g)) FROM gis_geometry;

SELECT COUNT(ST_CENTROID(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_CENTROID(g))) FROM gis_geometry;

############################################################################################
# Checking the ConvexHull of the spatial objects inserted into GEOMETRY class              #
############################################################################################

--echo # Checking the ConvexHull of the spatial objects inserted into GEOMETRY class
SELECT fid, ST_ASTEXT(ST_CONVEXHULL(g)) FROM gis_geometry;

SELECT COUNT(ST_CONVEXHULL(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_CONVEXHULL(g))) FROM gis_geometry;

############################################################################################
# Checking if the geometries are empty or not                                              #
############################################################################################

--echo # Checking if the geometries are empty or not
SELECT fid, ST_ISEMPTY(g) FROM gis_geometry;

SELECT COUNT(ST_ISEMPTY(g)) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ISEMPTY(g))) FROM gis_geometry;

############################################################################################
# Checking the procedure to work with the Geometry type properties                         #
############################################################################################

--echo # Check the procedure to work with the Geometry type properties

DELIMITER |;
CREATE PROCEDURE geom_attri()
BEGIN
    SELECT fid, ST_GEOMETRYTYPE(g) FROM gis_geometry; 
    SELECT fid, ST_SRID(g) FROM gis_geometry;
    SELECT fid, ST_DIMENSION(g) FROM gis_geometry;
    SELECT fid, ST_ISSIMPLE(g) FROM gis_geometry;
    SELECT fid, ST_ASTEXT(ST_ENVELOPE(g)) FROM gis_geometry;
    SELECT fid, ST_AREA(g) FROM gis_geometry;
    SELECT fid, ST_ASTEXT(ST_CENTROID(g)) FROM gis_geometry;
    SELECT fid, ST_ASTEXT(ST_CONVEXHULL(g)) FROM gis_geometry;
    SELECT fid, ST_ISEMPTY(g) FROM gis_geometry;
END |
DELIMITER ;|

--echo # Call the proc
CALL geom_attri;

--echo # Dropping the created procedure
DROP PROCEDURE geom_attri;

############################################################################################
# Checking the trigger to work with the Geometry type properties                           #
############################################################################################

--echo # Creating an empty table as gis_geometry_1
CREATE TABLE gis_geometry_1 AS SELECT * FROM gis_geometry;
TRUNCATE TABLE gis_geometry_1;

--echo # Create a tigger to populate the data FROM gis_geometry to gis_geometry_1
DELIMITER |;
CREATE TRIGGER geom_trigger AFTER UPDATE ON gis_geometry
FOR EACH ROW
BEGIN
    INSERT INTO gis_geometry_1 SELECT * FROM gis_geometry;
END|
DELIMITER ;|

--echo # Calling the trigger
UPDATE gis_geometry SET fid = 999 where fid = 111;

--echo # Checking the GEOMETRY class properties on the spatial data in the gis_geometry_1 table
SELECT fid, ST_GEOMETRYTYPE(g) FROM gis_geometry_1;
SELECT fid, ST_SRID(g) FROM gis_geometry_1;
SELECT fid, ST_DIMENSION(g) FROM gis_geometry_1;
SELECT fid, ST_ISSIMPLE(g) FROM gis_geometry_1;
SELECT fid, ST_ASTEXT(ST_ENVELOPE(g)) FROM gis_geometry_1;
SELECT fid, ST_AREA(g) FROM gis_geometry_1;
SELECT fid, ST_ASTEXT(ST_CENTROID(g)) FROM gis_geometry_1;
SELECT fid, ST_ASTEXT(ST_CONVEXHULL(g)) FROM gis_geometry_1;
SELECT fid, ST_ISEMPTY(g) FROM gis_geometry_1;

--echo # Cleaning up the trigger
DROP TRIGGER geom_trigger;

############################################################################################
# Checking the Geometry class properties within the cursor                                 #
############################################################################################

--echo # Checking the Geometry class properties within the cursor

DELIMITER |;
CREATE PROCEDURE geom_cursor()
BEGIN
    DECLARE v GEOMETRY;
    DECLARE c CURSOR FOR SELECT g FROM gis_geometry;
    OPEN c;
    FETCH c INTO v;
    CLOSE c;
    SELECT ST_GEOMETRYTYPE(v);
    SELECT ST_SRID(v);
    SELECT ST_DIMENSION(v);
    SELECT ST_ASTEXT(ST_ENVELOPE(v));
    SELECT ST_ISSIMPLE(v);
    SELECT ST_AREA(v);
    SELECT ST_ASTEXT(ST_CENTROID(v));
    SELECT ST_ASTEXT(ST_CONVEXHULL(v));
    SELECT ST_ISEMPTY(v);
END|
DELIMITER ;|

--echo # Calling the cursor
CALL geom_cursor();

--echo # Dropping the created cursor
DROP PROCEDURE geom_cursor;

############################################################################################
# Checking the Self join with the geometry properties                                      #
############################################################################################

--echo # Checking the Self join with the geometry properties

SELECT
    ST_GEOMETRYTYPE(tableX.g), ST_GEOMETRYTYPE(tableY.g),
    ST_SRID(tableX.g), ST_SRID(tableX.g),
    ST_DIMENSION(tableX.g), ST_DIMENSION(tableX.g),
    ST_ISSIMPLE(tableX.g), ST_ISSIMPLE(tableX.g),
    ST_AREA(tableX.g), ST_AREA(tableX.g),
    ST_ISEMPTY(tableX.g), ST_ISEMPTY(tableX.g)
FROM gis_geometry AS tableX, gis_geometry AS tableY
WHERE
    ST_GEOMETRYTYPE(tableX.g) = ST_GEOMETRYTYPE(tableY.g) AND
    ST_SRID(tableX.g) = ST_SRID(tableY.g) AND
    ST_DIMENSION(tableX.g) = ST_DIMENSION(tableY.g) AND
    ST_ISSIMPLE(tableX.g) = ST_ISSIMPLE(tableY.g) AND
    ST_AREA(tableX.g) = ST_AREA(tableY.g) AND
    ST_ISEMPTY(tableX.g) = ST_ISEMPTY(tableY.g);

############################################################################################
# Checking the aggregate functions on the geometry class properties                        #
############################################################################################

--echo # Checking the aggregate functions on the geometry class properties 

--echo # Checking the SUM function
--echo # Checking the SUM function
SELECT SUM(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT SUM(ST_SRID(g)) FROM gis_geometry;

SELECT SUM(ST_DIMENSION(g)) FROM gis_geometry;

SELECT SUM(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT SUM(ST_AREA(g)) FROM gis_geometry;

SELECT SUM(ST_ISEMPTY(g)) FROM gis_geometry;

--echo # Checking the MAX function
SELECT MAX(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT MAX(ST_SRID(g)) FROM gis_geometry;

SELECT MAX(ST_DIMENSION(g)) FROM gis_geometry;

SELECT MAX(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT MAX(ST_AREA(g)) FROM gis_geometry;

SELECT MAX(ST_ISEMPTY(g)) FROM gis_geometry;

--echo # Checking the MIN function
SELECT MIN(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT MIN(ST_SRID(g)) FROM gis_geometry;

SELECT MIN(ST_DIMENSION(g)) FROM gis_geometry;

SELECT MIN(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT MIN(ST_AREA(g)) FROM gis_geometry;

SELECT MIN(ST_ISEMPTY(g)) FROM gis_geometry;

--echo # Checking the STD function
SELECT STD(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT STD(ST_SRID(g)) FROM gis_geometry;

SELECT STD(ST_DIMENSION(g)) FROM gis_geometry;

SELECT STD(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT STD(ST_AREA(g)) FROM gis_geometry;

SELECT STD(ST_ISEMPTY(g)) FROM gis_geometry;

--echo # Checking the AVG function
SELECT AVG(ST_GEOMETRYTYPE(g)) FROM gis_geometry;

SELECT AVG(ST_SRID(g)) FROM gis_geometry;

SELECT AVG(ST_DIMENSION(g)) FROM gis_geometry;

SELECT AVG(ST_ISSIMPLE(g)) FROM gis_geometry;

SELECT AVG(ST_AREA(g)) FROM gis_geometry;

SELECT AVG(ST_ISEMPTY(g)) FROM gis_geometry;

--echo # Checking the DISTINCT function
SELECT COUNT(DISTINCT(ST_GEOMETRYTYPE(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_SRID(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_DIMENSION(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ENVELOPE(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ISSIMPLE(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_AREA(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_CENTROID(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_CONVEXHULL(g))) FROM gis_geometry;

SELECT COUNT(DISTINCT(ST_ISEMPTY(g))) FROM gis_geometry;

--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;
DROP TABLE gis_geometry;
DROP TABLE gis_geometry_1;

Man Man