|
#!/usr/bin/ruby |
|
require 'postgres' |
|
|
|
require 'highline.rb' |
|
include HighLine |
|
|
|
require 'rubygems' |
|
require 'json' |
|
require 'yaml' |
|
require 'pp' |
|
# make - { name: Civic Interchange Platform 1,stop_code: civic_platform_1, lat: -35.2794347, lng: 149.130588} |
|
connbus = PGconn.connect("localhost", 5432, '', '', "bus", "postgres", "snmc") |
|
|
|
f = File.open('cbrtable.yml.in.in') |
|
header = f.readlines |
|
f.close |
|
|
|
File.open('cbrtable.yml.in', 'w') do |f2| |
|
f2.puts header |
|
f2.puts "stops:\n"; |
|
begin |
|
time_points = connbus.exec("SELECT * from timing_point") |
|
rescue PGError => e |
|
puts "Error reading from DB #{e}" |
|
#conn.close() if conn |
|
end |
|
time_points.each do |time_point| |
|
#pp time_point |
|
# 0 = name |
|
|
|
# 1 = lat*100000 |
|
# 2 = lng*100000 |
|
f2.puts " - { name: #{time_point[0]},stop_code: #{time_point[0]}, lat: #{Float(time_point[1])/10000000}, lng: #{Float(time_point[2])/10000000}}" |
|
end |
|
f2.puts "routes:\n"; |
|
end |
|
|
|
|