Converts a trajectory from Protobuf format to the trajectory data type.
Syntax
trajectory ST_TrajFromProtobuf(bytea protobuf);Parameters
| Parameter | Description |
|---|---|
protobuf | A trajectory encoded in Protobuf format. For the Protobuf schema definition, see ST_AsProtobuf. |
Return value
Returns a trajectory object. Returns NULL if Protobuf parsing fails.
Example
The following example uses ST_AsProtobuf to encode a trajectory into Protobuf format, then passes the result to ST_TrajFromProtobuf to convert it back to the trajectory data type.
SELECT ST_TrajFromProtobuf(
ST_AsProtobuf(
st_makeTrajectory(
'STPOINT'::leaftype,
ARRAY[1::float8],
ARRAY[2::float8],
4326,
ARRAY['2010-01-01 11:30'::timestamp],
ARRAY['velocity'],
ARRAY[1::int4],
NULL,
NULL,
NULL::anyarray
)
)
);Output:
st_trajfromprotobuf
---------------------------
{"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 ...该文章对您有帮助吗?