geocoder 1.5.0 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +29 -2
  3. data/LICENSE +1 -1
  4. data/README.md +15 -17
  5. data/bin/console +7 -0
  6. data/examples/autoexpire_cache_redis.rb +2 -0
  7. data/lib/easting_northing.rb +171 -0
  8. data/lib/geocoder/calculations.rb +1 -1
  9. data/lib/geocoder/ip_address.rb +13 -0
  10. data/lib/geocoder/lookup.rb +8 -4
  11. data/lib/geocoder/lookups/baidu_ip.rb +1 -1
  12. data/lib/geocoder/lookups/ban_data_gouv_fr.rb +13 -0
  13. data/lib/geocoder/lookups/base.rb +7 -2
  14. data/lib/geocoder/lookups/bing.rb +2 -1
  15. data/lib/geocoder/lookups/esri.rb +38 -13
  16. data/lib/geocoder/lookups/freegeoip.rb +7 -7
  17. data/lib/geocoder/lookups/here.rb +28 -22
  18. data/lib/geocoder/lookups/ip2location.rb +7 -14
  19. data/lib/geocoder/lookups/ipapi_com.rb +2 -1
  20. data/lib/geocoder/lookups/ipdata_co.rb +5 -4
  21. data/lib/geocoder/lookups/ipgeolocation.rb +51 -0
  22. data/lib/geocoder/lookups/ipinfo_io.rb +2 -11
  23. data/lib/geocoder/lookups/ipregistry.rb +68 -0
  24. data/lib/geocoder/lookups/ipstack.rb +2 -2
  25. data/lib/geocoder/lookups/maxmind.rb +2 -2
  26. data/lib/geocoder/lookups/maxmind_geoip2.rb +4 -7
  27. data/lib/geocoder/lookups/nationaal_georegister_nl.rb +38 -0
  28. data/lib/geocoder/lookups/osmnames.rb +57 -0
  29. data/lib/geocoder/lookups/pelias.rb +2 -3
  30. data/lib/geocoder/lookups/pickpoint.rb +1 -1
  31. data/lib/geocoder/lookups/pointpin.rb +3 -3
  32. data/lib/geocoder/lookups/smarty_streets.rb +13 -3
  33. data/lib/geocoder/lookups/telize.rb +2 -2
  34. data/lib/geocoder/lookups/tencent.rb +59 -0
  35. data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +59 -0
  36. data/lib/geocoder/lookups/yandex.rb +2 -2
  37. data/lib/geocoder/query.rb +14 -0
  38. data/lib/geocoder/railtie.rb +1 -1
  39. data/lib/geocoder/results/baidu.rb +0 -4
  40. data/lib/geocoder/results/ban_data_gouv_fr.rb +1 -1
  41. data/lib/geocoder/results/here.rb +4 -1
  42. data/lib/geocoder/results/ipgeolocation.rb +59 -0
  43. data/lib/geocoder/results/ipregistry.rb +308 -0
  44. data/lib/geocoder/results/nationaal_georegister_nl.rb +62 -0
  45. data/lib/geocoder/results/osmnames.rb +56 -0
  46. data/lib/geocoder/results/smarty_streets.rb +48 -18
  47. data/lib/geocoder/results/tencent.rb +72 -0
  48. data/lib/geocoder/results/uk_ordnance_survey_names.rb +59 -0
  49. data/lib/geocoder/results/yandex.rb +217 -59
  50. data/lib/geocoder/sql.rb +4 -4
  51. data/lib/geocoder/stores/active_record.rb +1 -1
  52. data/lib/geocoder/version.rb +1 -1
  53. data/lib/hash_recursive_merge.rb +1 -2
  54. data/lib/maxmind_database.rb +3 -3
  55. metadata +18 -13
  56. data/lib/geocoder/lookups/geocoder_us.rb +0 -51
  57. data/lib/geocoder/lookups/mapzen.rb +0 -15
  58. data/lib/geocoder/results/geocoder_us.rb +0 -39
  59. data/lib/geocoder/results/mapzen.rb +0 -5
@@ -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
 
@@ -60,7 +60,7 @@ module Geocoder::Store
60
60
  # corner followed by the northeast corner of the box
61
61
  # (<tt>[[sw_lat, sw_lon], [ne_lat, ne_lon]]</tt>).
62
62
  #
63
- scope :within_bounding_box, lambda{ |bounds|
63
+ scope :within_bounding_box, lambda{ |*bounds|
64
64
  sw_lat, sw_lng, ne_lat, ne_lng = bounds.flatten if bounds
65
65
  if sw_lat && sw_lng && ne_lat && ne_lng
66
66
  where(Geocoder::Sql.within_bounding_box(
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.2"
3
3
  end
@@ -60,9 +60,8 @@ module HashRecursiveMerge
60
60
  # h1.merge(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
61
61
  #
62
62
  def rmerge(other_hash)
63
- r = {}
64
63
  merge(other_hash) do |key, oldval, newval|
65
- r[key] = oldval.class == self.class ? oldval.rmerge(newval) : newval
64
+ oldval.class == self.class ? oldval.rmerge(newval) : newval
66
65
  end
67
66
  end
68
67
 
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides object geocoding (by street or IP address), reverse geocoding
14
14
  (coordinates to street address), distance queries for ActiveRecord and Mongoid,
@@ -24,11 +24,13 @@ files:
24
24
  - CHANGELOG.md
25
25
  - LICENSE
26
26
  - README.md
27
+ - bin/console
27
28
  - bin/geocode
28
29
  - examples/autoexpire_cache_dalli.rb
29
30
  - examples/autoexpire_cache_redis.rb
30
31
  - examples/cache_bypass.rb
31
32
  - examples/reverse_geocode_job.rb
33
+ - lib/easting_northing.rb
32
34
  - lib/generators/geocoder/config/config_generator.rb
33
35
  - lib/generators/geocoder/config/templates/initializer.rb
34
36
  - lib/generators/geocoder/maxmind/geolite_city_generator.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,18 +72,21 @@ 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
77
+ - lib/geocoder/lookups/ipregistry.rb
75
78
  - lib/geocoder/lookups/ipstack.rb
76
79
  - lib/geocoder/lookups/latlon.rb
77
80
  - lib/geocoder/lookups/location_iq.rb
78
81
  - lib/geocoder/lookups/mapbox.rb
79
82
  - lib/geocoder/lookups/mapquest.rb
80
- - lib/geocoder/lookups/mapzen.rb
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
@@ -90,7 +94,9 @@ files:
90
94
  - lib/geocoder/lookups/postcodes_io.rb
91
95
  - lib/geocoder/lookups/smarty_streets.rb
92
96
  - lib/geocoder/lookups/telize.rb
97
+ - lib/geocoder/lookups/tencent.rb
93
98
  - lib/geocoder/lookups/test.rb
99
+ - lib/geocoder/lookups/uk_ordnance_survey_names.rb
94
100
  - lib/geocoder/lookups/yandex.rb
95
101
  - lib/geocoder/models/active_record.rb
96
102
  - lib/geocoder/models/base.rb
@@ -111,7 +117,6 @@ files:
111
117
  - lib/geocoder/results/esri.rb
112
118
  - lib/geocoder/results/freegeoip.rb
113
119
  - lib/geocoder/results/geocoder_ca.rb
114
- - lib/geocoder/results/geocoder_us.rb
115
120
  - lib/geocoder/results/geocodio.rb
116
121
  - lib/geocoder/results/geoip2.rb
117
122
  - lib/geocoder/results/geoportail_lu.rb
@@ -123,18 +128,21 @@ files:
123
128
  - lib/geocoder/results/ip2location.rb
124
129
  - lib/geocoder/results/ipapi_com.rb
125
130
  - lib/geocoder/results/ipdata_co.rb
131
+ - lib/geocoder/results/ipgeolocation.rb
126
132
  - lib/geocoder/results/ipinfo_io.rb
133
+ - lib/geocoder/results/ipregistry.rb
127
134
  - lib/geocoder/results/ipstack.rb
128
135
  - lib/geocoder/results/latlon.rb
129
136
  - lib/geocoder/results/location_iq.rb
130
137
  - lib/geocoder/results/mapbox.rb
131
138
  - lib/geocoder/results/mapquest.rb
132
- - lib/geocoder/results/mapzen.rb
133
139
  - lib/geocoder/results/maxmind.rb
134
140
  - lib/geocoder/results/maxmind_geoip2.rb
135
141
  - lib/geocoder/results/maxmind_local.rb
142
+ - lib/geocoder/results/nationaal_georegister_nl.rb
136
143
  - lib/geocoder/results/nominatim.rb
137
144
  - lib/geocoder/results/opencagedata.rb
145
+ - lib/geocoder/results/osmnames.rb
138
146
  - lib/geocoder/results/pelias.rb
139
147
  - lib/geocoder/results/pickpoint.rb
140
148
  - lib/geocoder/results/pointpin.rb
@@ -142,7 +150,9 @@ files:
142
150
  - lib/geocoder/results/postcodes_io.rb
143
151
  - lib/geocoder/results/smarty_streets.rb
144
152
  - lib/geocoder/results/telize.rb
153
+ - lib/geocoder/results/tencent.rb
145
154
  - lib/geocoder/results/test.rb
155
+ - lib/geocoder/results/uk_ordnance_survey_names.rb
146
156
  - lib/geocoder/results/yandex.rb
147
157
  - lib/geocoder/sql.rb
148
158
  - lib/geocoder/stores/active_record.rb
@@ -161,11 +171,7 @@ licenses:
161
171
  metadata:
162
172
  source_code_uri: https://github.com/alexreisner/geocoder
163
173
  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
-
174
+ post_install_message:
169
175
  rdoc_options: []
170
176
  require_paths:
171
177
  - lib
@@ -180,8 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
186
  - !ruby/object:Gem::Version
181
187
  version: '0'
182
188
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.5.2
189
+ rubygems_version: 3.0.1
185
190
  signing_key:
186
191
  specification_version: 4
187
192
  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,15 +0,0 @@
1
- require 'geocoder/lookups/pelias'
2
- require 'geocoder/results/mapzen'
3
-
4
- # https://mapzen.com/documentation/search/search/ for more information
5
- module Geocoder::Lookup
6
- class Mapzen < Pelias
7
- def name
8
- 'Mapzen'
9
- end
10
-
11
- def endpoint
12
- configuration[:endpoint] || 'search.mapzen.com'
13
- end
14
- end
15
- end
@@ -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,5 +0,0 @@
1
- require 'geocoder/results/pelias'
2
-
3
- module Geocoder::Result
4
- class Mapzen < Pelias; end
5
- end