Module: Tillless::Location
- Defined in:
- lib/tillless-core/location.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, RailsInstanceMethods, RubyInstanceMethods Classes: LocationCalibrationException
Constant Summary collapse
- RADIUS_OF_EARTH =
Radius of the Earth in km
Float(6378.7)
- MIN_DISTANCE_FOR_NEARBY_IN_KM =
Minimum distance apart to be considered ‘near’ in km
0.2
- MIN_DISTANCE_FOR_NEARBY_IN_M =
MIN_DISTANCE_FOR_NEARBY_IN_KM * 1000.0
- PI_RADIANCE =
Shorthand for Pi Radians
(Math::PI / 180)
- GREAT_CIRCLE_FACTOR =
Factor used in great circle calcs
57.2958
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tillless-core/location.rb', line 22 def self.included(base) base.send :include, InstanceMethods base.send :extend, ClassMethods # Set the right attr method if a rails environment (assuming it's an ActiveRecord model) if defined?(Rails.env) base.send :attr_accessible, :lat, :lon base.send :validates_presence_of, :lat, :lon # Always recalibrate on save base.send :before_save, :calibrate base.send :include, RailsInstanceMethods else base.send :include, RubyInstanceMethods attr_accessor :lat, :lon # true if calibrated, note: following lat= or lon= it will need to be re-calibrated attr_accessor :calibrated # These are used so that half of the Great Circle algorithm can be calculated on # instantiation which makes any subsequent comparison check significantly faster. # See calibrate() for more details. attr_accessor :term1, :term2, :term3, :term4, :term5, :term6 end end |