ST_eventType
更新时间:
复制 MD 格式
Returns the type ID of the event at the specified index in a trajectory object.
Syntax
integer ST_eventType(trajectory traj, integer index)Parameters
| Parameter | Description |
|---|---|
traj | The trajectory object. |
index | The zero-based index of the event. |
Usage notes
The type ID is the integer key of the event entry in the trajectory's events JSON array. For example, in {"1": "Fri Jan 01 14:30:00 2010"}, the type ID is 1.
Examples
The following example retrieves the type ID of the first event (index 0) in a trajectory that has two events with type IDs 1 and 2.
WITH traj AS (
-- A trajectory with two events: type ID 1 and type ID 2
SELECT '{"trajectory":{"version":1,"type":"STPOINT","leafcount":2,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 12:30:00","spatial":"SRID=4326;LINESTRING(1 1,3 5)","timeline":["2010-01-01 11:30:00","2010-01-01 12:30:00"],"attributes":{"leafcount":2,"velocity":{"type":"integer","length":4,"nullable":true,"value":[1,null]},"speed":{"type":"float","length":8,"nullable":true,"value":[null,1.0]},"angle":{"type":"string","length":64,"nullable":true,"value":["test",null]}, "tngel2":{"type":"timestamp","length":8,"nullable":true,"value":["2010-01-01 12:30:00",null]},"bearing":{"type":"bool","length":1,"nullable":true,"value":[null,true]}},"events":[{"1":"Fri Jan 01 14:30:00 2010"},{"2":"Fri Jan 01 14:30:00 2010"}]}}'::trajectory a
)
SELECT ST_eventType(a, 0) FROM traj;Result:
st_eventtype
--------------
1What's next
ST_eventCount: Get the total number of events in a trajectory.
ST_eventTime: Get the timestamp of an event at a specified index.
该文章对您有帮助吗?