1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
module Chouette
class AccessLink < Chouette::TridentActiveRecord
has_metadata
include ObjectidSupport
attr_accessor :access_link_type, :link_orientation_type, :link_key
belongs_to :access_point, :class_name => 'Chouette::AccessPoint'
belongs_to :stop_area, :class_name => 'Chouette::StopArea'
validates_presence_of :name
validates_presence_of :link_orientation
def self.nullable_attributes
[:link_distance, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration,
:mobility_restricted_traveller_duration, :link_type]
end
def access_link_type
link_type && Chouette::ConnectionLinkType.new(link_type.underscore)
end
def access_link_type=(access_link_type)
self.link_type = (access_link_type ? access_link_type.camelcase : nil)
end
@@access_link_types = nil
def self.access_link_types
@@access_link_types ||= Chouette::ConnectionLinkType.all
end
def link_orientation_type
link_orientation && Chouette::LinkOrientationType.new(link_orientation.underscore)
end
def link_orientation_type=(link_orientation_type)
self.link_orientation = (link_orientation_type ? link_orientation_type.camelcase : nil)
end
@@link_orientation_types = nil
def self.link_orientation_types
@@link_orientation_types ||= Chouette::LinkOrientationType.all
end
def geometry
GeoRuby::SimpleFeatures::LineString.from_points( [ access_point.geometry, stop_area.geometry], 4326) if access_point.geometry and stop_area.geometry
end
def link_key
Chouette::AccessLink.build_link_key(access_point,stop_area,link_orientation_type)
end
def self.build_link_key(access_point,stop_area,link_orientation_type)
if link_orientation_type == "access_point_to_stop_area"
"A_#{access_point.id}-S_#{stop_area.id}"
else
"S_#{stop_area.id}-A_#{access_point.id}"
end
end
def geometry_presenter
Chouette::Geometry::AccessLinkPresenter.new self
end
end
end
|