Search code examples
androidmysqlsqlsqlitegtfs

Multiple trip headsigns for a route?


So I just noticed this in my application, but when I get a list of routes that services a stop, I get multiple trip_headsigns for a specific route, but they all run the same route when I get all the stops and the route shape. Am I missing something here? Or can somebody explain why? Here is how I get routes for specific stop:

    SELECT DISTINCT t.trip_headsign, r.route_short_name,r.route_long_name
    FROM stop_times st INNER JOIN trips t
    ON t.trip_id = st.trip_id
    INNER JOIN routes r
    ON r.route_id = t.route_id
    WHERE st.stop_id = <stop_id>

Here is how I get all the stops for a specific route returned by the query

      SELECT DISTINCT t.trip_id, s.stop_code, s.stop_name, s.stop_lat, s.stop_lon, t.shape_id, st.arrival_time
      FROM trips as t INNER JOIN stop_times as st
      ON st.trip_id = t.trip_id
      INNER JOIN stops as s ON s.stop_id = st.stop_id
      WHERE t.route_id = <route_id>
      AND t.service_id = "Weekdays"
      AND t.direction_id = <direction_id>

But as I said, I get multiple trip_headsigns as a query return from the first one, but when I run the second query I get the same route for all those trip_headsigns. Any help/comments/ideas are appreciated!


Solution

  • Often a transit route has multiple branches that operate over different portions of a single path through the network. As a real-world example, York Region Transit operates route 85 (PDF link) with two branches, 85 and 85C. Both operate along the same east-west corridor but vary in the distance they cover: The western-most portion of the route is served only by the 85 branch.

    To make sure riders are able to get on the right bus, the headsign on each bus along this route indicates which branch it is following on its trip: Riders waiting at a westbound stop might see a bus displaying either "85 Napa Valley" or "85C Islington", and choose to get on or not based on how far they need to go.

    I expect this is what you're seeing in your data: Multiple branches of the same route that cover different portions of the same basic path. Note that YRT's 85 and 85C share the same path (i.e. shape) through the network; effectively, the 85C just ends its trips early. But since they're merely variations on the same basic route, it makes sense for them to be modelled in GTFS as a single route with trips that vary in their headsign and the distance they travel.