STS_TrajectoryDistance function
The STS_TrajectoryDistance function returns the shortest distance between the specified point and the trajectory of the specified moving object in the specified time range.
Syntax
STS_TrajectoryDistance(
ts TimeSeries,
begin_time DATETIME YEAR TO FRACTION(5),
end_time DATETIME YEAR TO FRACTION(5),
point ST_Point,
max_distance FLOAT)
returns FLOAT
STS_TrajectoryDistance(
ts TimeSeries,
begin_time DATETIME YEAR TO FRACTION(5),
end_time DATETIME YEAR TO FRACTION(5),
point ST_Point,
max_distance FLOAT,
uom VARCHAR(128))
returns FLOAT
- 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.
- point
- An ST_Point object.
- max_distance
- The distance from the point that defines the region of interest. The unit of measure is specified by the uom parameter.
- uom (Optional)
- The unit of measure for the radius parameter. If unitOfMeasure is not specified, then it is meter for a geographic coordinate systems, and, it is the linear unit of measure for projected coordinate systems. If the projected coordinate system does not have a linear unit of measure specified, it is meter. Must be the name of a linear unit of measure from the unit_name column of the st_units_of_measure table.
Usage
Run the STS_TrajectoryDistance function to find how close an object came to a specific point during a time range.
The following illustration shows a trajectory near the point (-78.7043 42.9197). A line connects the closest part of the trajectory to the point.
Returns
A FLOAT value = The distance in the specified unit of measure.
NULL = Nothing found.
Example
The following query returns the shortest distance of vehicle 1002 from the specified location between the times of 2015-06-14 12:30:00 and 2015-06-14 13:00:00:
SELECT modid, round(STS_TrajectoryDistance(ts_track,
'2015-06-14 12:30:00', '2015-06-14 13:00:00',
'4326 point(-78.7043 43.9197)', 10.0, 'meter'), 1)
FROM t_vehicle
WHERE modid = 1002;
modid (expression)
1002 4.3
1 row(s) retrieved.