geocoder 1.4.3 → 1.6.1
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +64 -0
- data/LICENSE +1 -1
- data/README.md +365 -883
- data/examples/autoexpire_cache_redis.rb +5 -3
- data/lib/generators/geocoder/config/templates/initializer.rb +3 -2
- data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +2 -0
- data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +2 -0
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +1 -1
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb +1 -1
- data/lib/generators/geocoder/migration_version.rb +15 -0
- data/lib/geocoder/cache.rb +6 -2
- data/lib/geocoder/calculations.rb +1 -1
- data/lib/geocoder/cli.rb +2 -2
- data/lib/geocoder/configuration.rb +2 -2
- data/lib/geocoder/exceptions.rb +1 -1
- data/lib/geocoder/ip_address.rb +14 -1
- data/lib/geocoder/lookup.rb +13 -6
- data/lib/geocoder/lookups/amap.rb +63 -0
- data/lib/geocoder/lookups/baidu.rb +14 -10
- data/lib/geocoder/lookups/baidu_ip.rb +7 -36
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +17 -4
- data/lib/geocoder/lookups/base.rb +28 -5
- data/lib/geocoder/lookups/bing.rb +15 -13
- data/lib/geocoder/lookups/db_ip_com.rb +52 -0
- data/lib/geocoder/lookups/dstk.rb +4 -2
- data/lib/geocoder/lookups/esri.rb +39 -29
- data/lib/geocoder/lookups/freegeoip.rb +16 -7
- data/lib/geocoder/lookups/geocoder_ca.rb +4 -4
- data/lib/geocoder/lookups/geocodio.rb +5 -5
- data/lib/geocoder/lookups/geoportail_lu.rb +7 -7
- data/lib/geocoder/lookups/google.rb +13 -9
- data/lib/geocoder/lookups/google_places_details.rb +4 -4
- data/lib/geocoder/lookups/google_places_search.rb +4 -4
- data/lib/geocoder/lookups/google_premier.rb +11 -1
- data/lib/geocoder/lookups/here.rb +29 -23
- data/lib/geocoder/lookups/ip2location.rb +67 -0
- data/lib/geocoder/lookups/ipapi_com.rb +9 -13
- data/lib/geocoder/lookups/ipdata_co.rb +62 -0
- data/lib/geocoder/lookups/ipgeolocation.rb +51 -0
- data/lib/geocoder/lookups/ipinfo_io.rb +11 -29
- data/lib/geocoder/lookups/ipregistry.rb +68 -0
- data/lib/geocoder/lookups/ipstack.rb +63 -0
- data/lib/geocoder/lookups/latlon.rb +4 -4
- data/lib/geocoder/lookups/location_iq.rb +26 -8
- data/lib/geocoder/lookups/mapbox.rb +12 -6
- data/lib/geocoder/lookups/mapquest.rb +4 -5
- data/lib/geocoder/lookups/maxmind.rb +6 -6
- data/lib/geocoder/lookups/maxmind_geoip2.rb +8 -7
- data/lib/geocoder/lookups/nominatim.rb +17 -5
- data/lib/geocoder/lookups/opencagedata.rb +7 -6
- data/lib/geocoder/lookups/osmnames.rb +57 -0
- data/lib/geocoder/lookups/pelias.rb +8 -9
- data/lib/geocoder/lookups/pickpoint.rb +41 -0
- data/lib/geocoder/lookups/pointpin.rb +10 -9
- data/lib/geocoder/lookups/postcode_anywhere_uk.rb +4 -5
- data/lib/geocoder/lookups/postcodes_io.rb +31 -0
- data/lib/geocoder/lookups/smarty_streets.rb +20 -10
- data/lib/geocoder/lookups/telize.rb +26 -6
- data/lib/geocoder/lookups/tencent.rb +59 -0
- data/lib/geocoder/lookups/yandex.rb +12 -8
- data/lib/geocoder/models/active_record.rb +4 -3
- data/lib/geocoder/query.rb +14 -0
- data/lib/geocoder/railtie.rb +1 -1
- data/lib/geocoder/request.rb +32 -0
- data/lib/geocoder/results/amap.rb +87 -0
- data/lib/geocoder/results/baidu.rb +10 -14
- data/lib/geocoder/results/ban_data_gouv_fr.rb +1 -1
- data/lib/geocoder/results/base.rb +13 -1
- data/lib/geocoder/results/bing.rb +1 -1
- data/lib/geocoder/results/db_ip_com.rb +58 -0
- data/lib/geocoder/results/freegeoip.rb +0 -5
- data/lib/geocoder/results/geocoder_ca.rb +3 -3
- data/lib/geocoder/results/geoip2.rb +24 -10
- data/lib/geocoder/results/geoportail_lu.rb +5 -3
- data/lib/geocoder/results/google.rb +16 -5
- data/lib/geocoder/results/here.rb +12 -1
- data/lib/geocoder/results/ip2location.rb +22 -0
- data/lib/geocoder/results/ipdata_co.rb +40 -0
- data/lib/geocoder/results/ipgeolocation.rb +59 -0
- data/lib/geocoder/results/ipregistry.rb +308 -0
- data/lib/geocoder/results/ipstack.rb +60 -0
- data/lib/geocoder/results/maxmind.rb +0 -5
- data/lib/geocoder/results/maxmind_local.rb +0 -5
- data/lib/geocoder/results/nominatim.rb +12 -0
- data/lib/geocoder/results/opencagedata.rb +12 -2
- data/lib/geocoder/results/osmnames.rb +56 -0
- data/lib/geocoder/results/pickpoint.rb +6 -0
- data/lib/geocoder/results/postcodes_io.rb +40 -0
- data/lib/geocoder/results/smarty_streets.rb +55 -19
- data/lib/geocoder/results/telize.rb +0 -5
- data/lib/geocoder/results/tencent.rb +72 -0
- data/lib/geocoder/results/test.rb +1 -1
- data/lib/geocoder/sql.rb +4 -4
- data/lib/geocoder/stores/active_record.rb +16 -5
- data/lib/geocoder/stores/base.rb +1 -2
- data/lib/geocoder/version.rb +1 -1
- data/lib/hash_recursive_merge.rb +1 -2
- data/lib/maxmind_database.rb +3 -3
- data/lib/tasks/geocoder.rake +11 -3
- metadata +30 -14
- data/lib/geocoder/lookups/geocoder_us.rb +0 -43
- data/lib/geocoder/lookups/mapzen.rb +0 -15
- data/lib/geocoder/lookups/okf.rb +0 -44
- data/lib/geocoder/lookups/ovi.rb +0 -62
- data/lib/geocoder/results/geocoder_us.rb +0 -39
- data/lib/geocoder/results/mapzen.rb +0 -5
- data/lib/geocoder/results/okf.rb +0 -106
- data/lib/geocoder/results/ovi.rb +0 -71
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class PostcodesIo < Base
|
|
5
|
+
|
|
6
|
+
def coordinates
|
|
7
|
+
[@data['latitude'].to_f, @data['longitude'].to_f]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def quality
|
|
11
|
+
@data['quality']
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def postal_code
|
|
15
|
+
@data['postcode']
|
|
16
|
+
end
|
|
17
|
+
alias address postal_code
|
|
18
|
+
|
|
19
|
+
def city
|
|
20
|
+
@data['admin_ward']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def county
|
|
24
|
+
@data['admin_county']
|
|
25
|
+
end
|
|
26
|
+
alias state county
|
|
27
|
+
|
|
28
|
+
def state_code
|
|
29
|
+
@data['codes']['admin_county']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def country
|
|
33
|
+
'United Kingdom'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def country_code
|
|
37
|
+
'UK'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -3,57 +3,89 @@ require 'geocoder/lookups/base'
|
|
|
3
3
|
module Geocoder::Result
|
|
4
4
|
class SmartyStreets < Base
|
|
5
5
|
def coordinates
|
|
6
|
-
%w(latitude longitude).map do |i|
|
|
6
|
+
result = %w(latitude longitude).map do |i|
|
|
7
7
|
zipcode_endpoint? ? zipcodes.first[i] : metadata[i]
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
if result.compact.empty?
|
|
11
|
+
nil
|
|
12
|
+
else
|
|
13
|
+
result
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
def address
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
parts =
|
|
19
|
+
if international_endpoint?
|
|
20
|
+
(1..12).map { |i| @data["address#{i}"] }
|
|
21
|
+
else
|
|
22
|
+
[
|
|
23
|
+
delivery_line_1,
|
|
24
|
+
delivery_line_2,
|
|
25
|
+
last_line
|
|
26
|
+
]
|
|
27
|
+
end
|
|
28
|
+
parts.select{ |i| i.to_s != "" }.join(" ")
|
|
17
29
|
end
|
|
18
30
|
|
|
19
31
|
def state
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
if international_endpoint?
|
|
33
|
+
components['administrative_area']
|
|
34
|
+
elsif zipcode_endpoint?
|
|
35
|
+
city_states.first['state']
|
|
36
|
+
else
|
|
22
37
|
components['state_abbreviation']
|
|
38
|
+
end
|
|
23
39
|
end
|
|
24
40
|
|
|
25
41
|
def state_code
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
if international_endpoint?
|
|
43
|
+
components['administrative_area']
|
|
44
|
+
elsif zipcode_endpoint?
|
|
45
|
+
city_states.first['state_abbreviation']
|
|
46
|
+
else
|
|
28
47
|
components['state_abbreviation']
|
|
48
|
+
end
|
|
29
49
|
end
|
|
30
50
|
|
|
31
51
|
def country
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
international_endpoint? ?
|
|
53
|
+
components['country_iso_3'] :
|
|
54
|
+
"United States"
|
|
34
55
|
end
|
|
35
56
|
|
|
36
57
|
def country_code
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
international_endpoint? ?
|
|
59
|
+
components['country_iso_3'] :
|
|
60
|
+
"US"
|
|
39
61
|
end
|
|
40
62
|
|
|
41
63
|
## Extra methods not in base.rb ------------------------
|
|
42
64
|
|
|
43
65
|
def street
|
|
44
|
-
|
|
66
|
+
international_endpoint? ?
|
|
67
|
+
components['thoroughfare_name'] :
|
|
68
|
+
components['street_name']
|
|
45
69
|
end
|
|
46
70
|
|
|
47
71
|
def city
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
if international_endpoint?
|
|
73
|
+
components['locality']
|
|
74
|
+
elsif zipcode_endpoint?
|
|
75
|
+
city_states.first['city']
|
|
76
|
+
else
|
|
50
77
|
components['city_name']
|
|
78
|
+
end
|
|
51
79
|
end
|
|
52
80
|
|
|
53
81
|
def zipcode
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
if international_endpoint?
|
|
83
|
+
components['postal_code']
|
|
84
|
+
elsif zipcode_endpoint?
|
|
85
|
+
zipcodes.first['zipcode']
|
|
86
|
+
else
|
|
56
87
|
components['zipcode']
|
|
88
|
+
end
|
|
57
89
|
end
|
|
58
90
|
alias_method :postal_code, :zipcode
|
|
59
91
|
|
|
@@ -72,6 +104,10 @@ module Geocoder::Result
|
|
|
72
104
|
zipcodes.any?
|
|
73
105
|
end
|
|
74
106
|
|
|
107
|
+
def international_endpoint?
|
|
108
|
+
!@data['address1'].nil?
|
|
109
|
+
end
|
|
110
|
+
|
|
75
111
|
[
|
|
76
112
|
:delivery_line_1,
|
|
77
113
|
:delivery_line_2,
|
|
@@ -3,11 +3,6 @@ require 'geocoder/results/base'
|
|
|
3
3
|
module Geocoder::Result
|
|
4
4
|
class Telize < Base
|
|
5
5
|
|
|
6
|
-
def address(format = :full)
|
|
7
|
-
s = state_code.to_s == "" ? "" : ", #{state_code}"
|
|
8
|
-
"#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def city
|
|
12
7
|
@data['city']
|
|
13
8
|
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Tencent < Base
|
|
5
|
+
|
|
6
|
+
def coordinates
|
|
7
|
+
['lat', 'lng'].map{ |i| @data['location'][i] }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def address
|
|
11
|
+
"#{province}#{city}#{district}#{street}#{street_number}"
|
|
12
|
+
|
|
13
|
+
#@data['title'] or @data['address']
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# NOTE: The Tencent reverse geocoding API has the field named
|
|
17
|
+
# 'address_component' compared to 'address_components' in the
|
|
18
|
+
# regular geocoding API.
|
|
19
|
+
def province
|
|
20
|
+
@data['address_components'] and (@data['address_components']['province']) or
|
|
21
|
+
(@data['address_component'] and @data['address_component']['province']) or
|
|
22
|
+
""
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
alias_method :state, :province
|
|
26
|
+
|
|
27
|
+
def city
|
|
28
|
+
@data['address_components'] and (@data['address_components']['city']) or
|
|
29
|
+
(@data['address_component'] and @data['address_component']['city']) or
|
|
30
|
+
""
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def district
|
|
34
|
+
@data['address_components'] and (@data['address_components']['district']) or
|
|
35
|
+
(@data['address_component'] and @data['address_component']['district']) or
|
|
36
|
+
""
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def street
|
|
40
|
+
@data['address_components'] and (@data['address_components']['street']) or
|
|
41
|
+
(@data['address_component'] and @data['address_component']['street']) or
|
|
42
|
+
""
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def street_number
|
|
46
|
+
@data['address_components'] and (@data['address_components']['street_number']) or
|
|
47
|
+
(@data['address_component'] and @data['address_component']['street_number']) or
|
|
48
|
+
""
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def address_components
|
|
52
|
+
@data['address_components'] or @data['address_component']
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def state_code
|
|
56
|
+
""
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def postal_code
|
|
60
|
+
""
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def country
|
|
64
|
+
"China"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def country_code
|
|
68
|
+
"CN"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -15,7 +15,7 @@ module Geocoder
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
%w[
|
|
18
|
+
%w[coordinates neighborhood city state state_code sub_state
|
|
19
19
|
sub_state_code province province_code postal_code country
|
|
20
20
|
country_code address street_address street_number route geometry].each do |attr|
|
|
21
21
|
add_result_attribute(attr)
|
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
|
|
|
@@ -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{
|
|
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(
|
|
@@ -87,8 +87,6 @@ module Geocoder::Store
|
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
private # ----------------------------------------------------------------
|
|
91
|
-
|
|
92
90
|
##
|
|
93
91
|
# Get options hash suitable for passing to ActiveRecord.find to get
|
|
94
92
|
# records within a radius (in kilometers) of the given point.
|
|
@@ -131,7 +129,11 @@ module Geocoder::Store
|
|
|
131
129
|
distance_column = options.fetch(:distance_column) { 'distance' }
|
|
132
130
|
bearing_column = options.fetch(:bearing_column) { 'bearing' }
|
|
133
131
|
|
|
134
|
-
|
|
132
|
+
# If radius is a DB column name, bounding box should include
|
|
133
|
+
# all rows within the maximum radius appearing in that column.
|
|
134
|
+
# Note: performance is dependent on variability of radii.
|
|
135
|
+
bb_radius = radius.is_a?(Symbol) ? maximum(radius) : radius
|
|
136
|
+
b = Geocoder::Calculations.bounding_box([latitude, longitude], bb_radius, options)
|
|
135
137
|
args = b + [
|
|
136
138
|
full_column_name(latitude_attribute),
|
|
137
139
|
full_column_name(longitude_attribute)
|
|
@@ -142,7 +144,16 @@ module Geocoder::Store
|
|
|
142
144
|
conditions = bounding_box_conditions
|
|
143
145
|
else
|
|
144
146
|
min_radius = options.fetch(:min_radius, 0).to_f
|
|
145
|
-
|
|
147
|
+
# if radius is a DB column name,
|
|
148
|
+
# find rows between min_radius and value in column
|
|
149
|
+
if radius.is_a?(Symbol)
|
|
150
|
+
c = "BETWEEN ? AND #{radius}"
|
|
151
|
+
a = [min_radius]
|
|
152
|
+
else
|
|
153
|
+
c = "BETWEEN ? AND ?"
|
|
154
|
+
a = [min_radius, radius]
|
|
155
|
+
end
|
|
156
|
+
conditions = [bounding_box_conditions + " AND (#{distance}) " + c] + a
|
|
146
157
|
end
|
|
147
158
|
{
|
|
148
159
|
:select => select_clause(options[:select],
|
data/lib/geocoder/stores/base.rb
CHANGED
|
@@ -90,7 +90,7 @@ module Geocoder
|
|
|
90
90
|
return
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
query_options = [:lookup, :ip_lookup, :language].inject({}) do |hash, key|
|
|
93
|
+
query_options = [:lookup, :ip_lookup, :language, :params].inject({}) do |hash, key|
|
|
94
94
|
if options.has_key?(key)
|
|
95
95
|
val = options[key]
|
|
96
96
|
hash[key] = val.respond_to?(:call) ? val.call(self) : val
|
|
@@ -113,4 +113,3 @@ module Geocoder
|
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
|
-
|
data/lib/geocoder/version.rb
CHANGED
data/lib/hash_recursive_merge.rb
CHANGED
|
@@ -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
|
-
|
|
64
|
+
oldval.class == self.class ? oldval.rmerge(newval) : newval
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
data/lib/maxmind_database.rb
CHANGED
|
@@ -96,9 +96,9 @@ module Geocoder
|
|
|
96
96
|
|
|
97
97
|
def archive_url_path(package)
|
|
98
98
|
{
|
|
99
|
-
geolite_country_csv: "
|
|
100
|
-
geolite_city_csv: "
|
|
101
|
-
geolite_asn_csv: "
|
|
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
|
|
data/lib/tasks/geocoder.rake
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "geocoder/models/mongoid"
|
|
1
|
+
require "geocoder/models/mongoid"
|
|
2
2
|
|
|
3
3
|
namespace :geocode do
|
|
4
4
|
desc "Geocode all objects without coordinates."
|
|
@@ -7,6 +7,7 @@ namespace :geocode do
|
|
|
7
7
|
sleep_timer = ENV['SLEEP'] || ENV['sleep']
|
|
8
8
|
batch = ENV['BATCH'] || ENV['batch']
|
|
9
9
|
reverse = ENV['REVERSE'] || ENV['reverse']
|
|
10
|
+
limit = ENV['LIMIT'] || ENV['limit']
|
|
10
11
|
raise "Please specify a CLASS (model)" unless class_name
|
|
11
12
|
klass = class_from_string(class_name)
|
|
12
13
|
batch = (batch.to_i unless batch.nil?) || 1000
|
|
@@ -20,13 +21,20 @@ namespace :geocode do
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
scope = reverse ? klass.not_reverse_geocoded : klass.not_geocoded
|
|
24
|
+
scope = scope.limit(limit) if limit
|
|
23
25
|
if orm == 'mongoid'
|
|
24
26
|
scope.each do |obj|
|
|
25
27
|
geocode_record.call(obj)
|
|
26
28
|
end
|
|
27
29
|
elsif orm == 'active_record'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
if limit
|
|
31
|
+
scope.each do |obj|
|
|
32
|
+
geocode_record.call(obj)
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
scope.find_each(batch_size: batch) do |obj|
|
|
36
|
+
geocode_record.call(obj)
|
|
37
|
+
end
|
|
30
38
|
end
|
|
31
39
|
end
|
|
32
40
|
|
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.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Reisner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-01-23 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,
|
|
@@ -35,6 +35,7 @@ files:
|
|
|
35
35
|
- lib/generators/geocoder/maxmind/geolite_country_generator.rb
|
|
36
36
|
- lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb
|
|
37
37
|
- lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb
|
|
38
|
+
- lib/generators/geocoder/migration_version.rb
|
|
38
39
|
- lib/geocoder.rb
|
|
39
40
|
- lib/geocoder/cache.rb
|
|
40
41
|
- lib/geocoder/calculations.rb
|
|
@@ -47,16 +48,17 @@ files:
|
|
|
47
48
|
- lib/geocoder/kernel_logger.rb
|
|
48
49
|
- lib/geocoder/logger.rb
|
|
49
50
|
- lib/geocoder/lookup.rb
|
|
51
|
+
- lib/geocoder/lookups/amap.rb
|
|
50
52
|
- lib/geocoder/lookups/baidu.rb
|
|
51
53
|
- lib/geocoder/lookups/baidu_ip.rb
|
|
52
54
|
- lib/geocoder/lookups/ban_data_gouv_fr.rb
|
|
53
55
|
- lib/geocoder/lookups/base.rb
|
|
54
56
|
- lib/geocoder/lookups/bing.rb
|
|
57
|
+
- lib/geocoder/lookups/db_ip_com.rb
|
|
55
58
|
- lib/geocoder/lookups/dstk.rb
|
|
56
59
|
- lib/geocoder/lookups/esri.rb
|
|
57
60
|
- lib/geocoder/lookups/freegeoip.rb
|
|
58
61
|
- lib/geocoder/lookups/geocoder_ca.rb
|
|
59
|
-
- lib/geocoder/lookups/geocoder_us.rb
|
|
60
62
|
- lib/geocoder/lookups/geocodio.rb
|
|
61
63
|
- lib/geocoder/lookups/geoip2.rb
|
|
62
64
|
- lib/geocoder/lookups/geoportail_lu.rb
|
|
@@ -65,25 +67,31 @@ files:
|
|
|
65
67
|
- lib/geocoder/lookups/google_places_search.rb
|
|
66
68
|
- lib/geocoder/lookups/google_premier.rb
|
|
67
69
|
- lib/geocoder/lookups/here.rb
|
|
70
|
+
- lib/geocoder/lookups/ip2location.rb
|
|
68
71
|
- lib/geocoder/lookups/ipapi_com.rb
|
|
72
|
+
- lib/geocoder/lookups/ipdata_co.rb
|
|
73
|
+
- lib/geocoder/lookups/ipgeolocation.rb
|
|
69
74
|
- lib/geocoder/lookups/ipinfo_io.rb
|
|
75
|
+
- lib/geocoder/lookups/ipregistry.rb
|
|
76
|
+
- lib/geocoder/lookups/ipstack.rb
|
|
70
77
|
- lib/geocoder/lookups/latlon.rb
|
|
71
78
|
- lib/geocoder/lookups/location_iq.rb
|
|
72
79
|
- lib/geocoder/lookups/mapbox.rb
|
|
73
80
|
- lib/geocoder/lookups/mapquest.rb
|
|
74
|
-
- lib/geocoder/lookups/mapzen.rb
|
|
75
81
|
- lib/geocoder/lookups/maxmind.rb
|
|
76
82
|
- lib/geocoder/lookups/maxmind_geoip2.rb
|
|
77
83
|
- lib/geocoder/lookups/maxmind_local.rb
|
|
78
84
|
- lib/geocoder/lookups/nominatim.rb
|
|
79
|
-
- lib/geocoder/lookups/okf.rb
|
|
80
85
|
- lib/geocoder/lookups/opencagedata.rb
|
|
81
|
-
- lib/geocoder/lookups/
|
|
86
|
+
- lib/geocoder/lookups/osmnames.rb
|
|
82
87
|
- lib/geocoder/lookups/pelias.rb
|
|
88
|
+
- lib/geocoder/lookups/pickpoint.rb
|
|
83
89
|
- lib/geocoder/lookups/pointpin.rb
|
|
84
90
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
|
91
|
+
- lib/geocoder/lookups/postcodes_io.rb
|
|
85
92
|
- lib/geocoder/lookups/smarty_streets.rb
|
|
86
93
|
- lib/geocoder/lookups/telize.rb
|
|
94
|
+
- lib/geocoder/lookups/tencent.rb
|
|
87
95
|
- lib/geocoder/lookups/test.rb
|
|
88
96
|
- lib/geocoder/lookups/yandex.rb
|
|
89
97
|
- lib/geocoder/models/active_record.rb
|
|
@@ -94,16 +102,17 @@ files:
|
|
|
94
102
|
- lib/geocoder/query.rb
|
|
95
103
|
- lib/geocoder/railtie.rb
|
|
96
104
|
- lib/geocoder/request.rb
|
|
105
|
+
- lib/geocoder/results/amap.rb
|
|
97
106
|
- lib/geocoder/results/baidu.rb
|
|
98
107
|
- lib/geocoder/results/baidu_ip.rb
|
|
99
108
|
- lib/geocoder/results/ban_data_gouv_fr.rb
|
|
100
109
|
- lib/geocoder/results/base.rb
|
|
101
110
|
- lib/geocoder/results/bing.rb
|
|
111
|
+
- lib/geocoder/results/db_ip_com.rb
|
|
102
112
|
- lib/geocoder/results/dstk.rb
|
|
103
113
|
- lib/geocoder/results/esri.rb
|
|
104
114
|
- lib/geocoder/results/freegeoip.rb
|
|
105
115
|
- lib/geocoder/results/geocoder_ca.rb
|
|
106
|
-
- lib/geocoder/results/geocoder_us.rb
|
|
107
116
|
- lib/geocoder/results/geocodio.rb
|
|
108
117
|
- lib/geocoder/results/geoip2.rb
|
|
109
118
|
- lib/geocoder/results/geoportail_lu.rb
|
|
@@ -112,25 +121,31 @@ files:
|
|
|
112
121
|
- lib/geocoder/results/google_places_search.rb
|
|
113
122
|
- lib/geocoder/results/google_premier.rb
|
|
114
123
|
- lib/geocoder/results/here.rb
|
|
124
|
+
- lib/geocoder/results/ip2location.rb
|
|
115
125
|
- lib/geocoder/results/ipapi_com.rb
|
|
126
|
+
- lib/geocoder/results/ipdata_co.rb
|
|
127
|
+
- lib/geocoder/results/ipgeolocation.rb
|
|
116
128
|
- lib/geocoder/results/ipinfo_io.rb
|
|
129
|
+
- lib/geocoder/results/ipregistry.rb
|
|
130
|
+
- lib/geocoder/results/ipstack.rb
|
|
117
131
|
- lib/geocoder/results/latlon.rb
|
|
118
132
|
- lib/geocoder/results/location_iq.rb
|
|
119
133
|
- lib/geocoder/results/mapbox.rb
|
|
120
134
|
- lib/geocoder/results/mapquest.rb
|
|
121
|
-
- lib/geocoder/results/mapzen.rb
|
|
122
135
|
- lib/geocoder/results/maxmind.rb
|
|
123
136
|
- lib/geocoder/results/maxmind_geoip2.rb
|
|
124
137
|
- lib/geocoder/results/maxmind_local.rb
|
|
125
138
|
- lib/geocoder/results/nominatim.rb
|
|
126
|
-
- lib/geocoder/results/okf.rb
|
|
127
139
|
- lib/geocoder/results/opencagedata.rb
|
|
128
|
-
- lib/geocoder/results/
|
|
140
|
+
- lib/geocoder/results/osmnames.rb
|
|
129
141
|
- lib/geocoder/results/pelias.rb
|
|
142
|
+
- lib/geocoder/results/pickpoint.rb
|
|
130
143
|
- lib/geocoder/results/pointpin.rb
|
|
131
144
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
|
145
|
+
- lib/geocoder/results/postcodes_io.rb
|
|
132
146
|
- lib/geocoder/results/smarty_streets.rb
|
|
133
147
|
- lib/geocoder/results/telize.rb
|
|
148
|
+
- lib/geocoder/results/tencent.rb
|
|
134
149
|
- lib/geocoder/results/test.rb
|
|
135
150
|
- lib/geocoder/results/yandex.rb
|
|
136
151
|
- lib/geocoder/sql.rb
|
|
@@ -147,7 +162,9 @@ files:
|
|
|
147
162
|
homepage: http://www.rubygeocoder.com
|
|
148
163
|
licenses:
|
|
149
164
|
- MIT
|
|
150
|
-
metadata:
|
|
165
|
+
metadata:
|
|
166
|
+
source_code_uri: https://github.com/alexreisner/geocoder
|
|
167
|
+
changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
|
|
151
168
|
post_install_message:
|
|
152
169
|
rdoc_options: []
|
|
153
170
|
require_paths:
|
|
@@ -156,15 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
156
173
|
requirements:
|
|
157
174
|
- - ">="
|
|
158
175
|
- !ruby/object:Gem::Version
|
|
159
|
-
version:
|
|
176
|
+
version: 2.0.0
|
|
160
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
178
|
requirements:
|
|
162
179
|
- - ">="
|
|
163
180
|
- !ruby/object:Gem::Version
|
|
164
181
|
version: '0'
|
|
165
182
|
requirements: []
|
|
166
|
-
|
|
167
|
-
rubygems_version: 2.5.1
|
|
183
|
+
rubygems_version: 3.0.1
|
|
168
184
|
signing_key:
|
|
169
185
|
specification_version: 4
|
|
170
186
|
summary: Complete geocoding solution for Ruby.
|