GTFS-realtime-bindings for iOS

632 views Asked by At

MTA Subway data (among other data) is formatted in GTFS-realtime. In order to convert the protobuf into a string representation I must run it through some Google protobuf tools using gtfs-realtime.proto. The only problem is that, as can be seen here, the gtfs-realtime-bindings are available only for

  • NET
  • Java
  • JavaScript / Node.js
  • PHP
  • Python
  • Ruby
  • Golang

Additionally,

We don't provide generated code for C++, use the official protoc compiler for that (from here or here)

None of these are Swift or Objective C. While there is an open issue/request for a Swift/Objective C version from 2016, I was wondering what I can do currently in order to do this. As of now, the only viable solution I see is to have a server parse the data and then GET the parsed data (JSON encoded?) from that server instead of directly from the MTA.

Here is the Google page for protocol buffers. I am not sure, but is there some way to use what is there to read the GTFS-realtime data.

Is that the best path forward? Are there any other possibilities?

2

There are 2 answers

0
Daniel On BEST ANSWER

As noted by Tony Laudig, having your app directly communicate with the MTA is a breach of their terms and conditions which you almost definitely would have had to agree to in order to get an api key.

Breaking terms and conditions is generally a pretty bad idea. In the case of this API, it seems like your key will be revoked.

Thus, I would not suggest using the library in Tony’s answer. Instead, do what you proposed:

Have a server parse the data and then GET the parsed data (JSON encoded? [—sounds good]) from that server instead of directly from the MTA.

Any of the languages you listed will do the job, it’s just a matter of which you’re most comfortable with.

0
Tony Laidig On

There is an official library in Objective C for parsing Protobuf. You can compile classes from the GTFS-rt standard and the MTA extension .proto files.

It looks like your planned usage, having the app connect to the MTA directly, doesn't conform to the MTA terms and conditions:

  1. In developing your app, you will provide that the MTA data feed is available to others only from a non-MTA server. Accordingly, you will download and store the MTA data feed on a non-MTA server which users of your App will access in order to obtain data. MTA prohibits the development of an app that would make the data available to others directly from MTA's server(s).