Network 10 changes
Network 10 changes

--- a/maxious-canberra-transit-feed/01-extracttimes.rb
+++ b/maxious-canberra-transit-feed/01-extracttimes.rb
@@ -14,7 +14,7 @@
 	timetable = {"between_stops" => [], "short_name" => short_name}
 	time_points = table.xpath('tr[1]//th').map do |tp|
 		if tp.content != "\302\240" && tp.content != "" && tp.content != "<br/>"
-			timing_point = tp.content.squeeze(" ").gsub(" Platform"," (Platform").gsub("  - "," - ").gsub("\n","").gsub("\r","").gsub("\\"," / ").squeeze(" ").strip
+			timing_point = tp.content.squeeze(" ").gsub("Bus Station"," Bus Station ").gsub(" Platform"," (Platform").gsub("  - "," - ").gsub("\n"," ").gsub("\r"," ").gsub("\t"," ").gsub("\\"," / ").gsub("/"," / ").gsub(",",", ").gsub("\302\240","").squeeze(" ").strip
 			if (tp.content.match('Platform'))
 			  timing_point.concat(")")
 			end;
@@ -22,6 +22,8 @@
 		end
 	end
 	time_points.delete(nil)
+	time_points.delete("WheelchairAccessible")
+	time_points.delete("Wheelchair Accessible")
 	timetable["time_points"] = time_points.to_a
 	timetable["long_name"] = "To " + time_points.last
 	periodtimes = []
@@ -31,8 +33,11 @@
 			time = time.gsub(/ *A\S?M/,"a").gsub(/ ?P\S?M/,"p").gsub("12:08 AM","1208x").gsub(":","").gsub("1.","1").gsub("2.","2")
 			time = time.gsub("3.","3").gsub("4.","4")
 			time = time.gsub("5.","5").gsub("6.","6").gsub("7.","7").gsub("8.","8").gsub("9.","9").gsub("10.","10")
-			time = time.gsub("11.","11").gsub("12.","12").gsub(/\.+/,"-")
+			time = time.gsub("11.","11").gsub("12.","12").gsub(/\.+/,"-").gsub("\302\240","")
+			if time == "" then time = nil end 
+			time
 		end
+		times.delete(nil)
 		if not times.empty?
 			if not (route = times.shift)
 				raise("TODO: account for shifting route numbers eg. intertown/redex 62/162")
@@ -54,7 +59,6 @@
 	timetable
 end
 
-#TODO fix route 934
 Dir.glob("source-html/Route*.htm*") { |file|
 	puts "Opened " + file
 	doc = Nokogiri::HTML(open(file))
@@ -62,7 +66,7 @@
 	timetables = []
 	short_name = "";
 	doc.xpath('//title').each do |title|
-		short_name = title.content.gsub("Route_","").gsub("Route ","").gsub(", ","/").squeeze(" ").strip
+		short_name = title.content.gsub("Route_","").gsub("Route ","").gsub(", ","/").gsub("ACTION Buses Timetable for ","").squeeze(" ").strip
 	end
 	if short_name == ""
 		raise "Route number(s) not found in <title> tag"
@@ -71,7 +75,15 @@
 	doc.xpath('//table[preceding::text()="Weekdays"]').each do |table|
 		timetables << makeTimetable(table, "stop_times", short_name)
 	end
-
+	doc.xpath('//table[preceding::text()="This timetable is effective from Monday 15th November 2010."]').each do |table|
+		timetables << makeTimetable(table, "stop_times", short_name)
+	end
+	#all tables are weekdays on some really malformatted timetables
+	if short_name == "170"
+		doc.xpath('//table').each do |table|
+			timetables << makeTimetable(table, "stop_times", short_name)
+		end
+	end
 	#weekends
 	doc.xpath('//table[preceding::text()="Saturdays" and following::a]').each do |table|
 		timetables << makeTimetable(table, "stop_times_saturday", short_name)

--- a/maxious-canberra-transit-feed/02-tidytimepoints.rb
+++ b/maxious-canberra-transit-feed/02-tidytimepoints.rb
@@ -25,61 +25,26 @@
 #pp $time_points_sources.sort
 
 time_point_corrections = {"North Lynehamham" => "North Lyneham",
-			 "Lathlain St (Platform 2)" => "Lathlain St Bus Station (Platform 2)",
-			 "Lathlain St Sation (Platform 5)" => "Lathlain St Bus Station (Platform 5)",
-	 		 "Lathlain Steet Station" => "Lathlain St Bus Station",
-			 "Lathlain St (Platform 3)" => "Lathlain St Bus Station (Platform 3)",
-			 "Lathlain Steet Station (Platform 3)"	 => "Lathlain St Bus Station (Platform 3)",
-			 "Lathlain St Station" => "Lathlain St Bus Station",
-			 "Lathlain St Station (Platform 1)" => "Lathlain St Bus Station (Platform 1)",
-			 "Lathlain St Station (Platform 2)" => "Lathlain St Bus Station (Platform 2)",
-			 "Lathlain St Station (Platform 3)" => "Lathlain St Bus Station (Platform 3)",
-			 "Lathlain St Station (Platform 4)" => "Lathlain St Bus Station (Platform 4)",
-			 "Lathlain St Station (Platform 5)" => "Lathlain St Bus Station (Platform 5)",
-			 "Lathlain St Station (Platform 6)" => "Lathlain St Bus Station (Platform 6)",
-			 "Flemington Rd, Sandford St" => "Flemington Rd/Sandford St",
-			 "Erindale Centre /Sternberg Crescent" => "Erindale Drive/Sternberg",
-			 "Canberra Hospita" => "Canberra Hospital",
-			 "Cohen Str Station (Platform 1)" => "Cohen St Bus Station (Platform 1)",
-			 "Cohen Street Station" => "Cohen St Bus Station",
-			 "Cohen Street Station (Platform 2)" => "Cohen St Bus Station (Platform 2)",
-			 "Cohn St Station (Platform 3)" => "Cohen St Bus Station (Platform 3)",
-			 "Cohen St Station" => "Cohen St Bus Station",
-			 "Cohen St Station (Platform 1)" => "Cohen St Bus Station (Platform 1)",
-			 "Cohen St Station (Platform 2)" => "Cohen St Bus Station (Platform 2)",
-			 "Cohen St Station (Platform 3)" => "Cohen St Bus Station (Platform 3)",
-			 "Cohen St Station (Platform 4)" => "Cohen St Bus Station (Platform 4)",
-			 "Cohen St Station (Platform 5)" => "Cohen St Bus Station (Platform 5)",
-			 "Cohen St Station (Platform 6)" => "Cohen St Bus Station (Platform 6)",
-			 "City (Platform 7)" => "City Interchange (Platform 7)",
-			 "Cameron Avenue Station" => "Cameron Ave Bus Station",
-			 "Cameron Avenue Station (Platform 1)" => "Cameron Ave Bus Station (Platform 1)",
-			 "Cameron Avenue Station (Platform 2)" => "Cameron Ave Bus Station (Platform 2)",
-			 "Cameron Avenue Station (Platform 3)" => "Cameron Ave Bus Station (Platform 3)",
-			 "Cameron Avenue Station (Platform 4)" => "Cameron Ave Bus Station (Platform 4)",
-			 "Cameron Avenue Station (Platform 5)" => "Cameron Ave Bus Station (Platform 5)",
-			 "Cameron Ave Station" => "Cameron Ave Bus Station",
-			 "Cameron Ave Station (Platform 1)" => "Cameron Ave Bus Station (Platform 1)",
-			 "Cameron Ave Station (Platform 2)" => "Cameron Ave Bus Station (Platform 2)",
-			 "Cameron Ave Station (Platform 3)" => "Cameron Ave Bus Station (Platform 3)",
-			 "Cameron Ave Station (Platform 4)" => "Cameron Ave Bus Station (Platform 4)",
-			 "Cameron Ave Station (Platform 5)" => "Cameron Ave Bus Station (Platform 5)",
-			 "Burton & Garranan Hall, Daley Road ANU" => "Burton & Garran Hall/Daley Road ANU",
-			 "Burton & Garranan Hall,Daley Road ANU" => "Burton & Garran Hall/Daley Road ANU",
-			 "Garran/Daley Rd" => "Burton & Garran Hall/Daley Road ANU",
-			 "Kingstons Ave/National Crt" => "Kings Ave/National Crt",
-			 "Newcastle Street after Isa St" => "Newcastle / Isa Street Fyshwick",
-			 "National Circ/Canberra Ave" => "National Circuit / Canberra Ave",
-			 "St Clare of Conder" => "St Clare of Assisi Primary",
-			 "McKillop College Isabella Campus" => "MacKillop College Isabella Campus",
-			 "Outrim / Duggan" => "Outtrim / Duggan",
-			 "Manuka Captain Cook" => "Manuka/Captain Cook",
-			 "Manuka, Captain Cook" => "Manuka/Captain Cook",
-			 "Menindee Drive - Hospice" => "Hospice",
-			 "Hospice, Menindee Drive" => "Hospice",
-			 "Tharwa/Pocket" => "Tharwa/Pockett",
-			 "Paul-Co / Mirrabei" => "Paul Coe / Mirrabei"
-			}
+  "Woden Bus Station Platform 10)" => "Woden Bus Station (Platform 10)",
+  "Saint AndrewsVillage Hughes"=>"Saint Andrews Village Hughes",
+ "Flemmington Road / Sandford St"=>"Flemington Road / Sandford St",
+ "City Interchange"=>"City Bus Station",
+ "City Interchange (Platform 9)"=>"City Bus Station (Platform 9)",
+ "Bridbabella Gardens Nursing Home"=>"Brindabella Gardens Nursing Home",
+ "Bridbabella GardensNursing Home"=> "Brindabella Gardens Nursing Home",
+ "BrindabellaBusiness Park"=> "Brindabella Business Park",
+ "NarrabundahTerminus"=>"Narrabundah Terminus",
+ "Railway StationKingston"=>"Railway Station Kingston",
+ "Saint AndrewsVillage Hughes"=>"Saint Andrews Village Hughes",
+ "Dickson ShopsAntill Street"=>"Dickson Shops",
+ "Cohen St Bus Station (Platform 3)"=>"Cohen Street Bus Station (Platform 3)",
+ "Cohen St Bus Station (Platform 6)"=>"Cohen Street Bus Station (Platform 6)",
+ "Newcastle Streetafter Isa Street"=>"Newcastle Street after Isa Street",
+ "William Web / Ginninderra Drive"=>"William Webb / Ginninderra Drive",
+ "Procor / Mead"=>"Proctor / Mead",
+"Fyshwick DirectFactory Outlet"=>"Fyshwick Direct Factory Outlet"
+}
+
 time_point_corrections.each do |wrong, right|
 	$time_points_sources[wrong].each do |wrongfile|
 		badtimetable = YAML::load_file(wrongfile)

--- a/maxious-canberra-transit-feed/03-locatetimepoints.rb
+++ b/maxious-canberra-transit-feed/03-locatetimepoints.rb
@@ -1,10 +1,10 @@
 #!/usr/bin/ruby
-require 'postgres'
 
 require 'highline.rb'
 include HighLine
 
 require 'rubygems'
+require 'postgres'
 require 'json'
 require 'net/http'
 def cbr_geocode(query)
@@ -51,13 +51,12 @@
 
 connbus = PGconn.connect("localhost", 5432, '', '', "bus", "postgres", 
 "snmc")
-connosm = PGconn.connect("localhost", 5432, '', '', "openstreetmap", 
-"postgres", "snmc")
+connosm = PGconn.connect("localhost", 5432, '', '', "openstreetmap", "postgres", "snmc")
 
 if ask_if("Insert Timing Point names to database?")
 	$time_points.each do |time_point|
 		begin
-			time_point = time_point.gsub(/\\/, '\&\&').gsub(/'/, "''").gsub("St", "%")
+			time_point = time_point.gsub(/\\/, '\&\&').gsub(/'/, "''")
 			res = connbus.exec("INSERT INTO timing_point (name) VALUES ('#{time_point}')")
 			puts "Put '#{time_point}' into DB"
 		rescue PGError => e