Re: [GTFS-realtime] GTFS will be my Death! Can anyone help?

1,048 views
Skip to first unread message

Brian Ferris

unread,
Nov 6, 2012, 4:19:18 AM11/6/12
to gtfs-r...@googlegroups.com
I don't think there is one simple script that does everything you want.  That said, I wrote a series of tutorials on working with GTFS-realtime a while back:


There is code to go along with it.  Might be helpful to look at.

Brian


On Tue, Nov 6, 2012 at 4:05 AM, Sam <smo...@gmail.com> wrote:
Hi all,

I've been studying this GTFS documentation for the past 4 hours and I'm completely lost! I'm a PHP programmer with absolutely no knowledge of Python or Java etc. I've been able to parse the data in PHP, but have no idea where to go from there. I am currently looking for a script that will do a few things. 
  1. Find all delays, alerts, construction updates or service interruptions. 
  2. Ideally, I'd like to play them on a dynamic map using the coordinates to place a tag on Google Maps. 
  3. Insert the delays/alerts/updates into a mySQL database. 

If anyone would be willing to share a script that I could install on my web server, or if you don't want to share, I am willing to pay for it. Any help and/or guidance would be AMAZING. I've found some scripts online, but they are in Java and I have no idea how to run them. 

--
You received this message because you are subscribed to the Google Groups "GTFS-realtime" group.
To view this discussion on the web visit https://groups.google.com/d/msg/gtfs-realtime/-/5tSBtjSBaBwJ.
To post to this group, send email to gtfs-r...@googlegroups.com.
To unsubscribe from this group, send email to gtfs-realtim...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gtfs-realtime?hl=en.

Alex (Maxious) Sadleir

unread,
Nov 6, 2012, 7:10:26 AM11/6/12
to gtfs-r...@googlegroups.com
Previously mentioned on this group is GTFSrDB which will download
gtfs-realtime into a mySQL database for you. It's python but you can
treat it as a black box
https://groups.google.com/d/topic/gtfs-realtime/DGcje4aJJqM/discussion
https://github.com/mattwigway/gtfsrdb

GTFSrDB also works with GTFSDB which will load the static timetable
data into the same database in a similar way
http://code.google.com/p/gtfsdb/

Unfortunately, you will need access to both the realtime
(GTFS-realtime) and static data (GTFS) to be able to plot alerts on a
map because if you look at the Alerts examples/specification, alerts
are tied to the route/stop they affect not a lat/lon location
https://developers.google.com/transit/gtfs-realtime/examples/alerts

You would then need to decide what location to display (a line along
the route? on the positions of the stops?).

It is possible to read the GTFS-realtime data in just PHP eg.
https://github.com/maxious/ACTBus-ui/blob/master/lib/Protobuf-PHP/test-import-alert.php
which opens https://github.com/maxious/ACTBus-ui/blob/master/lib/Protobuf-PHP/example-alert.proto
or any other valid GTFS-realtime file (alerts or route updates) and
converts it to a PHP array. But you still have to have a database for
the GTFS static data anyway.

Nicholls, Gregory

unread,
Nov 6, 2012, 5:48:08 PM11/6/12
to gtfs-r...@googlegroups.com

The following is an excerpt from the Trip Updates information:
"There should be at most one trip update for each scheduled trip. In case there is no trip update for a scheduled trip, it will be concluded that no realtime data is available for the trip. The data consumer should not assume that the trip is running on time."

When this says 'concluded that no realtime data is available', does that allow for the possibility that a subsequent TripUpdate feed _will_ provide realtime data for the trip in question ? ie. Can I amend my TripUpdate feed to include realtime data for trips as that data becomes available ?
Regards,
Greg.

Jeremy Baron

unread,
Nov 6, 2012, 5:56:27 PM11/6/12
to gtfs-r...@googlegroups.com
As an example from way MTA (NYC): I think the way it works is they
fill the feed with trains leaving their origin terminals up to 30 mins
in the future in each of the snapshots. (1x/ 30 sec) using schedule
data to supplement the realtime data for trains that haven't left ye.)
IDK how they behave if they lose and then later reestablish contact
with a train. Sounds like it would be reasonable for a train to
disappear from the feed when contact is lost and reappear when it's
back if it's a rare occurrence. Or maybe they could e.g. remove it
only after missing a full 60 secs of checkins?

-Jeremy

Nicholls, Gregory

unread,
Nov 6, 2012, 6:01:05 PM11/6/12
to gtfs-r...@googlegroups.com
I'm less concerned (at this point) about loss of data mid trip but more whether I can restrict TripUpdates to the subset of the TDB that is currently running. ie. The day of operations. Our TDB contains thousands of trips scheduled months in advance. I don't want to have to provide dummy entries for these in the TripUpdate feed for months on end simply as a placeholder so we are able to provide real data when they run.
Greg.

Jeremy Baron

unread,
Nov 6, 2012, 6:05:46 PM11/6/12
to gtfs-r...@googlegroups.com
On Tue, Nov 6, 2012 at 11:01 PM, Nicholls, Gregory
<Gregory....@railcorp.nsw.gov.au> wrote:
> I'm less concerned (at this point) about loss of data mid trip but more whether I can restrict TripUpdates to the subset of the TDB that is currently running. ie. The day of operations. Our TDB contains thousands of trips scheduled months in advance. I don't want to have to provide dummy entries for these in the TripUpdate feed for months on end simply as a placeholder so we are able to provide real data when they run.

The NYC MTA (again just an example, IDK the spec so well) includes
only trips which are either
* starting within the next 30 mins or
* still in progress

-Jeremy

Csaba Garay

unread,
Nov 6, 2012, 6:20:31 PM11/6/12
to gtfs-r...@googlegroups.com
Hi Greg,

Yes you can restrict TripUpdates to the subset which is either currently running our 'about to run' in the very near future.
As Jeremy wrote next 30 mins usually is a good pick but depending on our network/schedules you might chose only next 10 mins (frequent service with quickly changing status/predictions) or  >2 hours e.g. longdistance service.
It would not make sense to provide realtime predictions for trains starting in months from now.
In the spec at most one mean 0 or 1. So it's perfectly ok to provide no realtime data for a subset of trips especially in the distant future.

Regards,
Csaba




-Jeremy

Nicholls, Gregory

unread,
Nov 6, 2012, 7:10:47 PM11/6/12
to gtfs-r...@googlegroups.com
Excellent. I was hoping this was the case. It'll make my life a lot easier.
  Cheers,
    G.


From: gtfs-r...@googlegroups.com [mailto:gtfs-r...@googlegroups.com] On Behalf Of Csaba Garay
Sent: Wednesday, 7 November 2012 10:21 AM

To: gtfs-r...@googlegroups.com
Subject: Re: [GTFS-realtime] TripUpdates - Day of operations or everything ?

Sam

unread,
Nov 21, 2012, 7:26:18 AM11/21/12
to gtfs-r...@googlegroups.com
Thanks Brian. 

I didn't realize this turned into a discussion. My path has changed and I'm working with the GTFS-realtime nextbus API which is quite simple to use from a PHP/XML perspective. The only problem for me with nextbus is the lack of agencies since I am looking for a vast array of agencies. 

Any chance there are other XML or JSON feeds? All I want to do now is to create my own XML or JSON feeds using a similar structure to NextBus. The problem for me is that I don't know C++, JAVA or Python. I've put up a job post for a Python programmer to set up these private APIs for me, but haven't found one that knows GTFS well enough to do so. 

I've also taken a look at the OneBusAway GTFS to JSON converter and since it is written in Java, I'm not following too well. I tried some of the examples using a Java Client, but no success. Any recommendations on where I can find a way to create an API similar to Nextbus for RealTime feeds to find the "next bus"? 

Joachim Pfeiffer

unread,
Nov 22, 2012, 11:36:23 AM11/22/12
to gtfs-r...@googlegroups.com
Hi Sam,
There is no need to code against all the different data formats.
TransiCast is an API that integrates the various real-time feeds such as NextBus', TriMet Portland, Muni and BART in San Francisco, Chicago CTA and many more with their GTFS data. Scheduled next bus and train times are also available for agencies that do not offer real time feeds. Overall, we a are rolling more than 100 agency feeds in North America. Please check it out at www.transicast.com
Joachim


To view this discussion on the web visit https://groups.google.com/d/msg/gtfs-realtime/-/cCqjZb5AzhIJ.

Sam

unread,
Nov 26, 2012, 7:17:18 PM11/26/12
to gtfs-r...@googlegroups.com
Thanks Joa. I'll take a look into it. Right now we're looking for some free feeds so we've connected whatever we could to NextBus. In the case that we do need paid ones, we'll definitely check out your services! Thanks for the reference!

Joachim Pfeiffer

unread,
Nov 26, 2012, 9:44:45 PM11/26/12
to gtfs-r...@googlegroups.com
Great, thanks for taking a look.
JP

To view this discussion on the web visit https://groups.google.com/d/msg/gtfs-realtime/-/TxB9vn062sYJ.
Reply all
Reply to author
Forward
0 new messages