Sha256: f8a2f3d6d3dc8058d6c702f0bca83817862d152b6f6ca151613b76bf905044d4
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
require 'geokit' class Chouette::PtLink < Chouette::ActiveRecord # FIXME http://jira.codehaus.org/browse/JRUBY-6358 set_primary_key :id attr_accessible :start_of_link_id, :end_of_link_id, :route_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :link_distance include Geokit::Mappable def geometry the_geom end def self.import_csv csv_file = Rails.root + "chouette_pt_links.csv" if File.exists?( csv_file) csv = CSV::Reader.parse(File.read(csv_file)) slug = csv.shift.first Network::Base.find_by_slug( slug).tune_connection csv.each do |row| origin = Chouette::StopArea.find_by_objectid( row[0]) destination = Chouette::StopArea.find_by_objectid( row[1]) raise "unknown origin #{row[0]}" unless origin raise "unknown destination #{row[1]}" unless destination Chouette::PtLink.create( :departure_id => origin.id, :arrival_id => destination.id, :the_geom => GeoRuby::SimpleFeatures::Geometry.from_hex_ewkb( row[2])) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems