跳转至
🎉 Apache Sedona 1.9.1 已正式发布!🗺️ 新增 Geography SQL 函数、Box2D 与 Box3D 类型、栅格 Python UDF 等。查看发布说明 →

ST_LineSegments

Introduction: This function transforms a LineString containing multiple coordinates into an array of LineStrings, each with precisely two coordinates. The lenient argument, true by default, prevents an exception from being raised if the input geometry is not a LineString.

ST_LineSegments

Format:

ST_LineSegments(geom: Geometry, lenient: Boolean)

ST_LineSegments(geom: Geometry)

Return type: Array<Geometry>

Since: v1.7.1

SQL Example:

SELECT ST_LineSegments(
        ST_GeomFromWKT('LINESTRING(0 0, 10 10, 20 20, 30 30, 40 40, 50 50)'),
       false
    )

Output:

[LINESTRING (0 0, 10 10), LINESTRING (10 10, 20 20), LINESTRING (20 20, 30 30), LINESTRING (30 30, 40 40), LINESTRING (40 40, 50 50)]

SQL Example:

SELECT ST_LineSegments(
        ST_GeomFromWKT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))')
    )

Output:

[]