Class: Chouette::AccessPoint
Constant Summary
collapse
- @@access_point_types =
nil
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#build_objectid, #clean_object_id, #default_values, #fix_uniq_objectid, model_name, object_id_key, #objectid, #objectid_format_compliance, #prefix, #prepare_auto_columns, #reset_auto_columns, #timestamp_attributes_for_create, #timestamp_attributes_for_update, #uniq_objectid
#human_attribute_name, #nil_if_blank
Instance Attribute Details
#access_point_type ⇒ Object
Returns the value of attribute access_point_type.
11
12
13
|
# File 'app/models/chouette/access_point.rb', line 11
def access_point_type
@access_point_type
end
|
#coordinates ⇒ Object
46
47
48
|
# File 'app/models/chouette/access_point.rb', line 46
def coordinates
@coordinates || combine_lat_lng
end
|
Class Method Details
.access_point_types ⇒ Object
101
102
103
104
105
|
# File 'app/models/chouette/access_point.rb', line 101
def self.access_point_types
@@access_point_types ||= Chouette::AccessPointType.all.select do |access_point_type|
access_point_type.to_i >= 0
end
end
|
.nullable_attributes ⇒ Object
32
33
34
|
# File 'app/models/chouette/access_point.rb', line 32
def self.nullable_attributes
[:street_name, :country_code, :comment, :long_lat_type, :zip_code, :city_name]
end
|
Instance Method Details
#combine_lat_lng ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/models/chouette/access_point.rb', line 38
def combine_lat_lng
if self.latitude.nil? || self.longitude.nil?
""
else
self.latitude.to_s+","+self.longitude.to_s
end
end
|
#coordinates_to_lat_lng ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/models/chouette/access_point.rb', line 50
def coordinates_to_lat_lng
if ! @coordinates.nil?
if @coordinates.empty?
self.latitude = nil
self.longitude = nil
else
self.latitude = BigDecimal.new(@coordinates.split(",").first)
self.longitude = BigDecimal.new(@coordinates.split(",").last)
end
@coordinates = nil
end
end
|
#default_position ⇒ Object
87
88
89
|
# File 'app/models/chouette/access_point.rb', line 87
def default_position
stop_area.geometry or stop_area.default_position
end
|
#detail_access_link_matrix ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'app/models/chouette/access_point.rb', line 136
def detail_access_link_matrix
matrix = Array.new
hash = Hash.new
access_links.each do |link|
hash[link.link_key] = link
end
stop_area.children_at_base.each do |child|
key=Chouette::AccessLink.build_link_key(self,child,"access_point_to_stop_area")
if hash.has_key?(key)
matrix << hash[key]
else
link = Chouette::AccessLink.new
link.access_point = self
link.stop_area = child
link.link_orientation_type = "access_point_to_stop_area"
matrix << link
end
key=Chouette::AccessLink.build_link_key(self,child,"stop_area_to_access_point")
if hash.has_key?(key)
matrix << hash[key]
else
link = Chouette::AccessLink.new
link.access_point = self
link.stop_area = child
link.link_orientation_type = "stop_area_to_access_point"
matrix << link
end
end
matrix
end
|
#generic_access_link_matrix ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'app/models/chouette/access_point.rb', line 107
def generic_access_link_matrix
matrix = Array.new
hash = Hash.new
access_links.each do |link|
hash[link.link_key] = link
end
key=Chouette::AccessLink.build_link_key(self,stop_area,"access_point_to_stop_area")
if hash.has_key?(key)
matrix << hash[key]
else
link = Chouette::AccessLink.new
link.access_point = self
link.stop_area = stop_area
link.link_orientation_type = "access_point_to_stop_area"
matrix << link
end
key=Chouette::AccessLink.build_link_key(self,stop_area,"stop_area_to_access_point")
if hash.has_key?(key)
matrix << hash[key]
else
link = Chouette::AccessLink.new
link.access_point = self
link.stop_area = stop_area
link.link_orientation_type = "stop_area_to_access_point"
matrix << link
end
matrix
end
|
#geometry ⇒ Object
67
68
69
|
# File 'app/models/chouette/access_point.rb', line 67
def geometry
GeoRuby::SimpleFeatures::Point.from_lon_lat(longitude, latitude, 4326) if latitude and longitude
end
|
#geometry=(geometry) ⇒ Object
71
72
73
74
|
# File 'app/models/chouette/access_point.rb', line 71
def geometry=(geometry)
geometry = geometry.to_wgs84
self.latitude, self.longitude, self.long_lat_type = geometry.lat, geometry.lng, "WGS84"
end
|
#geometry_presenter ⇒ Object
167
168
169
|
# File 'app/models/chouette/access_point.rb', line 167
def geometry_presenter
Chouette::Geometry::AccessPointPresenter.new self
end
|
#position ⇒ Object
76
77
78
|
# File 'app/models/chouette/access_point.rb', line 76
def position
geometry
end
|
#position=(position) ⇒ Object
80
81
82
83
84
85
|
# File 'app/models/chouette/access_point.rb', line 80
def position=(position)
position = nil if String === position && position == ""
position = Geokit::LatLng.normalize(position), 4326 if String === position
self.latitude = position.lat
self.longitude = position.lng
end
|
#to_lat_lng ⇒ Object
63
64
65
|
# File 'app/models/chouette/access_point.rb', line 63
def to_lat_lng
Geokit::LatLng.new(latitude, longitude) if latitude and longitude
end
|