In this tutorial I will be able to provide you some information about Spatial Data and Spatial Data Type in MySQL.
What is Spatial Data ?
Spatial data also known as geospatial data, represents the location, size and shape of an object on Earth such as a minar, lake, mountain or temple.
this data can used to locate any device, mountain and place globally.
Spatial data consists of point, line, polygon and many others geometric object.
Spatial Data Types In MySQL
MySQL (here we use the version 5.7) has data types that correspond to OpenGIS classes. Some object that store single geometry values:
GEOMETRY can store geometry values of any type.
POINT, LINESTRING and POLYGON restrict their values to a particular geometry type.
data types that can hold multiple values:
MySQL supported spatial Data Format
Two types of format are supported by mysql queries-
1. WKT (well known text) format
2. WKB (well known binary) format
The Well-Known Text (WKT) format of geometry values is designed for exchanging geometry data in ASCII form
Example of representing a point in WKT format
The Well-Known Binary (WKB) format of geometric values is used for exchanging geometry data as binary streams described by BLOB (Binary Large Object) values containing geometric WKB information.
WKB uses 1-byte unsigned integers, 4-byte unsigned integers, and 8-byte double-precision numbers (IEEE 754 format). A byte is eight bits.
For example, a WKB value that corresponds to POINT(1 1) consists of this sequence of 21 bytes, each described by two hex digits:
The sequence consists of these components:
Byte order: 01
WKB type: 01000000
X coordinate: 000000000000F03F
Y coordinate: 000000000000F03F
Storing geolocation of a point in MySQL using Spatial Data Type