Skip to content

Commit

Permalink
Couple of variable fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 12, 2013
1 parent 9b047dc commit 2ea5583
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/fetch.py
Expand Up @@ -71,6 +71,8 @@ def parse_time(s):
if m: if m:
return int(m.group(1))*3600 + int(m.group(2))*60 + int(m.group(3)) return int(m.group(1))*3600 + int(m.group(2))*60 + int(m.group(3))
m = re.match('(\d+):(\d+)$', s) m = re.match('(\d+):(\d+)$', s)
if not m:
raise Exception, 'Did not match time %s' % s
return int(m.group(1))*60 + int(m.group(2)) return int(m.group(1))*60 + int(m.group(2))


# Loop through the trains # Loop through the trains
Expand Down Expand Up @@ -206,16 +208,16 @@ def canon_station_name(s, line):
if m: if m:
location_1 = station_locations[canon_station_name(m.group(1), line)] location_1 = station_locations[canon_station_name(m.group(1), line)]
location_2 = station_locations[station_name] location_2 = station_locations[station_name]
fraction = 30 / (time_to_station + 30) fraction = 30 / (arr['time_to_station'] + 30)
arr['location'] = (location_1[0] + (fraction*(location_2[0]-location_1[0])), location_1[1] + (fraction*(location_2[1]-location_1[1]))) arr['location'] = (location_1[0] + (fraction*(location_2[0]-location_1[0])), location_1[1] + (fraction*(location_2[1]-location_1[1])))
m = re.match('Between (.*?) and (.*)', arr['current_location']) m = re.match('Between (.*?) and (.*)', arr['current_location'])
if m: if m:
if line == 'H' and station_name != canon_station_name(m.group(2),line): if line == 'H' and station_name != canon_station_name(m.group(2),line):
continue continue
location_1 = station_locations[canon_station_name(m.group(1), line)] location_1 = station_locations[canon_station_name(m.group(1), line)]
location_2 = station_locations[canon_station_name(m.group(2), line)] location_2 = station_locations[canon_station_name(m.group(2), line)]
max = time_to_station+30 if time_to_station > 150 else 180 max = arr['time_to_station']+30 if arr['time_to_station'] > 150 else 180
fraction = (max-time_to_station) / max fraction = (max-arr['time_to_station']) / max
arr['location'] = (location_1[0] + (fraction*(location_2[0]-location_1[0])), location_1[1] + (fraction*(location_2[1]-location_1[1]))) arr['location'] = (location_1[0] + (fraction*(location_2[0]-location_1[0])), location_1[1] + (fraction*(location_2[1]-location_1[1])))
m = re.match('Approaching (.*)', arr['current_location']) m = re.match('Approaching (.*)', arr['current_location'])
if m: if m:
Expand Down

0 comments on commit 2ea5583

Please sign in to comment.