PostGIS
Description
Returns the 3-dimensional shortest line between two geometries. The function will only return the first shortest line if more than one, that the function finds. If g1 and g2 intersects in just one point the function will return a line with both start and end in that intersection-point. If g1 and g2 are intersecting with more than one point the function will return a line with start and end in the same point but it can be any of the intersecting points. The line returned will always start in g1 and end in g2. The 3D length of the line this function returns will always be the same as ST_3DDistance returns for g1 and g2.
Availability: 2.0.0
Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
Examples
linestring and point — both 3d and 2d shortest line
|
shl2d_line_pt ----------------------------------------------------------------------------+------------------------------------------------------ LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30) |
LINESTRING(73.0769230769231 115.384615384615,100 100) ---- |
linestring and multipoint — both 3d and 2d shortest line
|
shl2d_line_pt ---------------------------------------------------------------------------+------------------------ LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30) |
LINESTRING(50 75,50 74) ---- |
MultiLineString and polygon both 3d and 2d shortest line
|
shl2d ---------------------------------------------------------------------------------------------------+------------------------ LINESTRING(39.993580415989 54.1889925532825 5,40.4078575708294 53.6052383805529 5.03423778139177) |
LINESTRING(20 40,20 40) ---- |