The access functions of the Lindorm GanosBase spatiotemporal service allow you to quickly retrieve geometric properties, such as points and coordinate values. These functions simplify the spatial data processing flow and improve the ease and accuracy of data analytics. This topic describes the access functions that Lindorm supports.
Engine and version
Access functions apply only to LindormTable. There are no version requirements.
Function list
The following table lists the access functions that Lindorm GanosBase supports.
Function | Description |
Returns the centroid of a specified Geometry object. | |
Returns the last point of a specified LineString object. | |
Returns the number of vertices in a specified Geometry object. | |
Returns the start point of a specified LineString object. | |
Returns the X-coordinate value of a specified Point object. | |
Returns the maximum X-coordinate of the bounding box of a specified Geometry object. | |
Returns the minimum X-coordinate of the bounding box of a specified Geometry object. | |
Returns the Y-coordinate value of a specified Point object. | |
Returns the maximum Y-coordinate of the bounding box of a specified Geometry object. | |
Returns the minimum Y-coordinate of the bounding box of a specified Geometry object. |
ST_Centroid
Returns the centroid of a specified Geometry object.
Syntax
geometry ST_Centroid(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
If the Geometry object is empty, this function returns an empty geometry.
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
Returns the last point of a specified LineString object.
Syntax
geometry ST_EndPoint(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
If the Geometry object is not of the LineString type, 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 a specified Geometry object. This function applies to any Geometry object.
Syntax
int ST_NPoints(geometry g)Parameter description
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)Parameter description
Parameter | Description |
g | The specified Geometry object. |
If the Geometry object is not of the LineString type, 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)Parameter description
Parameter | Description |
a_point | The specified Point object. |
The input Geometry object must be of the Point type. 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 of the bounding box of a specified Geometry object.
Syntax
BigDecimal ST_XMax(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
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 of the bounding box of a specified Geometry object.
Syntax
BigDecimal ST_XMin(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
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)Parameter description
Parameter | Description |
a_point | The specified Point object. |
The Geometry object must be of the Point type. 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 of the bounding box of a specified Geometry object.
Syntax
BigDecimal ST_YMax(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
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 of the bounding box of a specified Geometry object.
Syntax
BigDecimal ST_YMin(geometry g)Parameter description
Parameter | Description |
g | The specified Geometry object. |
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 |
+------+