全部產品
Search
文件中心

ApsaraDB RDS:ST_Resample

更新時間:Feb 28, 2024

對一條軌跡重採樣。

文法

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)