geocoder 1.6.3 → 1.7.5
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 +4 -4
- data/CHANGELOG.md +48 -0
- data/LICENSE +1 -1
- data/README.md +329 -232
- data/examples/app_defined_lookup_services.rb +22 -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 +6 -0
- data/lib/geocoder/lookup.rb +30 -4
- 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 +4 -0
- data/lib/geocoder/lookups/freegeoip.rb +8 -6
- 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/location_iq.rb +5 -1
- 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/test.rb +4 -0
- data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +1 -1
- 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 +19 -5
- 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,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.7.5
|
|
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-03-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Object geocoding (by street or IP address), reverse geocoding (coordinates
|
|
14
14
|
to street address), distance queries for ActiveRecord and Mongoid, result caching,
|
|
@@ -25,8 +25,7 @@ files:
|
|
|
25
25
|
- README.md
|
|
26
26
|
- bin/console
|
|
27
27
|
- bin/geocode
|
|
28
|
-
- examples/
|
|
29
|
-
- examples/autoexpire_cache_redis.rb
|
|
28
|
+
- examples/app_defined_lookup_services.rb
|
|
30
29
|
- examples/cache_bypass.rb
|
|
31
30
|
- examples/reverse_geocode_job.rb
|
|
32
31
|
- lib/easting_northing.rb
|
|
@@ -39,6 +38,9 @@ files:
|
|
|
39
38
|
- lib/generators/geocoder/migration_version.rb
|
|
40
39
|
- lib/geocoder.rb
|
|
41
40
|
- lib/geocoder/cache.rb
|
|
41
|
+
- lib/geocoder/cache_stores/base.rb
|
|
42
|
+
- lib/geocoder/cache_stores/generic.rb
|
|
43
|
+
- lib/geocoder/cache_stores/redis.rb
|
|
42
44
|
- lib/geocoder/calculations.rb
|
|
43
45
|
- lib/geocoder/cli.rb
|
|
44
46
|
- lib/geocoder/configuration.rb
|
|
@@ -49,7 +51,9 @@ files:
|
|
|
49
51
|
- lib/geocoder/kernel_logger.rb
|
|
50
52
|
- lib/geocoder/logger.rb
|
|
51
53
|
- lib/geocoder/lookup.rb
|
|
54
|
+
- lib/geocoder/lookups/abstract_api.rb
|
|
52
55
|
- lib/geocoder/lookups/amap.rb
|
|
56
|
+
- lib/geocoder/lookups/amazon_location_service.rb
|
|
53
57
|
- lib/geocoder/lookups/baidu.rb
|
|
54
58
|
- lib/geocoder/lookups/baidu_ip.rb
|
|
55
59
|
- lib/geocoder/lookups/ban_data_gouv_fr.rb
|
|
@@ -59,6 +63,7 @@ files:
|
|
|
59
63
|
- lib/geocoder/lookups/dstk.rb
|
|
60
64
|
- lib/geocoder/lookups/esri.rb
|
|
61
65
|
- lib/geocoder/lookups/freegeoip.rb
|
|
66
|
+
- lib/geocoder/lookups/geoapify.rb
|
|
62
67
|
- lib/geocoder/lookups/geocoder_ca.rb
|
|
63
68
|
- lib/geocoder/lookups/geocodio.rb
|
|
64
69
|
- lib/geocoder/lookups/geoip2.rb
|
|
@@ -73,6 +78,7 @@ files:
|
|
|
73
78
|
- lib/geocoder/lookups/ipdata_co.rb
|
|
74
79
|
- lib/geocoder/lookups/ipgeolocation.rb
|
|
75
80
|
- lib/geocoder/lookups/ipinfo_io.rb
|
|
81
|
+
- lib/geocoder/lookups/ipqualityscore.rb
|
|
76
82
|
- lib/geocoder/lookups/ipregistry.rb
|
|
77
83
|
- lib/geocoder/lookups/ipstack.rb
|
|
78
84
|
- lib/geocoder/lookups/latlon.rb
|
|
@@ -82,11 +88,13 @@ files:
|
|
|
82
88
|
- lib/geocoder/lookups/maxmind.rb
|
|
83
89
|
- lib/geocoder/lookups/maxmind_geoip2.rb
|
|
84
90
|
- lib/geocoder/lookups/maxmind_local.rb
|
|
91
|
+
- lib/geocoder/lookups/melissa_street.rb
|
|
85
92
|
- lib/geocoder/lookups/nationaal_georegister_nl.rb
|
|
86
93
|
- lib/geocoder/lookups/nominatim.rb
|
|
87
94
|
- lib/geocoder/lookups/opencagedata.rb
|
|
88
95
|
- lib/geocoder/lookups/osmnames.rb
|
|
89
96
|
- lib/geocoder/lookups/pelias.rb
|
|
97
|
+
- lib/geocoder/lookups/photon.rb
|
|
90
98
|
- lib/geocoder/lookups/pickpoint.rb
|
|
91
99
|
- lib/geocoder/lookups/pointpin.rb
|
|
92
100
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
|
@@ -105,7 +113,9 @@ files:
|
|
|
105
113
|
- lib/geocoder/query.rb
|
|
106
114
|
- lib/geocoder/railtie.rb
|
|
107
115
|
- lib/geocoder/request.rb
|
|
116
|
+
- lib/geocoder/results/abstract_api.rb
|
|
108
117
|
- lib/geocoder/results/amap.rb
|
|
118
|
+
- lib/geocoder/results/amazon_location_service.rb
|
|
109
119
|
- lib/geocoder/results/baidu.rb
|
|
110
120
|
- lib/geocoder/results/baidu_ip.rb
|
|
111
121
|
- lib/geocoder/results/ban_data_gouv_fr.rb
|
|
@@ -115,6 +125,7 @@ files:
|
|
|
115
125
|
- lib/geocoder/results/dstk.rb
|
|
116
126
|
- lib/geocoder/results/esri.rb
|
|
117
127
|
- lib/geocoder/results/freegeoip.rb
|
|
128
|
+
- lib/geocoder/results/geoapify.rb
|
|
118
129
|
- lib/geocoder/results/geocoder_ca.rb
|
|
119
130
|
- lib/geocoder/results/geocodio.rb
|
|
120
131
|
- lib/geocoder/results/geoip2.rb
|
|
@@ -129,6 +140,7 @@ files:
|
|
|
129
140
|
- lib/geocoder/results/ipdata_co.rb
|
|
130
141
|
- lib/geocoder/results/ipgeolocation.rb
|
|
131
142
|
- lib/geocoder/results/ipinfo_io.rb
|
|
143
|
+
- lib/geocoder/results/ipqualityscore.rb
|
|
132
144
|
- lib/geocoder/results/ipregistry.rb
|
|
133
145
|
- lib/geocoder/results/ipstack.rb
|
|
134
146
|
- lib/geocoder/results/latlon.rb
|
|
@@ -138,11 +150,13 @@ files:
|
|
|
138
150
|
- lib/geocoder/results/maxmind.rb
|
|
139
151
|
- lib/geocoder/results/maxmind_geoip2.rb
|
|
140
152
|
- lib/geocoder/results/maxmind_local.rb
|
|
153
|
+
- lib/geocoder/results/melissa_street.rb
|
|
141
154
|
- lib/geocoder/results/nationaal_georegister_nl.rb
|
|
142
155
|
- lib/geocoder/results/nominatim.rb
|
|
143
156
|
- lib/geocoder/results/opencagedata.rb
|
|
144
157
|
- lib/geocoder/results/osmnames.rb
|
|
145
158
|
- lib/geocoder/results/pelias.rb
|
|
159
|
+
- lib/geocoder/results/photon.rb
|
|
146
160
|
- lib/geocoder/results/pickpoint.rb
|
|
147
161
|
- lib/geocoder/results/pointpin.rb
|
|
148
162
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
|
@@ -159,8 +173,8 @@ files:
|
|
|
159
173
|
- lib/geocoder/stores/mongo_base.rb
|
|
160
174
|
- lib/geocoder/stores/mongo_mapper.rb
|
|
161
175
|
- lib/geocoder/stores/mongoid.rb
|
|
176
|
+
- lib/geocoder/util.rb
|
|
162
177
|
- lib/geocoder/version.rb
|
|
163
|
-
- lib/hash_recursive_merge.rb
|
|
164
178
|
- lib/maxmind_database.rb
|
|
165
179
|
- lib/tasks/geocoder.rake
|
|
166
180
|
- lib/tasks/maxmind.rake
|
|
@@ -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
|