为轨迹增加一个新的属性。
语法
trajectory ST_InsertAttr(trajectory traj, anyarray arr, text name, integer loc default -1);
返回值
返回增加属性后的新轨迹。
参数
参数名称 | 描述 |
traj | 原轨迹。 |
arr | 一个数组,包含新增属性的值。 |
name | 新增属性的名称。 |
loc | 新增属性插入的位置,取值范围为[-n,n],n为原有属性数量。
|
描述
将一个数组作为一列新属性插入到轨迹中。
示例
With traj as (select ST_MakeTrajectory('STPOINT'::leaftype,
st_geomfromtext('LINESTRING (114 35, 115 36, 116 37)', 4326),
'[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange,
'{"leafcount":3,"attributes":{"velocity": {"type": "integer", "length": 2,"nullable" : true,"value": [120, 130, 140]}, "accuracy": {"type": "float", "length": 4, "nullable" : false,"value": [120, 130, 140]}, "bearing": {"type": "float", "length": 8, "nullable" : false,"value": [120, 130, 140]}, "acceleration": {"type": "string", "length": 20, "nullable" : true,"value": ["120", "130", "140"]}, "active": {"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"]}}}') as tj)
SELECT ST_InsertAttr(tj, ARRAY[1, 4, 6], 'add', 3) from traj;
返回结果:
{"trajectory":{"version":1,"type":"STPOINT","leafcount":3,"start_time":"2010-01-01 14:30:00","end_time":"2010-01-01 15:30:00","spatial":"SRID=4326;LINESTRING(114 35,115 36,116 37)","timeline":["2010-01-01 14:30:00","2010-01-01 15:00:00","2010-01-01 15:30:00"],"attributes":{"leafcount":3,"velocity":{"type":"integer","length":2,"nullable":true,"value":[120,130,140]},"accuracy":{"type":"float","length":4,"nullable":false,"value":[120.0,130.0,140.0]},"bearing":{"type":"float","length":8,"nullable":false,"value":[120.0,130.0,140.0]},"add":{"type":"integer","length":4,"nullable":true,"value":[1,4,6]},"acceleration":{"type":"string","length":20,"nullable":true,"value":["120","130","140"]},"active":{"type":"timestamp","length":8,"nullable":false,"value":["2010-01-01 14:30:00","2010-01-01 15:00:00","2010-01-01 15:30:00"]}}}}
文档内容是否对您有帮助?