Create tables, populate test data
Create TableGEOM1 (IDint not NULLAuto_incrementPrimary Key, Geo geometry);Insert intoGEOM1 (GEO)Values(St_geomfromtext ('Point (1 1)',3857));Insert intoGEOM1 (GEO)Values(St_geomfromtext ('Polygon ((0 0,10 0,10 10,0 10,0 0))',3857));
Select from Geom1; /* get Spatial data in WKT format */ Select from /* get Spatial data in WKB format */
Modify column self-increment type
Alter Table int Primary key auto_increment;
To establish a spatial index, the index column must be non-empty
Alter Table notnull;
Create SPATIAL Index on GEOM1 (GEO)
Common space calculation operations
Mbrcontains (G1,G2) returns 1 or 0 to indicate whether the smallest bounding rectangle of the G1 contains the smallest bounding rectangle of the G2. Mbrdisjoint (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle for the two geometric variables G1 and G2 is disjoint. Mbrequal (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle for the two geometric variables G1 and G2 is the same. Mbrintersects (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle for the two geometric variables G1 and G2 intersect. Mbroverlaps (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle for the two geometric variables G1 and G2 is overlapping. Mbrtouches (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle of the two geometric variables G1 and G2 is in contact. Mbrwithin (G1,G2) returns 1 or 0 to indicate whether the minimum bounding rectangle of the G1 is within the smallest bounding rectangle of the G2. Contains (G1,G2) returns 1 or 0 to indicate whether G1 fully contains G2. Crosses (G1,G2) returns 1 if G1 intersects with G2 in space. If G1 is polygon or multipolygon, returns NULL, or if G2 returns null for point or multipoint. Otherwise, 0 is returned. The term "spatial crossover" refers to the spatial relationship between 2 given geometric objects, which has the following properties: O 2 associative objects intersect. o its intersecting result will cause its dimension to be less than two geometric objects of the largest dimension of a given geometric object. o its intersection is not equal to any 1 of the two geometric objects. Disjoint (G1,G2) returns 1 or 0 to indicate whether G1 is spatially disjoint from G2. Distance (G1,G2) returns the shortest distance between 2 points in 2 geometric objects as a double-precision numeric value. Equals (G1,G2) returns 1 or 0 to indicate whether the G1 is spatially equivalent to G2. Intersects (G1,G2) returns 1 or 0 to indicate whether the G1 intersects the G2 spatially. Overlaps (g1,g2) returns 1 or 0 to indicate whether the G1 overlaps with G2 spatially. The term "space overlap" will be used if 2 geometries intersect and their intersections result in geometric objects that have the same dimension but are not identical to any of the geometric objects. Related (G1,g2,pattern_matrix) returns 1 or 0 to indicate whether the spatial relationship specified by Pattern_matrix exists between G1 and G2. If the parameter is NULL, return-1. The pattern rectangle is a string. If the function is implemented, its specification is given here. Touches (G1,G2) returns 1 or 0 to indicate whether the G1 is spatiallyContact with G2. If the interior of the geometry does not intersect, but the boundary of the 1 geometric objects is intersected with another boundary or interior, the two geometries are in contact with each other. Within (G1,G2) returns 1 or 0 to indicate whether G1 is spatially located within G2.
MySQL space type using notes