geocoder 1.5.2 → 1.6.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/LICENSE +1 -1
  4. data/README.md +16 -39
  5. data/bin/console +13 -0
  6. data/examples/autoexpire_cache_redis.rb +2 -0
  7. data/lib/easting_northing.rb +171 -0
  8. data/lib/geocoder/cache.rb +4 -0
  9. data/lib/geocoder/configuration.rb +2 -1
  10. data/lib/geocoder/configuration_hash.rb +4 -4
  11. data/lib/geocoder/ip_address.rb +2 -1
  12. data/lib/geocoder/lookup.rb +7 -3
  13. data/lib/geocoder/lookups/abstract_api.rb +46 -0
  14. data/lib/geocoder/lookups/ban_data_gouv_fr.rb +14 -1
  15. data/lib/geocoder/lookups/esri.rb +6 -0
  16. data/lib/geocoder/lookups/geocodio.rb +1 -1
  17. data/lib/geocoder/lookups/google.rb +7 -2
  18. data/lib/geocoder/lookups/google_places_details.rb +8 -14
  19. data/lib/geocoder/lookups/google_places_search.rb +28 -2
  20. data/lib/geocoder/lookups/google_premier.rb +4 -0
  21. data/lib/geocoder/lookups/here.rb +7 -16
  22. data/lib/geocoder/lookups/ip2location.rb +5 -13
  23. data/lib/geocoder/lookups/ipgeolocation.rb +51 -0
  24. data/lib/geocoder/lookups/latlon.rb +1 -2
  25. data/lib/geocoder/lookups/maxmind_local.rb +7 -1
  26. data/lib/geocoder/lookups/nationaal_georegister_nl.rb +38 -0
  27. data/lib/geocoder/lookups/osmnames.rb +57 -0
  28. data/lib/geocoder/lookups/pickpoint.rb +1 -1
  29. data/lib/geocoder/lookups/smarty_streets.rb +6 -1
  30. data/lib/geocoder/lookups/telize.rb +1 -1
  31. data/lib/geocoder/lookups/tencent.rb +9 -9
  32. data/lib/geocoder/lookups/test.rb +4 -0
  33. data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +59 -0
  34. data/lib/geocoder/lookups/yandex.rb +1 -2
  35. data/lib/geocoder/results/abstract_api.rb +146 -0
  36. data/lib/geocoder/results/baidu.rb +0 -4
  37. data/lib/geocoder/results/ban_data_gouv_fr.rb +27 -2
  38. data/lib/geocoder/results/db_ip_com.rb +1 -1
  39. data/lib/geocoder/results/ipgeolocation.rb +59 -0
  40. data/lib/geocoder/results/ipregistry.rb +4 -8
  41. data/lib/geocoder/results/nationaal_georegister_nl.rb +62 -0
  42. data/lib/geocoder/results/nominatim.rb +4 -0
  43. data/lib/geocoder/results/osmnames.rb +56 -0
  44. data/lib/geocoder/results/uk_ordnance_survey_names.rb +59 -0
  45. data/lib/geocoder/results/yandex.rb +217 -59
  46. data/lib/geocoder/sql.rb +4 -4
  47. data/lib/geocoder/util.rb +29 -0
  48. data/lib/geocoder/version.rb +1 -1
  49. data/lib/maxmind_database.rb +3 -3
  50. metadata +19 -11
  51. data/lib/geocoder/lookups/geocoder_us.rb +0 -51
  52. data/lib/geocoder/results/geocoder_us.rb +0 -39
  53. data/lib/hash_recursive_merge.rb +0 -74
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.2
4
+ version: 1.6.7
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-10-03 00:00:00.000000000 Z
11
+ date: 2021-04-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,13 @@ files:
24
23
  - CHANGELOG.md
25
24
  - LICENSE
26
25
  - README.md
26
+ - bin/console
27
27
  - bin/geocode
28
28
  - examples/autoexpire_cache_dalli.rb
29
29
  - examples/autoexpire_cache_redis.rb
30
30
  - examples/cache_bypass.rb
31
31
  - examples/reverse_geocode_job.rb
32
+ - lib/easting_northing.rb
32
33
  - lib/generators/geocoder/config/config_generator.rb
33
34
  - lib/generators/geocoder/config/templates/initializer.rb
34
35
  - lib/generators/geocoder/maxmind/geolite_city_generator.rb
@@ -48,6 +49,7 @@ files:
48
49
  - lib/geocoder/kernel_logger.rb
49
50
  - lib/geocoder/logger.rb
50
51
  - lib/geocoder/lookup.rb
52
+ - lib/geocoder/lookups/abstract_api.rb
51
53
  - lib/geocoder/lookups/amap.rb
52
54
  - lib/geocoder/lookups/baidu.rb
53
55
  - lib/geocoder/lookups/baidu_ip.rb
@@ -59,7 +61,6 @@ files:
59
61
  - lib/geocoder/lookups/esri.rb
60
62
  - lib/geocoder/lookups/freegeoip.rb
61
63
  - lib/geocoder/lookups/geocoder_ca.rb
62
- - lib/geocoder/lookups/geocoder_us.rb
63
64
  - lib/geocoder/lookups/geocodio.rb
64
65
  - lib/geocoder/lookups/geoip2.rb
65
66
  - lib/geocoder/lookups/geoportail_lu.rb
@@ -71,6 +72,7 @@ files:
71
72
  - lib/geocoder/lookups/ip2location.rb
72
73
  - lib/geocoder/lookups/ipapi_com.rb
73
74
  - lib/geocoder/lookups/ipdata_co.rb
75
+ - lib/geocoder/lookups/ipgeolocation.rb
74
76
  - lib/geocoder/lookups/ipinfo_io.rb
75
77
  - lib/geocoder/lookups/ipregistry.rb
76
78
  - lib/geocoder/lookups/ipstack.rb
@@ -81,8 +83,10 @@ files:
81
83
  - lib/geocoder/lookups/maxmind.rb
82
84
  - lib/geocoder/lookups/maxmind_geoip2.rb
83
85
  - lib/geocoder/lookups/maxmind_local.rb
86
+ - lib/geocoder/lookups/nationaal_georegister_nl.rb
84
87
  - lib/geocoder/lookups/nominatim.rb
85
88
  - lib/geocoder/lookups/opencagedata.rb
89
+ - lib/geocoder/lookups/osmnames.rb
86
90
  - lib/geocoder/lookups/pelias.rb
87
91
  - lib/geocoder/lookups/pickpoint.rb
88
92
  - lib/geocoder/lookups/pointpin.rb
@@ -92,6 +96,7 @@ files:
92
96
  - lib/geocoder/lookups/telize.rb
93
97
  - lib/geocoder/lookups/tencent.rb
94
98
  - lib/geocoder/lookups/test.rb
99
+ - lib/geocoder/lookups/uk_ordnance_survey_names.rb
95
100
  - lib/geocoder/lookups/yandex.rb
96
101
  - lib/geocoder/models/active_record.rb
97
102
  - lib/geocoder/models/base.rb
@@ -101,6 +106,7 @@ files:
101
106
  - lib/geocoder/query.rb
102
107
  - lib/geocoder/railtie.rb
103
108
  - lib/geocoder/request.rb
109
+ - lib/geocoder/results/abstract_api.rb
104
110
  - lib/geocoder/results/amap.rb
105
111
  - lib/geocoder/results/baidu.rb
106
112
  - lib/geocoder/results/baidu_ip.rb
@@ -112,7 +118,6 @@ files:
112
118
  - lib/geocoder/results/esri.rb
113
119
  - lib/geocoder/results/freegeoip.rb
114
120
  - lib/geocoder/results/geocoder_ca.rb
115
- - lib/geocoder/results/geocoder_us.rb
116
121
  - lib/geocoder/results/geocodio.rb
117
122
  - lib/geocoder/results/geoip2.rb
118
123
  - lib/geocoder/results/geoportail_lu.rb
@@ -124,6 +129,7 @@ files:
124
129
  - lib/geocoder/results/ip2location.rb
125
130
  - lib/geocoder/results/ipapi_com.rb
126
131
  - lib/geocoder/results/ipdata_co.rb
132
+ - lib/geocoder/results/ipgeolocation.rb
127
133
  - lib/geocoder/results/ipinfo_io.rb
128
134
  - lib/geocoder/results/ipregistry.rb
129
135
  - lib/geocoder/results/ipstack.rb
@@ -134,8 +140,10 @@ files:
134
140
  - lib/geocoder/results/maxmind.rb
135
141
  - lib/geocoder/results/maxmind_geoip2.rb
136
142
  - lib/geocoder/results/maxmind_local.rb
143
+ - lib/geocoder/results/nationaal_georegister_nl.rb
137
144
  - lib/geocoder/results/nominatim.rb
138
145
  - lib/geocoder/results/opencagedata.rb
146
+ - lib/geocoder/results/osmnames.rb
139
147
  - lib/geocoder/results/pelias.rb
140
148
  - lib/geocoder/results/pickpoint.rb
141
149
  - lib/geocoder/results/pointpin.rb
@@ -145,6 +153,7 @@ files:
145
153
  - lib/geocoder/results/telize.rb
146
154
  - lib/geocoder/results/tencent.rb
147
155
  - lib/geocoder/results/test.rb
156
+ - lib/geocoder/results/uk_ordnance_survey_names.rb
148
157
  - lib/geocoder/results/yandex.rb
149
158
  - lib/geocoder/sql.rb
150
159
  - lib/geocoder/stores/active_record.rb
@@ -152,8 +161,8 @@ files:
152
161
  - lib/geocoder/stores/mongo_base.rb
153
162
  - lib/geocoder/stores/mongo_mapper.rb
154
163
  - lib/geocoder/stores/mongoid.rb
164
+ - lib/geocoder/util.rb
155
165
  - lib/geocoder/version.rb
156
- - lib/hash_recursive_merge.rb
157
166
  - lib/maxmind_database.rb
158
167
  - lib/tasks/geocoder.rake
159
168
  - lib/tasks/maxmind.rake
@@ -178,8 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
187
  - !ruby/object:Gem::Version
179
188
  version: '0'
180
189
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.7.6
190
+ rubygems_version: 3.1.2
183
191
  signing_key:
184
192
  specification_version: 4
185
193
  summary: Complete geocoding solution for Ruby.
@@ -1,51 +0,0 @@
1
- require 'geocoder/lookups/base'
2
- require "geocoder/results/geocoder_us"
3
-
4
- module Geocoder::Lookup
5
- class GeocoderUs < Base
6
-
7
- def name
8
- "Geocoder.us"
9
- end
10
-
11
- def supported_protocols
12
- [:http]
13
- end
14
-
15
- private # ----------------------------------------------------------------
16
-
17
- def base_query_url(query)
18
- base_query_url_with_optional_key(configuration.api_key)
19
- end
20
-
21
- def cache_key(query)
22
- base_query_url_with_optional_key(nil) + url_query_string(query)
23
- end
24
-
25
- def base_query_url_with_optional_key(key = nil)
26
- base = "#{protocol}://"
27
- if configuration.api_key
28
- base << "#{configuration.api_key}@"
29
- end
30
- base + "geocoder.us/member/service/csv/geocode?"
31
- end
32
-
33
- def results(query)
34
- return [] unless doc = fetch_data(query)
35
- if doc[0].to_s =~ /^(\d+)\:/
36
- return []
37
- else
38
- return [doc.size == 5 ? ((doc[0..1] << nil) + doc[2..4]) : doc]
39
- end
40
- end
41
-
42
- def query_url_params(query)
43
- (query.text =~ /^\d{5}(?:-\d{4})?$/ ? {:zip => query} : {:address => query.sanitized_text}).merge(super)
44
- end
45
-
46
- def parse_raw_data(raw_data)
47
- raw_data.chomp.split(',')
48
- end
49
- end
50
- end
51
-
@@ -1,39 +0,0 @@
1
- require 'geocoder/results/base'
2
-
3
- module Geocoder::Result
4
- class GeocoderUs < Base
5
- def coordinates
6
- [@data[0].to_f, @data[1].to_f]
7
- end
8
-
9
- def address(format = :full)
10
- "#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
11
- end
12
-
13
- def street_address
14
- @data[2]
15
- end
16
-
17
- def city
18
- @data[3]
19
- end
20
-
21
- def state
22
- @data[4]
23
- end
24
-
25
- alias_method :state_code, :state
26
-
27
- def postal_code
28
- @data[5]
29
- end
30
-
31
- def country
32
- 'United States'
33
- end
34
-
35
- def country_code
36
- 'US'
37
- end
38
- end
39
- end
@@ -1,74 +0,0 @@
1
- #
2
- # = Hash Recursive Merge
3
- #
4
- # Merges a Ruby Hash recursively, Also known as deep merge.
5
- # Recursive version of Hash#merge and Hash#merge!.
6
- #
7
- # Category:: Ruby
8
- # Package:: Hash
9
- # Author:: Simone Carletti <weppos@weppos.net>
10
- # Copyright:: 2007-2008 The Authors
11
- # License:: MIT License
12
- # Link:: http://www.simonecarletti.com/
13
- # Source:: http://gist.github.com/gists/6391/
14
- #
15
- module HashRecursiveMerge
16
-
17
- #
18
- # Recursive version of Hash#merge!
19
- #
20
- # Adds the contents of +other_hash+ to +hsh+,
21
- # merging entries in +hsh+ with duplicate keys with those from +other_hash+.
22
- #
23
- # Compared with Hash#merge!, this method supports nested hashes.
24
- # When both +hsh+ and +other_hash+ contains an entry with the same key,
25
- # it merges and returns the values from both arrays.
26
- #
27
- # h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
28
- # h2 = {"b" => 254, "c" => {"c1" => 16, "c3" => 94}}
29
- # h1.rmerge!(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
30
- #
31
- # Simply using Hash#merge! would return
32
- #
33
- # h1.merge!(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
34
- #
35
- def rmerge!(other_hash)
36
- merge!(other_hash) do |key, oldval, newval|
37
- oldval.class == self.class ? oldval.rmerge!(newval) : newval
38
- end
39
- end
40
-
41
- #
42
- # Recursive version of Hash#merge
43
- #
44
- # Compared with Hash#merge!, this method supports nested hashes.
45
- # When both +hsh+ and +other_hash+ contains an entry with the same key,
46
- # it merges and returns the values from both arrays.
47
- #
48
- # Compared with Hash#merge, this method provides a different approch
49
- # for merging nasted hashes.
50
- # If the value of a given key is an Hash and both +other_hash+ abd +hsh
51
- # includes the same key, the value is merged instead replaced with
52
- # +other_hash+ value.
53
- #
54
- # h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
55
- # h2 = {"b" => 254, "c" => {"c1" => 16, "c3" => 94}}
56
- # h1.rmerge(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
57
- #
58
- # Simply using Hash#merge would return
59
- #
60
- # h1.merge(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
61
- #
62
- def rmerge(other_hash)
63
- r = {}
64
- merge(other_hash) do |key, oldval, newval|
65
- r[key] = oldval.class == self.class ? oldval.rmerge(newval) : newval
66
- end
67
- end
68
-
69
- end
70
-
71
-
72
- class Hash
73
- include HashRecursiveMerge
74
- end