Search code examples
androidgoogle-mapsgoogle-directions-api

How does the Google Maps Directions API differentiate interline transfers?


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.


Solution

  • 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.