Returns a new trajectory object that indicates the difference between a trajectory object within the specified time range and the specified geometry object.
Syntax
trajectory ST_difference(trajectory traj, tsrange range, geometry g);
trajectory ST_difference(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 source trajectory to evaluate. |
range | tsrange | The time range to evaluate. |
t1 | timestamp | The start of the time range to evaluate. |
t2 | timestamp | The end of the time range to evaluate. |
g | geometry | The geometry object to subtract from the trajectory. |
Example
SELECT ST_difference(traj, '2010-1-1 13:00:00', '2010-1-1 14:00:00', 'LINESTRING(0 0, 5 5, 9 9)'::geometry)
FROM traj_table;