Sha256: d70c93a50c6c710ea85cee8dbd8ee1e9e14ffb742ccd6d81214300f08217d8ce

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

class Chouette::ConnectionLink < Chouette::TridentActiveRecord
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
  self.primary_key = "id"

  attr_accessor :connection_link_type

  # attr_accessible :connection_link_type,:departure_id, :arrival_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment
  # attr_accessible :link_distance, :link_type, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration
  # attr_accessible :mobility_restricted_traveller_duration, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs

  belongs_to :departure, :class_name => 'Chouette::StopArea'
  belongs_to :arrival, :class_name => 'Chouette::StopArea'

  validates_presence_of :name

  def self.nullable_attributes
    [:link_distance, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration,
      :mobility_restricted_traveller_duration]
  end

  def connection_link_type
    link_type && Chouette::ConnectionLinkType.new( link_type.underscore)
  end

  def connection_link_type=(connection_link_type)
    self.link_type = (connection_link_type ? connection_link_type.camelcase : nil)
  end

  @@connection_link_types = nil
  def self.connection_link_types
    @@connection_link_types ||= Chouette::ConnectionLinkType.all
  end

  def possible_areas
    Chouette::StopArea.where("area_type != 'ITL'")
  end

  def stop_areas
    Chouette::StopArea.where(:id => [self.departure_id,self.arrival_id])
  end

  def geometry
    GeoRuby::SimpleFeatures::LineString.from_points( [ departure.geometry, arrival.geometry], 4326) if departure.geometry and arrival.geometry
  end

  def geometry_presenter
    Chouette::Geometry::ConnectionLinkPresenter.new self
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ninoxe-1.2.3 app/models/chouette/connection_link.rb
ninoxe-1.2.2 app/models/chouette/connection_link.rb