Returns the longest line between two geometry objects in 3D space.
Syntax
geometry ST_3DLongestLine(geometry g1, geometry g2);Parameters
| Parameter | Description |
|---|---|
g1 | The first geometry object. The returned line starts from this object. |
g2 | The second geometry object. The returned line ends at this object. |
Usage notes
If multiple longest lines exist, the function returns only the first one found.
The returned line always starts from
g1and ends atg2.The length of the returned line equals the result of
ST_3DMaxDistancewhen called with the same inputs.Z coordinates are preserved. The function supports 3D objects.
The function supports polyhedral surfaces.
Examples
Find the longest line between a point and a line string:
SELECT ST_AsText(
ST_3DLongestLine(
'POINT(0 0 0)'::geometry,
'LINESTRING(0 0 1, 1 1 0)'::geometry
)
);Output:
st_astext
----------------------------
LINESTRING Z (0 0 0,1 1 0)
(1 row)See also
ST_3DMaxDistance — returns the maximum 3D distance between two geometry objects