Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
Remove the requirement for headsigns to be present, by inferring a he…
…adsign from the trip's last stop if one is not otherwise defined.
  • Loading branch information
kurtraschke committed May 11, 2011
1 parent 175e308 commit df8942086e765477dd9eaa606e0b6a8178458e06
Showing with 6 additions and 2 deletions.
  1. +0 −1 README.txt
  2. +6 −1
@@ -29,7 +29,6 @@ for weekday and weekend service in the same run. requires that certain optional elements be present in the GTFS
* Trips must use the direction_id field
* Headsigns must be defined in either the trip or stoptime

Finally, do not be alarmed by long runtimes; transitfeed takes >5
minutes to load large GTFS feeds. After the feed is loaded, each
@@ -33,6 +33,11 @@ def get_name_for_route(schedule, route_id):
return route_id

def get_last_stop_name(schedule, trip):
stops = trip.GetStopTimes()
laststoptime = stops[-1]
return laststoptime.stop.stop_name

def find_service(schedule, target_date, target_routes, target_stopid):
#TODO: it would be good to validate that the given stop and routes exist.
@@ -69,7 +74,7 @@ def find_service(schedule, target_date, target_routes, target_stopid):
if stoptime.stop in target_stops:
hour = stoptime.arrival_time.split(':')[0]
count[int(hour) % 24] += 1
headsigns[trip.trip_headsign or stoptime.stop_headsign] += 1
headsigns[trip.trip_headsign or stoptime.stop_headsign or get_last_stop_name(schedule, trip)] += 1

results_temp[route.route_id] = {'route_color': route.route_color,
'route_name': get_name_for_route(schedule, route.route_id),

0 comments on commit df89420

Please sign in to comment.