--- 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 != "
"
- 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