將一個軌跡對象轉換為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
}
}
描述
將一條軌跡轉換為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...