ST_AsProtobuf関数を使用して、データ交換用に軌道オブジェクトをProtobuf (Pbf) 形式に変換できます。
構文
bytea ST_AsProtobuf(trajectory traj);パラメーター
パラメーター | 説明 |
traj | 変換する軌道。 |
戻り値
Protobuf形式の軌道オブジェクトを返します。
次のProtobuf定義を参照してください。
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
message Trajectory {
required uint32 srid = 1 [default = 4326]; // Srid
repeated Field fields = 2; // Fields definitions
repeated Point points = 3; // All trajectory Point
repeated Event events = 4; // Events
message Field {
required string name = 11; // Field Name
required FieldType type = 12; // Field Type
required uint32 length = 13; // Field length
required bool nullable = 14 [default = false]; // Field Nullable
}
message Value {
required bool is_null = 21 [default = false]; // Is null
oneof value_type {
string string_value = 22; // string value
double double_value = 23; // double value
float float_value = 24; // float value
sint32 int32_value = 25; // int32 value, int8 and int16 will in this value
sint64 int64_value = 26; // int64 value
bool bool_value = 27; // bool value
uint64 timestamp_value = 28; // timestamp value
}
}
enum FieldType {
string_type = 31;
double_type = 32;
integer_type = 33;
bool_type = 34;
timestamp_type = 35;
}
message Point {
required double x = 41; // x coordinate
required double y = 42; // y coordinate
optional double z = 43; // z value , optional
optional double m = 44; // m value, optional
required uint64 timestamp = 45; // timestamp
repeated Value attributes = 46; // all attribute values
}
message Event {
required int32 type = 51; // event type
required uint64 timestamp = 52; // timestamp
}
}説明
ST_AsProtobuf関数は、データ交換または表示のために軌道オブジェクトをProtobuf形式に変換するために使用されます。
例:
SELECT ST_AsProtobuf(ST_MakeTrajectory('STPOINT'::leaftype, st_geomfromtext('LINESTRING (114 35, 115 36, 116 37)', 4326), '[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange, '{"leafcount":3,"attributes":{"velocity": {"type": "integer", "length": 2,"nullable" : true,"value": [120, 130, 140]}, "accuracy": {"type": "float", "length": 4, "nullable" : false,"value": [120, 130, 140]}, "bearing": {"type": "float", "length": 8, "nullable" : false,"value": [120, 130, 140]}, "vesname": {"type": "string", "length": 20, "nullable" : true,"value": ["adsf", "sdf", "sdfff"]}, "active": {"type": "timestamp", "nullable" : false,"value": ["Fri Jan 01 14:30:00 2010", "Fri Jan 01 15:00:00 2010", "Fri Jan 01 15:30:00 2010"]}}, "events": [{"1" : "Fri Jan 01 14:30:00 2010"}, {"2" : "Fri Jan 01 15:00:00 2010"}, {"3" : "Fri Jan 01 15:30:00 2010"}]}'));
---
st_asprotobuf
---------------------
\x08e62112105a0876656c6f63...