指定された範囲と指定された解像度に基づいて、軌道オブジェクトのセットをヒートマップタイル (H個のM個のT個) に変換します。
構文
bytea ST_AsHMT(trajectory trajectory_set, geometry extent, int4 width, int4 height, int4 value default 1, boolean point_mode default false);
bytea ST_AsHMT(trajectory trajectory_set, geometry extent, int4 width, int4 height, int4 value);
bytea ST_AsHMT(trajectory trajectory_set, geometry extent, int4 width, int4 height, int4 value, boolean point_mode);
bytea ST_AsHMT(trajectory trajectory_set, geometry extent, int4 width, int4 height, float8 value);
bytea ST_AsHMT(trajectory trajectory_set, geometry extent, int4 width, int4 height, float8 value, boolean point_mode);戻り値
行列内の各点の値を表すProtobufベースのバイナリデータ構造を返します。 次のサンプルProtobufファイルを参照してください。
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
message HMT {
required Type type = 1; // data value type
required uint32 rows = 2; // rows of matrix
required uint32 columns = 3; // columns of matrix
required uint32 srid = 4; // columns of matrix
required float xmin = 5; // xmin
required float ymin = 6; // ymin
required float xmax = 7; // xmax
required float ymax = 8; // ymax
oneof matrix {
intMatrix intValues = 10;
doubleMatrix doubleValues = 11;
}
message intMatrix {
repeated sint32 values = 12 [packed = true];
}
message doubleMatrix {
repeated double values = 13 [packed = true];
}
enum Type {
INT32 = 0;
DOUBLE = 1;
}
}
説明
Type値は入力パラメーターによって指定され、int32またはdoubleにすることができます。 int32タイプは数量などの情報を計算するために使用され、doubleタイプはメトリクスなどの情報を計算するために使用されます。
行の値は、行列の行の数を表し、列の値は、行列の列の数を表す。
行列内の値は、typeで指定された型の配列であり、行ごとに編成されます。
ST_HMTAsArray関数を使用して、返された値を配列に変換できます。
Parameters
項目 | 説明 |
geometry_set | 集計関数で使用されるジオメトリ列フィールド。 |
extent | 取得する地理的範囲。 境界ボックスのみが得られる。 このパラメーターは、ST_TileEnvelope関数と組み合わせて使用できます。 |
width | 結果の列に対応する行列の幅。 |
height | 結果の行に対応する行列の高さ。 |
value | 計算される値。 指定された値の合計が計算されます。 |
point_mode | ポイントモードを有効にするかどうか。 ポイントモードを使用すると、行列内のポイントの値のみが計算されます。 |
説明
指定された範囲と指定された解像度に基づいて、一連の軌道オブジェクトをヒートマップタイルに変換します。
例
-- create table
CREATE test_table AS
SELECT i as num,
st_maketrajectory('STPOINT'::leaftype,
st_MakeLine(ST_Point(i::numeric/10, i::numeric/10), ST_Point((i+10)::numeric/10, (i+10)::numeric/10)),
'[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange, NULL) as traj,
i*100::int4 weight,
i*i*i::float8 volume
FROM generate_series(1, 100) i;
-- count quantity
SELECT ST_AsHMT(traj, --trajectory type
ST_MakeEnvelope(0, 0, 10, 10), -- Extent
1024, -- Width, in pixel
800 -- height
)
FROM test_table;
---------
\x080010a0061880083284...
-- count value
SELECT ST_AsHMT(traj, --trajectory type
ST_MakeEnvelope(0, 0, 10, 10), -- Extent
1024, -- Width
800, -- height
weight -- value column
)
FROM test_table;
---------
\x080010a0061880...
-- complex count
SELECT ST_AsHMT(traj, --trajectory type
ST_MakeEnvelope(0, 0, 10, 10), -- Extent
1024, -- Width
800, -- height
weight / volume * 1.2 -- complex value
)
FROM test_table;
---------
\x080110a0061880083a85...
-- point mode
SELECT ST_AsHMT(traj, --trajectory type
ST_MakeEnvelope(0, 0, 10, 10), -- Extent
1024, -- Width, in pixel
800, -- height,
1::integer, -- value
true -- point mode
)
FROM test_table;
---------
\x080010a0061880083...
-- where clause
SELECT ST_AsHMT(traj, --trajectory type
ST_MakeEnvelope(0, 0, 10, 10), -- Extent
1024, -- Width, in pixel
800 -- height
)
FROM test_table
WHERE num <5;
---------
\x080010a00618...