Trip Direction

223 views
Skip to first unread message

Paul Harrington

unread,
Jul 31, 2018, 3:29:44 PM7/31/18
to Transit Developers
Hi,

I see the GTFS spec currently has

direction_idOptionalThe direction_id field contains a binary value that indicates the direction of travel for a trip. Use this field to distinguish between bi-directional trips with the same route_id. This field is not used in routing; it provides a way to separate trips by direction when publishing time tables. You can specify names for each direction with the trip_headsign field.
* 0 - travel in one direction (e.g. outbound travel)
* 1 - travel in the opposite direction (e.g. inbound travel)

If memory serves me correctly (which it may not of course !) in an earlier version of the spec there was a stronger emphasis on inbound and outbound. 

I gather thought that the field is only useful for distinguishing directions of travel of a route and that a description of the route direction is in many or even most cases meaningless.
Is this correct ? I ask because In trip information I currently show direction as inbound or outbound and am thinking of removing it.

Paul.

l...@frachet.ca

unread,
Jul 31, 2018, 3:45:19 PM7/31/18
to Transit Developers
Hi Paul,

direction_id is used to group the trips into directions, but you shouldn't assume than direction_id 0 implies outbound, and that direction_id 1 implies inbound.

There are currently no fields in the GTFS to give a name to the direction, and most data consumer use the most frequent headsign of the direction as name.

The other options are:
- Trillium uses an extra file, called directions.txt, containing the fields route_id, direction_id and Direction, where they give name to direction (https://trilliumtransit.com/gtfs/reference/#h.a3iswhm1yxip)
- Transit app uses the extra field trip_direction_headsign in trips.txt and stop_direction_headsign in stop_times.txt to give name to the directions.
- A proposal for direction_name (or trip_long_name) has also be made in the past on the GTFS-changes Google Group.

Could you tell me more on your use case? Are you producing or consuming the dataset? Where do you currently show the direction information? Which transit network are you working one?

Thanks,

Frank P

unread,
Aug 1, 2018, 1:18:00 AM8/1/18
to Transit Developers
FYI, to add to Leo's list of elaborations on direction_id, TriMet includes a route_direction.txt file, which includes route_id,direction_id,direction_name. I think there's a proposal (circa ~2008) out there for route_direction.txt. There is also (at least) 1 implementation for route_direction,txt in gtfsdb (https://github.com). A route-direction file with named directions is useful where a route/direction has multiple end points (e.g. it would be hard to determine the proper direction/destination name, based on collecting & counting & concatenating head sign information at the trip level, and trying to come up with a destination name based on multiple different trip names, etc...). For example, https://trimet.org/ride/stop_select_list.html?route=15 (and https://trimet.org/schedules/w/t1015_0map.htm) has trips that terminate at 4 different destinations (e.g., Portland City Center, Thurman, Montgomery Park, or Yeon & 44th) ... so having someone manually name the route destinations, and have that named route direction in GTFS via a route_directions.txt (or directions.txt ala Trillium's file) is necessary ... there's no way I could imagine constructing that destination name w/out the benefit of route_directions.txt.

FWIW, the original proposal for direction_id in the trip table was timetable production, where a timetable would exist as a bi-directional pair (in most cases...uni-directional in some). Was easier to just specify 1 or 0 for the two directions in trips.txt, rather than trying to assign buckets of trips based on a stop list, since there were a handful of ambiguous corner cases (e.g., diamond routes and short-line trips might only share a stop or two with the predominance of other trips, such that assignment of a given trip to direction X or Y could be ambiguous at best).

Paul Harrington

unread,
Aug 1, 2018, 4:11:25 AM8/1/18
to Transit Developers
Thanks Guys,

I hadn't realized there were so many variant solutions out there and that it was something that different organizations handled in different ways.

I am a consumer Leo but don't have a focus on any particular transit network. You will see the direction used at


if you search for a stop and then click on a departure to see detailed information.  I am currently working on improving the UI and have reached the conclusion that displaying the direction is meaningless particularly as the headsign field is also being displayed. I originally though direction could be of use to those not familiar with the transit network who want an indication of whether a trip is heading out of a city or in towards the center but with cross city trips, circular trips etc this is too misleading

Regards Paul.
Reply all
Reply to author
Forward
0 new messages