Created
May 4, 2011 21:00
-
-
Save graybill/956024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.coordinates(addr) | |
include Geokit::Geocoders | |
res=MultiGeocoder.geocode(addr) | |
r = res.ll.split(',') | |
[r[0].to_f, r[1].to_f] | |
end | |
def self.create(params = nil) | |
loc = coordinates(params[:address1] + "+PA+" + params[:zipcode]) | |
super | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class Matching < ActiveRecord::Base
before_create :set_location
private
def set_location
self.loc = coordinates(params[:address1] + "+PA+" + params[:zipcode])
end
def coordinates(addr)
include Geokit::Geocoders
res=MultiGeocoder.geocode(addr)
r = res.ll.split(',')
[r[0].to_f, r[1].to_f]
end