ST_nearestApproachDistance
更新时间:
复制 MD 格式
Returns the minimum distance between a trajectory object and a geometry object within a specified time range. The return type is float8.
Syntax
float8 ST_nearestApproachDistance(trajectory traj, tsrange range, geometry g);
float8 ST_nearestApproachDistance(trajectory traj, timestamp t1, timestamp t2, geometry g);Two overloads are available: one accepts a tsrange value, the other accepts explicit start and end timestamps.
Parameters
| Parameter | Type | Description |
|---|---|---|
traj | trajectory | The trajectory object. |
range | tsrange | The time range. |
t1 | timestamp | The start time. |
t2 | timestamp | The end time. |
g | geometry | The geometry object to measure distance against. |
Example
The following query returns the minimum distance between each trajectory in traj_table and a line segment over a one-hour window.
-- Find the nearest approach distance between each trajectory and a line, from 13:00 to 14:00
SELECT ST_nearestApproachDistance(
traj,
'2010-01-01 13:00:00',
'2010-01-01 14:00:00',
'LINESTRING(0 0, 5 5, 9 9)'::geometry
) AS nearest_distance
FROM traj_table;该文章对您有帮助吗?