PostGIS
Description
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 (requires PostgreSQL 9.5.0 or higher).
|
|
Availability: 2.2.0. Index-supported only available for PostgreSQL 9.5+
Examples
-- 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)