跳转至
🎉 SedonaDB 0.4.0 已正式发布!🗺️ 新增 Python DataFrame API、R dplyr 接口、Geography 支持及 GPU 加速空间连接。阅读发布博客 →

ST_ShortestLine

Introduction: Returns the shortest LineString between two geometries. The line starts on geom1 and ends on geom2. If either geometry is empty, the function returns null.

ST_ShortestLine

Format: ST_ShortestLine(geom1: Geometry, geom2: Geometry)

Return type: Geometry

Since: v1.9.0

SQL Example:

ST_ShortestLine Point to Point

SELECT ST_ShortestLine(
        ST_GeomFromText('POINT (0 0)'),
        ST_GeomFromText('POINT (3 4)')
)

Output:

LINESTRING (0 0, 3 4)

SQL Example:

ST_ShortestLine Point to LineString

SELECT ST_ShortestLine(
        ST_GeomFromText('POINT (0 1)'),
        ST_GeomFromText('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)')
)

Output:

LINESTRING (0 1, 0 0)