geocoder 1.1.9 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +157 -0
  3. data/README.md +467 -70
  4. data/examples/reverse_geocode_job.rb +40 -0
  5. data/lib/generators/geocoder/config/templates/initializer.rb +16 -16
  6. data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +28 -0
  7. data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +28 -0
  8. data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +30 -0
  9. data/lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb +17 -0
  10. data/lib/geocoder/cache.rb +3 -2
  11. data/lib/geocoder/calculations.rb +44 -2
  12. data/lib/geocoder/configuration.rb +17 -10
  13. data/lib/geocoder/esri_token.rb +38 -0
  14. data/lib/geocoder/exceptions.rb +19 -0
  15. data/lib/geocoder/ip_address.rb +13 -0
  16. data/lib/geocoder/kernel_logger.rb +25 -0
  17. data/lib/geocoder/logger.rb +47 -0
  18. data/lib/geocoder/lookup.rb +32 -8
  19. data/lib/geocoder/lookups/baidu.rb +18 -13
  20. data/lib/geocoder/lookups/baidu_ip.rb +59 -0
  21. data/lib/geocoder/lookups/base.rb +81 -19
  22. data/lib/geocoder/lookups/bing.rb +40 -7
  23. data/lib/geocoder/lookups/esri.rb +42 -5
  24. data/lib/geocoder/lookups/freegeoip.rb +9 -1
  25. data/lib/geocoder/lookups/geocoder_ca.rb +1 -2
  26. data/lib/geocoder/lookups/geocoder_us.rb +6 -2
  27. data/lib/geocoder/lookups/geocodio.rb +42 -0
  28. data/lib/geocoder/lookups/geoip2.rb +45 -0
  29. data/lib/geocoder/lookups/geoportail_lu.rb +65 -0
  30. data/lib/geocoder/lookups/google.rb +29 -5
  31. data/lib/geocoder/lookups/google_places_details.rb +50 -0
  32. data/lib/geocoder/lookups/google_premier.rb +1 -1
  33. data/lib/geocoder/lookups/here.rb +62 -0
  34. data/lib/geocoder/lookups/ipapi_com.rb +86 -0
  35. data/lib/geocoder/lookups/ipinfo_io.rb +55 -0
  36. data/lib/geocoder/lookups/latlon.rb +59 -0
  37. data/lib/geocoder/lookups/mapbox.rb +53 -0
  38. data/lib/geocoder/lookups/mapquest.rb +6 -6
  39. data/lib/geocoder/lookups/mapzen.rb +15 -0
  40. data/lib/geocoder/lookups/maxmind.rb +4 -2
  41. data/lib/geocoder/lookups/maxmind_geoip2.rb +69 -0
  42. data/lib/geocoder/lookups/maxmind_local.rb +65 -0
  43. data/lib/geocoder/lookups/nominatim.rb +9 -1
  44. data/lib/geocoder/lookups/okf.rb +44 -0
  45. data/lib/geocoder/lookups/opencagedata.rb +58 -0
  46. data/lib/geocoder/lookups/pelias.rb +64 -0
  47. data/lib/geocoder/lookups/pointpin.rb +68 -0
  48. data/lib/geocoder/lookups/postcode_anywhere_uk.rb +51 -0
  49. data/lib/geocoder/lookups/smarty_streets.rb +53 -0
  50. data/lib/geocoder/lookups/telize.rb +55 -0
  51. data/lib/geocoder/lookups/yandex.rb +8 -4
  52. data/lib/geocoder/models/active_record.rb +7 -3
  53. data/lib/geocoder/models/base.rb +1 -4
  54. data/lib/geocoder/models/mongo_base.rb +6 -4
  55. data/lib/geocoder/query.rb +9 -5
  56. data/lib/geocoder/railtie.rb +1 -1
  57. data/lib/geocoder/request.rb +74 -12
  58. data/lib/geocoder/results/baidu_ip.rb +62 -0
  59. data/lib/geocoder/results/bing.rb +4 -0
  60. data/lib/geocoder/results/esri.rb +30 -6
  61. data/lib/geocoder/results/freegeoip.rb +2 -2
  62. data/lib/geocoder/results/geocodio.rb +70 -0
  63. data/lib/geocoder/results/geoip2.rb +62 -0
  64. data/lib/geocoder/results/geoportail_lu.rb +69 -0
  65. data/lib/geocoder/results/google.rb +15 -0
  66. data/lib/geocoder/results/google_places_details.rb +35 -0
  67. data/lib/geocoder/results/here.rb +71 -0
  68. data/lib/geocoder/results/ipapi_com.rb +45 -0
  69. data/lib/geocoder/results/ipinfo_io.rb +48 -0
  70. data/lib/geocoder/results/latlon.rb +71 -0
  71. data/lib/geocoder/results/mapbox.rb +47 -0
  72. data/lib/geocoder/results/mapquest.rb +5 -8
  73. data/lib/geocoder/results/mapzen.rb +5 -0
  74. data/lib/geocoder/results/maxmind_geoip2.rb +9 -0
  75. data/lib/geocoder/results/maxmind_local.rb +49 -0
  76. data/lib/geocoder/results/nominatim.rb +6 -1
  77. data/lib/geocoder/results/okf.rb +106 -0
  78. data/lib/geocoder/results/opencagedata.rb +90 -0
  79. data/lib/geocoder/results/ovi.rb +9 -0
  80. data/lib/geocoder/results/pelias.rb +58 -0
  81. data/lib/geocoder/results/pointpin.rb +40 -0
  82. data/lib/geocoder/results/postcode_anywhere_uk.rb +42 -0
  83. data/lib/geocoder/results/smarty_streets.rb +106 -0
  84. data/lib/geocoder/results/telize.rb +45 -0
  85. data/lib/geocoder/results/test.rb +20 -3
  86. data/lib/geocoder/results/yandex.rb +18 -6
  87. data/lib/geocoder/sql.rb +16 -15
  88. data/lib/geocoder/stores/active_record.rb +51 -18
  89. data/lib/geocoder/stores/base.rb +8 -12
  90. data/lib/geocoder/stores/mongo_base.rb +0 -31
  91. data/lib/geocoder/version.rb +1 -1
  92. data/lib/geocoder.rb +6 -13
  93. data/lib/maxmind_database.rb +109 -0
  94. data/lib/tasks/geocoder.rake +14 -3
  95. data/lib/tasks/maxmind.rake +73 -0
  96. metadata +59 -85
  97. data/.gitignore +0 -5
  98. data/.travis.yml +0 -27
  99. data/Rakefile +0 -25
  100. data/gemfiles/Gemfile.mongoid-2.4.x +0 -15
  101. data/lib/geocoder/lookups/yahoo.rb +0 -86
  102. data/lib/geocoder/results/yahoo.rb +0 -55
  103. data/lib/oauth_util.rb +0 -112
  104. data/test/active_record_test.rb +0 -15
  105. data/test/cache_test.rb +0 -35
  106. data/test/calculations_test.rb +0 -211
  107. data/test/configuration_test.rb +0 -78
  108. data/test/custom_block_test.rb +0 -32
  109. data/test/error_handling_test.rb +0 -43
  110. data/test/fixtures/baidu_invalid_key +0 -1
  111. data/test/fixtures/baidu_no_results +0 -1
  112. data/test/fixtures/baidu_reverse +0 -1
  113. data/test/fixtures/baidu_shanghai_pearl_tower +0 -12
  114. data/test/fixtures/bing_invalid_key +0 -1
  115. data/test/fixtures/bing_madison_square_garden +0 -40
  116. data/test/fixtures/bing_no_results +0 -16
  117. data/test/fixtures/bing_reverse +0 -42
  118. data/test/fixtures/esri_madison_square_garden +0 -59
  119. data/test/fixtures/esri_no_results +0 -8
  120. data/test/fixtures/esri_reverse +0 -21
  121. data/test/fixtures/freegeoip_74_200_247_59 +0 -12
  122. data/test/fixtures/freegeoip_no_results +0 -1
  123. data/test/fixtures/geocoder_ca_madison_square_garden +0 -1
  124. data/test/fixtures/geocoder_ca_no_results +0 -1
  125. data/test/fixtures/geocoder_ca_reverse +0 -34
  126. data/test/fixtures/geocoder_us_madison_square_garden +0 -1
  127. data/test/fixtures/geocoder_us_no_results +0 -1
  128. data/test/fixtures/google_garbage +0 -456
  129. data/test/fixtures/google_madison_square_garden +0 -57
  130. data/test/fixtures/google_no_city_data +0 -44
  131. data/test/fixtures/google_no_locality +0 -51
  132. data/test/fixtures/google_no_results +0 -4
  133. data/test/fixtures/google_over_limit +0 -4
  134. data/test/fixtures/mapquest_error +0 -16
  135. data/test/fixtures/mapquest_invalid_api_key +0 -16
  136. data/test/fixtures/mapquest_invalid_request +0 -16
  137. data/test/fixtures/mapquest_madison_square_garden +0 -52
  138. data/test/fixtures/mapquest_no_results +0 -16
  139. data/test/fixtures/maxmind_24_24_24_21 +0 -1
  140. data/test/fixtures/maxmind_24_24_24_22 +0 -1
  141. data/test/fixtures/maxmind_24_24_24_23 +0 -1
  142. data/test/fixtures/maxmind_24_24_24_24 +0 -1
  143. data/test/fixtures/maxmind_74_200_247_59 +0 -1
  144. data/test/fixtures/maxmind_invalid_key +0 -1
  145. data/test/fixtures/maxmind_no_results +0 -1
  146. data/test/fixtures/nominatim_madison_square_garden +0 -150
  147. data/test/fixtures/nominatim_no_results +0 -1
  148. data/test/fixtures/ovi_madison_square_garden +0 -72
  149. data/test/fixtures/ovi_no_results +0 -8
  150. data/test/fixtures/yahoo_error +0 -1
  151. data/test/fixtures/yahoo_invalid_key +0 -2
  152. data/test/fixtures/yahoo_madison_square_garden +0 -52
  153. data/test/fixtures/yahoo_no_results +0 -10
  154. data/test/fixtures/yahoo_over_limit +0 -2
  155. data/test/fixtures/yandex_invalid_key +0 -1
  156. data/test/fixtures/yandex_kremlin +0 -48
  157. data/test/fixtures/yandex_no_city_and_town +0 -112
  158. data/test/fixtures/yandex_no_results +0 -16
  159. data/test/geocoder_test.rb +0 -59
  160. data/test/https_test.rb +0 -16
  161. data/test/integration/smoke_test.rb +0 -26
  162. data/test/lookup_test.rb +0 -117
  163. data/test/method_aliases_test.rb +0 -25
  164. data/test/mongoid_test.rb +0 -46
  165. data/test/mongoid_test_helper.rb +0 -43
  166. data/test/near_test.rb +0 -61
  167. data/test/oauth_util_test.rb +0 -30
  168. data/test/proxy_test.rb +0 -36
  169. data/test/query_test.rb +0 -52
  170. data/test/request_test.rb +0 -29
  171. data/test/result_test.rb +0 -42
  172. data/test/services_test.rb +0 -393
  173. data/test/test_helper.rb +0 -289
  174. data/test/test_mode_test.rb +0 -59
@@ -1,211 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class CalculationsTest < Test::Unit::TestCase
5
- def setup
6
- Geocoder.configure(
7
- :units => :mi,
8
- :distances => :linear
9
- )
10
- end
11
-
12
- # --- degree distance ---
13
-
14
- def test_longitude_degree_distance_at_equator
15
- assert_equal 69, Geocoder::Calculations.longitude_degree_distance(0).round
16
- end
17
-
18
- def test_longitude_degree_distance_at_new_york
19
- assert_equal 53, Geocoder::Calculations.longitude_degree_distance(40).round
20
- end
21
-
22
- def test_longitude_degree_distance_at_north_pole
23
- assert_equal 0, Geocoder::Calculations.longitude_degree_distance(89.98).round
24
- end
25
-
26
-
27
- # --- distance between ---
28
-
29
- def test_distance_between_in_miles
30
- assert_equal 69, Geocoder::Calculations.distance_between([0,0], [0,1]).round
31
- la_to_ny = Geocoder::Calculations.distance_between([34.05,-118.25], [40.72,-74]).round
32
- assert (la_to_ny - 2444).abs < 10
33
- end
34
-
35
- def test_distance_between_in_kilometers
36
- assert_equal 111, Geocoder::Calculations.distance_between([0,0], [0,1], :units => :km).round
37
- la_to_ny = Geocoder::Calculations.distance_between([34.05,-118.25], [40.72,-74], :units => :km).round
38
- assert (la_to_ny - 3942).abs < 10
39
- end
40
-
41
- def test_distance_between_in_nautical_miles
42
- assert_equal 60, Geocoder::Calculations.distance_between([0,0], [0,1], :units => :nm).round
43
- la_to_ny = Geocoder::Calculations.distance_between([34.05,-118.25], [40.72,-74], :units => :nm).round
44
- assert (la_to_ny - 2124).abs < 10
45
- end
46
-
47
-
48
- # --- geographic center ---
49
-
50
- def test_geographic_center_with_arrays
51
- assert_equal [0.0, 0.5],
52
- Geocoder::Calculations.geographic_center([[0,0], [0,1]])
53
- assert_equal [0.0, 1.0],
54
- Geocoder::Calculations.geographic_center([[0,0], [0,1], [0,2]])
55
- end
56
-
57
- def test_geographic_center_with_mixed_arguments
58
- p1 = [0, 0]
59
- p2 = Landmark.new("Some Cold Place", 0, 1)
60
- assert_equal [0.0, 0.5], Geocoder::Calculations.geographic_center([p1, p2])
61
- end
62
-
63
-
64
- # --- bounding box ---
65
-
66
- def test_bounding_box_calculation_in_miles
67
- center = [51, 7] # Cologne, DE
68
- radius = 10 # miles
69
- dlon = radius / Geocoder::Calculations.latitude_degree_distance
70
- dlat = radius / Geocoder::Calculations.longitude_degree_distance(center[0])
71
- corners = [50.86, 6.77, 51.14, 7.23]
72
- assert_equal corners.map{ |i| (i * 100).round },
73
- Geocoder::Calculations.bounding_box(center, radius).map{ |i| (i * 100).round }
74
- end
75
-
76
- def test_bounding_box_calculation_in_kilometers
77
- center = [51, 7] # Cologne, DE
78
- radius = 111 # kilometers (= 1 degree latitude)
79
- dlon = radius / Geocoder::Calculations.latitude_degree_distance(:km)
80
- dlat = radius / Geocoder::Calculations.longitude_degree_distance(center[0], :km)
81
- corners = [50, 5.41, 52, 8.59]
82
- assert_equal corners.map{ |i| (i * 100).round },
83
- Geocoder::Calculations.bounding_box(center, radius, :units => :km).map{ |i| (i * 100).round }
84
- end
85
-
86
- def test_bounding_box_calculation_with_object
87
- center = [51, 7] # Cologne, DE
88
- radius = 10 # miles
89
- dlon = radius / Geocoder::Calculations.latitude_degree_distance
90
- dlat = radius / Geocoder::Calculations.longitude_degree_distance(center[0])
91
- corners = [50.86, 6.77, 51.14, 7.23]
92
- obj = Landmark.new("Cologne", center[0], center[1])
93
- assert_equal corners.map{ |i| (i * 100).round },
94
- Geocoder::Calculations.bounding_box(obj, radius).map{ |i| (i * 100).round }
95
- end
96
-
97
- def test_bounding_box_calculation_with_address_string
98
- assert_nothing_raised do
99
- Geocoder::Calculations.bounding_box("4893 Clay St, San Francisco, CA", 50)
100
- end
101
- end
102
-
103
- # --- random point ---
104
-
105
- def test_random_point_within_radius
106
- 20.times do
107
- center = [51, 7] # Cologne, DE
108
- radius = 10 # miles
109
- random_point = Geocoder::Calculations.random_point_near(center, radius)
110
- distance = Geocoder::Calculations.distance_between(center, random_point)
111
- assert distance <= radius
112
- end
113
- end
114
-
115
- # --- bearing ---
116
-
117
- def test_compass_points
118
- assert_equal "N", Geocoder::Calculations.compass_point(0)
119
- assert_equal "N", Geocoder::Calculations.compass_point(1.0)
120
- assert_equal "N", Geocoder::Calculations.compass_point(360)
121
- assert_equal "N", Geocoder::Calculations.compass_point(361)
122
- assert_equal "N", Geocoder::Calculations.compass_point(-22)
123
- assert_equal "NW", Geocoder::Calculations.compass_point(-23)
124
- assert_equal "S", Geocoder::Calculations.compass_point(180)
125
- assert_equal "S", Geocoder::Calculations.compass_point(181)
126
- end
127
-
128
- def test_bearing_between
129
- bearings = {
130
- :n => 0,
131
- :e => 90,
132
- :s => 180,
133
- :w => 270
134
- }
135
- points = {
136
- :n => [41, -75],
137
- :e => [40, -74],
138
- :s => [39, -75],
139
- :w => [40, -76]
140
- }
141
- directions = [:n, :e, :s, :w]
142
- methods = [:linear, :spherical]
143
-
144
- methods.each do |m|
145
- directions.each_with_index do |d,i|
146
- opp = directions[(i + 2) % 4] # opposite direction
147
- b = Geocoder::Calculations.bearing_between(
148
- points[d], points[opp], :method => m)
149
- assert (b - bearings[opp]).abs < 1,
150
- "Bearing (#{m}) should be close to #{bearings[opp]} but was #{b}."
151
- end
152
- end
153
- end
154
-
155
- def test_spherical_bearing_to
156
- l = Landmark.new(*landmark_params(:msg))
157
- assert_equal 324, l.bearing_to([50,-85], :method => :spherical).round
158
- end
159
-
160
- def test_spherical_bearing_from
161
- l = Landmark.new(*landmark_params(:msg))
162
- assert_equal 136, l.bearing_from([50,-85], :method => :spherical).round
163
- end
164
-
165
- def test_linear_bearing_from_and_to_are_exactly_opposite
166
- l = Landmark.new(*landmark_params(:msg))
167
- assert_equal l.bearing_from([50,-86.1]), l.bearing_to([50,-86.1]) - 180
168
- end
169
-
170
- def test_extract_coordinates
171
- coords = [-23,47]
172
- l = Landmark.new("Madagascar", coords[0], coords[1])
173
- assert_equal coords, Geocoder::Calculations.extract_coordinates(l)
174
- assert_equal coords, Geocoder::Calculations.extract_coordinates(coords)
175
- end
176
-
177
- def test_extract_nan_coordinates
178
- result = Geocoder::Calculations.extract_coordinates([ nil, nil ])
179
- assert_nan_coordinates?(result)
180
-
181
- result = Geocoder::Calculations.extract_coordinates(nil)
182
- assert_nan_coordinates?(result)
183
-
184
- result = Geocoder::Calculations.extract_coordinates('')
185
- assert_nan_coordinates?(result)
186
-
187
- result = Geocoder::Calculations.extract_coordinates([ 'nix' ])
188
- assert_nan_coordinates?(result)
189
-
190
- o = Object.new
191
- result = Geocoder::Calculations.extract_coordinates(o)
192
- assert_nan_coordinates?(result)
193
- end
194
-
195
- def test_coordinates_present
196
- assert Geocoder::Calculations.coordinates_present?(3.23)
197
- assert !Geocoder::Calculations.coordinates_present?(nil)
198
- assert !Geocoder::Calculations.coordinates_present?(Geocoder::Calculations::NAN)
199
- assert !Geocoder::Calculations.coordinates_present?(3.23, nil)
200
- end
201
-
202
- private # ------------------------------------------------------------------
203
-
204
- def assert_nan_coordinates?(value)
205
- assert value.is_a?(Array) &&
206
- value.size == 2 &&
207
- value[0].nan? &&
208
- value[1].nan?,
209
- "Expected value to be [NaN, NaN] but was #{value}"
210
- end
211
- end
@@ -1,78 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class ConfigurationTest < Test::Unit::TestCase
5
- def setup
6
- Geocoder::Configuration.set_defaults
7
- end
8
-
9
- def test_exception_raised_on_bad_lookup_config
10
- Geocoder.configure(:lookup => :stoopid)
11
- assert_raises Geocoder::ConfigurationError do
12
- Geocoder.search "something dumb"
13
- end
14
- end
15
-
16
- def test_setting_with_class_method
17
- Geocoder::Configuration.units = :test
18
- assert_equal :test, Geocoder.config.units
19
- end
20
-
21
- def test_setting_with_configure_method
22
- Geocoder.configure(:units => :test)
23
- assert_equal :test, Geocoder.config.units
24
- end
25
-
26
- def test_setting_with_block_syntax
27
- orig = $VERBOSE; $VERBOSE = nil
28
- Geocoder.configure do |config|
29
- config.units = :test
30
- end
31
- assert_equal :test, Geocoder.config.units
32
- ensure
33
- $VERBOSE = orig
34
- end
35
-
36
- def test_config_for_lookup
37
- Geocoder.configure(
38
- :timeout => 5,
39
- :api_key => "aaa",
40
- :google => {
41
- :timeout => 2
42
- }
43
- )
44
- assert_equal 2, Geocoder.config_for_lookup(:google).timeout
45
- assert_equal "aaa", Geocoder.config_for_lookup(:google).api_key
46
- end
47
-
48
- def test_model_configuration
49
- Landmark.reverse_geocoded_by :latitude, :longitude, :method => :spherical, :units => :km
50
- assert_equal :km, Landmark.geocoder_options[:units]
51
- assert_equal :spherical, Landmark.geocoder_options[:method]
52
-
53
- v = Landmark.new(*landmark_params(:msg))
54
- v.latitude = 0
55
- v.longitude = 0
56
- assert_equal 111, v.distance_to([0,1]).round
57
- v.latitude = 40.750354
58
- v.longitude = -73.993371
59
- assert_equal 136, v.bearing_from([50,-85]).round
60
- end
61
-
62
- def test_configuration_chain
63
- v = Landmark.new(*landmark_params(:msg))
64
- v.latitude = 0
65
- v.longitude = 0
66
-
67
- # method option > global configuration
68
- Geocoder.configure(:units => :km)
69
- assert_equal 69, v.distance_to([0,1], :mi).round
70
-
71
- # per-model configuration > global configuration
72
- Landmark.reverse_geocoded_by :latitude, :longitude, :method => :spherical, :units => :mi
73
- assert_equal 69, v.distance_to([0,1]).round
74
-
75
- # method option > per-model configuration
76
- assert_equal 111, v.distance_to([0,1], :km).round
77
- end
78
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class CustomBlockTest < Test::Unit::TestCase
5
-
6
- def test_geocode_with_block_runs_block
7
- e = Event.new(*venue_params(:msg))
8
- coords = [40.750354, -73.993371]
9
- e.geocode
10
- assert_equal coords.map{ |c| c.to_s }.join(','), e.coords_string
11
- end
12
-
13
- def test_geocode_with_block_doesnt_auto_assign_coordinates
14
- e = Event.new(*venue_params(:msg))
15
- e.geocode
16
- assert_nil e.latitude
17
- assert_nil e.longitude
18
- end
19
-
20
- def test_reverse_geocode_with_block_runs_block
21
- e = Party.new(*landmark_params(:msg))
22
- e.reverse_geocode
23
- assert_equal "US", e.country
24
- end
25
-
26
- def test_reverse_geocode_with_block_doesnt_auto_assign_address
27
- e = Party.new(*landmark_params(:msg))
28
- e.reverse_geocode
29
- assert_nil e.address
30
- end
31
- end
32
-
@@ -1,43 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class ErrorHandlingTest < Test::Unit::TestCase
5
-
6
- def teardown
7
- Geocoder.configure(:always_raise => [])
8
- end
9
-
10
- def test_does_not_choke_on_timeout
11
- # keep test output clean: suppress timeout warning
12
- orig = $VERBOSE; $VERBOSE = nil
13
- Geocoder::Lookup.all_services_except_test.each do |l|
14
- Geocoder.configure(:lookup => l)
15
- set_api_key!(l)
16
- assert_nothing_raised { Geocoder.search("timeout") }
17
- end
18
- ensure
19
- $VERBOSE = orig
20
- end
21
-
22
- def test_always_raise_timeout_error
23
- Geocoder.configure(:always_raise => [TimeoutError])
24
- Geocoder::Lookup.all_services_except_test.each do |l|
25
- lookup = Geocoder::Lookup.get(l)
26
- set_api_key!(l)
27
- assert_raises TimeoutError do
28
- lookup.send(:results, Geocoder::Query.new("timeout"))
29
- end
30
- end
31
- end
32
-
33
- def test_always_raise_socket_error
34
- Geocoder.configure(:always_raise => [SocketError])
35
- Geocoder::Lookup.all_services_except_test.each do |l|
36
- lookup = Geocoder::Lookup.get(l)
37
- set_api_key!(l)
38
- assert_raises SocketError do
39
- lookup.send(:results, Geocoder::Query.new("socket_error"))
40
- end
41
- end
42
- end
43
- end
@@ -1 +0,0 @@
1
- {"results":[],"status":5,"msg":"AK Illegal or Not Exist:"}
@@ -1 +0,0 @@
1
- {"status":0,"result":[]}
@@ -1 +0,0 @@
1
- {"status":0,"result":{"location":{"lng":121.48789948569,"lat":31.249161555654},"formatted_address":"上海市闸北区天潼路619号","business":"七浦路,海宁路,北京东路","addressComponent":{"city":"上海市","district":"闸北区","province":"上海市","street":"天潼路","street_number":"619号"},"cityCode":289}}
@@ -1,12 +0,0 @@
1
- {
2
- "status":0,
3
- "result":{
4
- "location":{
5
- "lng":116.30814954222,
6
- "lat":40.056885091681
7
- },
8
- "precise":1,
9
- "confidence":80,
10
- "level":"\u5546\u52a1\u5927\u53a6"
11
- }
12
- }
@@ -1 +0,0 @@
1
- {"authenticationResultCode":"InvalidCredentials","brandLogoUri":"http:\\/\\/dev.virtualearth.net\\/Branding\\/logo_powered_by.png","copyright":"Copyright \xC2\xA9 2012 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","errorDetails":["Access was denied. You may have entered your credentials incorrectly, or you might not have access to the requested resource or operation."],"resourceSets":[],"statusCode":401,"statusDescription":"Unauthorized","traceId":"5c539f6e70c44b2e858741b6c932318e|EWRM001670|02.00.83.1900|"}
@@ -1,40 +0,0 @@
1
- {
2
- "authenticationResultCode":"ValidCredentials",
3
- "brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
4
- "copyright":"Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
5
- "resourceSets":[
6
- {
7
- "estimatedTotal":1,
8
- "resources":[
9
- {
10
- "__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
11
- "bbox":[
12
- 40.744944289326668,
13
- -74.002353921532631,
14
- 40.755675807595253,
15
- -73.983625397086143
16
- ],
17
- "name":"Madison Square Garden, NY",
18
- "point":{
19
- "type":"Point",
20
- "coordinates":[
21
- 40.75031,
22
- -73.99299
23
- ]
24
- },
25
- "address":{
26
- "adminDistrict":"NY",
27
- "countryRegion":"United States",
28
- "formattedAddress":"Madison Square Garden, NY",
29
- "locality":"New York"
30
- },
31
- "confidence":"High",
32
- "entityType":"Stadium"
33
- }
34
- ]
35
- }
36
- ],
37
- "statusCode":200,
38
- "statusDescription":"OK",
39
- "traceId":"55094ee53c8d45e789794014666328cd|CH1M001466|02.00.82.2800|CH1MSNVM001396, CH1MSNVM001370, CH1MSNVM001397"
40
- }
@@ -1,16 +0,0 @@
1
- {
2
- "authenticationResultCode":"ValidCredentials",
3
- "brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
4
- "copyright":"Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
5
- "resourceSets":[
6
- {
7
- "estimatedTotal":0,
8
- "resources":[
9
-
10
- ]
11
- }
12
- ],
13
- "statusCode":200,
14
- "statusDescription":"OK",
15
- "traceId":"907b76a307bc49129a489de3d4c992ea|CH1M001463|02.00.82.2800|CH1MSNVM001383, CH1MSNVM001358, CH1MSNVM001397"
16
- }
@@ -1,42 +0,0 @@
1
- {
2
- "authenticationResultCode":"ValidCredentials",
3
- "brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
4
- "copyright":"Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
5
- "resourceSets":[
6
- {
7
- "estimatedTotal":1,
8
- "resources":[
9
- {
10
- "__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
11
- "bbox":[
12
- 45.419835111675845,
13
- -75.683656128790716,
14
- 45.4275605468172,
15
- -75.66898098334994
16
- ],
17
- "name":"291 Rue Somerset E, Ottawa, ON, K1N",
18
- "point":{
19
- "type":"Point",
20
- "coordinates":[
21
- 45.423697829246521,
22
- -75.676318556070328
23
- ]
24
- },
25
- "address":{
26
- "addressLine":"291 Rue Somerset E",
27
- "adminDistrict":"ON",
28
- "countryRegion":"Canada",
29
- "formattedAddress":"291 Rue Somerset E, Ottawa, ON, K1N",
30
- "locality":"Ottawa",
31
- "postalCode":"K1N"
32
- },
33
- "confidence":"Medium",
34
- "entityType":"Address"
35
- }
36
- ]
37
- }
38
- ],
39
- "statusCode":200,
40
- "statusDescription":"OK",
41
- "traceId":"27bd5ed659e64ba6970c4144f1d4ea94|CH1M001470|02.00.82.2800|CH1MSNVM001396, CH1MSNVM001374"
42
- }
@@ -1,59 +0,0 @@
1
- {
2
- "spatialReference": {
3
- "wkid": 4326,
4
- "latestWkid": 4326
5
- },
6
- "locations": [
7
- {
8
- "name": "Madison Square Garden",
9
- "extent": {
10
- "xmin": -74.000241000000003,
11
- "ymin": 40.744050000000001,
12
- "xmax": -73.988241000000002,
13
- "ymax": 40.756050000000002
14
- },
15
- "feature": {
16
- "geometry": {
17
- "x": -73.994238897999651,
18
- "y": 40.750049813000487
19
- },
20
- "attributes": {
21
- "Loc_name": "Gaz.WorldGazetteer.POI2",
22
- "Score": 100,
23
- "Match_addr": "Madison Square Garden",
24
- "Addr_type": "POI",
25
- "Type": "Sports Complex",
26
- "PlaceName": "Madison Square Garden",
27
- "Rank": "18",
28
- "AddBldg": "",
29
- "AddNum": "",
30
- "AddNumFrom": "",
31
- "AddNumTo": "",
32
- "Side": "",
33
- "StPreDir": "",
34
- "StPreType": "",
35
- "StName": "",
36
- "StType": "",
37
- "StDir": "",
38
- "Nbrhd": "",
39
- "City": "New York",
40
- "Subregion": "New York",
41
- "Region": "New York",
42
- "Postal": "10001",
43
- "PostalExt": "",
44
- "Country": "USA",
45
- "LangCode": "",
46
- "Distance": 0,
47
- "X": -73.994240000000005,
48
- "Y": 40.750050000000002,
49
- "DisplayX": -73.994240000000005,
50
- "DisplayY": 40.750050000000002,
51
- "Xmin": -74.000241000000003,
52
- "Xmax": -73.988241000000002,
53
- "Ymin": 40.744050000000001,
54
- "Ymax": 40.756050000000002
55
- }
56
- }
57
- }
58
- ]
59
- }
@@ -1,8 +0,0 @@
1
- {
2
- "spatialReference": {
3
- "wkid": 4326,
4
- "latestWkid": 4326
5
- },
6
- "locations": [
7
- ]
8
- }
@@ -1,21 +0,0 @@
1
- {
2
- "address": {
3
- "Address": "4 Avenue Gustave Eiffel",
4
- "Neighborhood": "7e Arrondissement",
5
- "City": "Paris",
6
- "Subregion": "Paris",
7
- "Region": "Île-de-France",
8
- "Postal": "75007",
9
- "PostalExt": null,
10
- "CountryCode": "FRA",
11
- "Loc_name": "FRA.PointAddress"
12
- },
13
- "location": {
14
- "x": 2.2956200048981574,
15
- "y": 48.858129997357558,
16
- "spatialReference": {
17
- "wkid": 4326,
18
- "latestWkid": 4326
19
- }
20
- }
21
- }
@@ -1,12 +0,0 @@
1
- {
2
- "city": "Plano",
3
- "region_code": "TX",
4
- "region_name": "Texas",
5
- "metrocode": "623",
6
- "zipcode": "75093",
7
- "longitude": "-96.8134",
8
- "country_name": "United States",
9
- "country_code": "US",
10
- "ip": "74.200.247.59",
11
- "latitude": "33.0347"
12
- }
@@ -1 +0,0 @@
1
- <html><title>404: Not Found</title><body>404: Not Found</body></html>
@@ -1 +0,0 @@
1
- test({"longt":"-73.992006","latt":"40.749101"});
@@ -1 +0,0 @@
1
- test({"longt":"-0.000000","error":{"description":"Postal Code is not in the proper Format.","code":"005"},"latt":"176946676.000000"});
@@ -1,34 +0,0 @@
1
- test({
2
- "latt":"45.423733",
3
- "longt":"-75.676333",
4
- "inlatt":"45.424035",
5
- "inlongt":"-75.675941",
6
- "betweenRoad1":"Chapel",
7
- "betweenRoad2":"Russell",
8
- "distance":"0.034",
9
- "stnumber":"289",
10
- "staddress":"Somerset ST E",
11
- "city":"Ottawa",
12
- "prov":"ON",
13
- "postal":"K1N6W1",
14
- "NearRoad":"Somerset ST E",
15
- "NearRoadDistance":"0.013",
16
- "intersection":{
17
- "lattx":"45.423733",
18
- "longtx":"-75.676333",
19
- "distance":"0.045",
20
- "street1":"Somerset St E",
21
- "street2":"Russell Ave",
22
- "city":"OTTAWA",
23
- "prov":"ON"
24
- },
25
- "major_intersection":{
26
- "lattx":"45.4241623853",
27
- "longtx":"-75.6753026518",
28
- "distance":"0.052",
29
- "street1":"Chapel St",
30
- "street2":"Somerset St E",
31
- "city":"OTTAWA",
32
- "prov":"ON"
33
- }
34
- });
@@ -1 +0,0 @@
1
- 40.678107, -73.897460, 4 Pennsylvania Ave, New York, NY, 11207
@@ -1 +0,0 @@
1
- 2: couldn't find this address! sorry