geocoder 1.5.1 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +65 -0
  3. data/LICENSE +1 -1
  4. data/README.md +333 -238
  5. data/bin/console +13 -0
  6. data/lib/easting_northing.rb +171 -0
  7. data/lib/generators/geocoder/config/templates/initializer.rb +7 -1
  8. data/lib/geocoder/cache.rb +16 -33
  9. data/lib/geocoder/cache_stores/base.rb +40 -0
  10. data/lib/geocoder/cache_stores/generic.rb +35 -0
  11. data/lib/geocoder/cache_stores/redis.rb +34 -0
  12. data/lib/geocoder/configuration.rb +11 -4
  13. data/lib/geocoder/configuration_hash.rb +4 -4
  14. data/lib/geocoder/ip_address.rb +8 -1
  15. data/lib/geocoder/lookup.rb +21 -3
  16. data/lib/geocoder/lookups/abstract_api.rb +46 -0
  17. data/lib/geocoder/lookups/amazon_location_service.rb +54 -0
  18. data/lib/geocoder/lookups/ban_data_gouv_fr.rb +14 -1
  19. data/lib/geocoder/lookups/base.rb +10 -2
  20. data/lib/geocoder/lookups/bing.rb +1 -1
  21. data/lib/geocoder/lookups/esri.rb +6 -0
  22. data/lib/geocoder/lookups/freegeoip.rb +4 -4
  23. data/lib/geocoder/lookups/geoapify.rb +72 -0
  24. data/lib/geocoder/lookups/geocodio.rb +1 -1
  25. data/lib/geocoder/lookups/geoip2.rb +4 -0
  26. data/lib/geocoder/lookups/google.rb +7 -2
  27. data/lib/geocoder/lookups/google_places_details.rb +8 -14
  28. data/lib/geocoder/lookups/google_places_search.rb +28 -2
  29. data/lib/geocoder/lookups/google_premier.rb +4 -0
  30. data/lib/geocoder/lookups/here.rb +7 -16
  31. data/lib/geocoder/lookups/ip2location.rb +10 -14
  32. data/lib/geocoder/lookups/ipdata_co.rb +1 -1
  33. data/lib/geocoder/lookups/ipgeolocation.rb +51 -0
  34. data/lib/geocoder/lookups/ipqualityscore.rb +50 -0
  35. data/lib/geocoder/lookups/ipregistry.rb +68 -0
  36. data/lib/geocoder/lookups/latlon.rb +1 -2
  37. data/lib/geocoder/lookups/maxmind_local.rb +7 -1
  38. data/lib/geocoder/lookups/melissa_street.rb +41 -0
  39. data/lib/geocoder/lookups/nationaal_georegister_nl.rb +38 -0
  40. data/lib/geocoder/lookups/osmnames.rb +57 -0
  41. data/lib/geocoder/lookups/photon.rb +89 -0
  42. data/lib/geocoder/lookups/pickpoint.rb +1 -1
  43. data/lib/geocoder/lookups/smarty_streets.rb +6 -1
  44. data/lib/geocoder/lookups/telize.rb +1 -1
  45. data/lib/geocoder/lookups/tencent.rb +9 -9
  46. data/lib/geocoder/lookups/test.rb +4 -0
  47. data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +59 -0
  48. data/lib/geocoder/lookups/yandex.rb +3 -4
  49. data/lib/geocoder/results/abstract_api.rb +146 -0
  50. data/lib/geocoder/results/amazon_location_service.rb +57 -0
  51. data/lib/geocoder/results/baidu.rb +0 -4
  52. data/lib/geocoder/results/ban_data_gouv_fr.rb +27 -2
  53. data/lib/geocoder/results/db_ip_com.rb +1 -1
  54. data/lib/geocoder/results/esri.rb +5 -2
  55. data/lib/geocoder/results/geoapify.rb +179 -0
  56. data/lib/geocoder/results/here.rb +4 -1
  57. data/lib/geocoder/results/ipgeolocation.rb +59 -0
  58. data/lib/geocoder/results/ipqualityscore.rb +54 -0
  59. data/lib/geocoder/results/ipregistry.rb +304 -0
  60. data/lib/geocoder/results/mapbox.rb +10 -4
  61. data/lib/geocoder/results/melissa_street.rb +46 -0
  62. data/lib/geocoder/results/nationaal_georegister_nl.rb +62 -0
  63. data/lib/geocoder/results/nominatim.rb +27 -15
  64. data/lib/geocoder/results/osmnames.rb +56 -0
  65. data/lib/geocoder/results/photon.rb +119 -0
  66. data/lib/geocoder/results/uk_ordnance_survey_names.rb +59 -0
  67. data/lib/geocoder/results/yandex.rb +217 -59
  68. data/lib/geocoder/sql.rb +4 -4
  69. data/lib/geocoder/util.rb +29 -0
  70. data/lib/geocoder/version.rb +1 -1
  71. data/lib/maxmind_database.rb +3 -3
  72. metadata +35 -18
  73. data/examples/autoexpire_cache_dalli.rb +0 -62
  74. data/examples/autoexpire_cache_redis.rb +0 -28
  75. data/lib/geocoder/lookups/geocoder_us.rb +0 -51
  76. data/lib/geocoder/results/geocoder_us.rb +0 -39
  77. data/lib/hash_recursive_merge.rb +0 -74
@@ -2,78 +2,223 @@ require 'geocoder/results/base'
2
2
 
3
3
  module Geocoder::Result
4
4
  class Yandex < Base
5
+ # Yandex result has difficult tree structure,
6
+ # and presence of some nodes depends on exact search case.
7
+
8
+ # Also Yandex lacks documentation about it.
9
+ # See https://tech.yandex.com/maps/doc/geocoder/desc/concepts/response_structure-docpage/
10
+
11
+ # Ultimatly, we need to find Locality and/or Thoroughfare data.
12
+
13
+ # It may resides on the top (ADDRESS_DETAILS) level.
14
+ # example: 'Baltic Sea'
15
+ # "AddressDetails": {
16
+ # "Locality": {
17
+ # "Premise": {
18
+ # "PremiseName": "Baltic Sea"
19
+ # }
20
+ # }
21
+ # }
22
+
23
+ ADDRESS_DETAILS = %w[
24
+ GeoObject metaDataProperty GeocoderMetaData
25
+ AddressDetails
26
+ ].freeze
27
+
28
+ # On COUNTRY_LEVEL.
29
+ # example: 'Potomak'
30
+ # "AddressDetails": {
31
+ # "Country": {
32
+ # "AddressLine": "reka Potomak",
33
+ # "CountryNameCode": "US",
34
+ # "CountryName": "United States of America",
35
+ # "Locality": {
36
+ # "Premise": {
37
+ # "PremiseName": "reka Potomak"
38
+ # }
39
+ # }
40
+ # }
41
+ # }
42
+
43
+ COUNTRY_LEVEL = %w[
44
+ GeoObject metaDataProperty GeocoderMetaData
45
+ AddressDetails Country
46
+ ].freeze
47
+
48
+ # On ADMIN_LEVEL (usually state or city)
49
+ # example: 'Moscow, Tverskaya'
50
+ # "AddressDetails": {
51
+ # "Country": {
52
+ # "AddressLine": "Moscow, Tverskaya Street",
53
+ # "CountryNameCode": "RU",
54
+ # "CountryName": "Russia",
55
+ # "AdministrativeArea": {
56
+ # "AdministrativeAreaName": "Moscow",
57
+ # "Locality": {
58
+ # "LocalityName": "Moscow",
59
+ # "Thoroughfare": {
60
+ # "ThoroughfareName": "Tverskaya Street"
61
+ # }
62
+ # }
63
+ # }
64
+ # }
65
+ # }
66
+
67
+ ADMIN_LEVEL = %w[
68
+ GeoObject metaDataProperty GeocoderMetaData
69
+ AddressDetails Country
70
+ AdministrativeArea
71
+ ].freeze
72
+
73
+ # On SUBADMIN_LEVEL (may refer to urban district)
74
+ # example: 'Moscow Region, Krasnogorsk'
75
+ # "AddressDetails": {
76
+ # "Country": {
77
+ # "AddressLine": "Moscow Region, Krasnogorsk",
78
+ # "CountryNameCode": "RU",
79
+ # "CountryName": "Russia",
80
+ # "AdministrativeArea": {
81
+ # "AdministrativeAreaName": "Moscow Region",
82
+ # "SubAdministrativeArea": {
83
+ # "SubAdministrativeAreaName": "gorodskoy okrug Krasnogorsk",
84
+ # "Locality": {
85
+ # "LocalityName": "Krasnogorsk"
86
+ # }
87
+ # }
88
+ # }
89
+ # }
90
+ # }
91
+
92
+ SUBADMIN_LEVEL = %w[
93
+ GeoObject metaDataProperty GeocoderMetaData
94
+ AddressDetails Country
95
+ AdministrativeArea
96
+ SubAdministrativeArea
97
+ ].freeze
98
+
99
+ # On DEPENDENT_LOCALITY_1 (may refer to district of city)
100
+ # example: 'Paris, Etienne Marcel'
101
+ # "AddressDetails": {
102
+ # "Country": {
103
+ # "AddressLine": "Île-de-France, Paris, 1er Arrondissement, Rue Étienne Marcel",
104
+ # "CountryNameCode": "FR",
105
+ # "CountryName": "France",
106
+ # "AdministrativeArea": {
107
+ # "AdministrativeAreaName": "Île-de-France",
108
+ # "Locality": {
109
+ # "LocalityName": "Paris",
110
+ # "DependentLocality": {
111
+ # "DependentLocalityName": "1er Arrondissement",
112
+ # "Thoroughfare": {
113
+ # "ThoroughfareName": "Rue Étienne Marcel"
114
+ # }
115
+ # }
116
+ # }
117
+ # }
118
+ # }
119
+ # }
120
+
121
+ DEPENDENT_LOCALITY_1 = %w[
122
+ GeoObject metaDataProperty GeocoderMetaData
123
+ AddressDetails Country
124
+ AdministrativeArea Locality
125
+ DependentLocality
126
+ ].freeze
127
+
128
+ # On DEPENDENT_LOCALITY_2 (for special cases like turkish "mahalle")
129
+ # https://en.wikipedia.org/wiki/Mahalle
130
+ # example: 'Istanbul Mabeyinci Yokuşu 17'
131
+
132
+ # "AddressDetails": {
133
+ # "Country": {
134
+ # "AddressLine": "İstanbul, Fatih, Saraç İshak Mah., Mabeyinci Yokuşu, 17",
135
+ # "CountryNameCode": "TR",
136
+ # "CountryName": "Turkey",
137
+ # "AdministrativeArea": {
138
+ # "AdministrativeAreaName": "İstanbul",
139
+ # "SubAdministrativeArea": {
140
+ # "SubAdministrativeAreaName": "Fatih",
141
+ # "Locality": {
142
+ # "DependentLocality": {
143
+ # "DependentLocalityName": "Saraç İshak Mah.",
144
+ # "Thoroughfare": {
145
+ # "ThoroughfareName": "Mabeyinci Yokuşu",
146
+ # "Premise": {
147
+ # "PremiseNumber": "17"
148
+ # }
149
+ # }
150
+ # }
151
+ # }
152
+ # }
153
+ # }
154
+ # }
155
+ # }
156
+
157
+ DEPENDENT_LOCALITY_2 = %w[
158
+ GeoObject metaDataProperty GeocoderMetaData
159
+ AddressDetails Country
160
+ AdministrativeArea
161
+ SubAdministrativeArea Locality
162
+ DependentLocality
163
+ ].freeze
5
164
 
6
165
  def coordinates
7
166
  @data['GeoObject']['Point']['pos'].split(' ').reverse.map(&:to_f)
8
167
  end
9
168
 
10
- def address(format = :full)
169
+ def address(_format = :full)
11
170
  @data['GeoObject']['metaDataProperty']['GeocoderMetaData']['text']
12
171
  end
13
172
 
14
173
  def city
15
- if state.empty? and address_details and address_details.has_key? 'Locality'
16
- address_details['Locality']['LocalityName']
17
- elsif sub_state.empty? and address_details and address_details.has_key? 'AdministrativeArea' and
18
- address_details['AdministrativeArea'].has_key? 'Locality'
19
- address_details['AdministrativeArea']['Locality']['LocalityName']
20
- elsif not sub_state_city.empty?
21
- sub_state_city
22
- else
23
- ""
24
- end
174
+ result =
175
+ if state.empty?
176
+ find_in_hash(@data, *COUNTRY_LEVEL, 'Locality', 'LocalityName')
177
+ elsif sub_state.empty?
178
+ find_in_hash(@data, *ADMIN_LEVEL, 'Locality', 'LocalityName')
179
+ else
180
+ find_in_hash(@data, *SUBADMIN_LEVEL, 'Locality', 'LocalityName')
181
+ end
182
+
183
+ result || ""
25
184
  end
26
185
 
27
186
  def country
28
- if address_details
29
- address_details['CountryName']
30
- else
31
- ""
32
- end
187
+ find_in_hash(@data, *COUNTRY_LEVEL, 'CountryName') || ""
33
188
  end
34
189
 
35
190
  def country_code
36
- if address_details
37
- address_details['CountryNameCode']
38
- else
39
- ""
40
- end
191
+ find_in_hash(@data, *COUNTRY_LEVEL, 'CountryNameCode') || ""
41
192
  end
42
193
 
43
194
  def state
44
- if address_details and address_details['AdministrativeArea']
45
- address_details['AdministrativeArea']['AdministrativeAreaName']
46
- else
47
- ""
48
- end
195
+ find_in_hash(@data, *ADMIN_LEVEL, 'AdministrativeAreaName') || ""
49
196
  end
50
197
 
51
198
  def sub_state
52
- if !state.empty? and address_details and address_details['AdministrativeArea']['SubAdministrativeArea']
53
- address_details['AdministrativeArea']['SubAdministrativeArea']['SubAdministrativeAreaName']
54
- else
55
- ""
56
- end
199
+ return "" if state.empty?
200
+ find_in_hash(@data, *SUBADMIN_LEVEL, 'SubAdministrativeAreaName') || ""
57
201
  end
58
202
 
59
203
  def state_code
60
204
  ""
61
205
  end
62
206
 
63
- def postal_code
64
- ""
207
+ def street
208
+ thoroughfare_data.is_a?(Hash) ? thoroughfare_data['ThoroughfareName'] : ""
65
209
  end
66
210
 
67
- def premise_name
68
- address_details['Locality']['Premise']['PremiseName']
211
+ def street_number
212
+ premise.is_a?(Hash) ? premise.fetch('PremiseNumber', "") : ""
69
213
  end
70
214
 
71
- def street
72
- thoroughfare_data && thoroughfare_data['ThoroughfareName']
215
+ def premise_name
216
+ premise.is_a?(Hash) ? premise.fetch('PremiseName', "") : ""
73
217
  end
74
218
 
75
- def street_number
76
- thoroughfare_data && thoroughfare_data['Premise'] && thoroughfare_data['Premise']['PremiseNumber']
219
+ def postal_code
220
+ return "" unless premise.is_a?(Hash)
221
+ find_in_hash(premise, 'PostalCode', 'PostalCodeNumber') || ""
77
222
  end
78
223
 
79
224
  def kind
@@ -93,42 +238,55 @@ module Geocoder::Result
93
238
 
94
239
  private # ----------------------------------------------------------------
95
240
 
96
- def thoroughfare_data
97
- locality_data && locality_data['Thoroughfare']
241
+ def top_level_locality
242
+ find_in_hash(@data, *ADDRESS_DETAILS, 'Locality')
98
243
  end
99
244
 
100
- def locality_data
101
- dependent_locality && subadmin_locality && admin_locality
245
+ def country_level_locality
246
+ find_in_hash(@data, *COUNTRY_LEVEL, 'Locality')
102
247
  end
103
248
 
104
249
  def admin_locality
105
- address_details && address_details['AdministrativeArea'] &&
106
- address_details['AdministrativeArea']['Locality']
250
+ find_in_hash(@data, *ADMIN_LEVEL, 'Locality')
107
251
  end
108
252
 
109
253
  def subadmin_locality
110
- address_details && address_details['AdministrativeArea'] &&
111
- address_details['AdministrativeArea']['SubAdministrativeArea'] &&
112
- address_details['AdministrativeArea']['SubAdministrativeArea']['Locality']
254
+ find_in_hash(@data, *SUBADMIN_LEVEL, 'Locality')
113
255
  end
114
256
 
115
257
  def dependent_locality
116
- address_details && address_details['AdministrativeArea'] &&
117
- address_details['AdministrativeArea']['SubAdministrativeArea'] &&
118
- address_details['AdministrativeArea']['SubAdministrativeArea']['Locality'] &&
119
- address_details['AdministrativeArea']['SubAdministrativeArea']['Locality']['DependentLocality']
258
+ find_in_hash(@data, *DEPENDENT_LOCALITY_1) ||
259
+ find_in_hash(@data, *DEPENDENT_LOCALITY_2)
260
+ end
261
+
262
+ def locality_data
263
+ dependent_locality || subadmin_locality || admin_locality ||
264
+ country_level_locality || top_level_locality
265
+ end
266
+
267
+ def thoroughfare_data
268
+ locality_data['Thoroughfare'] if locality_data.is_a?(Hash)
120
269
  end
121
270
 
122
- def address_details
123
- @data['GeoObject']['metaDataProperty']['GeocoderMetaData']['AddressDetails']['Country']
271
+ def premise
272
+ if thoroughfare_data.is_a?(Hash)
273
+ thoroughfare_data['Premise']
274
+ elsif locality_data.is_a?(Hash)
275
+ locality_data['Premise']
276
+ end
124
277
  end
125
278
 
126
- def sub_state_city
127
- if !sub_state.empty? and address_details and address_details['AdministrativeArea']['SubAdministrativeArea'].has_key? 'Locality'
128
- address_details['AdministrativeArea']['SubAdministrativeArea']['Locality']['LocalityName'] || ""
129
- else
130
- ""
279
+ def find_in_hash(source, *keys)
280
+ key = keys.shift
281
+ result = source[key]
282
+
283
+ if keys.empty?
284
+ return result
285
+ elsif !result.is_a?(Hash)
286
+ return nil
131
287
  end
288
+
289
+ find_in_hash(result, *keys)
132
290
  end
133
291
  end
134
292
  end
data/lib/geocoder/sql.rb CHANGED
@@ -44,13 +44,13 @@ module Geocoder
44
44
  end
45
45
 
46
46
  def within_bounding_box(sw_lat, sw_lng, ne_lat, ne_lng, lat_attr, lon_attr)
47
- spans = "#{lat_attr} BETWEEN #{sw_lat} AND #{ne_lat} AND "
47
+ spans = "#{lat_attr} BETWEEN #{sw_lat.to_f} AND #{ne_lat.to_f} AND "
48
48
  # handle box that spans 180 longitude
49
49
  if sw_lng.to_f > ne_lng.to_f
50
- spans + "(#{lon_attr} BETWEEN #{sw_lng} AND 180 OR " +
51
- "#{lon_attr} BETWEEN -180 AND #{ne_lng})"
50
+ spans + "(#{lon_attr} BETWEEN #{sw_lng.to_f} AND 180 OR " +
51
+ "#{lon_attr} BETWEEN -180 AND #{ne_lng.to_f})"
52
52
  else
53
- spans + "#{lon_attr} BETWEEN #{sw_lng} AND #{ne_lng}"
53
+ spans + "#{lon_attr} BETWEEN #{sw_lng.to_f} AND #{ne_lng.to_f}"
54
54
  end
55
55
  end
56
56
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Geocoder
4
+ module Util
5
+ #
6
+ # Recursive version of Hash#merge!
7
+ #
8
+ # Adds the contents of +h2+ to +h1+,
9
+ # merging entries in +h1+ with duplicate keys with those from +h2+.
10
+ #
11
+ # Compared with Hash#merge!, this method supports nested hashes.
12
+ # When both +h1+ and +h2+ contains an entry with the same key,
13
+ # it merges and returns the values from both hashes.
14
+ #
15
+ # h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
16
+ # h2 = {"b" => 254, "c" => {"c1" => 16, "c3" => 94}}
17
+ # recursive_hash_merge(h1, h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
18
+ #
19
+ # Simply using Hash#merge! would return
20
+ #
21
+ # h1.merge!(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
22
+ #
23
+ def self.recursive_hash_merge(h1, h2)
24
+ h1.merge!(h2) do |_key, oldval, newval|
25
+ oldval.class == h1.class ? self.recursive_hash_merge(oldval, newval) : newval
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.5.1"
2
+ VERSION = "1.7.3"
3
3
  end
@@ -96,9 +96,9 @@ module Geocoder
96
96
 
97
97
  def archive_url_path(package)
98
98
  {
99
- geolite_country_csv: "GeoIPCountryCSV.zip",
100
- geolite_city_csv: "GeoLiteCity_CSV/GeoLiteCity-latest.zip",
101
- geolite_asn_csv: "asnum/GeoIPASNum2.zip"
99
+ geolite_country_csv: "GeoLite2-Country-CSV.zip",
100
+ geolite_city_csv: "GeoLite2-City-CSV.zip",
101
+ geolite_asn_csv: "GeoLite2-ASN-CSV.zip"
102
102
  }[package]
103
103
  end
104
104
 
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-23 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Provides object geocoding (by street or IP address), reverse geocoding
14
- (coordinates to street address), distance queries for ActiveRecord and Mongoid,
15
- result caching, and more. Designed for Rails but works with Sinatra and other Rack
16
- frameworks too.
13
+ description: Object geocoding (by street or IP address), reverse geocoding (coordinates
14
+ to street address), distance queries for ActiveRecord and Mongoid, result caching,
15
+ and more. Designed for Rails but works with Sinatra and other Rack frameworks too.
17
16
  email:
18
17
  - alex@alexreisner.com
19
18
  executables:
@@ -24,11 +23,11 @@ files:
24
23
  - CHANGELOG.md
25
24
  - LICENSE
26
25
  - README.md
26
+ - bin/console
27
27
  - bin/geocode
28
- - examples/autoexpire_cache_dalli.rb
29
- - examples/autoexpire_cache_redis.rb
30
28
  - examples/cache_bypass.rb
31
29
  - examples/reverse_geocode_job.rb
30
+ - lib/easting_northing.rb
32
31
  - lib/generators/geocoder/config/config_generator.rb
33
32
  - lib/generators/geocoder/config/templates/initializer.rb
34
33
  - lib/generators/geocoder/maxmind/geolite_city_generator.rb
@@ -38,6 +37,9 @@ files:
38
37
  - lib/generators/geocoder/migration_version.rb
39
38
  - lib/geocoder.rb
40
39
  - lib/geocoder/cache.rb
40
+ - lib/geocoder/cache_stores/base.rb
41
+ - lib/geocoder/cache_stores/generic.rb
42
+ - lib/geocoder/cache_stores/redis.rb
41
43
  - lib/geocoder/calculations.rb
42
44
  - lib/geocoder/cli.rb
43
45
  - lib/geocoder/configuration.rb
@@ -48,7 +50,9 @@ files:
48
50
  - lib/geocoder/kernel_logger.rb
49
51
  - lib/geocoder/logger.rb
50
52
  - lib/geocoder/lookup.rb
53
+ - lib/geocoder/lookups/abstract_api.rb
51
54
  - lib/geocoder/lookups/amap.rb
55
+ - lib/geocoder/lookups/amazon_location_service.rb
52
56
  - lib/geocoder/lookups/baidu.rb
53
57
  - lib/geocoder/lookups/baidu_ip.rb
54
58
  - lib/geocoder/lookups/ban_data_gouv_fr.rb
@@ -58,8 +62,8 @@ files:
58
62
  - lib/geocoder/lookups/dstk.rb
59
63
  - lib/geocoder/lookups/esri.rb
60
64
  - lib/geocoder/lookups/freegeoip.rb
65
+ - lib/geocoder/lookups/geoapify.rb
61
66
  - lib/geocoder/lookups/geocoder_ca.rb
62
- - lib/geocoder/lookups/geocoder_us.rb
63
67
  - lib/geocoder/lookups/geocodio.rb
64
68
  - lib/geocoder/lookups/geoip2.rb
65
69
  - lib/geocoder/lookups/geoportail_lu.rb
@@ -71,7 +75,10 @@ files:
71
75
  - lib/geocoder/lookups/ip2location.rb
72
76
  - lib/geocoder/lookups/ipapi_com.rb
73
77
  - lib/geocoder/lookups/ipdata_co.rb
78
+ - lib/geocoder/lookups/ipgeolocation.rb
74
79
  - lib/geocoder/lookups/ipinfo_io.rb
80
+ - lib/geocoder/lookups/ipqualityscore.rb
81
+ - lib/geocoder/lookups/ipregistry.rb
75
82
  - lib/geocoder/lookups/ipstack.rb
76
83
  - lib/geocoder/lookups/latlon.rb
77
84
  - lib/geocoder/lookups/location_iq.rb
@@ -80,9 +87,13 @@ files:
80
87
  - lib/geocoder/lookups/maxmind.rb
81
88
  - lib/geocoder/lookups/maxmind_geoip2.rb
82
89
  - lib/geocoder/lookups/maxmind_local.rb
90
+ - lib/geocoder/lookups/melissa_street.rb
91
+ - lib/geocoder/lookups/nationaal_georegister_nl.rb
83
92
  - lib/geocoder/lookups/nominatim.rb
84
93
  - lib/geocoder/lookups/opencagedata.rb
94
+ - lib/geocoder/lookups/osmnames.rb
85
95
  - lib/geocoder/lookups/pelias.rb
96
+ - lib/geocoder/lookups/photon.rb
86
97
  - lib/geocoder/lookups/pickpoint.rb
87
98
  - lib/geocoder/lookups/pointpin.rb
88
99
  - lib/geocoder/lookups/postcode_anywhere_uk.rb
@@ -91,6 +102,7 @@ files:
91
102
  - lib/geocoder/lookups/telize.rb
92
103
  - lib/geocoder/lookups/tencent.rb
93
104
  - lib/geocoder/lookups/test.rb
105
+ - lib/geocoder/lookups/uk_ordnance_survey_names.rb
94
106
  - lib/geocoder/lookups/yandex.rb
95
107
  - lib/geocoder/models/active_record.rb
96
108
  - lib/geocoder/models/base.rb
@@ -100,7 +112,9 @@ files:
100
112
  - lib/geocoder/query.rb
101
113
  - lib/geocoder/railtie.rb
102
114
  - lib/geocoder/request.rb
115
+ - lib/geocoder/results/abstract_api.rb
103
116
  - lib/geocoder/results/amap.rb
117
+ - lib/geocoder/results/amazon_location_service.rb
104
118
  - lib/geocoder/results/baidu.rb
105
119
  - lib/geocoder/results/baidu_ip.rb
106
120
  - lib/geocoder/results/ban_data_gouv_fr.rb
@@ -110,8 +124,8 @@ files:
110
124
  - lib/geocoder/results/dstk.rb
111
125
  - lib/geocoder/results/esri.rb
112
126
  - lib/geocoder/results/freegeoip.rb
127
+ - lib/geocoder/results/geoapify.rb
113
128
  - lib/geocoder/results/geocoder_ca.rb
114
- - lib/geocoder/results/geocoder_us.rb
115
129
  - lib/geocoder/results/geocodio.rb
116
130
  - lib/geocoder/results/geoip2.rb
117
131
  - lib/geocoder/results/geoportail_lu.rb
@@ -123,7 +137,10 @@ files:
123
137
  - lib/geocoder/results/ip2location.rb
124
138
  - lib/geocoder/results/ipapi_com.rb
125
139
  - lib/geocoder/results/ipdata_co.rb
140
+ - lib/geocoder/results/ipgeolocation.rb
126
141
  - lib/geocoder/results/ipinfo_io.rb
142
+ - lib/geocoder/results/ipqualityscore.rb
143
+ - lib/geocoder/results/ipregistry.rb
127
144
  - lib/geocoder/results/ipstack.rb
128
145
  - lib/geocoder/results/latlon.rb
129
146
  - lib/geocoder/results/location_iq.rb
@@ -132,9 +149,13 @@ files:
132
149
  - lib/geocoder/results/maxmind.rb
133
150
  - lib/geocoder/results/maxmind_geoip2.rb
134
151
  - lib/geocoder/results/maxmind_local.rb
152
+ - lib/geocoder/results/melissa_street.rb
153
+ - lib/geocoder/results/nationaal_georegister_nl.rb
135
154
  - lib/geocoder/results/nominatim.rb
136
155
  - lib/geocoder/results/opencagedata.rb
156
+ - lib/geocoder/results/osmnames.rb
137
157
  - lib/geocoder/results/pelias.rb
158
+ - lib/geocoder/results/photon.rb
138
159
  - lib/geocoder/results/pickpoint.rb
139
160
  - lib/geocoder/results/pointpin.rb
140
161
  - lib/geocoder/results/postcode_anywhere_uk.rb
@@ -143,6 +164,7 @@ files:
143
164
  - lib/geocoder/results/telize.rb
144
165
  - lib/geocoder/results/tencent.rb
145
166
  - lib/geocoder/results/test.rb
167
+ - lib/geocoder/results/uk_ordnance_survey_names.rb
146
168
  - lib/geocoder/results/yandex.rb
147
169
  - lib/geocoder/sql.rb
148
170
  - lib/geocoder/stores/active_record.rb
@@ -150,8 +172,8 @@ files:
150
172
  - lib/geocoder/stores/mongo_base.rb
151
173
  - lib/geocoder/stores/mongo_mapper.rb
152
174
  - lib/geocoder/stores/mongoid.rb
175
+ - lib/geocoder/util.rb
153
176
  - lib/geocoder/version.rb
154
- - lib/hash_recursive_merge.rb
155
177
  - lib/maxmind_database.rb
156
178
  - lib/tasks/geocoder.rake
157
179
  - lib/tasks/maxmind.rake
@@ -161,11 +183,7 @@ licenses:
161
183
  metadata:
162
184
  source_code_uri: https://github.com/alexreisner/geocoder
163
185
  changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
164
- post_install_message: |2+
165
-
166
-
167
- NOTE: Geocoder's default IP address lookup has changed from FreeGeoIP.net to IPInfo.io. If you explicitly specify :freegeoip in your configuration you must choose a different IP lookup before FreeGeoIP is discontinued on July 1, 2018. If you do not explicitly specify :freegeoip you do not need to change anything.
168
-
186
+ post_install_message:
169
187
  rdoc_options: []
170
188
  require_paths:
171
189
  - lib
@@ -180,8 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
198
  - !ruby/object:Gem::Version
181
199
  version: '0'
182
200
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.5.2
201
+ rubygems_version: 3.1.2
185
202
  signing_key:
186
203
  specification_version: 4
187
204
  summary: Complete geocoding solution for Ruby.
@@ -1,62 +0,0 @@
1
- # This class implements a cache with simple delegation to the the Dalli Memcached client
2
- # https://github.com/mperham/dalli
3
- #
4
- # A TTL is set on initialization
5
-
6
- class AutoexpireCacheDalli
7
- def initialize(store, ttl = 86400)
8
- @store = store
9
- @keys = 'GeocoderDalliClientKeys'
10
- @ttl = ttl
11
- end
12
-
13
- def [](url)
14
- res = @store.get(url)
15
- res = YAML::load(res) if res.present?
16
- res
17
- end
18
-
19
- def []=(url, value)
20
- if value.nil?
21
- del(url)
22
- else
23
- key_cache_add(url) if @store.add(url, YAML::dump(value), @ttl)
24
- end
25
- value
26
- end
27
-
28
- def keys
29
- key_cache
30
- end
31
-
32
- def del(url)
33
- key_cache_delete(url) if @store.delete(url)
34
- end
35
-
36
- private
37
-
38
- def key_cache
39
- the_keys = @store.get(@keys)
40
- if the_keys.nil?
41
- @store.add(@keys, YAML::dump([]))
42
- []
43
- else
44
- YAML::load(the_keys)
45
- end
46
- end
47
-
48
- def key_cache_add(key)
49
- @store.replace(@keys, YAML::dump(key_cache << key))
50
- end
51
-
52
- def key_cache_delete(key)
53
- tmp = key_cache
54
- tmp.delete(key)
55
- @store.replace(@keys, YAML::dump(tmp))
56
- end
57
- end
58
-
59
- # Here Dalli is set up as on Heroku using the Memcachier gem.
60
- # https://devcenter.heroku.com/articles/memcachier#ruby
61
- # On other setups you might have to specify your Memcached server in Dalli::Client.new
62
- Geocoder.configure(:cache => AutoexpireCacheDalli.new(Dalli::Client.new))
@@ -1,28 +0,0 @@
1
- # This class implements a cache with simple delegation to the Redis store, but
2
- # when it creates a key/value pair, it also sends an EXPIRE command with a TTL.
3
- # It should be fairly simple to do the same thing with Memcached.
4
- class AutoexpireCacheRedis
5
- def initialize(store, ttl = 86400)
6
- @store = store
7
- @ttl = ttl
8
- end
9
-
10
- def [](url)
11
- @store.get(url)
12
- end
13
-
14
- def []=(url, value)
15
- @store.set(url, value)
16
- @store.expire(url, @ttl)
17
- end
18
-
19
- def keys
20
- @store.keys
21
- end
22
-
23
- def del(url)
24
- @store.del(url)
25
- end
26
- end
27
-
28
- Geocoder.configure(:cache => AutoexpireCacheRedis.new(Redis.new))