homework-jianmu/docs/en/12-taos-sql/11-geometry-function.md

3.9 KiB
Raw Blame History

sidebar_label title toc_max_heading_level
Geometry Functions Geometry Functions 4

Geometry Input Functions

Geometry input functions create geometry data from WTK.

ST_GeomFromText

ST_GeomFromText(VARCHAR WKT expr)

Description: Return a specified GEOMETRY value from Well-Known Text representation (WKT).

Return value type: GEOMETRY

Applicable data types: VARCHAR

Applicable table types: standard tables and supertables

Explanations

  • The input can be one of WTK string, like POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION.
  • The output is a GEOMETRY data type, internal defined as binary string.

Geometry Output Functions

Geometry output functions convert geometry data into WTK.

ST_AsText

ST_AsText(GEOMETRY geom)

Description: Return a specified Well-Known Text representation (WKT) value from GEOMETRY data.

Return value type: VARCHAR

Applicable data types: GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • The output can be one of WTK string, like POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION.

Geometry Relationships Functions

Geometry relationships functions determine spatial relationships between geometries.

ST_Intersects

ST_Intersects(GEOMETRY geomA, GEOMETRY geomB)

Description: Compares two geometries and returns true if they intersect.

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • Geometries intersect if they have any point in common.

ST_Equals

ST_Equals(GEOMETRY geomA, GEOMETRY geomB)

Description: Returns TRUE if the given geometries are "spatially equal".

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • 'Spatially equal' means ST_Contains(A,B) = true and ST_Contains(B,A) = true, and the ordering of points can be different but represent the same geometry structure.

ST_Touches

ST_Touches(GEOMETRY geomA, GEOMETRY geomB)

Description: Returns TRUE if A and B intersect, but their interiors do not intersect.

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • A and B have at least one point in common, and the common points lie in at least one boundary.
  • For Point/Point inputs the relationship is always FALSE, since points do not have a boundary.

ST_Covers

ST_Covers(GEOMETRY geomA, GEOMETRY geomB)

Description: Returns TRUE if every point in Geometry B lies inside (intersects the interior or boundary of) Geometry A.

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • A covers B means no point of B lies outside (in the exterior of) A.

ST_Contains

ST_Contains(GEOMETRY geomA, GEOMETRY geomB)

Description: Returns TRUE if geometry A contains geometry B.

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • A contains B if and only if all points of B lie inside (i.e. in the interior or boundary of) A (or equivalently, no points of B lie in the exterior of A), and the interiors of A and B have at least one point in common.

ST_ContainsProperly

ST_ContainsProperly(GEOMETRY geomA, GEOMETRY geomB)

Description: Returns TRUE if every point of B lies inside A.

Return value type: BOOL

Applicable data types: GEOMETRY, GEOMETRY

Applicable table types: standard tables and supertables

Explanations

  • There is no point of B lies in the the boundary or exterior of A.