文档

ST_Resample

更新时间:

对一条轨迹重采样。

语法

trajectory ST_Resample(trajectory traj, config);

参数

参数名称

描述

traj

被重采样的轨迹对象。

config

重采样轨迹的规则。格式{"规则":"取值"}

目前包含以下可选规则,每次调用此函数时,仅可选择一个规则:

规则名称

参数类型

说明

add_point.distance_lesser

浮点数

在每条轨迹线上均匀添加点,使每一段之间的距离均小于参数。

add_point.period_lesser

可以转化为Interval类型的字符串

在每条轨迹线上均匀添加点,使每一段的时长均小于参数。

drop_point.distance_lesser

浮点数

如果相邻多段轨迹线段上所有的点到起点的长度,均小于此参数给定的空间长度时,将其合并(仅保留起点和终点)。

drop_point.period_lesser

可以转化为Interval类型的字符串

当相邻多段轨迹线段的时间长度之和小于给定的时间长度时,将其合并(仅保留起点和终点)。

描述

根据提前设定的规则对轨迹对象重采样,返回重采样后的轨迹。

示例

With traj As
(
  select '{"trajectory":{"version":1,"type":"STPOINT","leafcount":5,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,10 10,11 11,13 13,15 15)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00"]}}'::trajectory a
)
SELECT ST_Resample(a, '{"add_point.distance_lesser":3}') from traj;
                                                                                                                                                                                                              st_resample                                                                                                                                                                                                               
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"trajectory":{"version":1,"type":"STPOINT","leafcount":9,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,2.8 2.8,4.6 4.6,6.4 6.4,8.2 8.2,10 10,11 11,13 13,15 15)","timeline":["2000-01-01 00:00:00","2000-01-01 04:48:00","2000-01-01 09:36:00","2000-01-01 14:24:00","2000-01-01 19:12:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00"]}}
(1 row)

With traj As
(
  select '{"trajectory":{"version":1,"type":"STPOINT","leafcount":5,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,10 10,11 11,13 13,15 15)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00"]}}'::trajectory a
)
SELECT ST_Resample(a, '{"add_point.period_lesser":"0.5 day"}') from traj;
                                                                                                                                                                                                             st_resample                                                                                                                                                                                                              
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"trajectory":{"version":1,"type":"STPOINT","leafcount":9,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,5.5 5.5,10 10,10.5 10.5,11 11,12 12,13 13,14 14,15 15)","timeline":["2000-01-01 00:00:00","2000-01-01 12:00:00","2000-01-02 00:00:00","2000-01-02 12:00:00","2000-01-03 00:00:00","2000-01-03 12:00:00","2000-01-04 00:00:00","2000-01-04 12:00:00","2000-01-05 00:00:00"]}}
(1 row)

With traj As
(
  select '{"trajectory":{"version":1,"type":"STPOINT","leafcount":5,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,10 10,11 11,13 13,15 15)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00"]}}'::trajectory a
)
SELECT ST_Resample(a, '{"drop_point.distance_lesser":3}') from traj;
                                                                                                                                    st_resample                                                                                                                                     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"trajectory":{"version":1,"type":"STPOINT","leafcount":4,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"LINESTRING(1 1,10 10,13 13,15 15)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00"]}}
(1 row)
  • 本页导读 (1)
文档反馈