Name

ST_ShortestLine — 二つのジオメトリの3次元の最短ラインを返します。

Synopsis

geometry ST_ShortestLine(geometry geom1, geometry geom2);

geography ST_ShortestLine(geography geom1, geography geom2, boolean use_spheroid = true);

説明

二つのジオメトリの間の2次元の最短ラインを返します。返されるラインはgeom1内から始まり、geom2内で終わります。geom1geom2がインタセクトしている場合には、結果はインタセクションするポイントを始点と終点にしたラインになります。ラインの長さはST_Distance でg1とg2を引数に取った時と同じになります。

Enhanced: 3.4.0 - ジオグラフィに対応しました。

Availability: 1.5.0

ポイントとラインストリングの最短ライン

SELECT ST_AsText(  ST_ShortestLine(
        'POINT (160 40)',
        'LINESTRING (10 30, 50 50, 30 110, 70 90, 180 140, 130 190)')
        ) As sline;
---------------------------------------------------------
 LINESTRING(160 40,125.75342465753425 115.34246575342466)

ポリゴン間の最短ライン

SELECT ST_AsText( ST_ShortestLine(
         'POLYGON ((190 150, 20 10, 160 70, 190 150))',
         ST_Buffer('POINT(80 160)', 30)
              ) ) AS llinewkt;
-----------------
LINESTRING(131.59149149528952 101.89887534906197,101.21320343559644 138.78679656440357)

関連情報

ST_ClosestPoint, ST_Distance, ST_LongestLine, ST_MaxDistance