ST_3DClosestPoint — g1上の、g2に最も近い3次元ポイントを返します。これは3次元の最短ラインの始点です。
geometry ST_3DClosestPoint(geometry g1, geometry g2);
g1上の、g2に最も近い3次元ポイントを返します。3次元最短線の一つ目のポイントです。3次元最短線の長さは、3次元距離と同じです。
この関数は3次元に対応し、Z値を削除しません。
この関数は多面体サーフェスに対応しています。
Availability: 2.0.0
Changed: 2.2.0 - 二つの2次元ジオメトリが入力である場合には、2次元ポイントが返ります (古い挙動では、存在しないZの値について0を仮定していました)。2次元と3次元の場合には、もはや、存在しない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;