app/models/chouette/access_point.rb in ninoxe-0.1.2 vs app/models/chouette/access_point.rb in ninoxe-0.1.3
- old
+ new
@@ -1,43 +1,44 @@
require 'geokit'
require 'geo_ruby'
class Chouette::AccessPoint < Chouette::TridentActiveRecord
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
- set_primary_key :id
+ self.primary_key = "id"
include Geokit::Mappable
has_many :access_links, :dependent => :destroy
belongs_to :stop_area
attr_accessor :access_point_type
attr_accessible :objectid, :object_version, :creation_time, :creator_id, :name, :comment
- attr_accessible :longitude, :latitude, :long_lat_type, :x, :y, :projection_type
+ attr_accessible :longitude, :latitude, :long_lat_type
+ #attr_accessible :x, :y, :projection_type
attr_accessible :country_code, :street_name
attr_accessible :openning_time, :closing_time, :access_type, :access_point_type
attr_accessible :mobility_restricted_suitability, :stairs_availability, :lift_availability
attr_accessible :stop_area_id
# workaround of ruby 1.8 private method y block attribute y reading access
- def y
- read_attribute :y
- end
+ #def y
+ # read_attribute :y
+ #end
validates_presence_of :name
validates_presence_of :access_type
validates_presence_of :latitude, :if => :longitude
validates_presence_of :longitude, :if => :latitude
validates_numericality_of :latitude, :less_than_or_equal_to => 90, :greater_than_or_equal_to => -90, :allow_nil => true
validates_numericality_of :longitude, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180, :allow_nil => true
- validates_presence_of :x, :if => :y
- validates_presence_of :y, :if => :x
- validates_numericality_of :x, :allow_nil => true
- validates_numericality_of :y, :allow_nil => true
+ #validates_presence_of :x, :if => :y
+ #validates_presence_of :y, :if => :x
+ #validates_numericality_of :x, :allow_nil => true
+ #validates_numericality_of :y, :allow_nil => true
def self.nullable_attributes
- [:street_name, :country_code, :comment, :projection_type, :long_lat_type, :x, :y]
+ [:street_name, :country_code, :comment, :long_lat_type]
end
def to_lat_lng
Geokit::LatLng.new(latitude, longitude) if latitude and longitude
end
@@ -140,6 +141,9 @@
end
end
matrix
end
+ def geometry_presenter
+ Chouette::Geometry::AccessPointPresenter.new self
+ end
end