|=| — 返回 A 和 B 轨迹在最接近点处的距离。
double precision |=|( geometry A , geometry B );
|=| 运算符返回两个轨迹的 3D 距离(参见 ST_IsValidTrajectory)。它的作用等同于 ST_DistanceCPA,但作为运算符可以结合 N 维索引用于最近邻搜索。
|
|
|
该操作数将利用几何上可能可用的 ND GiST 索引。 它与其他使用空间索引的运算符不同,只有当该运算符位于 ORDER BY 子句中时才会使用空间索引。 |
|
|
|
仅当其中一个几何图形是常量(不在子查询/cte 中)时,索引才会启动。 例如 'SRID=3005;LINESTRINGM(0 0 0,0 0 1)'::geometry 而不是 a.geom |
可用性:2.2.0。
-- Save a literal query trajectory in a psql variable...
\set qt 'ST_AddMeasure(ST_MakeLine(ST_MakePointM(-350,300,0),ST_MakePointM(-410,490,0)),10,20)'
-- Run the query !
SELECT track_id, dist FROM (
SELECT track_id, ST_DistanceCPA(tr,:qt) dist
FROM trajectories
ORDER BY tr |=| :qt
LIMIT 5
) foo;
track_id dist
----------+-------------------
395 | 0.576496831518066
380 | 5.06797130410151
390 | 7.72262293958322
385 | 9.8004461358071
405 | 10.9534397988433
(5 rows)