Determining direction of travel for a route and stop

19 views
Skip to first unread message

Aaron Springut

unread,
Aug 28, 2014, 8:04:24 PM8/28/14
to onebusa...@googlegroups.com
Is there a way to determine if a stop is "inbound" or "outbound" for a route?  Stop elements have have a direction, but it seems to indicate the direction the bus will be facing when it is at that stop and not the bus's ultimate direction of travel. For example, if a bus needs to turn onto a parallel road and has a stop, it can be difficult to determine which way the bus is headed at the stop:
e.g.:
                
                     +-------------------------------+
                     
|       Uptown                  |
                     
+-------------------------------+
                       
^                       ++
                       
|                        |
                       
|                        |
                       
|                        |
                   
+--+                          |
   
Route:1 Stop:3 |  |                          |
   
Direction:N    |  |                          |
   
To:Uptown      |  |                          |
                   
+--+                          |
                       
^                        |
                       
|                        |
                       
|                        |
                       
|                        |
                       
|                        |
                       
|  +-----          <-----+
                       
|  |     +--------+
                       
|  |     |        |   Route:1 Stop:3
                       
|  |     +--------+   Direction:W
                       
|  |                  To:Downtown
                       
|  |
                       
|  |
                       
|  |
                       
|  |
                       
+  v
                   
+--+     +--+
Route:1 Stop:1      |  |     |  |   Route:1 Stop:2
Direction:N         |  |     |  |   Direction:S
To:Uptown           +--+     +--+   To:Downtown
                       
^   +
                       
|   |
                       
|   |
                       
|   |
                       
|   |
                       
|   |
                       
|   |
                       
|   |
                       
+   v
                   
+-------------+
                   
|Downtown     |
                   
+-------------+

Is there any way to do this?

Sean Barbeau

unread,
Sep 2, 2014, 12:27:41 PM9/2/14
to onebusa...@googlegroups.com
Aaron,
If you have the the tripId associated with the trip for a particular route, you can get trip direction information from the trips API endpoint:
http://developer.onebusaway.org/modules/onebusaway-application-modules/current/api/where/methods/trip.html

Sample response:

<response>
  <version>2</version>
  <code>200</code>
  <text>OK</text>
  <currentTime>1270614730908</currentTime>
  <data class="entryWithReferences">
    <references>...</references>
    <entry class="trip">
      <id>1_12540399</id>
      <routeId>1_44</routeId>
      <tripShortName>LOCAL</tripShortName>
      <tripHeadsign>Downtown via University District</tripHeadsign>
      <serviceId>1_114-115-WEEK</serviceId>
      <shapeId>1_20044006</shapeId>
      <directionId>1</directionId>
    </entry>
  </data>
</response>

Usually the values correspond to outbound (0) or inbound (1) direction information.  However, GTFS doesn't specify exact definitions for direction_id 0/1 values (see https://developers.google.com/transit/gtfs/reference#trips_fields), so you'll need to take a look at some example data from the API to figure out if the agency is consistently mapping the two trip directions (0/1) to outbound/inbound.

Sean
Reply all
Reply to author
Forward
0 new messages