Filters trajectory points by a timestamp attribute field and returns the matching attribute values as a timestamp[] array. Use a single value to filter by exact comparison, or two values to filter by range.
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);Parameters
| Parameter | Description |
|---|---|
traj | The trajectory object. |
attr_field_name | The name of the attribute field to filter on. |
operator | The filter operator. Valid values: '=', '!=', '>', '<', '>=', '<=', '[]', '(]', '[)', '()'. |
value / value1 | The filter value (single-value overload), or the lower bound of the range (range overload). |
value2 | The upper bound of the range. Required only for the range overload. |
The interval operators follow standard mathematical notation: [] is closed on both ends, () is open on both ends, [) is closed-open, and (] is open-closed.
Examples
Insert a trajectory with a heading attribute of type timestamp, then filter for points where heading is later than 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;Expected output:
st_attrtimestampfilter
-------------------------
{"2010-01-01 15:30:00"}
(1 row)该文章对您有帮助吗?