geokit 1.8.4 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -6
- data/CHANGELOG.md +9 -0
- data/README.markdown +27 -3
- data/fixtures/vcr_cassettes/bing_au.yml +86 -0
- data/fixtures/vcr_cassettes/bing_full.yml +61 -68
- data/fixtures/vcr_cassettes/bing_full_au.yml +43 -39
- data/fixtures/vcr_cassettes/bing_full_de.yml +43 -39
- data/fixtures/vcr_cassettes/fcc_reverse_geocode.yml +9 -7
- data/fixtures/vcr_cassettes/geocodio_geocode.yml +43 -0
- data/fixtures/vcr_cassettes/google_city.yml +8 -6
- data/fixtures/vcr_cassettes/google_country_code_biased_result.yml +27 -25
- data/fixtures/vcr_cassettes/google_full.yml +13 -16
- data/fixtures/vcr_cassettes/google_full_short.yml +8 -6
- data/fixtures/vcr_cassettes/google_language_response_fr.yml +23 -21
- data/fixtures/vcr_cassettes/google_multi.yml +7 -5
- data/fixtures/vcr_cassettes/google_reverse_madrid.yml +281 -278
- data/fixtures/vcr_cassettes/google_reverse_madrid_es.yml +26 -32
- data/fixtures/vcr_cassettes/map_quest_full.yml +53 -0
- data/fixtures/vcr_cassettes/map_quest_reverse_madrid.yml +52 -0
- data/fixtures/vcr_cassettes/ripe_geocode_45.yml +45 -0
- data/fixtures/vcr_cassettes/yahoo_city.yml +1 -1
- data/fixtures/vcr_cassettes/yahoo_full.yml +1 -1
- data/fixtures/vcr_cassettes/yahoo_no_results.yml +1 -1
- data/lib/geokit/geocoders.rb +16 -1
- data/lib/geokit/geocoders/bing.rb +22 -18
- data/lib/geokit/geocoders/fcc.rb +2 -1
- data/lib/geokit/geocoders/geocodio.rb +59 -0
- data/lib/geokit/geocoders/google.rb +7 -3
- data/lib/geokit/geocoders/mapquest.rb +3 -2
- data/lib/geokit/geocoders/ripe.rb +8 -5
- data/lib/geokit/geocoders/yahoo.rb +2 -1
- data/lib/geokit/lat_lng.rb +13 -3
- data/lib/geokit/mappable.rb +13 -0
- data/lib/geokit/multi_geocoder.rb +13 -2
- data/lib/geokit/net_adapter/net_http.rb +6 -1
- data/lib/geokit/version.rb +1 -1
- data/test/helper.rb +2 -1
- data/test/test_bing_geocoder.rb +23 -3
- data/test/test_fcc_geocoder.rb +1 -1
- data/test/test_geocodio_geocoder.rb +33 -0
- data/test/test_google_geocoder.rb +31 -17
- data/test/test_latlng.rb +18 -0
- data/test/test_map_quest.rb +56 -0
- data/test/test_multi_geocoder.rb +7 -0
- data/test/test_ripe_geocoder.rb +19 -12
- data/test/test_yahoo_geocoder.rb +7 -7
- metadata +12 -8
data/test/test_latlng.rb
CHANGED
@@ -216,4 +216,22 @@ class LatLngTest < Test::Unit::TestCase #:nodoc: all
|
|
216
216
|
assert_equal "Porscheplatz 1, 45127 Essen, Deutschland", res.full_address #slightly different from yahoo
|
217
217
|
assert_equal "google", res.provider
|
218
218
|
end
|
219
|
+
|
220
|
+
def test_to_dms
|
221
|
+
point = Geokit::LatLng.new(41.957254, -87.660333)
|
222
|
+
|
223
|
+
dms = point.lat_dms
|
224
|
+
assert_kind_of Array, dms
|
225
|
+
assert_equal 3, dms.length
|
226
|
+
assert_kind_of Numeric, dms.length
|
227
|
+
assert_equal [41, 57], dms[0, 2]
|
228
|
+
assert_equal 26, dms[2].round
|
229
|
+
|
230
|
+
dms = point.lng_dms
|
231
|
+
assert_kind_of Array, dms
|
232
|
+
assert_equal 3, dms.length
|
233
|
+
assert_kind_of Numeric, dms.length
|
234
|
+
assert_equal [-87, 39], dms[0, 2]
|
235
|
+
assert_equal 37, dms[2].round
|
236
|
+
end
|
219
237
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class MapQuestGeocoderTest < BaseGeocoderTest #:nodoc: all
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@full_address = '100 Spear St Apt. 5, San Francisco, CA, 94105-1522, US'
|
8
|
+
@google_full_hash = {:street_address=>"100 Spear St Apt. 5", :city=>"San Francisco", :state=>"CA", :zip=>"94105", :country_code=>"US"}
|
9
|
+
@google_city_hash = {:city=>"San Francisco", :state=>"CA"}
|
10
|
+
|
11
|
+
@google_full_loc = Geokit::GeoLoc.new(@google_full_hash)
|
12
|
+
@google_city_loc = Geokit::GeoLoc.new(@google_city_hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_map_quest_full_address_with_geo_loc
|
17
|
+
VCR.use_cassette('map_quest_full') do
|
18
|
+
key = 'Fmjtd%7Cluur2d0125%2C2s%3Do5-9a8lhz'
|
19
|
+
Geokit::Geocoders::MapQuestGeocoder.key =key
|
20
|
+
url = "https://www.mapquestapi.com/geocoding/v1/address?key=#{key}&location=100+Spear+St+Apt.+5%2C+San+Francisco%2C+CA%2C+94105%2C+US"
|
21
|
+
TestHelper.expects(:last_url).with(url)
|
22
|
+
res=Geokit::Geocoders::MapQuestGeocoder.geocode(@google_full_loc)
|
23
|
+
assert_equal "CA", res.state
|
24
|
+
assert_equal "San Francisco", res.city
|
25
|
+
assert_array_in_delta [37.7921509, -122.394], res.to_a # slightly dif from yahoo
|
26
|
+
assert res.is_us?
|
27
|
+
assert_equal "100 Spear St, Apt 5, San Francisco, CA, 94105-1500, US", res.full_address #slightly different from yahoo
|
28
|
+
assert_equal "map_quest", res.provider
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def test_reverse_geocode
|
34
|
+
VCR.use_cassette('map_quest_reverse_madrid') do
|
35
|
+
madrid = Geokit::GeoLoc.new
|
36
|
+
madrid.lat, madrid.lng = "40.4167413", "-3.7032498"
|
37
|
+
key = 'Fmjtd%7Cluur2d0125%2C2s%3Do5-9a8lhz'
|
38
|
+
Geokit::Geocoders::MapQuestGeocoder.key =key
|
39
|
+
url = "https://www.mapquestapi.com/geocoding/v1/reverse?key=#{key}&location=#{madrid.lat},#{madrid.lng}"
|
40
|
+
TestHelper.expects(:last_url).with(url)
|
41
|
+
res=Geokit::Geocoders::MapQuestGeocoder.do_reverse_geocode(madrid.ll)
|
42
|
+
|
43
|
+
assert_equal madrid.lat.to_s.slice(1..5), res.lat.to_s.slice(1..5)
|
44
|
+
assert_equal madrid.lng.to_s.slice(1..5), res.lng.to_s.slice(1..5)
|
45
|
+
assert_equal "ES", res.country_code
|
46
|
+
assert_equal "map_quest", res.provider
|
47
|
+
|
48
|
+
assert_equal "Madrid", res.city
|
49
|
+
assert_equal "Comunidad de Madrid", res.state
|
50
|
+
|
51
|
+
assert_equal nil, res.country
|
52
|
+
assert_equal "28014", res.zip
|
53
|
+
assert_equal true, res.success
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/test/test_multi_geocoder.rb
CHANGED
@@ -92,4 +92,11 @@ class MultiGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
92
92
|
assert_equal @failure, Geokit::Geocoders::MultiGeocoder.reverse_geocode("")
|
93
93
|
Geokit::Geocoders.provider_order = t1 # reset to orig values
|
94
94
|
end
|
95
|
+
|
96
|
+
def test_custom_provider_order
|
97
|
+
Geokit::Geocoders::YahooGeocoder.expects(:geocode).with(@address, {}).returns(@success)
|
98
|
+
Geokit::Geocoders::GoogleGeocoder.expects(:geocode).never
|
99
|
+
Geokit::Geocoders::UsGeocoder.expects(:geocode).never
|
100
|
+
assert_equal @success, Geokit::Geocoders::MultiGeocoder.geocode(@address, :provider_order => [:yahoo, :google, :us])
|
101
|
+
end
|
95
102
|
end
|
data/test/test_ripe_geocoder.rb
CHANGED
@@ -11,25 +11,32 @@ class RipeGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
11
11
|
assert_equal expected_url, TestHelper.get_last_url.gsub(/&oauth_[a-z_]+=[a-zA-Z0-9\-. %]+/, '').gsub('%20', '+')
|
12
12
|
end
|
13
13
|
|
14
|
+
def test_45
|
15
|
+
VCR.use_cassette('ripe_geocode_45') do
|
16
|
+
res = Geokit::Geocoders::RipeGeocoder.geocode('45.45.45.45')
|
17
|
+
assert !res.success
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
14
21
|
def test_ripe_geocode
|
15
22
|
VCR.use_cassette('ripe_geocode') do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
url = "http://stat.ripe.net/data/geoloc/data.json?resource=#{@ip}"
|
24
|
+
res = Geokit::Geocoders::RipeGeocoder.geocode(@ip)
|
25
|
+
assert_url url
|
26
|
+
assert_equal res.city, 'Mountain View'
|
27
|
+
assert_equal res.state, 'CA'
|
28
|
+
assert_equal res.country_code, 'US'
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
25
32
|
def test_ripe_geocode_au
|
26
33
|
VCR.use_cassette('ripe_geocode_au') do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
url = "http://stat.ripe.net/data/geoloc/data.json?resource=#{@ip_au}"
|
35
|
+
res = Geokit::Geocoders::RipeGeocoder.geocode(@ip_au)
|
36
|
+
assert_url url
|
37
|
+
assert_equal res.city, 'Adelaide'
|
38
|
+
assert_equal res.state, nil
|
39
|
+
assert_equal res.country_code, 'AU'
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
data/test/test_yahoo_geocoder.rb
CHANGED
@@ -19,7 +19,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
19
19
|
# the testing methods themselves
|
20
20
|
def test_yahoo_full_address
|
21
21
|
VCR.use_cassette('yahoo_full') do
|
22
|
-
url = "
|
22
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@full_address)}"
|
23
23
|
do_full_address_assertions(Geokit::Geocoders::YahooGeocoder.geocode(@full_address))
|
24
24
|
assert_yahoo_url url
|
25
25
|
end
|
@@ -27,7 +27,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
27
27
|
|
28
28
|
def test_yahoo_full_address_accuracy
|
29
29
|
VCR.use_cassette('yahoo_full') do
|
30
|
-
url = "
|
30
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@full_address)}"
|
31
31
|
res = Geokit::Geocoders::YahooGeocoder.geocode(@full_address)
|
32
32
|
assert_yahoo_url url
|
33
33
|
assert_equal 8, res.accuracy
|
@@ -36,7 +36,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
36
36
|
|
37
37
|
def test_yahoo_full_address_with_geo_loc
|
38
38
|
VCR.use_cassette('yahoo_full') do
|
39
|
-
url = "
|
39
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@full_address)}"
|
40
40
|
do_full_address_assertions(Geokit::Geocoders::YahooGeocoder.geocode(@yahoo_full_loc))
|
41
41
|
assert_yahoo_url url
|
42
42
|
end
|
@@ -44,7 +44,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
44
44
|
|
45
45
|
def test_yahoo_city
|
46
46
|
VCR.use_cassette('yahoo_city') do
|
47
|
-
url = "
|
47
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@address)}"
|
48
48
|
do_city_assertions(Geokit::Geocoders::YahooGeocoder.geocode(@address))
|
49
49
|
assert_yahoo_url url
|
50
50
|
end
|
@@ -52,7 +52,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
52
52
|
|
53
53
|
def test_yahoo_city_accuracy
|
54
54
|
VCR.use_cassette('yahoo_city') do
|
55
|
-
url = "
|
55
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@address)}"
|
56
56
|
res = Geokit::Geocoders::YahooGeocoder.geocode(@address)
|
57
57
|
assert_yahoo_url url
|
58
58
|
assert_equal 4, res.accuracy
|
@@ -61,7 +61,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
61
61
|
|
62
62
|
def test_yahoo_city_with_geo_loc
|
63
63
|
VCR.use_cassette('yahoo_city') do
|
64
|
-
url = "
|
64
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(@address)}"
|
65
65
|
do_city_assertions(Geokit::Geocoders::YahooGeocoder.geocode(@yahoo_city_loc))
|
66
66
|
assert_yahoo_url url
|
67
67
|
end
|
@@ -73,7 +73,7 @@ class YahooGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
73
73
|
no_results_full_loc = Geokit::GeoLoc.new(no_results_full_hash)
|
74
74
|
|
75
75
|
VCR.use_cassette('yahoo_no_results') do
|
76
|
-
url = "
|
76
|
+
url = "https://yboss.yahooapis.com/geo/placefinder?flags=J&q=#{Geokit::Inflector.url_escape(no_results_address)}"
|
77
77
|
result = Geokit::Geocoders::YahooGeocoder.geocode(no_results_address)
|
78
78
|
assert_yahoo_url url
|
79
79
|
assert_equal ",", result.ll
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: multi_json
|
@@ -190,12 +190,14 @@ files:
|
|
190
190
|
- MIT-LICENSE
|
191
191
|
- README.markdown
|
192
192
|
- Rakefile
|
193
|
+
- fixtures/vcr_cassettes/bing_au.yml
|
193
194
|
- fixtures/vcr_cassettes/bing_full.yml
|
194
195
|
- fixtures/vcr_cassettes/bing_full_au.yml
|
195
196
|
- fixtures/vcr_cassettes/bing_full_de.yml
|
196
197
|
- fixtures/vcr_cassettes/fcc_reverse_geocode.yml
|
197
198
|
- fixtures/vcr_cassettes/free_geo_ip_geocode.yml
|
198
199
|
- fixtures/vcr_cassettes/geo_plugin_geocode.yml
|
200
|
+
- fixtures/vcr_cassettes/geocodio_geocode.yml
|
199
201
|
- fixtures/vcr_cassettes/geonames_geocode.yml
|
200
202
|
- fixtures/vcr_cassettes/google_city.yml
|
201
203
|
- fixtures/vcr_cassettes/google_country_code_biased_result.yml
|
@@ -205,7 +207,10 @@ files:
|
|
205
207
|
- fixtures/vcr_cassettes/google_multi.yml
|
206
208
|
- fixtures/vcr_cassettes/google_reverse_madrid.yml
|
207
209
|
- fixtures/vcr_cassettes/google_reverse_madrid_es.yml
|
210
|
+
- fixtures/vcr_cassettes/map_quest_full.yml
|
211
|
+
- fixtures/vcr_cassettes/map_quest_reverse_madrid.yml
|
208
212
|
- fixtures/vcr_cassettes/ripe_geocode.yml
|
213
|
+
- fixtures/vcr_cassettes/ripe_geocode_45.yml
|
209
214
|
- fixtures/vcr_cassettes/ripe_geocode_au.yml
|
210
215
|
- fixtures/vcr_cassettes/yahoo_city.yml
|
211
216
|
- fixtures/vcr_cassettes/yahoo_full.yml
|
@@ -222,6 +227,7 @@ files:
|
|
222
227
|
- lib/geokit/geocoders/fcc.rb
|
223
228
|
- lib/geokit/geocoders/free_geo_ip.rb
|
224
229
|
- lib/geokit/geocoders/geo_plugin.rb
|
230
|
+
- lib/geokit/geocoders/geocodio.rb
|
225
231
|
- lib/geokit/geocoders/geonames.rb
|
226
232
|
- lib/geokit/geocoders/google.rb
|
227
233
|
- lib/geokit/geocoders/ip.rb
|
@@ -248,12 +254,14 @@ files:
|
|
248
254
|
- test/test_fcc_geocoder.rb
|
249
255
|
- test/test_free_geo_ip_geocoder.rb
|
250
256
|
- test/test_geo_plugin_geocoder.rb
|
257
|
+
- test/test_geocodio_geocoder.rb
|
251
258
|
- test/test_geoloc.rb
|
252
259
|
- test/test_geonames_geocoder.rb
|
253
260
|
- test/test_google_geocoder.rb
|
254
261
|
- test/test_inflector.rb
|
255
262
|
- test/test_ipgeocoder.rb
|
256
263
|
- test/test_latlng.rb
|
264
|
+
- test/test_map_quest.rb
|
257
265
|
- test/test_mappable.rb
|
258
266
|
- test/test_maxmind_geocoder.rb
|
259
267
|
- test/test_multi_geocoder.rb
|
@@ -280,18 +288,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
288
|
- - ! '>='
|
281
289
|
- !ruby/object:Gem::Version
|
282
290
|
version: '0'
|
283
|
-
segments:
|
284
|
-
- 0
|
285
|
-
hash: -1117828600571501675
|
286
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
287
292
|
none: false
|
288
293
|
requirements:
|
289
294
|
- - ! '>='
|
290
295
|
- !ruby/object:Gem::Version
|
291
296
|
version: '0'
|
292
|
-
segments:
|
293
|
-
- 0
|
294
|
-
hash: -1117828600571501675
|
295
297
|
requirements: []
|
296
298
|
rubyforge_project:
|
297
299
|
rubygems_version: 1.8.25
|
@@ -307,12 +309,14 @@ test_files:
|
|
307
309
|
- test/test_fcc_geocoder.rb
|
308
310
|
- test/test_free_geo_ip_geocoder.rb
|
309
311
|
- test/test_geo_plugin_geocoder.rb
|
312
|
+
- test/test_geocodio_geocoder.rb
|
310
313
|
- test/test_geoloc.rb
|
311
314
|
- test/test_geonames_geocoder.rb
|
312
315
|
- test/test_google_geocoder.rb
|
313
316
|
- test/test_inflector.rb
|
314
317
|
- test/test_ipgeocoder.rb
|
315
318
|
- test/test_latlng.rb
|
319
|
+
- test/test_map_quest.rb
|
316
320
|
- test/test_mappable.rb
|
317
321
|
- test/test_maxmind_geocoder.rb
|
318
322
|
- test/test_multi_geocoder.rb
|