ST_CPAWithin — 测试两条轨迹的最近接近点是否在指定距离内。
boolean ST_CPAWithin(
geometry track1, geometry track2, float8 dist)
;
测试两个移动物体是否曾经比指定距离更近。
输入必须是经 ST_IsValidTrajectory 检查的有效轨迹。 如果轨迹在其 M 范围内不重叠,则返回 False。
可用性:2.2.0
该函数支持 3d 并且不会丢失 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