文档

ST_AsTableFormat

更新时间:

获取一条轨迹的定义,用于在ST_AsTable函数中指定列类型。

语法

text ST_AsTableFormat(trajectory traj);

参数

参数名称

描述

traj

原始轨迹。

描述

此函数用于获取一条轨迹的定义,并以文本的形式输出Record type,在ST_AsTable函数将一条轨迹转化成表时被使用。

例如:如果需要将一个轨迹转化成表,则先通过此函数获得其定义为(t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer),再通过下列语句,将轨迹转化为拥有特定列的表格。

SELECT f.* FROM table_name, ST_AsTable(traj) AS f(t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer);

示例

SELECT ST_AsTableFormat('{"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 11:30:00","spatial":"SRID=4326;POINT(1 1)","timeline":["2010-01-01 11:30:00"],"attributes":{"leafcount":1,"i1":{"type":"integer","length":1,"nullable":true,"value":[1]},"i2":{"type":"integer","length":2,"nullable":true,"value":[1]},"i4":{"type":"integer","length":4,"nullable":true,"value":[1]},"i8":{"type":"integer","length":8,"nullable":true,"value":[1]}, "f4":{"type":"float","length":4,"nullable":true,"value":[1]},"f8":{"type":"float","length":8,"nullable":true,"value":[1]},"string":{"type":"string","length":10,"nullable":true,"value":["fat"]},"timestamp":{"type":"timestamp","length":8,"nullable":true,"value":["2010-01-01 11:30:00"]},"bool":{"type":"bool","length":1,"nullable":true,"value":["true"]}}}}'::trajectory);
-----
(t timestamp, x double precision, y double precision, i1 integer, i2 smallint, i4 integer, i8 bigint, f4 real, f8 double precision, string text, timestamp timestamp, bool boolean)