Returns true if the distance between a trajectory object within the specified time range and the specified geometry object is within the reference distance.
Syntax
boolean ST_distanceWithin(trajectory traj, tsrange range, geometry g, float8 d);
boolean ST_distanceWithin(trajectory traj, timestamp t1, timestamp t2, geometry g, float8 d);Both overloads accept the time range either as a tsrange value or as discrete t1/t2 timestamps.
Parameters
| Parameter | Type | Description |
|---|---|---|
traj | trajectory | The trajectory object to test. |
range | tsrange | The time range. Used in the first overload. |
t1 | timestamp | The start time. Used in the second overload. |
t2 | timestamp | The end time. Used in the second overload. |
g | geometry | The specified geometry object. |
d | float8 | The reference distance. |
Example
The following query tests whether each trajectory in traj_table came within a distance of 10 from the linestring LINESTRING(0 0, 5 5, 9 9) between 13:00 and 14:00 on January 1, 2010.
SELECT ST_distanceWithin(
traj,
'2010-1-1 13:00:00',
'2010-1-1 14:00:00',
'LINESTRING(0 0, 5 5, 9 9)'::geometry,
10
)
FROM traj_table;Output:
st_distancewithin
-------------------
f
fBoth rows return f (false), meaning neither trajectory came within 10 units of the linestring during the time window.
该文章对您有帮助吗?