ST_distanceWithin

更新时间:
复制 MD 格式

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

ParameterTypeDescription
trajtrajectoryThe trajectory object to test.
rangetsrangeThe time range. Used in the first overload.
t1timestampThe start time. Used in the second overload.
t2timestampThe end time. Used in the second overload.
ggeometryThe specified geometry object.
dfloat8The 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
 f

Both rows return f (false), meaning neither trajectory came within 10 units of the linestring during the time window.