|=| — 返回轨迹 A 和轨迹 B 在它们最近接近点之间的距离。
double precision |=|( geometry A , geometry B );
|=| 运算符返回两个轨迹之间的 3D 距离 (参见 ST_IsValidTrajectory)。这与 ST_DistanceCPA 相同,但作为运算符,它可以用于使用 N 维索引进行最近邻搜索(需要 PostgreSQL 9.5.0 或更高版本)。
|
|
|
此操作数将利用几何图形上可能存在的 ND GiST 索引。它与其他使用空间索引的运算符不同,因为空间索引仅在运算符位于 ORDER BY 子句中时才使用。 |
|
|
|
仅当其中一个几何图形是常量(不在子查询/cte 中)时,索引才会生效。 例如 'SRID=3005;LINESTRINGM(0 0 0,0 0 1)'::geometry 而不是 a.geom |
可用性: 2.2.0。仅 PostgreSQL 9.5+ 版本支持索引。
-- 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)