geocoder 1.6.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/LICENSE +1 -1
- data/README.md +328 -231
- data/bin/console +6 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +7 -1
- data/lib/geocoder/cache.rb +16 -33
- data/lib/geocoder/cache_stores/base.rb +40 -0
- data/lib/geocoder/cache_stores/generic.rb +35 -0
- data/lib/geocoder/cache_stores/redis.rb +34 -0
- data/lib/geocoder/configuration.rb +11 -4
- data/lib/geocoder/configuration_hash.rb +4 -4
- data/lib/geocoder/ip_address.rb +8 -1
- data/lib/geocoder/lookup.rb +16 -2
- data/lib/geocoder/lookups/abstract_api.rb +46 -0
- data/lib/geocoder/lookups/amazon_location_service.rb +54 -0
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +1 -1
- data/lib/geocoder/lookups/base.rb +8 -2
- data/lib/geocoder/lookups/bing.rb +1 -1
- data/lib/geocoder/lookups/esri.rb +6 -0
- data/lib/geocoder/lookups/geoapify.rb +72 -0
- data/lib/geocoder/lookups/geocodio.rb +1 -1
- data/lib/geocoder/lookups/geoip2.rb +4 -0
- data/lib/geocoder/lookups/google.rb +7 -2
- data/lib/geocoder/lookups/google_places_details.rb +8 -14
- data/lib/geocoder/lookups/google_places_search.rb +28 -2
- data/lib/geocoder/lookups/google_premier.rb +4 -0
- data/lib/geocoder/lookups/ip2location.rb +10 -6
- data/lib/geocoder/lookups/ipdata_co.rb +1 -1
- data/lib/geocoder/lookups/ipqualityscore.rb +50 -0
- data/lib/geocoder/lookups/latlon.rb +1 -2
- data/lib/geocoder/lookups/maxmind_local.rb +7 -1
- data/lib/geocoder/lookups/melissa_street.rb +41 -0
- data/lib/geocoder/lookups/photon.rb +89 -0
- data/lib/geocoder/lookups/smarty_streets.rb +6 -1
- data/lib/geocoder/lookups/telize.rb +1 -1
- data/lib/geocoder/lookups/test.rb +4 -0
- data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +1 -1
- data/lib/geocoder/lookups/yandex.rb +1 -2
- data/lib/geocoder/results/abstract_api.rb +146 -0
- data/lib/geocoder/results/amazon_location_service.rb +57 -0
- data/lib/geocoder/results/ban_data_gouv_fr.rb +26 -1
- data/lib/geocoder/results/db_ip_com.rb +1 -1
- data/lib/geocoder/results/esri.rb +5 -2
- data/lib/geocoder/results/geoapify.rb +179 -0
- data/lib/geocoder/results/ipqualityscore.rb +54 -0
- data/lib/geocoder/results/ipregistry.rb +4 -8
- data/lib/geocoder/results/mapbox.rb +10 -4
- data/lib/geocoder/results/melissa_street.rb +46 -0
- data/lib/geocoder/results/nationaal_georegister_nl.rb +1 -1
- data/lib/geocoder/results/nominatim.rb +27 -15
- data/lib/geocoder/results/photon.rb +119 -0
- data/lib/geocoder/util.rb +29 -0
- data/lib/geocoder/version.rb +1 -1
- metadata +22 -10
- data/examples/autoexpire_cache_dalli.rb +0 -62
- data/examples/autoexpire_cache_redis.rb +0 -30
- data/lib/hash_recursive_merge.rb +0 -73
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.
|
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:
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
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:
|
@@ -26,8 +25,6 @@ files:
|
|
26
25
|
- README.md
|
27
26
|
- bin/console
|
28
27
|
- bin/geocode
|
29
|
-
- examples/autoexpire_cache_dalli.rb
|
30
|
-
- examples/autoexpire_cache_redis.rb
|
31
28
|
- examples/cache_bypass.rb
|
32
29
|
- examples/reverse_geocode_job.rb
|
33
30
|
- lib/easting_northing.rb
|
@@ -40,6 +37,9 @@ files:
|
|
40
37
|
- lib/generators/geocoder/migration_version.rb
|
41
38
|
- lib/geocoder.rb
|
42
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
|
43
43
|
- lib/geocoder/calculations.rb
|
44
44
|
- lib/geocoder/cli.rb
|
45
45
|
- lib/geocoder/configuration.rb
|
@@ -50,7 +50,9 @@ files:
|
|
50
50
|
- lib/geocoder/kernel_logger.rb
|
51
51
|
- lib/geocoder/logger.rb
|
52
52
|
- lib/geocoder/lookup.rb
|
53
|
+
- lib/geocoder/lookups/abstract_api.rb
|
53
54
|
- lib/geocoder/lookups/amap.rb
|
55
|
+
- lib/geocoder/lookups/amazon_location_service.rb
|
54
56
|
- lib/geocoder/lookups/baidu.rb
|
55
57
|
- lib/geocoder/lookups/baidu_ip.rb
|
56
58
|
- lib/geocoder/lookups/ban_data_gouv_fr.rb
|
@@ -60,6 +62,7 @@ files:
|
|
60
62
|
- lib/geocoder/lookups/dstk.rb
|
61
63
|
- lib/geocoder/lookups/esri.rb
|
62
64
|
- lib/geocoder/lookups/freegeoip.rb
|
65
|
+
- lib/geocoder/lookups/geoapify.rb
|
63
66
|
- lib/geocoder/lookups/geocoder_ca.rb
|
64
67
|
- lib/geocoder/lookups/geocodio.rb
|
65
68
|
- lib/geocoder/lookups/geoip2.rb
|
@@ -74,6 +77,7 @@ files:
|
|
74
77
|
- lib/geocoder/lookups/ipdata_co.rb
|
75
78
|
- lib/geocoder/lookups/ipgeolocation.rb
|
76
79
|
- lib/geocoder/lookups/ipinfo_io.rb
|
80
|
+
- lib/geocoder/lookups/ipqualityscore.rb
|
77
81
|
- lib/geocoder/lookups/ipregistry.rb
|
78
82
|
- lib/geocoder/lookups/ipstack.rb
|
79
83
|
- lib/geocoder/lookups/latlon.rb
|
@@ -83,11 +87,13 @@ files:
|
|
83
87
|
- lib/geocoder/lookups/maxmind.rb
|
84
88
|
- lib/geocoder/lookups/maxmind_geoip2.rb
|
85
89
|
- lib/geocoder/lookups/maxmind_local.rb
|
90
|
+
- lib/geocoder/lookups/melissa_street.rb
|
86
91
|
- lib/geocoder/lookups/nationaal_georegister_nl.rb
|
87
92
|
- lib/geocoder/lookups/nominatim.rb
|
88
93
|
- lib/geocoder/lookups/opencagedata.rb
|
89
94
|
- lib/geocoder/lookups/osmnames.rb
|
90
95
|
- lib/geocoder/lookups/pelias.rb
|
96
|
+
- lib/geocoder/lookups/photon.rb
|
91
97
|
- lib/geocoder/lookups/pickpoint.rb
|
92
98
|
- lib/geocoder/lookups/pointpin.rb
|
93
99
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
@@ -106,7 +112,9 @@ files:
|
|
106
112
|
- lib/geocoder/query.rb
|
107
113
|
- lib/geocoder/railtie.rb
|
108
114
|
- lib/geocoder/request.rb
|
115
|
+
- lib/geocoder/results/abstract_api.rb
|
109
116
|
- lib/geocoder/results/amap.rb
|
117
|
+
- lib/geocoder/results/amazon_location_service.rb
|
110
118
|
- lib/geocoder/results/baidu.rb
|
111
119
|
- lib/geocoder/results/baidu_ip.rb
|
112
120
|
- lib/geocoder/results/ban_data_gouv_fr.rb
|
@@ -116,6 +124,7 @@ files:
|
|
116
124
|
- lib/geocoder/results/dstk.rb
|
117
125
|
- lib/geocoder/results/esri.rb
|
118
126
|
- lib/geocoder/results/freegeoip.rb
|
127
|
+
- lib/geocoder/results/geoapify.rb
|
119
128
|
- lib/geocoder/results/geocoder_ca.rb
|
120
129
|
- lib/geocoder/results/geocodio.rb
|
121
130
|
- lib/geocoder/results/geoip2.rb
|
@@ -130,6 +139,7 @@ files:
|
|
130
139
|
- lib/geocoder/results/ipdata_co.rb
|
131
140
|
- lib/geocoder/results/ipgeolocation.rb
|
132
141
|
- lib/geocoder/results/ipinfo_io.rb
|
142
|
+
- lib/geocoder/results/ipqualityscore.rb
|
133
143
|
- lib/geocoder/results/ipregistry.rb
|
134
144
|
- lib/geocoder/results/ipstack.rb
|
135
145
|
- lib/geocoder/results/latlon.rb
|
@@ -139,11 +149,13 @@ files:
|
|
139
149
|
- lib/geocoder/results/maxmind.rb
|
140
150
|
- lib/geocoder/results/maxmind_geoip2.rb
|
141
151
|
- lib/geocoder/results/maxmind_local.rb
|
152
|
+
- lib/geocoder/results/melissa_street.rb
|
142
153
|
- lib/geocoder/results/nationaal_georegister_nl.rb
|
143
154
|
- lib/geocoder/results/nominatim.rb
|
144
155
|
- lib/geocoder/results/opencagedata.rb
|
145
156
|
- lib/geocoder/results/osmnames.rb
|
146
157
|
- lib/geocoder/results/pelias.rb
|
158
|
+
- lib/geocoder/results/photon.rb
|
147
159
|
- lib/geocoder/results/pickpoint.rb
|
148
160
|
- lib/geocoder/results/pointpin.rb
|
149
161
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
@@ -160,8 +172,8 @@ files:
|
|
160
172
|
- lib/geocoder/stores/mongo_base.rb
|
161
173
|
- lib/geocoder/stores/mongo_mapper.rb
|
162
174
|
- lib/geocoder/stores/mongoid.rb
|
175
|
+
- lib/geocoder/util.rb
|
163
176
|
- lib/geocoder/version.rb
|
164
|
-
- lib/hash_recursive_merge.rb
|
165
177
|
- lib/maxmind_database.rb
|
166
178
|
- lib/tasks/geocoder.rake
|
167
179
|
- lib/tasks/maxmind.rake
|
@@ -186,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
198
|
- !ruby/object:Gem::Version
|
187
199
|
version: '0'
|
188
200
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.1.2
|
190
202
|
signing_key:
|
191
203
|
specification_version: 4
|
192
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,30 +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
|
-
# Alternatively, this class could inherit from Redis, which would make most
|
5
|
-
# of the below methods unnecessary.
|
6
|
-
class AutoexpireCacheRedis
|
7
|
-
def initialize(store, ttl = 86400)
|
8
|
-
@store = store
|
9
|
-
@ttl = ttl
|
10
|
-
end
|
11
|
-
|
12
|
-
def [](url)
|
13
|
-
@store.get(url)
|
14
|
-
end
|
15
|
-
|
16
|
-
def []=(url, value)
|
17
|
-
@store.set(url, value)
|
18
|
-
@store.expire(url, @ttl)
|
19
|
-
end
|
20
|
-
|
21
|
-
def keys
|
22
|
-
@store.keys
|
23
|
-
end
|
24
|
-
|
25
|
-
def del(url)
|
26
|
-
@store.del(url)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Geocoder.configure(:cache => AutoexpireCacheRedis.new(Redis.new))
|
data/lib/hash_recursive_merge.rb
DELETED
@@ -1,73 +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
|
-
merge(other_hash) do |key, oldval, newval|
|
64
|
-
oldval.class == self.class ? oldval.rmerge(newval) : newval
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
class Hash
|
72
|
-
include HashRecursiveMerge
|
73
|
-
end
|