Using the POLYGON object in the variable : polygon « Geometric « SQL / MySQL






Using the POLYGON object in the variable

    
mysql>
mysql> CREATE TABLE cities (
    ->   id int(11) ,
    ->   pt point NOT NULL default '',
    ->   zip int(11) default NULL,
    ->   country varchar(10) default NULL,
    ->   state char(2) default NULL,
    ->   city varchar(100) default NULL,
    ->   district varchar(100) default NULL
    -> );
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>
mysql>
mysql>
mysql> SET @d0 = 30000;
Query OK, 0 rows affected (0.00 sec)

mysql> SET @str = CONCAT('MULTIPOINT(', @x0-@d0, ' ', @y0-@d0, ', ',@x0+@d0, ' ', @y0+@d0, ')');
Query OK, 0 rows affected (0.00 sec)

mysql> SET @bbox = ENVELOPE(GEOMFROMTEXT(@str));
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @str;
+------+
| @str |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> SELECT city, X(pt), Y(pt) FROM cities WHERE MBRCONTAINS(@bbox, pt);
Empty set (0.00 sec)

mysql>
mysql> drop table cities;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.Determine the length of the outer polygon with EXTERIORRING function:
2.Geometric Functions for Polygon Objects
3.POLYGON type column: A closed LINESTRING; two-dimensional.