ST_attrTimestampFilter

更新时间:
复制 MD 格式

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

ParameterDescription
trajThe trajectory object.
attr_field_nameThe name of the attribute field to filter on.
operatorThe filter operator. Valid values: '=', '!=', '>', '<', '>=', '<=', '[]', '(]', '[)', '()'.
value / value1The filter value (single-value overload), or the lower bound of the range (range overload).
value2The 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)