geocoder 1.6.6 → 1.8.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 +68 -2
- data/README.md +355 -211
- data/examples/app_defined_lookup_services.rb +22 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +6 -1
- data/lib/geocoder/cache.rb +14 -35
- 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 +17 -4
- data/lib/geocoder/ip_address.rb +9 -0
- data/lib/geocoder/lookup.rb +37 -5
- data/lib/geocoder/lookups/abstract_api.rb +46 -0
- data/lib/geocoder/lookups/amap.rb +2 -2
- data/lib/geocoder/lookups/amazon_location_service.rb +58 -0
- data/lib/geocoder/lookups/azure.rb +56 -0
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +1 -1
- data/lib/geocoder/lookups/base.rb +2 -1
- data/lib/geocoder/lookups/bing.rb +2 -2
- data/lib/geocoder/lookups/esri.rb +18 -5
- data/lib/geocoder/lookups/freegeoip.rb +8 -6
- data/lib/geocoder/lookups/geoapify.rb +78 -0
- data/lib/geocoder/lookups/geoip2.rb +4 -0
- data/lib/geocoder/lookups/geoportail_lu.rb +1 -1
- data/lib/geocoder/lookups/google_places_details.rb +20 -0
- data/lib/geocoder/lookups/google_places_search.rb +21 -5
- data/lib/geocoder/lookups/here.rb +25 -20
- data/lib/geocoder/lookups/ip2location.rb +10 -6
- data/lib/geocoder/lookups/ip2location_io.rb +62 -0
- data/lib/geocoder/lookups/ip2location_lite.rb +40 -0
- data/lib/geocoder/lookups/ipbase.rb +49 -0
- 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/mapbox.rb +3 -3
- data/lib/geocoder/lookups/melissa_street.rb +41 -0
- data/lib/geocoder/lookups/pc_miler.rb +85 -0
- data/lib/geocoder/lookups/pdok_nl.rb +43 -0
- data/lib/geocoder/lookups/photon.rb +89 -0
- data/lib/geocoder/lookups/test.rb +1 -0
- data/lib/geocoder/lookups/twogis.rb +58 -0
- data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +1 -1
- data/lib/geocoder/lookups/yandex.rb +3 -3
- data/lib/geocoder/query.rb +1 -1
- data/lib/geocoder/results/abstract_api.rb +146 -0
- data/lib/geocoder/results/amazon_location_service.rb +62 -0
- data/lib/geocoder/results/azure.rb +65 -0
- data/lib/geocoder/results/ban_data_gouv_fr.rb +1 -1
- data/lib/geocoder/results/esri.rb +5 -2
- data/lib/geocoder/results/geoapify.rb +179 -0
- data/lib/geocoder/results/here.rb +20 -25
- data/lib/geocoder/results/ip2location_io.rb +21 -0
- data/lib/geocoder/results/ip2location_lite.rb +47 -0
- data/lib/geocoder/results/ipbase.rb +40 -0
- data/lib/geocoder/results/ipqualityscore.rb +54 -0
- data/lib/geocoder/results/mapbox.rb +34 -10
- data/lib/geocoder/results/melissa_street.rb +46 -0
- data/lib/geocoder/results/nominatim.rb +24 -16
- data/lib/geocoder/results/pc_miler.rb +98 -0
- data/lib/geocoder/results/pdok_nl.rb +62 -0
- data/lib/geocoder/results/photon.rb +119 -0
- data/lib/geocoder/results/twogis.rb +76 -0
- data/lib/geocoder/version.rb +1 -1
- data/lib/maxmind_database.rb +12 -12
- data/lib/tasks/maxmind.rake +1 -1
- metadata +65 -11
- data/examples/autoexpire_cache_dalli.rb +0 -62
- data/examples/autoexpire_cache_redis.rb +0 -30
- data/lib/geocoder/lookups/dstk.rb +0 -22
- data/lib/geocoder/results/dstk.rb +0 -6
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class PcMiler < Base
|
5
|
+
# sample response:
|
6
|
+
# https://singlesearch.alk.com/na/api/search?authToken=<TOKEN>&include=Meta&query=Feasterville
|
7
|
+
#
|
8
|
+
# {
|
9
|
+
# "Err": 0,
|
10
|
+
# "ErrString": "OK",
|
11
|
+
# "QueryConfidence": 1,
|
12
|
+
# "TimeInMilliseconds": 93,
|
13
|
+
# "GridDataVersion": "GRD_ALK.NA.2023.01.18.29.1.1",
|
14
|
+
# "CommitID": "pcmws-22.08.11.0-1778-g586da49bd1b: 05/30/2023 20:14",
|
15
|
+
# "Locations": [
|
16
|
+
# {
|
17
|
+
# "Address": {
|
18
|
+
# "StreetAddress": "",
|
19
|
+
# "LocalArea": "",
|
20
|
+
# "City": "Feasterville",
|
21
|
+
# "State": "PA",
|
22
|
+
# "StateName": "Pennsylvania",
|
23
|
+
# "Zip": "19053",
|
24
|
+
# "County": "Bucks",
|
25
|
+
# "Country": "US",
|
26
|
+
# "CountryFullName": "United States",
|
27
|
+
# "SPLC": null
|
28
|
+
# },
|
29
|
+
# "Coords": {
|
30
|
+
# "Lat": "40.150025",
|
31
|
+
# "Lon": "-75.002511"
|
32
|
+
# },
|
33
|
+
# "StreetCoords": {
|
34
|
+
# "Lat": "40.150098",
|
35
|
+
# "Lon": "-75.002827"
|
36
|
+
# },
|
37
|
+
# "Region": 4,
|
38
|
+
# "POITypeID": 0,
|
39
|
+
# "PersistentPOIID": -1,
|
40
|
+
# "SiteID": -1,
|
41
|
+
# "ResultType": 4,
|
42
|
+
# "ShortString": "Feasterville",
|
43
|
+
# "GridID": 37172748,
|
44
|
+
# "LinkID": 188,
|
45
|
+
# "Percent": 6291,
|
46
|
+
# "TimeZone": "GMT-4:00 EDT"
|
47
|
+
# }
|
48
|
+
# ]
|
49
|
+
# }
|
50
|
+
|
51
|
+
def address(format=:unused)
|
52
|
+
[street, city, state, postal_code, country]
|
53
|
+
.map { |i| i == '' ? nil : i }
|
54
|
+
.compact
|
55
|
+
.join(', ')
|
56
|
+
end
|
57
|
+
|
58
|
+
def coordinates
|
59
|
+
coords = data["Coords"] || {}
|
60
|
+
[coords["Lat"].to_f, coords["Lon"].to_f]
|
61
|
+
end
|
62
|
+
|
63
|
+
def street
|
64
|
+
address_data["StreetAddress"]
|
65
|
+
end
|
66
|
+
|
67
|
+
def city
|
68
|
+
address_data["City"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def state
|
72
|
+
address_data["StateName"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def state_code
|
76
|
+
address_data["State"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def postal_code
|
80
|
+
address_data["Zip"]
|
81
|
+
end
|
82
|
+
|
83
|
+
def country
|
84
|
+
address_data["CountryFullName"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def country_code
|
88
|
+
address_data["Country"]
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def address_data
|
94
|
+
data["Address"] || {}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class PdokNl < Base
|
5
|
+
|
6
|
+
def response_attributes
|
7
|
+
@data
|
8
|
+
end
|
9
|
+
|
10
|
+
def coordinates
|
11
|
+
@data['centroide_ll'][6..-2].split(' ').map(&:to_f).reverse
|
12
|
+
end
|
13
|
+
|
14
|
+
def formatted_address
|
15
|
+
@data['weergavenaam']
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :address, :formatted_address
|
19
|
+
|
20
|
+
def province
|
21
|
+
@data['provincienaam']
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :state, :province
|
25
|
+
|
26
|
+
def city
|
27
|
+
@data['woonplaatsnaam']
|
28
|
+
end
|
29
|
+
|
30
|
+
def district
|
31
|
+
@data['gemeentenaam']
|
32
|
+
end
|
33
|
+
|
34
|
+
def street
|
35
|
+
@data['straatnaam']
|
36
|
+
end
|
37
|
+
|
38
|
+
def street_number
|
39
|
+
@data['huis_nlt']
|
40
|
+
end
|
41
|
+
|
42
|
+
def address_components
|
43
|
+
@data
|
44
|
+
end
|
45
|
+
|
46
|
+
def state_code
|
47
|
+
@data['provinciecode']
|
48
|
+
end
|
49
|
+
|
50
|
+
def postal_code
|
51
|
+
@data['postcode']
|
52
|
+
end
|
53
|
+
|
54
|
+
def country
|
55
|
+
"Netherlands"
|
56
|
+
end
|
57
|
+
|
58
|
+
def country_code
|
59
|
+
"NL"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Photon < Base
|
5
|
+
def name
|
6
|
+
properties['name']
|
7
|
+
end
|
8
|
+
|
9
|
+
def address(_format = :full)
|
10
|
+
parts = []
|
11
|
+
parts << name if name
|
12
|
+
parts << street_address if street_address
|
13
|
+
parts << city
|
14
|
+
parts << state if state
|
15
|
+
parts << postal_code
|
16
|
+
parts << country
|
17
|
+
|
18
|
+
parts.join(', ')
|
19
|
+
end
|
20
|
+
|
21
|
+
def street_address
|
22
|
+
return unless street
|
23
|
+
return street unless house_number
|
24
|
+
|
25
|
+
"#{house_number} #{street}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def house_number
|
29
|
+
properties['housenumber']
|
30
|
+
end
|
31
|
+
|
32
|
+
def street
|
33
|
+
properties['street']
|
34
|
+
end
|
35
|
+
|
36
|
+
def postal_code
|
37
|
+
properties['postcode']
|
38
|
+
end
|
39
|
+
|
40
|
+
def city
|
41
|
+
properties['city']
|
42
|
+
end
|
43
|
+
|
44
|
+
def state
|
45
|
+
properties['state']
|
46
|
+
end
|
47
|
+
|
48
|
+
def state_code
|
49
|
+
''
|
50
|
+
end
|
51
|
+
|
52
|
+
def country
|
53
|
+
properties['country']
|
54
|
+
end
|
55
|
+
|
56
|
+
def country_code
|
57
|
+
''
|
58
|
+
end
|
59
|
+
|
60
|
+
def coordinates
|
61
|
+
return unless geometry
|
62
|
+
return unless geometry[:coordinates]
|
63
|
+
|
64
|
+
geometry[:coordinates].reverse
|
65
|
+
end
|
66
|
+
|
67
|
+
def geometry
|
68
|
+
return unless data['geometry']
|
69
|
+
|
70
|
+
symbol_hash data['geometry']
|
71
|
+
end
|
72
|
+
|
73
|
+
def bounds
|
74
|
+
properties['extent']
|
75
|
+
end
|
76
|
+
|
77
|
+
# Type of the result (OSM object type), one of:
|
78
|
+
#
|
79
|
+
# :node
|
80
|
+
# :way
|
81
|
+
# :relation
|
82
|
+
#
|
83
|
+
def type
|
84
|
+
{
|
85
|
+
'N' => :node,
|
86
|
+
'W' => :way,
|
87
|
+
'R' => :relation
|
88
|
+
}[properties['osm_type']]
|
89
|
+
end
|
90
|
+
|
91
|
+
def osm_id
|
92
|
+
properties['osm_id']
|
93
|
+
end
|
94
|
+
|
95
|
+
# See: https://wiki.openstreetmap.org/wiki/Tags
|
96
|
+
def osm_tag
|
97
|
+
return unless properties['osm_key']
|
98
|
+
return properties['osm_key'] unless properties['osm_value']
|
99
|
+
|
100
|
+
"#{properties['osm_key']}=#{properties['osm_value']}"
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def properties
|
106
|
+
@properties ||= data['properties'] || {}
|
107
|
+
end
|
108
|
+
|
109
|
+
def symbol_hash(orig_hash)
|
110
|
+
{}.tap do |result|
|
111
|
+
orig_hash.each_key do |key|
|
112
|
+
next unless orig_hash[key]
|
113
|
+
|
114
|
+
result[key.to_sym] = orig_hash[key]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Twogis < Base
|
5
|
+
def coordinates
|
6
|
+
['lat', 'lon'].map{ |i| @data['point'][i] } if @data['point']
|
7
|
+
end
|
8
|
+
|
9
|
+
def address(_format = :full)
|
10
|
+
@data['full_address_name'] || ''
|
11
|
+
end
|
12
|
+
|
13
|
+
def city
|
14
|
+
return '' unless @data['adm_div']
|
15
|
+
@data['adm_div'].select{|u| u["type"] == "city"}.first.try(:[], 'name') || ''
|
16
|
+
end
|
17
|
+
|
18
|
+
def region
|
19
|
+
return '' unless @data['adm_div']
|
20
|
+
@data['adm_div'].select{|u| u["type"] == "region"}.first.try(:[], 'name') || ''
|
21
|
+
end
|
22
|
+
|
23
|
+
def country
|
24
|
+
return '' unless @data['adm_div']
|
25
|
+
@data['adm_div'].select{|u| u["type"] == "country"}.first.try(:[], 'name') || ''
|
26
|
+
end
|
27
|
+
|
28
|
+
def district
|
29
|
+
return '' unless @data['adm_div']
|
30
|
+
@data['adm_div'].select{|u| u["type"] == "district"}.first.try(:[], 'name') || ''
|
31
|
+
end
|
32
|
+
|
33
|
+
def district_area
|
34
|
+
return '' unless @data['adm_div']
|
35
|
+
@data['adm_div'].select{|u| u["type"] == "district_area"}.first.try(:[], 'name') || ''
|
36
|
+
end
|
37
|
+
|
38
|
+
def street_address
|
39
|
+
@data['address_name'] || ''
|
40
|
+
end
|
41
|
+
|
42
|
+
def street
|
43
|
+
return '' unless @data['address_name']
|
44
|
+
@data['address_name'].split(', ').first
|
45
|
+
end
|
46
|
+
|
47
|
+
def street_number
|
48
|
+
return '' unless @data['address_name']
|
49
|
+
@data['address_name'].split(', ')[1] || ''
|
50
|
+
end
|
51
|
+
|
52
|
+
def type
|
53
|
+
@data['type'] || ''
|
54
|
+
end
|
55
|
+
|
56
|
+
def purpose_name
|
57
|
+
@data['purpose_name'] || ''
|
58
|
+
end
|
59
|
+
|
60
|
+
def building_name
|
61
|
+
@data['building_name'] || ''
|
62
|
+
end
|
63
|
+
|
64
|
+
def subtype
|
65
|
+
@data['subtype'] || ''
|
66
|
+
end
|
67
|
+
|
68
|
+
def subtype_specification
|
69
|
+
@data['subtype_specification'] || ''
|
70
|
+
end
|
71
|
+
|
72
|
+
def name
|
73
|
+
@data['name'] || ''
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/geocoder/version.rb
CHANGED
data/lib/maxmind_database.rb
CHANGED
@@ -6,9 +6,9 @@ module Geocoder
|
|
6
6
|
extend self
|
7
7
|
|
8
8
|
def download(package, dir = "tmp")
|
9
|
-
filepath = File.expand_path(File.join(dir,
|
9
|
+
filepath = File.expand_path(File.join(dir, "#{archive_edition(package)}.zip"))
|
10
10
|
open(filepath, 'wb') do |file|
|
11
|
-
uri = URI.parse(
|
11
|
+
uri = URI.parse(base_url(package))
|
12
12
|
Net::HTTP.start(uri.host, uri.port) do |http|
|
13
13
|
http.request_get(uri.path) do |resp|
|
14
14
|
# TODO: show progress
|
@@ -35,6 +35,14 @@ module Geocoder
|
|
35
35
|
p[s..-1]
|
36
36
|
end
|
37
37
|
|
38
|
+
def archive_edition(package)
|
39
|
+
{
|
40
|
+
geolite_country_csv: "GeoLite2-Country-CSV",
|
41
|
+
geolite_city_csv: "GeoLite2-City-CSV",
|
42
|
+
geolite_asn_csv: "GeoLite2-ASN-CSV"
|
43
|
+
}[package]
|
44
|
+
end
|
45
|
+
|
38
46
|
private # -------------------------------------------------------------
|
39
47
|
|
40
48
|
def table_columns(table_name)
|
@@ -94,16 +102,8 @@ module Geocoder
|
|
94
102
|
base_url + archive_url_path(package)
|
95
103
|
end
|
96
104
|
|
97
|
-
def
|
98
|
-
{
|
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
|
-
}[package]
|
103
|
-
end
|
104
|
-
|
105
|
-
def base_url
|
106
|
-
"http://geolite.maxmind.com/download/geoip/database/"
|
105
|
+
def base_url(edition)
|
106
|
+
"https://download.maxmind.com/app/geoip_download?edition_id=#{edition}&license_key=#{ENV['LICENSE_KEY']}&suffix=zip"
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
data/lib/tasks/maxmind.rake
CHANGED
@@ -54,7 +54,7 @@ module MaxmindTask
|
|
54
54
|
end
|
55
55
|
require 'fileutils'
|
56
56
|
p = "geolite_#{package}_csv".intern
|
57
|
-
archive_filename = Geocoder::MaxmindDatabase.
|
57
|
+
archive_filename = "#{Geocoder::MaxmindDatabase.archive_edition(p)}.zip"
|
58
58
|
Zip::File.open(File.join(options[:dir], archive_filename)).each do |entry|
|
59
59
|
filepath = File.join(options[:dir], entry.name)
|
60
60
|
if File.exist? filepath
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: csv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
13
41
|
description: Object geocoding (by street or IP address), reverse geocoding (coordinates
|
14
42
|
to street address), distance queries for ActiveRecord and Mongoid, result caching,
|
15
43
|
and more. Designed for Rails but works with Sinatra and other Rack frameworks too.
|
@@ -25,8 +53,7 @@ files:
|
|
25
53
|
- README.md
|
26
54
|
- bin/console
|
27
55
|
- bin/geocode
|
28
|
-
- examples/
|
29
|
-
- examples/autoexpire_cache_redis.rb
|
56
|
+
- examples/app_defined_lookup_services.rb
|
30
57
|
- examples/cache_bypass.rb
|
31
58
|
- examples/reverse_geocode_job.rb
|
32
59
|
- lib/easting_northing.rb
|
@@ -39,6 +66,9 @@ files:
|
|
39
66
|
- lib/generators/geocoder/migration_version.rb
|
40
67
|
- lib/geocoder.rb
|
41
68
|
- lib/geocoder/cache.rb
|
69
|
+
- lib/geocoder/cache_stores/base.rb
|
70
|
+
- lib/geocoder/cache_stores/generic.rb
|
71
|
+
- lib/geocoder/cache_stores/redis.rb
|
42
72
|
- lib/geocoder/calculations.rb
|
43
73
|
- lib/geocoder/cli.rb
|
44
74
|
- lib/geocoder/configuration.rb
|
@@ -49,16 +79,19 @@ files:
|
|
49
79
|
- lib/geocoder/kernel_logger.rb
|
50
80
|
- lib/geocoder/logger.rb
|
51
81
|
- lib/geocoder/lookup.rb
|
82
|
+
- lib/geocoder/lookups/abstract_api.rb
|
52
83
|
- lib/geocoder/lookups/amap.rb
|
84
|
+
- lib/geocoder/lookups/amazon_location_service.rb
|
85
|
+
- lib/geocoder/lookups/azure.rb
|
53
86
|
- lib/geocoder/lookups/baidu.rb
|
54
87
|
- lib/geocoder/lookups/baidu_ip.rb
|
55
88
|
- lib/geocoder/lookups/ban_data_gouv_fr.rb
|
56
89
|
- lib/geocoder/lookups/base.rb
|
57
90
|
- lib/geocoder/lookups/bing.rb
|
58
91
|
- lib/geocoder/lookups/db_ip_com.rb
|
59
|
-
- lib/geocoder/lookups/dstk.rb
|
60
92
|
- lib/geocoder/lookups/esri.rb
|
61
93
|
- lib/geocoder/lookups/freegeoip.rb
|
94
|
+
- lib/geocoder/lookups/geoapify.rb
|
62
95
|
- lib/geocoder/lookups/geocoder_ca.rb
|
63
96
|
- lib/geocoder/lookups/geocodio.rb
|
64
97
|
- lib/geocoder/lookups/geoip2.rb
|
@@ -69,10 +102,14 @@ files:
|
|
69
102
|
- lib/geocoder/lookups/google_premier.rb
|
70
103
|
- lib/geocoder/lookups/here.rb
|
71
104
|
- lib/geocoder/lookups/ip2location.rb
|
105
|
+
- lib/geocoder/lookups/ip2location_io.rb
|
106
|
+
- lib/geocoder/lookups/ip2location_lite.rb
|
72
107
|
- lib/geocoder/lookups/ipapi_com.rb
|
108
|
+
- lib/geocoder/lookups/ipbase.rb
|
73
109
|
- lib/geocoder/lookups/ipdata_co.rb
|
74
110
|
- lib/geocoder/lookups/ipgeolocation.rb
|
75
111
|
- lib/geocoder/lookups/ipinfo_io.rb
|
112
|
+
- lib/geocoder/lookups/ipqualityscore.rb
|
76
113
|
- lib/geocoder/lookups/ipregistry.rb
|
77
114
|
- lib/geocoder/lookups/ipstack.rb
|
78
115
|
- lib/geocoder/lookups/latlon.rb
|
@@ -82,11 +119,15 @@ files:
|
|
82
119
|
- lib/geocoder/lookups/maxmind.rb
|
83
120
|
- lib/geocoder/lookups/maxmind_geoip2.rb
|
84
121
|
- lib/geocoder/lookups/maxmind_local.rb
|
122
|
+
- lib/geocoder/lookups/melissa_street.rb
|
85
123
|
- lib/geocoder/lookups/nationaal_georegister_nl.rb
|
86
124
|
- lib/geocoder/lookups/nominatim.rb
|
87
125
|
- lib/geocoder/lookups/opencagedata.rb
|
88
126
|
- lib/geocoder/lookups/osmnames.rb
|
127
|
+
- lib/geocoder/lookups/pc_miler.rb
|
128
|
+
- lib/geocoder/lookups/pdok_nl.rb
|
89
129
|
- lib/geocoder/lookups/pelias.rb
|
130
|
+
- lib/geocoder/lookups/photon.rb
|
90
131
|
- lib/geocoder/lookups/pickpoint.rb
|
91
132
|
- lib/geocoder/lookups/pointpin.rb
|
92
133
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
@@ -95,6 +136,7 @@ files:
|
|
95
136
|
- lib/geocoder/lookups/telize.rb
|
96
137
|
- lib/geocoder/lookups/tencent.rb
|
97
138
|
- lib/geocoder/lookups/test.rb
|
139
|
+
- lib/geocoder/lookups/twogis.rb
|
98
140
|
- lib/geocoder/lookups/uk_ordnance_survey_names.rb
|
99
141
|
- lib/geocoder/lookups/yandex.rb
|
100
142
|
- lib/geocoder/models/active_record.rb
|
@@ -105,16 +147,19 @@ files:
|
|
105
147
|
- lib/geocoder/query.rb
|
106
148
|
- lib/geocoder/railtie.rb
|
107
149
|
- lib/geocoder/request.rb
|
150
|
+
- lib/geocoder/results/abstract_api.rb
|
108
151
|
- lib/geocoder/results/amap.rb
|
152
|
+
- lib/geocoder/results/amazon_location_service.rb
|
153
|
+
- lib/geocoder/results/azure.rb
|
109
154
|
- lib/geocoder/results/baidu.rb
|
110
155
|
- lib/geocoder/results/baidu_ip.rb
|
111
156
|
- lib/geocoder/results/ban_data_gouv_fr.rb
|
112
157
|
- lib/geocoder/results/base.rb
|
113
158
|
- lib/geocoder/results/bing.rb
|
114
159
|
- lib/geocoder/results/db_ip_com.rb
|
115
|
-
- lib/geocoder/results/dstk.rb
|
116
160
|
- lib/geocoder/results/esri.rb
|
117
161
|
- lib/geocoder/results/freegeoip.rb
|
162
|
+
- lib/geocoder/results/geoapify.rb
|
118
163
|
- lib/geocoder/results/geocoder_ca.rb
|
119
164
|
- lib/geocoder/results/geocodio.rb
|
120
165
|
- lib/geocoder/results/geoip2.rb
|
@@ -125,10 +170,14 @@ files:
|
|
125
170
|
- lib/geocoder/results/google_premier.rb
|
126
171
|
- lib/geocoder/results/here.rb
|
127
172
|
- lib/geocoder/results/ip2location.rb
|
173
|
+
- lib/geocoder/results/ip2location_io.rb
|
174
|
+
- lib/geocoder/results/ip2location_lite.rb
|
128
175
|
- lib/geocoder/results/ipapi_com.rb
|
176
|
+
- lib/geocoder/results/ipbase.rb
|
129
177
|
- lib/geocoder/results/ipdata_co.rb
|
130
178
|
- lib/geocoder/results/ipgeolocation.rb
|
131
179
|
- lib/geocoder/results/ipinfo_io.rb
|
180
|
+
- lib/geocoder/results/ipqualityscore.rb
|
132
181
|
- lib/geocoder/results/ipregistry.rb
|
133
182
|
- lib/geocoder/results/ipstack.rb
|
134
183
|
- lib/geocoder/results/latlon.rb
|
@@ -138,11 +187,15 @@ files:
|
|
138
187
|
- lib/geocoder/results/maxmind.rb
|
139
188
|
- lib/geocoder/results/maxmind_geoip2.rb
|
140
189
|
- lib/geocoder/results/maxmind_local.rb
|
190
|
+
- lib/geocoder/results/melissa_street.rb
|
141
191
|
- lib/geocoder/results/nationaal_georegister_nl.rb
|
142
192
|
- lib/geocoder/results/nominatim.rb
|
143
193
|
- lib/geocoder/results/opencagedata.rb
|
144
194
|
- lib/geocoder/results/osmnames.rb
|
195
|
+
- lib/geocoder/results/pc_miler.rb
|
196
|
+
- lib/geocoder/results/pdok_nl.rb
|
145
197
|
- lib/geocoder/results/pelias.rb
|
198
|
+
- lib/geocoder/results/photon.rb
|
146
199
|
- lib/geocoder/results/pickpoint.rb
|
147
200
|
- lib/geocoder/results/pointpin.rb
|
148
201
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
@@ -151,6 +204,7 @@ files:
|
|
151
204
|
- lib/geocoder/results/telize.rb
|
152
205
|
- lib/geocoder/results/tencent.rb
|
153
206
|
- lib/geocoder/results/test.rb
|
207
|
+
- lib/geocoder/results/twogis.rb
|
154
208
|
- lib/geocoder/results/uk_ordnance_survey_names.rb
|
155
209
|
- lib/geocoder/results/yandex.rb
|
156
210
|
- lib/geocoder/sql.rb
|
@@ -170,7 +224,7 @@ licenses:
|
|
170
224
|
metadata:
|
171
225
|
source_code_uri: https://github.com/alexreisner/geocoder
|
172
226
|
changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
|
173
|
-
post_install_message:
|
227
|
+
post_install_message:
|
174
228
|
rdoc_options: []
|
175
229
|
require_paths:
|
176
230
|
- lib
|
@@ -185,8 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
239
|
- !ruby/object:Gem::Version
|
186
240
|
version: '0'
|
187
241
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
189
|
-
signing_key:
|
242
|
+
rubygems_version: 3.3.26
|
243
|
+
signing_key:
|
190
244
|
specification_version: 4
|
191
245
|
summary: Complete geocoding solution for Ruby.
|
192
246
|
test_files: []
|
@@ -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))
|