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
| Parameter | Description |
|---|---|
traj | The trajectory object. |
attr_field_name | The name of the attribute field to filter on. |
operator | The comparison operator. Valid values: '=', '!=', '>', '<', '>=', '<=', '[]', '(]', '[)', '()'. |
value | The fixed value to compare against. Used with the first signature. |
value1 | The lower bound of the value range. Used with the second signature. |
value2 | The 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)Is this page helpful?