MySQL4.1 and later contains the spatial data engine, you can access space data through the SQL statement, and spatially queries.
MySQL's Spatial Engine uses OGC (Well-KNown Text) / WKB (Well-KNown) defined by OGC (Open Gis Consortium)
Save space data in a binary format.
MySQL spatial data model
* Geometry (not supported)
o Point (already supported)
o Curve (not supported)
LINESTRING (supported)
# Line
# Linearring
o Surface (not supported)
Polygon (supported)
o GeometryCollection (already supported)
MULTIPOINT (already supported)
MultiCurve (not supported)
# MultiLinestring (supported)
Multisurface (not supported)
# MultiPolygon (supported)
For more information, please check the Mysql Reference Document Chapter 18 (version 4.1.8, other versions of the section may have access)
Applications
Geotable table structure
Field Type
ID INT
Geo Geometry
Construction table SQL statement
"CREATE TABLE GEOTABLE (` ID` int (11) Not null auto_increment, `geo` Geometry Default Null,
Primary key (`ID`) ENGINE = MyISAM"
Note: Only a Myisam type table supports space data
Insert a fold line to the Geotable table
INSERT INTO GEOTABLE VALUES (GEOMFROMTEXT (LINESTRING (0 0, 1 1, 2 2)))
Returns the data of the entire table
"SELECT ID, Astext (GEO) from GeOTABLE"
Returns data in the Polygon area
"SELECT ID, Astext (GEO) from GeoTable Where Mbrintersects (Geo, Geomfromtext ('Polygon
((...)) ')) "
Complete application examples You can view the mysqlgeometrylayer.java file for open source WebGIS platform OpenMap