Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Remove the requirement for headsigns to be present, by inferring a he…
Browse files Browse the repository at this point in the history
…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 df89420
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ for weekday and weekend service in the same run.
tph.py requires that certain optional elements be present in the GTFS
feed:
* 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
Expand Down
7 changes: 6 additions & 1 deletion find_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def get_name_for_route(schedule, route_id):
else:
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.
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit df89420

Please sign in to comment.