Name

|=| — 返回 A 和 B 轨迹在最接近点处的距离。

Synopsis

double precision |=|( geometry A , geometry B );

描述

The |=| operator returns the 3D distance between two trajectories (See ST_IsValidTrajectory). This is the same as ST_DistanceCPA but as an operator it can be used for doing nearest neighbor searches using an N-dimensional index.

[Note]

该操作数将利用几何上可能可用的 ND GiST 索引。 它与其他使用空间索引的运算符不同,只有当该运算符位于 ORDER BY 子句中时才会使用空间索引。

[Note]

仅当其中一个几何图形是常量(不在子查询/cte 中)时,索引才会启动。 例如 'SRID=3005;LINESTRINGM(0 0 0,0 0 1)'::geometry 而不是 a.geom

Availability: 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)