Skip to content

Commit

Permalink
fix subway realtime for 2011 changes, which were bad
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Choi committed Jan 17, 2011
1 parent 927cee4 commit 5bf76ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions OpenMBTA/Classes/ServerUrl.h
@@ -1,3 +1,3 @@
#define ServerURL @"http://iphonembta.org"
//#define ServerURL @"http://localhost:3000"
//#define ServerURL @"http://iphonembta.org"
#define ServerURL @"http://localhost:3000"

9 changes: 7 additions & 2 deletions rails/lib/subway_real_time.rb
Expand Up @@ -40,12 +40,17 @@ def self.add_data(data, params)
stopsdict = YAML::load(File.read(predictions_file(route_short_name, headsign)))
puts "=" * 80

#puts stopsdict
# puts "STOPDICT"
# puts stopsdict
if data[:stops].nil?
return data
end
data[:stops].each do |stop_id, stop_data|
stop_predictions = stopsdict[stop_data[:parent_stop_mbta_id]]
# stop_predictions = stopsdict[stop_data[:parent_stop_mbta_id]]
# changed for 2011
key = stop_data[:name].split(/\s/)[0] # first work
target_key = stopsdict.keys.detect {|k| k =~ /^#{key}/}
stop_predictions = stopsdict[target_key]
if stop_predictions.nil?
data[:stops][stop_id][:next_arrivals] = [["real time data missing", nil]]
next
Expand Down
2 changes: 1 addition & 1 deletion rails/realtime/bin/get_subway_predictions.rb
Expand Up @@ -5,7 +5,7 @@
require 'yaml'

def compile(lines, line)
lines.map {|x| translate(CSV.parse_line(x), line)}.group_by {|x| x[:stop_id]}
lines.map {|x| translate(CSV.parse_line(x), line)}.group_by {|x| x[:name]}
end

def translate(line_data, line)
Expand Down

0 comments on commit 5bf76ad

Please sign in to comment.