Returns true if the distance between two trajectory objects within the specified time range is within the reference distance.
Syntax
boolean ST_distanceWithin(trajectory traj1, trajectory traj2, tsrange range, float8 d);
boolean ST_distanceWithin(trajectory traj1, trajectory traj2, timestamp t1, timestamp t2, float8 d);Parameters
| Parameter | Type | Description |
|---|---|---|
traj1, traj2 | trajectory | The trajectory objects to compare. |
range | tsrange | The time range to check. Use either this parameter or t1/t2, not both. |
t1 | timestamp | The start of the time range. |
t2 | timestamp | The end of the time range. |
d | float8 | The reference distance. |
Examples
Check whether two vehicles come within 100 meters of each other between 13:00 and 14:00:
SELECT ST_distanceWithin(
(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',
100
);Use a tsrange value to check proximity within a time window:
SELECT ST_distanceWithin(
(SELECT traj FROM traj_table WHERE id = 1),
(SELECT traj FROM traj_table WHERE id = 2),
'[2010-01-01 13:00:00, 2010-01-01 14:00:00]'::tsrange,
100
);该文章对您有帮助吗?