Class: Chouette::PtLink
- Inherits:
-
ActiveRecord
show all
- Includes:
- Geokit::Mappable
- Defined in:
- app/models/chouette/pt_link.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#human_attribute_name, #nil_if_blank, nullable_attributes
Class Method Details
.import_csv ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/chouette/pt_link.rb', line 15
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
|
Instance Method Details
#geometry ⇒ Object
11
12
13
|
# File 'app/models/chouette/pt_link.rb', line 11
def geometry
the_geom
end
|