STS_TrajectoryIntersect function

The STS_TrajectoryIntersect function indicates whether the trajectory of an object intersected the region during the time range.

Syntax

STS_TrajectoryIntersect(
                        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_TrajectoryIntersect function to find out whether the specified object moved through the specified region during the specified time range. Intersection means either crossed the boundary of the region or remained within the boundary of the region.

The following image shows a trajectory that crosses the boundary of a region.

Figure 1: A trajectory that crosses a region

The image shows a circle with a trajectory that starts within it and continues across the boundary.

The following image shows a trajectory that is entirely within a region.

Figure 2: A trajectory within a region

The image shows a circle with a trajectory within it.

Returns

t = The trajectory of the object crossed the boundary of the region during the time range.

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

f = The trajectory of the object did not intersect the region during the time range.

An exception = An error.

Example

The following query returns whether any vehicles intersected the specified region between the times 2015-06-14 12:30:00 and 2015-06-14 13:00:00:

SELECT modid, STS_TrajectoryIntersect(ts_track, 
         '2015-06-14 12:30:00', '2015-06-14 13:00:00',
         ST_Buffer('4326 point(-78.704122 43.919747)', 100.0, 'meter')) 
         FROM t_vehicle;

modid                                      (expression)

1001                                                 f
1002                                                 t

2 row(s) retrieved.

Vehicle 1002 intersected the region.