この関数は、MEAN-MAX アルゴリズムを使用して、属性フィールドの最大平均値を返します。
構文
SETOF record ST_trajAttrsMeanMax(trajectory traj, cstring attr_field_name, out interval duration, out float8 max);
パラメーター
パラメーター | 説明 |
---|---|
traj | 軌道オブジェクトです。 |
attr_field_name | 指定された属性フィールドの名前です。 |
説明
MEAN-MAX アルゴリズムは、スライディングウィンドウを使用して、ウィンドウで指定された各時間範囲の指定された属性フィールドの平均値を計算し、すべての平均値の最大値を返します。
この関数は、整数型と浮動小数点型の属性フィールドのみをサポートします。 指定された属性フィールドの値を 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)