Google 地图路线 API 如何区分联运中转?

How does the Google Maps Directions API differentiate interline transfers?

我正在构建一个 android 实时 bus/train 到达的交通应用程序,我还想为使用 google 地图方向 API 的用户添加方向.

我的运输机构 (TriMet) 使用联运/直达路线中转。联运转机是指车辆(公共汽车、铁路等)在载有乘客的情况下改变路线的转机。 Google 地图显示这样的交通:

我的问题:google 映射方向 API 如何实现联运转机,即我如何知道转机何时是联运转机?谢谢

Xomena is totally right in his comment: you need Google Transit API Static Transit,但你也是对的:从中获取想要的数据并不容易。

无论如何,您可以使用一些 "dirty" 解决方法: 使 Google 地图 Directions API 请求像

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

获取JSON响应并分析它:如果路由有多个步骤并且

  • TRANSITstep[i]step[i+1]之间没有WALKING(and/or其他)步骤;

  • end_location latlngname 标签 step[i] 等于 start_location latlngnamestep[i+1]

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

  • line -> agencies -> name (以及其他,如 phonestep[i] 的标签等于相应的step[i+1];

  • 的标签
  • line -> vehicle -> name& type for step[i] 等于相应的标签 step[i+1] ;

  • 对于step[i]step[i+1]

  • 可能是其他属性等于(或近似等于时间)的东西

很可能 step[i]step[i+1] 之间在 Google 地图方向 API 路线上有转机。