Supporting "protocol buffers" for more languages

302 views
Skip to first unread message

Michael Sanderson

unread,
Oct 7, 2013, 12:05:06 AM10/7/13
to mtadevelop...@googlegroups.com
Hi,

I've lost days and days over the past few months with nothing to show for it periodically making new attempts to figure out how to get GTFS-realtime to work with PHP. Information on "protocol buffers" is really scant. It seems that the first step to get it to work is to "generate the necessary libraries" in the language you want to use. 

However, I'm trying to use PHP, and it's not supported by Google, which only provides documentation Java, Python and C++. (I found this line amusing: "Try the tutorial for your favourite language." Is anyone's favorite language C++?) 

More seriously, trying to get it to work with PHP leads from screen to screen until the list of third party tools, "none of these projects are affiliated with or endorsed by Google; try them at your own risk." (Red emphasis in the original.) Maybe justified, because I couldn't get the ones I tried to work.

So since everyone's first step is the same, would it be possible for the MTA or others to release these compiled class files for the MTA's GTFS-realtime specification for common languages? PHP, .NET, and even those using java server-side might appreciate being able to use the MTA's real time data without having to first learn this obscure binary file format. 

Michael


PS. Two other ideas: Providing a feed of just the Subway Time information in JSON would be fantastic (I would mirror it on my server) as would open sourcing the code for the MTA Subway Time and Bus Time apps on various platforms. But just some basic class files would be a breakthrough.   

Brian Ferris

unread,
Oct 7, 2013, 9:38:19 AM10/7/13
to mtadevelop...@googlegroups.com
Given Java was maybe fourth-down on your list of preferred languages, I'm not sure it will bring you much satisfaction, but I do provide pre-compiled Java libraries that include the NYCT extensions, which can easily be included as a Maven dependency in a Java project:


Also, I might be in the minority, but I certainly prefer C++ to PHP ; )


--
You received this message because you are subscribed to the Google Groups "mtadeveloperresources" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtadeveloperreso...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

dougla...@gmail.com

unread,
Oct 7, 2013, 7:58:54 PM10/7/13
to mtadevelop...@googlegroups.com
I used the DrSlump libraries:

Then some manual work I don't remember...

Then this, with the attached files:
include_once("library/DrSlump/Protobuf.php");
include_once("library/DrSlump/Protobuf/Message.php");
include_once("library/DrSlump/Protobuf/Registry.php");
include_once("library/DrSlump/Protobuf/Descriptor.php");
include_once("library/DrSlump/Protobuf/Field.php");
include_once("gtfs-realtime.php");
include_once("nyct-subway.php");
include_once("library/DrSlump/Protobuf/CodecInterface.php");
include_once("library/DrSlump/Protobuf/Codec/PhpArray.php");
include_once("library/DrSlump/Protobuf/Codec/Binary.php");
include_once("library/DrSlump/Protobuf/Codec/Binary/Reader.php");

$fm = DrSlump\Protobuf::decode('transit_realtime\FeedMessage',file_get_contents(  ... URL to gtfs file here ...  ));

Then I walked it to get what I needed.
gtfs-realtime.php
nyct-subway.php

mike c

unread,
Oct 8, 2013, 6:33:08 AM10/8/13
to mtadevelop...@googlegroups.com
I don't understand why we're banging our heads against the wall with protocol buffers in the first place. Why can't we just have a JSON file like with buses?

Egbert Bleyenburg

unread,
Nov 11, 2015, 6:32:49 PM11/11/15
to mtadeveloperresources

I am also trying to do the manual work you described because I need to generate these php class files for other transportation agencies. After some day installing, reinstalling, debugging and just rambling on I now have a setup where I can really generate the php cl;asses with a command protoc-gen-php -i . nyct-subway.proto, bit I then rteceive lots of warnings and the resulting php classes are broken...

WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "TripReplacementPeriod"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "NyctTripDescriptor.Direction"
WARNING: Non tracked package name found "NyctTripDescriptor.Direction"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor.Direction"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "NyctTripDescriptor.Direction"
WARNING: Non tracked package name found "NyctStopTimeUpdate"
WARNING: Non tracked package name found "NyctStopTimeUpdate"
WARNING: Non tracked package name found "NyctStopTimeUpdate"
WARNING: Non tracked package name found "NyctStopTimeUpdate"
WARNING: Non tracked package name found "nyct_feed_header"
WARNING: Non tracked package name found "NyctFeedHeader"
WARNING: Non tracked package name found "nyct_trip_descriptor"
WARNING: Non tracked package name found "NyctTripDescriptor"
WARNING: Non tracked package name found "nyct_stop_time_update"
WARNING: Non tracked package name found "NyctStopTimeUpdate"


Jon Thornton

unread,
Nov 12, 2015, 10:51:19 AM11/12/15
to mtadeveloperresources

tsoo...@gmail.com

unread,
Dec 28, 2015, 8:45:30 AM12/28/15
to mtadeveloperresources
I wrote a quick guide on using Daniel Wirtz's JavaScript implementation https://github.com/dcodeIO/ProtoBuf.js/ with the NYC Subway: 

The resulting feeds are JSON.
Reply all
Reply to author
Forward
0 new messages