ST_attrTimestampFilter

Updated at:
Copy as MD

Filters trajectory points by the value of a specified attribute field and returns an array of matching attribute field values.

Syntax

timestamp[] ST_attrTimestampFilter(trajectory traj, cstring attr_field_name, cstring operator, timestamp value);
timestamp[] ST_attrTimestampFilter(trajectory traj, cstring attr_field_name, cstring operator, timestamp value1, timestamp value2);

Use the first signature to filter by a fixed value. Use the second signature to filter by a value range.

Parameters

ParameterDescription
trajThe trajectory object.
attr_field_nameThe name of the attribute field to filter on.
operatorThe comparison operator. Valid values: '=', '!=', '>', '<', '>=', '<=', '[]', '(]', '[)', '()'.
valueThe fixed value to compare against. Used with the first signature.
value1The lower bound of the value range. Used with the second signature.
value2The upper bound of the value range. Used with the second signature.

Examples

Insert a trajectory with a heading attribute field of type timestamp, then filter points where heading is after 2010-01-01 15:00:00.

INSERT INTO traj VALUES(3, ST_makeTrajectory('STPOINT'::leaftype, st_geomfromtext('LINESTRING (114 35, 115 36, 116 37)', 4326), ARRAY['2010-01-01 14:30'::timestamp, '2010-01-01 15:00', '2010-01-01 15:30'], '{"leafcount": 3, "attributes": {"heading": {"type": "timestamp", "nullable": false,"value":["Fri Jan 01 14:30:00 2010", "Fri Jan 01 15:00:00 2010", "Fri Jan 01 15:30:00 2010"]}}}'));

SELECT st_attrTimestampFilter(traj, 'heading', '>', 'Fri Jan 01 15:00:00 2010'::timestamp) FROM traj WHERE id = 3;

Output:

 st_attrtimestampfilter
-------------------------
{"2010-01-01 15:30:00"}
(1 row)