根據MEAN-MAX算法,計算出每個時間段內的均值的最大值。
語法
SETOF record ST_trajAttrsMeanMax(trajectory traj, cstring attr_field_name, out interval duration, out float8 max);
參數
參數名稱 | 描述 |
traj | 軌跡對象。 |
attr_field_name | 指定的屬性名稱。 |
描述
Mean-Max 算法通過一個滑動窗口,分別計算出落入該窗口的屬性值的平均值,再求出所有均值的最大值。
該函數僅對integer和float類型的屬性值有效。屬性值不能為NULL。
示例
With traj AS (
Select ST_makeTrajectory('STPOINT', 'LINESTRING(1 1, 6 6, 9 8, 10 12)'::geometry,
ARRAY['2010-01-01 11:30'::timestamp, '2010-01-01 12:30', '2010-01-01 13:30', '2010-01-01 14:30'],
'{"leafcount":4, "attributes":{"velocity": {"type": "float", "length": 8,"nullable" : true,"value": [120.0, 130.0, 140.0, 120.0]}, "power": {"type": "float", "length": 4,"nullable" : true,"value": [120.0, 130.0, 140.0, 120.0]}}}') a)
Select st_trajAttrsMeanMax(a, 'velocity') from traj;
st_trajattrsmeanmax
---------------------
("@ 1 hour",135)
("@ 2 hours",130)
("@ 3 hours",127.5)
(3 rows)
With traj AS (
Select ST_makeTrajectory('STPOINT', 'LINESTRING(1 1, 6 6, 9 8, 10 12)'::geometry,
ARRAY['2010-01-01 11:30'::timestamp, '2010-01-01 12:30', '2010-01-01 13:30', '2010-01-01 14:30'],
'{"leafcount":4, "attributes":{"velocity": {"type": "float", "length": 8,"nullable" : true,"value": [120.0, 130.0, 140.0, 120.0]}, "power": {"type": "float", "length": 4,"nullable" : true,"value": [120.0, 130.0, 140.0, 120.0]}}}') a)
Select (st_trajAttrsMeanMax(a, 'velocity')).* from traj;
duration | max
----------+-------
01:00:00 | 135
02:00:00 | 130
03:00:00 | 127.5
(3 rows)
文檔內容是否對您有幫助?