All Products
Search
Document Center

PolarDB:ST_TrajFromProtobuf

Last Updated:Mar 30, 2026

Converts Protocol Buffers (Protobuf) binary data into a trajectory object.

Syntax

trajectory ST_TrajFromProtobuf(bytea protobuf)

Parameters

Parameter Description
protobuf A bytea value containing Protobuf-encoded trajectory data. For the expected schema, see .

Return values

Returns a trajectory object. Returns NULL if the input cannot be parsed.

Example

The following query round-trips a trajectory through Protobuf encoding and decoding: st_makeTrajectory builds the trajectory, ST_AsProtobuf serializes it to bytea, and ST_TrajFromProtobuf deserializes it back to a trajectory object.

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 ...