require 'ruby-debug'
module Graticule #:nodoc:
module Geocoder #:nodoc:
# Mapquest requires both a client id and a password, which you can
# get by registering at:
# http://developer.mapquest.com/Home/Register?_devAPISignup_WAR_devAPISignup_action=signup&_devAPISignup_WAR_devAPISignup_clientType=Developer
#
# mq = Graticule.service(:mapquest).new(CLIENT_ID, PASSWORD)
# location = gg.locate('44 Allen Rd., Lovell, ME 04051')
# [42.78942, -86.104424]
#
class Mapquest < Rest
# I would link to the documentation here, but there is none that will do anything but confuse you.
PRECISION = {
'L1' => :address,
'I1' => :street,
'B1' => :street,
'B2' => :street,
'B3' => :street,
'Z3' => :zip,
'Z4' => :zip,
'Z2' => :zip,
'Z1' => :zip,
'A5' => :city,
'A4' => :county,
'A3' => :state,
'A1' => :country
}
def initialize(client_id, password)
@password = password
@client_id = client_id
@url = URI.parse('http://geocode.dev.mapquest.com/mq/mqserver.dll')
end
# Locates +address+ returning a Location
def locate(address)
do_locate(address, false)
end
def locate_all(address)
do_locate(address, true)
end
protected
def do_locate(address, multi)
get(:q => address.is_a?(String) ? address : location_from_params(address).to_s, :multiple => multi)
end
def make_url(params) #:nodoc
query = "e=5&