Returns the point on trajectory object 1 that is geometrically closest to trajectory object 2 within a given time window. The result is a geometry value representing the spatial position of traj1 at the moment of nearest approach.
Syntax
geometry ST_nearestApproachPoint(trajectory traj1, trajectory traj2)
geometry ST_nearestApproachPoint(trajectory traj1, trajectory traj2, tsrange range)
geometry ST_nearestApproachPoint(trajectory traj1, trajectory traj2, timestamp t1, timestamp t2)The second and third overloads restrict the evaluation to a time window, passed as a tsrange value or as explicit timestamp bounds.
Parameters
| Parameter | Description |
|---|---|
traj1 | The source trajectory. The returned point lies on this trajectory. |
traj2 | The reference trajectory to measure distance against. |
t1 | The start of the time window. |
t2 | The end of the time window. |
range | The time window as a tsrange value. |
Example
The following query finds the point on trajectory 1 that was closest to trajectory 2 between 13:00 and 14:00 on January 1, 2010.
SELECT ST_nearestApproachPoint(
(SELECT traj FROM traj_table WHERE id = 1),
(SELECT traj FROM traj_table WHERE id = 2),
'2010-1-1 13:00:00',
'2010-1-1 14:00:00'
);The query returns a geometry point representing the location of trajectory 1 at the moment it was nearest to trajectory 2 during the specified window.