名前

ST_CPAWithin — 二つのトラジェクトリの最接近点が指定した距離内にある場合にはtrueを返します。

概要

boolean ST_CPAWithin(geometry track1, geometry track2, float8 maxdist);

説明

二つの移動体が指定した最大距離内にあるかどうかを確認します。

入力はST_IsValidTrajectoryで確認された妥当なトラジェクトリでなければなりません。トラジェクトリのM値の範囲が重ならない場合にはFALSEを返します。

初出: 2.2.0

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

WITH inp AS ( SELECT
  ST_AddMeasure('LINESTRING Z (0 0 0, 10 0 5)'::geometry,
    extract(epoch from '2015-05-26 10:00'::timestamptz),
    extract(epoch from '2015-05-26 11:00'::timestamptz)
  ) a,
  ST_AddMeasure('LINESTRING Z (0 2 10, 12 1 2)'::geometry,
    extract(epoch from '2015-05-26 10:00'::timestamptz),
    extract(epoch from '2015-05-26 11:00'::timestamptz)
  ) b
)
SELECT ST_CPAWithin(a,b,2), ST_DistanceCPA(a,b) distance FROM inp;

 st_cpawithin |     distance
--------------+------------------
 t            | 1.96521473776207

関連情報

ST_IsValidTrajectory, ST_ClosestPointOfApproach, ST_DistanceCPA, |=|