You are here: Browse Railsplugins Acts As Locatable
acts_as_locatable adds typical functionality to geographically located objects, like:
It allows for using meters or miles as measure unit, and Cosine Law, Haversine or Vincenty formulae for distance computation.
The locatable class should be an ActiveRecord model with columns for storing latitude/longitude. Usage:
class Place < ActiveRecord::Base acts_as_locatable end
The ‘test’ directory contains unit tests for acts_as_locatable. To run them:
The default measure unit is meters. To override and use miles:
acts_as_locatable :unit => 'mile'
To override the unit only in certain situation use directly method variants for each unit.
The default distance calculation is the Cosine Law. To override pass the :formula option with value 'vincenty' or 'haversine':
acts_as_locatable :formula => 'vincenty'
Note that the Vincenty formula is more accurate, but may not converge for antipode locations.
To override the formula only in certain situations use directly method variants for each formula.
Tests
This project is hosted at RubyForge: http://actsaslocatable.rubyforge.org/ Please use the tools provided there to contact developers and submit bugs!
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly