ST_3DClosestPoint — g2에 가장 가까운 g1 상에 있는 3차원 포인트를 반환합니다. 해당 포인트는 3D 최단 라인의 첫 번째 포인트입니다.
geometry ST_3DClosestPoint(geometry g1, geometry g2);
g2에 가장 가까운 g1 상에 있는 3차원 포인트를 반환합니다. 해당 포인트는 3D 최단 라인의 첫 번째 포인트입니다. 3D 최단 라인의 3D 길이가 3D 거리입니다.
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
2.0.0 버전부터 사용할 수 있습니다.
변경 사항: 2.2.0 버전부터 2D 도형 두 개를 입력할 경우, (존재하지 않는 Z을 0으로 가정하는 예전 습성 대신) 2D 포인트를 반환합니다. 2D 및 3D의 경우, 더 이상 Z가 없을 때 Z를 0으로 가정하지 않습니다.
Compare the 3D closest point to the 2D closest point for a LineString and a Point.
WITH input AS (
SELECT 'POINT(100 100 30)'::geometry AS pt,
'LINESTRING (20 80 20,98 190 1,110 180 3,50 75 1000)'::geometry AS line
)
SELECT ST_3DClosestPoint(line, pt) AS cp3d_line_pt,
ST_ClosestPoint(line, pt) AS cp2d_line_pt
FROM input;
Compare the 3D closest point to the 2D closest point for a LineString and a MultiPoint.
WITH input AS (
SELECT 'MULTIPOINT(100 100 30,50 74 1000)'::geometry AS pt,
'LINESTRING (20 80 20,98 190 1,110 180 3,50 75 900)'::geometry AS line
)
SELECT ST_3DClosestPoint(line, pt) AS cp3d_line_pt,
ST_ClosestPoint(line, pt) AS cp2d_line_pt
FROM input;
Compare the 3D closest point to the 2D closest point for a Polygon and a MultiLineString.
WITH input AS (
SELECT ST_GeomFromEWKT(
'POLYGON((175 150 5,20 40 5,35 45 5,50 60 5,100 100 5,175 150 5))'
) AS poly,
ST_GeomFromEWKT(
'MULTILINESTRING((175 155 2,20 40 20,50 60 -2,125 100 1,175 155 1),
(1 10 2,5 20 1))'
) AS mline
)
SELECT ST_3DClosestPoint(poly, mline) AS cp3d,
ST_ClosestPoint(poly, mline) AS cp2d
FROM input;