Skip to content
Snippets Groups Projects
Commit 1949305b authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge commit 'fcdd2d7a'

Conflicts:
	lib/geocoder.rb
parents 0678ae8f fcdd2d7a
No related branches found
No related tags found
No related merge requests found
......@@ -227,6 +227,7 @@ Street address geocoding services currently supported (valid settings for the ab
* Google: <tt>:google</tt>
* Yahoo: <tt>:yahoo</tt>
* Geocoder.ca: <tt>:geocoder_ca</tt> (US and Canada only)
* Bing: <tt>:bing</tt>
Note that the result objects returned by different geocoding services all implement the methods listed above. Beyond that, however, you must be familiar with your particular subclass of <tt>Geocoder::Result</tt> and the geocoding service's result structure:
......@@ -235,7 +236,7 @@ Note that the result objects returned by different geocoding services all implem
* Geocoder.ca: (???)
* Yandex: http://api.yandex.ru/maps/geocoder/doc/desc/concepts/response_structure.xml
* FreeGeoIP: http://github.com/fiorix/freegeoip/blob/master/README.rst
* Bing: http://msdn.microsoft.com/en-us/library/ff701715.aspx
=== API Keys
To use your Google API key or Yahoo app ID:
......@@ -247,6 +248,7 @@ To obtain an API key:
* Yahoo: https://developer.apps.yahoo.com/wsregapp (not required)
* Google: http://code.google.com/apis/maps/signup.html (not required)
* Yandex: http://api.yandex.ru/maps/intro/concepts/intro.xml#apikey (required)
* Bing: http://www.bingmapsportal.com/
=== Timeout
......
......@@ -83,7 +83,7 @@ module Geocoder
# All street address lookups, default first.
#
def street_lookups
[:google, :yahoo, :geocoder_ca, :yandex]
[:google, :yahoo, :bing, :geocoder_ca, :yandex]
end
##
......
......@@ -403,6 +403,23 @@ class GeocoderTest < Test::Unit::TestCase
end
# --- Bing ---
def test_bing_result_components
Geocoder::Configuration.lookup = :bing
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "Madison Square Garden, NY", result.address
assert_equal "NY", result.state
assert_equal "New York", result.city
end
def test_bing_no_results
Geocoder::Configuration.lookup = :bing
results = Geocoder.search("no results")
assert_equal 0, results.length
end
# --- search queries ---
def test_hash_to_query
......
......@@ -119,6 +119,23 @@ module Geocoder
read_fixture "freegeoip_74_200_247_59.json"
end
end
class Bing < Base
private #-----------------------------------------------------------------
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
if reverse
read_fixture "bing_reverse.json"
else
file = case query
when "no results"; :no_results
else :madison_square_garden
end
read_fixture "bing_#{file}.json"
end
end
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment