STS_TrajectoryWithin function

The STS_TrajectoryWithin function indicates whether the trajectory of a specified object stayed within the specified region during the specified time range.

Syntax

STS_TrajectoryWithin(
                        ts           TimeSeries,
                        begin_time   DATETIME YEAR TO FRACTION(5),
                        end_time     DATETIME YEAR TO FRACTION(5),
                        geometry     ST_Geometry)
returns Boolean
ts
The name of the time series.
begin_time
The start of the time range. Can be NULL to indicate the first element in the time series.
end_time
The end of the time range. Can be NULL to indicate the last element in the time series.
geometry
The region of interest. Can be an ST_Point, ST_MultiPoint, ST_LineString, ST_MultiLineString, ST_Polygon, or ST_MultiPolygon. Must use the SRID 4326.

Usage

Run the STS_TrajectoryWithin function to find out whether an object stayed within a region during the entire time range.

Returns

t = The trajectory of the object was within the region during the time range.

f = The trajectory of the object was not within the region during the time range.

An exception = An error.

Example

The following query returns whether the vehicles had trajectories that were always within the region:

SELECT modid, STS_TrajectoryWithin(ts_track, NULL, NULL,
         ST_Buffer('4326 LINESTRING (-78.703923 43.919695, 
                   -78.704498 43.919757)'::st_linestring, 20.0, 'meter'))
         FROM t_vehicle;

modid                                           (expression)

1001                                                      f
1002                                                      t

2 row(s) retrieved.

Vehicle 1002 always stayed within the region.