How can I list all the stops associated with a route using GTFS?

后端 未结 6 658
执笔经年
执笔经年 2020-12-23 22:49

I\'m working with some GTFS data and would like to be able to create a list of all stops associated served by a route. I don\'t really understand how to do with with GTFS da

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 23:23

    If the direction of the stop is needed, a change in Lukmaan's answer should be done:

    SELECT unique_stops.route_id, unique_stops.stop_id, stop_name, stop_desc, stop_lat, stop_lon, unique_stops.direction_id
    FROM
      stops,
      (SELECT stop_id, route_id, direction_id
       FROM
         stop_times,
         (SELECT trip_id, route_id, direction_id
          FROM trips
          WHERE route_id IN (801, 803)
          GROUP BY direction_id
         ) AS unique_trips
       WHERE stop_times.trip_id = unique_trips.id
       GROUP BY stop_id, direction_id) AS unique_stops
    WHERE stops.stop_id = unique_stops.stop_id
    

    If you add also stop_times.stop_sequence the same way, and order by direction and stop_sequence, the stops will be sorted as they are in the trip.

提交回复
热议问题