Sha256: 0b08a9b6d0967d195144bf765de693b919eec181d22305beb40ee3de9f3effa5
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
class ActiveRoad::AccessLink attr_accessor :departure, :arrival def initialize(attributes = {}) attributes.each do |k, v| send("#{k}=", v) end end def name "AccessLink : #{departure} -> #{arrival}" end alias_method :to_s, :name def self.from(location, constraints = {}) ActiveRoad::AccessPoint.from(location, constraints).collect do |access_point| new :departure => location, :arrival => access_point end end def length @length ||= departure.to_geometry.spherical_distance arrival.to_geometry end # TODO Delete this hack due to postgis adapter in physical road alias_method :length_in_meter, :length def geometry @geometry ||= GeoRuby::SimpleFeatures::LineString.from_points [departure.to_geometry, arrival.to_geometry] end alias_method :to_geometry, :geometry delegate :access_to_road?, :to => :arrival def paths(constraints = {}) arrival.respond_to?(:paths) ? arrival.paths(constraints) : [arrival] end def access_to_road?(road) arrival.respond_to?(:access_to_road?) ? arrival.access_to_road?(road) : false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_road-0.0.2 | app/models/active_road/access_link.rb |