diff --git a/README.md b/README.md index dfa1370d4ef7bf2f4be4704be0b94e618ad8f3d5..6f162bd558baebbc8f43baa95aa2c4eca8d7d0bb 100644 --- a/README.md +++ b/README.md @@ -374,7 +374,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of #### Mapquest (`:mapquest`) -* **API key**: required for the licensed API, do not use for open tier +* **API key**: required * **Quota**: ? * **HTTP Headers**: in order to use the licensed API you can configure the http_headers to include a referer as so: `Geocoder.configure(:http_headers => { "Referer" => "http://foo.com" })` @@ -385,6 +385,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of * **Documentation**: http://www.mapquestapi.com/geocoding/ * **Terms of Service**: http://info.mapquest.com/terms-of-use/ * **Limitations**: ? +* **Notes**: You can specify the licensed API by setting: `Geocoder.configure(:mapquest => {:licensed => true})` (defaults to free "open" version) #### Ovi/Nokia (`:ovi`) diff --git a/lib/geocoder/lookups/mapquest.rb b/lib/geocoder/lookups/mapquest.rb index ce0c8ac02f4dda4d8c30eaf4bb7efb1cdf786b6b..e1b9c4d1974801574061010c0fa6a2079e0d96c7 100644 --- a/lib/geocoder/lookups/mapquest.rb +++ b/lib/geocoder/lookups/mapquest.rb @@ -10,12 +10,11 @@ module Geocoder::Lookup end def required_api_key_parts - [] + ["key"] end def query_url(query) - key = configuration.api_key - domain = key ? "www" : "open" + domain = configuration[:licensed] ? "www" : "open" url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v1/#{search_type(query)}?" url + url_query_string(query) end diff --git a/test/services_test.rb b/test/services_test.rb index 022b42334940951666c89e037f4fa90f5f398fe1..c6ba1f91c61cdd42f6d6315418dbeef01662f398 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -276,6 +276,15 @@ class ServicesTest < Test::Unit::TestCase lookup = Geocoder::Lookup::Mapquest.new query = Geocoder::Query.new("Bluffton, SC") res = lookup.query_url(query) + assert_equal "http://open.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", + res + end + + def test_api_route_licensed + Geocoder.configure(:lookup => :mapquest, :api_key => "abc123", :mapquest => {:licensed => true}) + lookup = Geocoder::Lookup::Mapquest.new + query = Geocoder::Query.new("Bluffton, SC") + res = lookup.query_url(query) assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", res end