Sha256: 3327a4c90b910dd91d0f07ee76be457121e90587aba268acfbdd49ee6399a52c

Contents?: true

Size: 533 Bytes

Versions: 31

Compression:

Stored size: 533 Bytes

Contents

class LocationGps < AbstractAdapter
  belongs_to :location
  has_many :beacons, through: :location

  # lat and lng in degrees altitude in meters
  validates_numericality_of :lat, greater_than_or_equal_to: -90.0, less_than_or_equal_to: 90.0
  validates_numericality_of :lng, greater_than_or_equal_to: -180.0, less_than_or_equal_to: 180.0
  validates_numericality_of :alt

  def distance_from(lat,lng) # calc distance between this location and the passed coords
    Haversine.distance(self.lat,self.lng, lat,lng).to_meters
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
introspective_grape-0.6.1 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.7 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.6 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.5 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.4 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.2 spec/dummy/app/models/location_gps.rb
introspective_grape-0.5.0 spec/dummy/app/models/location_gps.rb
introspective_grape-0.4.3 spec/dummy/app/models/location_gps.rb
introspective_grape-0.4.2 spec/dummy/app/models/location_gps.rb
introspective_grape-0.4.1 spec/dummy/app/models/location_gps.rb
introspective_grape-0.4.0 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.9 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.7 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.6 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.5 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.3 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.2 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.1 spec/dummy/app/models/location_gps.rb
introspective_grape-0.3.0 spec/dummy/app/models/location_gps.rb
introspective_grape-0.2.9 spec/dummy/app/models/location_gps.rb