Access functions

Updated at:

Access functions in the Lindorm Ganos spatiotemporal service allow you to quickly retrieve geometric properties, such as points and coordinate values. These functions simplify spatial data processing and improve the ease and accuracy of data analytics. This topic describes the access functions that Lindorm supports.

Engine and version

Access functions are available only for the wide table engine and do not have specific version requirements.

Function list

The following table describes the access functions that Lindorm Ganos supports.

Function

Description

ST_Centroid

Returns the geometric center of a specified Geometry object.

ST_EndPoint

Returns the last point of a specified LineString object.

ST_NPoints

Returns the number of vertices in a specified Geometry object.

ST_StartPoint

Returns the start point of a specified LineString object.

ST_X

Returns the X-coordinate value of a specified Point object.

ST_XMax

Returns the maximum X-coordinate value of the bounding box of a specified Geometry object.

ST_XMin

Returns the minimum X-coordinate value of the bounding box of a specified Geometry object.

ST_Y

Returns the Y-coordinate value of a specified Point object.

ST_YMax

Returns the maximum Y-coordinate value of the bounding box of a specified Geometry object.

ST_YMin

Returns the minimum Y-coordinate value of the bounding box of a specified Geometry object.

ST_Centroid

Returns the geometric center of a specified Geometry object.

Syntax

geometry ST_Centroid(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note

If the input Geometry object is empty, this function returns an empty Geometry object.

Examples

  • Example 1

    SELECT ST_AsText(ST_Centroid(ST_Collect(ST_MakePoint(1,1),ST_MakePoint(-1,-1)))) AS astext;

    The following result is returned:

    +-------------+
    |   astext    |
    +-------------+
    | POINT (0 0) |
    +-------------+
  • Example 2

    SELECT ST_AsText(ST_Centroid(ST_GeomFromText('LINESTRING(0 0,0 1,1 2)'))) AS astext;

    The following result is returned:

    +--------------------------------+
    |             astext             |
    +--------------------------------+
    | POINT (0.2928932188134525      |
    | 1.085786437626905)             |
    +--------------------------------+

ST_EndPoint

The last point of the LineString object.

Syntax

geometry ST_EndPoint(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note

If the Geometry object is not a LineString object, this function returns NULL.

Example

SELECT ST_AsText(ST_EndPoint(ST_GEOMFROMTEXT('LINESTRING(1 1, 2 2, 3 3)'))) AS endpoint;

The following result is returned:

+-------------+
|  endpoint   |
+-------------+
| POINT (3 3) |
+-------------+

ST_NPoints

Returns the number of vertices in any specified Geometry object.

Syntax

int ST_NPoints(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Example

SELECT ST_NPoints(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)')) AS npoints;

The following result is returned:

+---------+
| npoints |
+---------+
| 4       |
+---------+

ST_StartPoint

Returns the start point of a specified LineString object.

Syntax

geometry ST_StartPoint(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note

If the Geometry object is not a LineString object, this function returns NULL.

Example

SELECT ST_AsText(ST_StartPoint(ST_GEOMFROMTEXT('LINESTRING(0 1, 0 2)'))) AS startpoint;

The following result is returned:

+-------------+
| startpoint  |
+-------------+
| POINT (0 1) |
+-------------+

ST_X

Returns the X-coordinate value of a specified Point object.

Syntax

BigDecimal ST_X(geometry a_point)

Parameters

Parameter

Description

a_point

The specified Point object.

Note

The input Geometry object must be a Point object. If the input Geometry object is empty or the input value is NULL, this function returns NULL.

Example

SELECT ST_X(ST_MakePoint(1.0, 2.0)) AS x;

The following result is returned:

+---+
| x |
+---+
| 1 |
+---+

ST_XMax

Returns the maximum X-coordinate value of the bounding box of a specified Geometry object.

Syntax

BigDecimal ST_XMax(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note
  • The Geometry object can be a Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection object.

  • If the Geometry object is empty, this function returns -1.

Example

SELECT ST_XMax(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS xmax;

The following result is returned:

+------+
| xmax |
+------+
| 5    |
+------+

ST_XMin

Returns the minimum X-coordinate value of the bounding box of a specified Geometry object.

Syntax

BigDecimal ST_XMin(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note
  • The Geometry object can be a Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection object.

  • If the Geometry object is empty, this function returns 0.

Example

SELECT ST_XMin(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS xmin;

The following result is returned:

+------+
| xmin |
+------+
| 1    |
+------+

ST_Y

Returns the Y-coordinate value of a specified Point object.

Syntax

BigDecimal ST_Y(geometry a_point)

Parameters

Parameter

Description

a_point

The specified Point object.

Note

The input Geometry object must be a Point object. If the input Geometry object is empty or the input value is NULL, this function returns NULL.

Example

SELECT ST_Y(ST_MakePoint(1.0, 2.0)) AS y;

The following result is returned:

+---+
| y |
+---+
| 2 |
+---+

ST_YMax

Returns the maximum Y-coordinate value of the bounding box of a specified Geometry object.

Syntax

BigDecimal ST_YMax(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note
  • The Geometry object can be a Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection object.

  • If the Geometry object is empty, this function returns -1.

Example

SELECT ST_YMax(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS ymax;

The following result is returned:

+------+
| ymax |
+------+
| 6    |
+------+

ST_YMin

Returns the minimum Y-coordinate value of the bounding box of a specified Geometry object.

Syntax

BigDecimal ST_YMin(geometry g)

Parameters

Parameter

Description

g

The specified Geometry object.

Note
  • The Geometry object can be a Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection object.

  • If the Geometry object is empty, this function returns 0.

Example

SELECT ST_YMin(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS ymin;

The following result is returned:

+------+
| ymin |
+------+
| 3    |
+------+