ST_nearestApproachDistance

Updated at:

Returns the minimum distance between two trajectory objects at their closest point of approach. Optionally, restrict the calculation to a specific time window.

Syntax

float8 S​T_nearestApproachDistance(trajectory traj,  trajectory traj2);
float8 S​T_nearestApproachDistance(trajectory traj,  trajectory traj2, tsrange range);
float8 S​T_nearestApproachDistance(trajectory traj,  trajectory traj2, timestamp t1, timestamp t2);

Parameters

Parameter name

Description

traj1

Trajectory object 1.

traj2

Trajectory object 2.

t1

The start time.

t2

The end time.

range

The time range.

Example

The following example retrieves two trajectories from traj_table and returns the minimum distance between them between 13:00 and 14:00 on January 1, 2010.

Select ST_nearestApproachDistance((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');