제목

ST_3DShortestLine — 두 도형 사이의 3차원 최단(shortest) 라인을 반환합니다.

요약

geometry ST_3DShortestLine(geometry g1, geometry g2);

설명

두 도형 사이의 3차원 최단(shortest) 라인을 반환합니다. 하나 이상의 최단 라인이 있을 경우, 이 함수는 첫 번째 최단 라인만 반환할 것입니다. g1과 g2가 단 한 개의 포인트에서만 교차할 경우, 이 함수는 교차점에서 시작하고 끝나는 라인을 반환할 것입니다. g1과 g2가 한 개 이상의 포인트에서 교차할 경우, 이 함수는 동일한 포인트에서 시작하고 끝나는 라인을 반환하지만 해당 포인트는 교차하는 포인트들 가운데 어떤 포인트라도 될 수 있습니다. 반환되는 라인은 항상 g1에서 시작해서 g2에서 끝납니다. 이 함수가 반환하는 라인의 3차원 길이는 ST_3DDistance 함수가 g1과 g2에 대해 반환하는 길이와 언제나 동일합니다.

2.0.0 버전부터 사용할 수 있습니다.

변경 사항: 2.2.0 버전부터 2D 도형 두 개를 입력할 경우, (존재하지 않는 Z을 0으로 가정하는 예전 습성 대신) 2D 포인트를 반환합니다. 2D 및 3D의 경우, 더 이상 Z가 없을 때 Z를 0으로 가정하지 않습니다.

This function supports 3d and will not drop the z-index.

This function supports Polyhedral surfaces.

예시

Compare the 3D shortest line to the 2D shortest line for a LineString and a Point.

Code
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_3DShortestLine(line, pt) AS shl3d_line_pt,
       ST_ShortestLine(line, pt) AS shl2d_line_pt
FROM input;
래스터 출력
-[ RECORD 1 ]--+--------------------------------------------------------------------------------
shl3d_line_pt  | LINESTRING(54.69937988676193 128.93502291722837 11.547586950660556,100 100 30)
shl2d_line_pt  | LINESTRING(73.07692307692307 115.38461538461539,100 100)
Figure
Geometry figure for visual-st-3dshortestline-01

Compare the 3D shortest line to the 2D shortest line for a LineString and a MultiPoint.

Code
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_3DShortestLine(line, pt) AS shl3d_line_pt,
       ST_ShortestLine(line, pt) AS shl2d_line_pt
FROM input;
래스터 출력
-[ RECORD 1 ]--+--------------------------------------------------------------------------------
shl3d_line_pt  | LINESTRING(54.69937988676193 128.93502291722837 11.547586950660556,100 100 30)
shl2d_line_pt  | LINESTRING(50 75,50 74)
Figure
Geometry figure for visual-st-3dshortestline-02

Compare the 3D shortest line to the 2D shortest line for a Polygon and a MultiLineString.

Code
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_3DShortestLine(poly, mline) AS shl3d,
       ST_ShortestLine(poly, mline) AS shl2d
FROM input;
래스터 출력
-[ RECORD 1 ]--+--------------------------------------------------------------------------------------
shl3d          | LINESTRING(40.45454545454545 53.63636363636364 5,40.45454545454545 53.63636363636364 5)
shl2d          | LINESTRING(20 40,20 40)
Figure
Geometry figure for visual-st-3dshortestline-03