The Lindorm GanosBase access functions retrieve geometric properties from spatial data, including points, coordinate values, bounding box extents, and vertex counts. These functions apply to LindormTable with no version requirements.
Function list
| Function | Description |
|---|---|
| ST_Centroid | Returns the centroid of a Geometry object |
| ST_EndPoint | Returns the last point of a LineString |
| ST_NPoints | Returns the number of vertices in a Geometry object |
| ST_StartPoint | Returns the start point of a LineString |
| ST_X | Returns the X-coordinate value of a Point |
| ST_XMax | Returns the maximum X-coordinate of the bounding box of a Geometry object |
| ST_XMin | Returns the minimum X-coordinate of the bounding box of a Geometry object |
| ST_Y | Returns the Y-coordinate value of a Point |
| ST_YMax | Returns the maximum Y-coordinate of the bounding box of a Geometry object |
| ST_YMin | Returns the minimum Y-coordinate of the bounding box of a Geometry object |
ST_Centroid
Returns the centroid of a Geometry object.
If the Geometry object is empty, this function returns an empty geometry.
Syntax
geometry ST_Centroid(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Examples
Example 1: Centroid of a point collection
SELECT ST_AsText(ST_Centroid(ST_Collect(ST_MakePoint(1,1),ST_MakePoint(-1,-1)))) AS astext;
Result:
+-------------+
| astext |
+-------------+
| POINT (0 0) |
+-------------+
Example 2: Centroid of a LineString
SELECT ST_AsText(ST_Centroid(ST_GeomFromText('LINESTRING(0 0,0 1,1 2)'))) AS astext;
Result:
+--------------------------------+
| astext |
+--------------------------------+
| POINT (0.2928932188134525 |
| 1.085786437626905) |
+--------------------------------+
Related functions
ST_EndPoint, ST_NPoints, ST_StartPoint, ST_X, ST_Y
ST_EndPoint
Returns the last point of a LineString.
Returns NULL if the input is not a LineString.
Syntax
geometry ST_EndPoint(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Examples
Example 1: Last point of a LineString
SELECT ST_AsText(ST_EndPoint(ST_GEOMFROMTEXT('LINESTRING(1 1, 2 2, 3 3)'))) AS endpoint;
Result:
+-------------+
| endpoint |
+-------------+
| POINT (3 3) |
+-------------+
Example 2: Non-LineString input returns NULL
SELECT ST_EndPoint(ST_GeomFromText('POINT(1 1)')) IS NULL AS is_null;
Result:
+---------+
| is_null |
+---------+
| true |
+---------+
Related functions
ST_StartPoint, ST_NPoints
ST_NPoints
Returns the number of vertices in a Geometry object. Applies to any geometry type.
Syntax
int ST_NPoints(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input 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;
Result:
+---------+
| npoints |
+---------+
| 4 |
+---------+
Related functions
ST_StartPoint, ST_EndPoint
ST_StartPoint
Returns the start point of a LineString.
Returns NULL if the input is not a LineString.
Syntax
geometry ST_StartPoint(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Examples
Example 1: Start point of a LineString
SELECT ST_AsText(ST_StartPoint(ST_GEOMFROMTEXT('LINESTRING(0 1, 0 2)'))) AS startpoint;
Result:
+-------------+
| startpoint |
+-------------+
| POINT (0 1) |
+-------------+
Example 2: Non-LineString input returns NULL
SELECT ST_StartPoint(ST_GeomFromText('POINT(1 1)')) IS NULL AS is_null;
Result:
+---------+
| is_null |
+---------+
| true |
+---------+
Related functions
ST_EndPoint, ST_NPoints
ST_X
Returns the X-coordinate value of a Point.
The input must be of the Point type. Returns NULL if the input is an empty Point or NULL.
Syntax
BigDecimal ST_X(geometry a_point)
Parameters
| Parameter | Description |
|---|---|
| a_point | The input Point object |
Examples
Example 1: X-coordinate of a Point
SELECT ST_X(ST_MakePoint(1.0, 2.0)) AS x;
Result:
+---+
| x |
+---+
| 1 |
+---+
Example 2: NULL input returns NULL
SELECT ST_X(NULL) IS NULL AS is_null;
Result:
+---------+
| is_null |
+---------+
| true |
+---------+
Related functions
ST_Y, ST_XMax, ST_XMin
ST_XMax
Returns the maximum X-coordinate of the bounding box of a Geometry object.
Supports Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. Returns -1 if the Geometry object is empty.
Syntax
BigDecimal ST_XMax(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Example
SELECT ST_XMax(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS xmax;
Result:
+------+
| xmax |
+------+
| 5 |
+------+
Related functions
ST_XMin, ST_YMax, ST_YMin, ST_X
ST_XMin
Returns the minimum X-coordinate of the bounding box of a Geometry object.
Supports Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. Returns 0 if the Geometry object is empty.
Syntax
BigDecimal ST_XMin(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Example
SELECT ST_XMin(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS xmin;
Result:
+------+
| xmin |
+------+
| 1 |
+------+
Related functions
ST_XMax, ST_YMax, ST_YMin, ST_X
ST_Y
Returns the Y-coordinate value of a Point.
The input must be of the Point type. Returns NULL if the input is an empty Point or NULL.
Syntax
BigDecimal ST_Y(geometry a_point)
Parameters
| Parameter | Description |
|---|---|
| a_point | The input Point object |
Examples
Example 1: Y-coordinate of a Point
SELECT ST_Y(ST_MakePoint(1.0, 2.0)) AS y;
Result:
+---+
| y |
+---+
| 2 |
+---+
Example 2: NULL input returns NULL
SELECT ST_Y(NULL) IS NULL AS is_null;
Result:
+---------+
| is_null |
+---------+
| true |
+---------+
Related functions
ST_X, ST_YMax, ST_YMin
ST_YMax
Returns the maximum Y-coordinate of the bounding box of a Geometry object.
Supports Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. Returns -1 if the Geometry object is empty.
Syntax
BigDecimal ST_YMax(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Example
SELECT ST_YMax(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS ymax;
Result:
+------+
| ymax |
+------+
| 6 |
+------+
Related functions
ST_YMin, ST_XMax, ST_XMin, ST_Y
ST_YMin
Returns the minimum Y-coordinate of the bounding box of a Geometry object.
Supports Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. Returns 0 if the Geometry object is empty.
Syntax
BigDecimal ST_YMin(geometry g)
Parameters
| Parameter | Description |
|---|---|
| g | The input Geometry object |
Example
SELECT ST_YMin(ST_GeomFromText('LINESTRING(1 3,5 6)')) AS ymin;
Result:
+------+
| ymin |
+------+
| 3 |
+------+
Related functions
ST_YMax, ST_XMax, ST_XMin, ST_Y