Class: ActiveRoad::AccessPoint
- Inherits:
-
Object
- Object
- ActiveRoad::AccessPoint
- Defined in:
- app/models/active_road/access_point.rb
Overview
Access Point is a projection from an origin point on a Physical Road This origin point and Access Point are linked by an Access Link
Instance Attribute Summary collapse
-
#exit ⇒ Object
(also: #exit?)
Returns the value of attribute exit.
-
#location ⇒ Object
Returns the value of attribute location.
-
#physical_road ⇒ Object
Returns the value of attribute physical_road.
Class Method Summary collapse
-
.from(location) ⇒ Object
Find access points from a location.
-
.to(location) ⇒ Object
Find access points to go to a location.
Instance Method Summary collapse
- #access_to_road?(road) ⇒ Boolean
-
#initialize(attributes = {}) ⇒ AccessPoint
constructor
A new instance of AccessPoint.
- #location_on_road(road = nil) ⇒ Object
- #name ⇒ Object
- #paths(constraints = {}) ⇒ Object
- #point_on_road ⇒ Object (also: #to_geometry, #geometry)
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ AccessPoint
Returns a new instance of AccessPoint.
9 10 11 12 13 |
# File 'app/models/active_road/access_point.rb', line 9 def initialize(attributes = {}) attributes.each do |k, v| send("#{k}=", v) end end |
Instance Attribute Details
#exit ⇒ Object Also known as: exit?
Returns the value of attribute exit.
6 7 8 |
# File 'app/models/active_road/access_point.rb', line 6 def exit @exit end |
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'app/models/active_road/access_point.rb', line 6 def location @location end |
#physical_road ⇒ Object
Returns the value of attribute physical_road.
6 7 8 |
# File 'app/models/active_road/access_point.rb', line 6 def physical_road @physical_road end |
Class Method Details
.from(location) ⇒ Object
Find access points from a location
16 17 18 19 20 |
# File 'app/models/active_road/access_point.rb', line 16 def self.from(location) ActiveRoad::PhysicalRoad.nearest_to(location).collect do |physical_road| new :location => location, :physical_road => physical_road end end |
.to(location) ⇒ Object
Find access points to go to a location
23 24 25 26 27 |
# File 'app/models/active_road/access_point.rb', line 23 def self.to(location) ActiveRoad::PhysicalRoad.nearest_to(location).collect do |physical_road| new :location => location, :physical_road => physical_road, :exit => true end end |
Instance Method Details
#access_to_road?(road) ⇒ Boolean
39 40 41 |
# File 'app/models/active_road/access_point.rb', line 39 def access_to_road?(road) physical_road.id == road.id end |
#location_on_road(road = nil) ⇒ Object
29 30 31 |
# File 'app/models/active_road/access_point.rb', line 29 def location_on_road(road = nil) @location_on_road ||= physical_road.locate_point location end |
#name ⇒ Object
43 44 45 |
# File 'app/models/active_road/access_point.rb', line 43 def name "Access on #{physical_road.objectid} @#{point_on_road.to_lat_lng} (for @#{location.to_lat_lng})" end |
#paths(constraints = {}) ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/models/active_road/access_point.rb', line 53 def paths(constraints = {}) unless exit? ActiveRoad::Path.all self, physical_road.junctions, physical_road else [ActiveRoad::AccessLink.new(:departure => self, :arrival => location)] end end |
#point_on_road ⇒ Object Also known as: to_geometry, geometry
33 34 35 |
# File 'app/models/active_road/access_point.rb', line 33 def point_on_road @point_on_road ||= physical_road.interpolate_point location_on_road end |
#to_s ⇒ Object
49 50 51 |
# File 'app/models/active_road/access_point.rb', line 49 def to_s name end |