Module GeoKit::ActsAsMappable
In: vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb

Contains the class method acts_as_mappable targeted to be mixed into ActiveRecord. When mixed in, augments find services such that they provide distance calculation query services. The find method accepts additional options:

  • :origin - can be
    1. a two-element array of latititude/longitude — :origin=>
    2. a geocodeable string — :origin=>’100 Spear st, San Francisco, CA‘
    3. an object which responds to lat and lng methods, or latitude and longitude methods, or whatever methods you have specified for lng_column_name and lat_column_name

Other finder methods are provided for specific queries. These are:

  • find_within (alias: find_inside)
  • find_beyond (alias: find_outside)
  • find_closest (alias: find_nearest)
  • find_farthest

Counter methods are available and work similarly to finders.

If raw SQL is desired, the distance_sql method can be used to obtain SQL appropriate to use in a find_by_sql call.

Methods

Public Instance methods

this is the callback for auto_geocoding

[Source]

    # File vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb, line 79
79:     def auto_geocode_address
80:       address=self.send(auto_geocode_field)
81:       geo=GeoKit::Geocoders::MultiGeocoder.geocode(address)
82:   
83:       if geo.success
84:         self.send("#{lat_column_name}=", geo.lat)
85:         self.send("#{lng_column_name}=", geo.lng)
86:       else
87:         errors.add(auto_geocode_field, auto_geocode_error_message) 
88:       end
89:       
90:       geo.success
91:     end

[Validate]