geokit 1.8.5 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +7 -0
  4. data/README.markdown +31 -14
  5. data/fixtures/vcr_cassettes/geonames_geocode.yml +1 -1
  6. data/fixtures/vcr_cassettes/geonames_geocode_premium.yml +42 -0
  7. data/fixtures/vcr_cassettes/google_country_code_biased_result_orly.yml +160 -0
  8. data/fixtures/vcr_cassettes/google_country_code_biased_result_toledo.yml +111 -0
  9. data/fixtures/vcr_cassettes/google_result_toledo_default_bias.yml +275 -0
  10. data/fixtures/vcr_cassettes/google_sublocality.yml +126 -0
  11. data/fixtures/vcr_cassettes/mapbox_forward_geocode.yml +59 -0
  12. data/fixtures/vcr_cassettes/mapbox_reverse_geocode.yml +63 -0
  13. data/fixtures/vcr_cassettes/opencage_city.yml +51 -0
  14. data/fixtures/vcr_cassettes/opencage_full.yml +65 -0
  15. data/fixtures/vcr_cassettes/opencage_language_response_es.yml +66 -0
  16. data/fixtures/vcr_cassettes/opencage_reverse_madrid.yml +51 -0
  17. data/fixtures/vcr_cassettes/opencage_reverse_prilep.yml +53 -0
  18. data/geokit.gemspec +5 -3
  19. data/lib/geokit/bounds.rb +40 -31
  20. data/lib/geokit/core_ext.rb +1 -1
  21. data/lib/geokit/geo_loc.rb +63 -41
  22. data/lib/geokit/geocoders.rb +13 -13
  23. data/lib/geokit/geocoders/bing.rb +9 -9
  24. data/lib/geokit/geocoders/ca_geocoder.rb +29 -29
  25. data/lib/geokit/geocoders/fcc.rb +4 -4
  26. data/lib/geokit/geocoders/free_geo_ip.rb +6 -7
  27. data/lib/geokit/geocoders/geo_plugin.rb +5 -6
  28. data/lib/geokit/geocoders/geocodio.rb +2 -2
  29. data/lib/geokit/geocoders/geonames.rb +18 -12
  30. data/lib/geokit/geocoders/google.rb +31 -30
  31. data/lib/geokit/geocoders/ip.rb +3 -4
  32. data/lib/geokit/geocoders/mapbox.rb +94 -0
  33. data/lib/geokit/geocoders/mapquest.rb +5 -5
  34. data/lib/geokit/geocoders/opencage.rb +93 -0
  35. data/lib/geokit/geocoders/openstreetmap.rb +9 -6
  36. data/lib/geokit/geocoders/ripe.rb +3 -3
  37. data/lib/geokit/geocoders/us_geocoder.rb +10 -9
  38. data/lib/geokit/geocoders/yahoo.rb +33 -34
  39. data/lib/geokit/geocoders/yandex.rb +17 -17
  40. data/lib/geokit/inflectors.rb +4 -10
  41. data/lib/geokit/lat_lng.rb +50 -26
  42. data/lib/geokit/mappable.rb +83 -83
  43. data/lib/geokit/multi_geocoder.rb +25 -20
  44. data/lib/geokit/net_adapter/net_http.rb +7 -4
  45. data/lib/geokit/polygon.rb +36 -4
  46. data/lib/geokit/version.rb +1 -1
  47. data/test/helper.rb +15 -13
  48. data/test/test_base_geocoder.rb +6 -7
  49. data/test/test_bing_geocoder.rb +20 -21
  50. data/test/test_bounds.rb +26 -28
  51. data/test/test_ca_geocoder.rb +9 -10
  52. data/test/test_fcc_geocoder.rb +1 -1
  53. data/test/test_free_geo_ip_geocoder.rb +1 -1
  54. data/test/test_geo_plugin_geocoder.rb +9 -9
  55. data/test/test_geoloc.rb +7 -6
  56. data/test/test_geonames_geocoder.rb +28 -6
  57. data/test/test_google_geocoder.rb +210 -176
  58. data/test/test_inflector.rb +0 -1
  59. data/test/test_ipgeocoder.rb +17 -18
  60. data/test/test_latlng.rb +105 -85
  61. data/test/test_map_quest.rb +18 -21
  62. data/test/test_mapbox_geocoder.rb +31 -0
  63. data/test/test_mappable.rb +46 -0
  64. data/test/test_maxmind_geocoder.rb +1 -3
  65. data/test/test_multi_geocoder.rb +8 -9
  66. data/test/test_multi_ip_geocoder.rb +3 -5
  67. data/test/test_net_adapter.rb +4 -4
  68. data/test/test_opencage_geocoder.rb +108 -0
  69. data/test/test_openstreetmap_geocoder.rb +62 -44
  70. data/test/{test_polygon_contains.rb → test_polygon.rb} +30 -20
  71. data/test/test_ripe_geocoder.rb +2 -0
  72. data/test/test_us_geocoder.rb +7 -8
  73. data/test/test_yahoo_geocoder.rb +20 -21
  74. data/test/test_yandex_geocoder.rb +34 -35
  75. metadata +79 -56
  76. data/fixtures/vcr_cassettes/google_country_code_biased_result.yml +0 -401
@@ -0,0 +1,275 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://maps.google.com/maps/api/geocode/json?address=toledo&sensor=false
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=UTF-8
23
+ Date:
24
+ - Tue, 23 Sep 2014 13:48:30 GMT
25
+ Expires:
26
+ - Wed, 24 Sep 2014 13:48:30 GMT
27
+ Cache-Control:
28
+ - public, max-age=86400
29
+ Vary:
30
+ - Accept-Language
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Server:
34
+ - mafe
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Alternate-Protocol:
40
+ - 443:quic,p=0.002
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: UTF-8
45
+ string: |
46
+ {
47
+ "results" : [
48
+ {
49
+ "address_components" : [
50
+ {
51
+ "long_name" : "Toledo",
52
+ "short_name" : "Toledo",
53
+ "types" : [ "locality", "political" ]
54
+ },
55
+ {
56
+ "long_name" : "Lucas County",
57
+ "short_name" : "Lucas County",
58
+ "types" : [ "administrative_area_level_2", "political" ]
59
+ },
60
+ {
61
+ "long_name" : "Ohio",
62
+ "short_name" : "OH",
63
+ "types" : [ "administrative_area_level_1", "political" ]
64
+ },
65
+ {
66
+ "long_name" : "United States",
67
+ "short_name" : "US",
68
+ "types" : [ "country", "political" ]
69
+ }
70
+ ],
71
+ "formatted_address" : "Toledo, OH, USA",
72
+ "geometry" : {
73
+ "bounds" : {
74
+ "northeast" : {
75
+ "lat" : 41.732844,
76
+ "lng" : -83.4547053
77
+ },
78
+ "southwest" : {
79
+ "lat" : 41.580266,
80
+ "lng" : -83.69423700000002
81
+ }
82
+ },
83
+ "location" : {
84
+ "lat" : 41.6639383,
85
+ "lng" : -83.55521200000001
86
+ },
87
+ "location_type" : "APPROXIMATE",
88
+ "viewport" : {
89
+ "northeast" : {
90
+ "lat" : 41.732844,
91
+ "lng" : -83.4547053
92
+ },
93
+ "southwest" : {
94
+ "lat" : 41.580266,
95
+ "lng" : -83.69423700000002
96
+ }
97
+ }
98
+ },
99
+ "types" : [ "locality", "political" ]
100
+ },
101
+ {
102
+ "address_components" : [
103
+ {
104
+ "long_name" : "Toledo",
105
+ "short_name" : "Toledo",
106
+ "types" : [ "locality", "political" ]
107
+ },
108
+ {
109
+ "long_name" : "Lincoln County",
110
+ "short_name" : "Lincoln County",
111
+ "types" : [ "administrative_area_level_2", "political" ]
112
+ },
113
+ {
114
+ "long_name" : "Oregon",
115
+ "short_name" : "OR",
116
+ "types" : [ "administrative_area_level_1", "political" ]
117
+ },
118
+ {
119
+ "long_name" : "United States",
120
+ "short_name" : "US",
121
+ "types" : [ "country", "political" ]
122
+ }
123
+ ],
124
+ "formatted_address" : "Toledo, OR, USA",
125
+ "geometry" : {
126
+ "bounds" : {
127
+ "northeast" : {
128
+ "lat" : 44.6383219,
129
+ "lng" : -123.9129439
130
+ },
131
+ "southwest" : {
132
+ "lat" : 44.598776,
133
+ "lng" : -123.954585
134
+ }
135
+ },
136
+ "location" : {
137
+ "lat" : 44.621507,
138
+ "lng" : -123.9384478
139
+ },
140
+ "location_type" : "APPROXIMATE",
141
+ "viewport" : {
142
+ "northeast" : {
143
+ "lat" : 44.6383219,
144
+ "lng" : -123.9129439
145
+ },
146
+ "southwest" : {
147
+ "lat" : 44.598776,
148
+ "lng" : -123.954585
149
+ }
150
+ }
151
+ },
152
+ "types" : [ "locality", "political" ]
153
+ },
154
+ {
155
+ "address_components" : [
156
+ {
157
+ "long_name" : "Toledo",
158
+ "short_name" : "Toledo",
159
+ "types" : [ "locality", "political" ]
160
+ },
161
+ {
162
+ "long_name" : "Toledo",
163
+ "short_name" : "Toledo",
164
+ "types" : [ "administrative_area_level_3", "political" ]
165
+ },
166
+ {
167
+ "long_name" : "Tama County",
168
+ "short_name" : "Tama County",
169
+ "types" : [ "administrative_area_level_2", "political" ]
170
+ },
171
+ {
172
+ "long_name" : "Iowa",
173
+ "short_name" : "IA",
174
+ "types" : [ "administrative_area_level_1", "political" ]
175
+ },
176
+ {
177
+ "long_name" : "United States",
178
+ "short_name" : "US",
179
+ "types" : [ "country", "political" ]
180
+ }
181
+ ],
182
+ "formatted_address" : "Toledo, IA, USA",
183
+ "geometry" : {
184
+ "bounds" : {
185
+ "northeast" : {
186
+ "lat" : 42.00388600000001,
187
+ "lng" : -92.56695289999999
188
+ },
189
+ "southwest" : {
190
+ "lat" : 41.9784431,
191
+ "lng" : -92.60007299999999
192
+ }
193
+ },
194
+ "location" : {
195
+ "lat" : 41.9972134,
196
+ "lng" : -92.5835266
197
+ },
198
+ "location_type" : "APPROXIMATE",
199
+ "viewport" : {
200
+ "northeast" : {
201
+ "lat" : 42.00388600000001,
202
+ "lng" : -92.56695289999999
203
+ },
204
+ "southwest" : {
205
+ "lat" : 41.9784431,
206
+ "lng" : -92.60007299999999
207
+ }
208
+ }
209
+ },
210
+ "types" : [ "locality", "political" ]
211
+ },
212
+ {
213
+ "address_components" : [
214
+ {
215
+ "long_name" : "Toledo",
216
+ "short_name" : "Toledo",
217
+ "types" : [ "locality", "political" ]
218
+ },
219
+ {
220
+ "long_name" : "Lewis County",
221
+ "short_name" : "Lewis County",
222
+ "types" : [ "administrative_area_level_2", "political" ]
223
+ },
224
+ {
225
+ "long_name" : "Washington",
226
+ "short_name" : "WA",
227
+ "types" : [ "administrative_area_level_1", "political" ]
228
+ },
229
+ {
230
+ "long_name" : "United States",
231
+ "short_name" : "US",
232
+ "types" : [ "country", "political" ]
233
+ },
234
+ {
235
+ "long_name" : "98591",
236
+ "short_name" : "98591",
237
+ "types" : [ "postal_code" ]
238
+ }
239
+ ],
240
+ "formatted_address" : "Toledo, WA 98591, USA",
241
+ "geometry" : {
242
+ "bounds" : {
243
+ "northeast" : {
244
+ "lat" : 46.44799889999999,
245
+ "lng" : -122.8419249
246
+ },
247
+ "southwest" : {
248
+ "lat" : 46.43233009999999,
249
+ "lng" : -122.85575
250
+ }
251
+ },
252
+ "location" : {
253
+ "lat" : 46.4398305,
254
+ "lng" : -122.846783
255
+ },
256
+ "location_type" : "APPROXIMATE",
257
+ "viewport" : {
258
+ "northeast" : {
259
+ "lat" : 46.44799889999999,
260
+ "lng" : -122.8419249
261
+ },
262
+ "southwest" : {
263
+ "lat" : 46.43233009999999,
264
+ "lng" : -122.85575
265
+ }
266
+ }
267
+ },
268
+ "types" : [ "locality", "political" ]
269
+ }
270
+ ],
271
+ "status" : "OK"
272
+ }
273
+ http_version:
274
+ recorded_at: Tue, 23 Sep 2014 13:48:30 GMT
275
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,126 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://maps.google.com/maps/api/geocode/json?address=682%20prospect%20place%20Brooklyn%20ny%2011216&sensor=false
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=UTF-8
23
+ Date:
24
+ - Sun, 26 Jan 2014 05:46:39 GMT
25
+ Expires:
26
+ - Mon, 27 Jan 2014 05:46:39 GMT
27
+ Cache-Control:
28
+ - public, max-age=86400
29
+ Vary:
30
+ - Accept-Language
31
+ Access-Control-Allow-Origin:
32
+ - '*'
33
+ Server:
34
+ - mafe
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Alternate-Protocol:
40
+ - 443:quic
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: UTF-8
45
+ string: |
46
+ {
47
+ "results" : [
48
+ {
49
+ "address_components" : [
50
+ {
51
+ "long_name" : "682",
52
+ "short_name" : "682",
53
+ "types" : [ "street_number" ]
54
+ },
55
+ {
56
+ "long_name" : "Prospect Place",
57
+ "short_name" : "Prospect Pl",
58
+ "types" : [ "route" ]
59
+ },
60
+ {
61
+ "long_name" : "Crown Heights",
62
+ "short_name" : "Crown Heights",
63
+ "types" : [ "neighborhood", "political" ]
64
+ },
65
+ {
66
+ "long_name" : "Brooklyn",
67
+ "short_name" : "Brooklyn",
68
+ "types" : [ "sublocality_level_1", "sublocality", "political" ]
69
+ },
70
+ {
71
+ "long_name" : "Kings County",
72
+ "short_name" : "Kings County",
73
+ "types" : [ "administrative_area_level_2", "political" ]
74
+ },
75
+ {
76
+ "long_name" : "New York",
77
+ "short_name" : "NY",
78
+ "types" : [ "administrative_area_level_1", "political" ]
79
+ },
80
+ {
81
+ "long_name" : "United States",
82
+ "short_name" : "US",
83
+ "types" : [ "country", "political" ]
84
+ },
85
+ {
86
+ "long_name" : "11216",
87
+ "short_name" : "11216",
88
+ "types" : [ "postal_code" ]
89
+ }
90
+ ],
91
+ "formatted_address" : "682 Prospect Place, Brooklyn, NY 11216, USA",
92
+ "geometry" : {
93
+ "bounds" : {
94
+ "northeast" : {
95
+ "lat" : 40.6745947,
96
+ "lng" : -73.9541534
97
+ },
98
+ "southwest" : {
99
+ "lat" : 40.6745812,
100
+ "lng" : -73.95415819999999
101
+ }
102
+ },
103
+ "location" : {
104
+ "lat" : 40.6745812,
105
+ "lng" : -73.95415819999999
106
+ },
107
+ "location_type" : "RANGE_INTERPOLATED",
108
+ "viewport" : {
109
+ "northeast" : {
110
+ "lat" : 40.6759369302915,
111
+ "lng" : -73.95280681970848
112
+ },
113
+ "southwest" : {
114
+ "lat" : 40.6732389697085,
115
+ "lng" : -73.95550478029149
116
+ }
117
+ }
118
+ },
119
+ "types" : [ "street_address" ]
120
+ }
121
+ ],
122
+ "status" : "OK"
123
+ }
124
+ http_version:
125
+ recorded_at: Sun, 26 Jan 2014 05:46:39 GMT
126
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/1714+14th+Street+NW,+Washington,+DC.json?access_token=
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/vnd.geo+json; charset=utf-8
23
+ Content-Length:
24
+ - '1243'
25
+ Connection:
26
+ - keep-alive
27
+ Access-Control-Allow-Methods:
28
+ - GET
29
+ Access-Control-Allow-Origin:
30
+ - '*'
31
+ Cache-Control:
32
+ - max-age=3600
33
+ Date:
34
+ - Thu, 21 Aug 2014 05:42:19 GMT
35
+ Etag:
36
+ - '"9363c6116c867d7a272693e81eb6c456"'
37
+ Last-Modified:
38
+ - Thu, 21 Aug 2014 05:42:19 GMT
39
+ Server:
40
+ - nginx
41
+ X-Powered-By:
42
+ - Express
43
+ X-Cache:
44
+ - Miss from cloudfront
45
+ Via:
46
+ - 1.1 25e6ff20e328e7479b6db9fee82a8d60.cloudfront.net (CloudFront)
47
+ X-Amz-Cf-Id:
48
+ - QRVX5xyBFaHKip4ALpz6ZPtpDGVGm9FDjn_DleC3PMmCUXyfABDeCw==
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"type":"FeatureCollection","query":["1714","14th","street","nw","washington","dc"],"features":[{"id":"city.20001","type":"Feature","text":"Washington","place_name":"Washington,
52
+ 20002, District of Columbia, United States","relevance":0.3233333333333333,"center":[-76.992695,38.899393],"geometry":{"type":"Point","coordinates":[-76.992695,38.899393]},"bbox":[-77.11976790632382,38.80310600134152,-76.90938401684849,38.99555498159024],"properties":{"title":"Washington"},"context":[{"id":"postcode-us.3962709191","text":"20002"},{"id":"province.1190806886","text":"District
53
+ of Columbia"},{"id":"country.4150104525","text":"United States"}]},{"id":"city.21154","type":"Feature","text":"Street","place_name":"Street,
54
+ 21154, Maryland, United States","relevance":0.16666666666666666,"center":[-76.344429,39.645749],"geometry":{"type":"Point","coordinates":[-76.344429,39.645749]},"bbox":[-76.49929286959762,39.59802207980489,-76.22835205150847,39.693469713854434],"properties":{"title":"Street"},"context":[{"id":"postcode-us.2234502147","text":"21154"},{"id":"province.928365533","text":"Maryland"},{"id":"country.4150104525","text":"United
55
+ States"}]}],"attribution":"<a href=''https://www.mapbox.com/about/maps/''
56
+ target=''_blank''>&copy; Mapbox</a>"}'
57
+ http_version:
58
+ recorded_at: Thu, 21 Aug 2014 05:42:19 GMT
59
+ recorded_with: VCR 2.9.2