PostGIS
Name
ST_3DClosestPoint — Returns the 3D point on g1 that is closest to g2. This is the first point of the 3D shortest line.
Description
Returns the 3-dimensional point on g1 that is closest to g2. This is the first point of the 3D shortest line. The 3D length of the 3D shortest line is the 3D distance.
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
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.
Examples
linestring and point — both 3d and 2d closest point
|
cp2d_line_pt -----------------------------------------------------------+------------------------------------------ POINT(54.6993798867619 128.935022917228 11.5475869506606) |
POINT(73.0769230769231 115.384615384615) ---- |
linestring and multipoint — both 3d and 2d closest point
|
cp2d_line_pt -----------------------------------------------------------+-------------- POINT(54.6993798867619 128.935022917228 11.5475869506606) |
POINT(50 75) ---- |
Multilinestring and polygon both 3d and 2d closest point
|
cp2d -------------------------------------------+-------------- POINT(39.993580415989 54.1889925532825 5) |
POINT(20 40) ---- |