OceanBase Database supports the construction, storage, and analysis of spatial data types of Geographic Information System (GIS).
The supported spatial data types in OceanBase Database are as follows:
GEOMETRYPOINTLINESTRINGPOLYGONMULTIPOINTMULTILINESTRINGMULTIPOLYGONGEOMETRYCOLLECTION
Single-value types
A single-value type holds a single spatial value, such as:
GEOMETRY, which can hold any type of geometry value.POINT,LINESTRING, andPOLYGON, which are the most basic types and can only hold specific types of geometry values.POINT: represents a point in a coordinate system. For example,POINT(50 60)specifies a longitude value and a latitude value, which are separated by a space.LINESTRING: represents a line that consists of a series of points connected together. For example,LINESTRING(30 20,10 30,50 50)specifies a line consisting of three points separated by commas (,). Each point consists of a longitude value and a latitude value separated by a space, which is consistent with thePOINTformat.POLYGON: represents a simple or solid polygon, which can be open or boundary only, such as a boundary-only polygonPOLYGON((0 0,10 0,10 10,0 10)).
GEOMETRY is the base class of all spatial types, and types such as POINT, LINESTRING, and POLYGON are subclasses of GEOMETRY.
Collection types
These types hold collections of values, such as:
MULTIPOINT,MULTILINESTRING, andMULTIPOLYGON, which hold collections of spatial data of a certain base type.MULTIPOINT: represents a collection of points, such asMULTIPOINT(10 0),(5 10),(25 5),(20 5)andMULTIPOINT(10 0,5 10,25 5,20 5).MULTILINESTRING: represents a collection of lines, such asMULTILINESTRING((0 0,15 5,10 10),(30 20,10 30,40 40)).MULTIPOLYGON: represents a collection of graphs, such asMULTIPOLYGON(((30 20, 45 40, 10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))andMULTIPOLYGON(((40 40,20 45,45 30,40 40)),((20 35,10 30,10 10,30 5,45 20,20 35),(30 20,20 15,20 25,30 20))).
GEOMETRYCOLLECTIONcan hold a collection of objects of any spatial data type, such asGEOMETRYCOLLECTION(POINT(40 10),LINESTRING(10 10,20 20,10 40),POLYGON((40 40,20 45,45 30,40 40))).
MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEOMETRYCOLLECTION are value collection data types holding vales of the POINT, LINESTRING, or POLYGON type.
SRID attribute
The SRID attribute defines a value in the spatial reference system (SRS) on a column of the spatial type. A column that defines the SRID attribute has the following two characteristics:
- The
SRIDvalue of the spatial object written to the column must be consistent with theSRIDattribute defined for the column. Otherwise, the write operation fails. - The spatial index defined on this column can take effect during spatial queries.
Example
A field of the spatial type supports the nullable attribute and the SRID attribute of a space coordinate system. Here is an example:
obclient [test]> CREATE TABLE tbl1_g(g GEOMETRY NOT NULL SRID 0);
Query OK, 0 rows affected