Converting the vehiclePositions.pb file

1,571 views
Skip to first unread message

Drew werD

unread,
Jan 11, 2017, 2:30:51 PM1/11/17
to GTFS-realtime
Is there any advice on how to convert the vehiclePositions.pb to json or xml or plain text, using a scripting language, ie JavaScript, Classic ASP, PHP?

Thanks in advice.

Stefan de Konink

unread,
Jan 11, 2017, 2:36:38 PM1/11/17
to gtfs-r...@googlegroups.com
On Wednesday, January 11, 2017 8:30:51 PM CET, Drew werD wrote:
> Is there any advice on how to convert the vehiclePositions.pb
> to json or xml or plain text, using a scripting language, ie
> JavaScript, Classic ASP, PHP?

Mmm... I would suggest to implement procolbuffers. Or use a tool that works
with protocol buffers and export it as json.

--
Stefan

Drew werD

unread,
Jan 11, 2017, 2:54:06 PM1/11/17
to GTFS-realtime
Yes, but how? I'm looking for some tutorials or examples to read the PB file, so I can provide specific data in json for a web app. 

"then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages."

Stefan de Konink

unread,
Jan 11, 2017, 2:56:52 PM1/11/17
to gtfs-r...@googlegroups.com
On woensdag 11 januari 2017 20:54:05 CET, Drew werD wrote:
> Yes, but how? I'm looking for some tutorials or examples to
> read the PB file, so I can provide specific data in json for a
> web app.
>
> "then you can use special generated source code to easily write
> and read your structured data to and from a variety of data
> streams and using a variety of languages."

Which search terms did you use? I used google protocol buffers php.

https://github.com/protobuf-php/protobuf

--
Stefan

Sean Barbeau

unread,
Jan 12, 2017, 12:59:12 PM1/12/17
to GTFS-realtime
The official protocol buffers bindings project for GTFS-rt is:

Among others, there are libraries for:

Sean

Neville Dipale

unread,
Jan 12, 2017, 1:31:31 PM1/12/17
to GTFS-realtime
If you want to use JavaScript, there is Protobuf.js (https://github.com/dcodeIO/ProtoBuf.js/), from which you can take one of the examples and replace the protobuf file with the VehiclePositions one, and just map variables around to see how it works.

I think that would be the easiest solution if you're not very familiar with how protobufs work. Otherwise it's a good idea to Google tutorials for your preferred language.

Regards
Reply all
Reply to author
Forward
0 new messages