Permalink
Browse files

Merge branch 'master' of github.com:danchoi/openmbta

  • Loading branch information...
2 parents 3f8c797 + 3722eb1 commit 46cc831c2eaaf4b5b4a0487feea133076f15dfbb @danchoi committed Jun 1, 2011
@@ -102,6 +102,7 @@ - (void)startLoadingData
- (void)didFinishLoadingData:(NSString *)rawData
{
[self hideNetworkActivity];
+ NSLog(@"raw Data: %@", rawData);
NSDictionary *rawDict = [rawData JSONValue];
self.data = [rawDict objectForKey:@"data"];
[self checkForMessage:rawDict];
@@ -1,9 +1,9 @@
module Subway
ROUTE_NAME_TO_MBTA_ID = {
- "Green Line" => %w{810 811 812 822 830 831 852 880 881},
- "Red Line" => %w{931 933 899},
- "Blue Line" => %w{946 948 9462},
+ "Green Line" => %w{810 811 812 822 830 831 840 842 852 880 881 882},
+ "Red Line" => %w{931 933 889 899},
+ "Blue Line" => %w{946 948 9462 9482},
"Orange Line" => %w{903 913}
}
@@ -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
@@ -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)

0 comments on commit 46cc831

Please sign in to comment.