0

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!

Masterofawesome
  • 69
  • 1
  • 11

1 Answers1

2

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.

  • Hey Simon! Thanks again for replying! So to follow up, is there any way to differentiate the variations on the route using the gtfs data? – Masterofawesome Jul 30 '15 at 20:42
  • By headsign would be the only easy and reliable way I'm aware of. This is how riders themselves distinguish among the various branches, after all. You could try being clever and analyzing the distance travelled or number of stops visited but I think this would be a lot more trouble than it's worth. –  Jul 30 '15 at 21:52
  • Thank you for the help! I agree that it would be a lot more trouble than it's worth – Masterofawesome Jul 31 '15 at 14:48
  • Hey Simon! So I tried separating the different branches of the route based on the headsign but i still have some leftover stops that are not supposed to be part of that route. Any idea why that would be? – Masterofawesome Aug 03 '15 at 15:45
  • No; you'll need to explain to me more about what you're trying to do and what results you're seeing (in another question, maybe?). Note that if a stop is visited on a trip associated with a route, the stop by definition belongs to that route. If you're seeing stops you know for certain (how?) aren't part of the route there is likely something wrong with your query. –  Aug 03 '15 at 19:20
  • Thanks Simon, your note just answered my question – Masterofawesome Aug 04 '15 at 20:38