Spatial data types

2024-04-19 08:42:50  Updated

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:

  • GEOMETRY
  • POINT
  • LINESTRING
  • POLYGON
  • MULTIPOINT
  • MULTILINESTRING
  • MULTIPOLYGON
  • GEOMETRYCOLLECTION

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, and POLYGON, 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 the POINT format.
    • POLYGON: represents a simple or solid polygon, which can be open or boundary only, such as a boundary-only polygon POLYGON((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, and MULTIPOLYGON, which hold collections of spatial data of a certain base type.

    • MULTIPOINT: represents a collection of points, such as MULTIPOINT(10 0),(5 10),(25 5),(20 5) and MULTIPOINT(10 0,5 10,25 5,20 5).
    • MULTILINESTRING: represents a collection of lines, such as MULTILINESTRING((0 0,15 5,10 10),(30 20,10 30,40 40)).
    • MULTIPOLYGON: represents a collection of graphs, such as MULTIPOLYGON(((30 20, 45 40, 10 40,30 20)),((15 5,40 10,10 20,5 10,15 5))) and MULTIPOLYGON(((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))).
  • GEOMETRYCOLLECTION can hold a collection of objects of any spatial data type, such as GEOMETRYCOLLECTION(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 SRID value of the spatial object written to the column must be consistent with the SRID attribute 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

Contact Us