2

I am building an android transit app for real-time bus/train arrivals, I would also like to add directions for users using the google maps directions API.

My transportation agency (TriMet) uses interline / thru-route transfers. Interline transfers are transfers where the vehicle (bus, rail, etc) changes routes with passengers on board. Google Maps shows such transfers as:

Google Maps Screenshot showing an interline transfer

My question: how does the google maps direction API implement interline transfers i.e. how do I know when the transfer is an interline transfer? Thanks.

Roman
  • 774
  • 7
  • 12
  • 1
    The data is supplied by travel agencies in form of GTFS feeds, apparently GTFS specification has something to define this type of transfers. Have a look at documentation: https://developers.google.com/transit/gtfs/reference/gtfs-extensions – xomena Mar 30 '18 at 14:52
  • @xomena While a possibility, TriMet doesn't implement any of those GTFS extensions. Google is definitely using the GTFS data but question is how. And more importantly why isn't the interline transfer type part of the API response? Does Google expect me to dig through the GTFS every time I look up transit directions? – Roman Mar 31 '18 at 07:52

1 Answers1

0

Xomena is totally right in his comment: you need Google Transit API Static Transit, but you are right too: its not easy to get desired data from it.

Anyway, you can use some "dirty" workaround: make Google Maps Directions API request like

https://maps.googleapis.com/maps/api/directions/json?origin=Milwaukie/Main+St+MAX+Station,+Portland,+OR,+us&destination=Pioneer+Courthouse,+Portland,+OR,+us&mode=transit

get JSON response and analyze it: if route has several steps and

  • there is no WALKING (and/or other) step between TRANSIT step[i] and step[i+1];

  • end_location lat, lng and name tags of step[i] equals to start_location lat, lng and name of step[i+1];

  • arrival_time tag of step[i] is around (1-2 minutes differs with) departure_time tag of step[i+1];

  • line -> agencies -> name (and others, like phone) tag of step[i] equals to corresponding tags of step[i+1];

  • line -> vehicle -> name& type for step[i] equals to corresponding tags step[i+1];

  • may be something others attributes equals (or approximately equals for time) for step[i] and step[i+1];

its highly likely that there is interline transfer between step[i] and step[i+1] on Google Maps Directions API route.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
  • Thank you for the answer. I used a similar approach in my code but with less restrictive checks. I have marked the answered as accepted but I still would like an official answer from Google. I am surprised the API documentation doesn't mention interline transfers. – Roman Apr 05 '18 at 06:36
  • @BrianKeen You are welcome! I'm know that is workaround. Seems official answer is hard to be done because of third party transport companies. – Andrii Omelchenko Apr 05 '18 at 11:16