geocoder 1.4.7 → 1.5.0
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 +20 -0
- data/README.md +352 -935
- data/examples/autoexpire_cache_redis.rb +3 -3
- data/lib/generators/geocoder/config/templates/initializer.rb +2 -2
- data/lib/geocoder/cache.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 +1 -1
- data/lib/geocoder/lookup.rb +4 -3
- data/lib/geocoder/lookups/amap.rb +7 -3
- data/lib/geocoder/lookups/baidu.rb +14 -10
- data/lib/geocoder/lookups/baidu_ip.rb +6 -35
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +4 -4
- data/lib/geocoder/lookups/base.rb +21 -3
- data/lib/geocoder/lookups/bing.rb +8 -12
- data/lib/geocoder/lookups/db_ip_com.rb +9 -6
- data/lib/geocoder/lookups/dstk.rb +4 -2
- data/lib/geocoder/lookups/esri.rb +1 -16
- data/lib/geocoder/lookups/freegeoip.rb +4 -0
- data/lib/geocoder/lookups/geocoder_ca.rb +4 -4
- data/lib/geocoder/lookups/geocoder_us.rb +17 -9
- data/lib/geocoder/lookups/geocodio.rb +5 -5
- data/lib/geocoder/lookups/geoportail_lu.rb +7 -7
- data/lib/geocoder/lookups/google.rb +8 -8
- 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 +10 -0
- data/lib/geocoder/lookups/here.rb +4 -4
- data/lib/geocoder/lookups/ip2location.rb +74 -0
- data/lib/geocoder/lookups/ipapi_com.rb +7 -12
- data/lib/geocoder/lookups/ipdata_co.rb +4 -0
- data/lib/geocoder/lookups/ipinfo_io.rb +10 -19
- data/lib/geocoder/lookups/ipstack.rb +63 -0
- data/lib/geocoder/lookups/latlon.rb +4 -4
- data/lib/geocoder/lookups/location_iq.rb +10 -4
- data/lib/geocoder/lookups/mapbox.rb +7 -6
- data/lib/geocoder/lookups/mapquest.rb +4 -5
- data/lib/geocoder/lookups/maxmind.rb +4 -4
- data/lib/geocoder/lookups/maxmind_geoip2.rb +4 -0
- data/lib/geocoder/lookups/nominatim.rb +4 -4
- data/lib/geocoder/lookups/opencagedata.rb +6 -5
- data/lib/geocoder/lookups/pelias.rb +6 -6
- data/lib/geocoder/lookups/pickpoint.rb +9 -3
- data/lib/geocoder/lookups/pointpin.rb +7 -6
- 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 +8 -8
- data/lib/geocoder/lookups/telize.rb +24 -4
- data/lib/geocoder/lookups/yandex.rb +4 -4
- data/lib/geocoder/results/baidu.rb +10 -10
- data/lib/geocoder/results/base.rb +13 -1
- data/lib/geocoder/results/bing.rb +1 -1
- data/lib/geocoder/results/db_ip_com.rb +0 -5
- data/lib/geocoder/results/freegeoip.rb +0 -5
- data/lib/geocoder/results/geocoder_ca.rb +3 -3
- data/lib/geocoder/results/geoip2.rb +2 -6
- data/lib/geocoder/results/geoportail_lu.rb +5 -3
- data/lib/geocoder/results/ip2location.rb +22 -0
- data/lib/geocoder/results/ipdata_co.rb +0 -5
- 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/postcodes_io.rb +40 -0
- data/lib/geocoder/results/telize.rb +0 -5
- data/lib/geocoder/results/test.rb +1 -1
- data/lib/geocoder/stores/active_record.rb +0 -2
- data/lib/geocoder/stores/base.rb +1 -1
- data/lib/geocoder/version.rb +1 -1
- metadata +14 -8
- data/lib/geocoder/lookups/okf.rb +0 -44
- data/lib/geocoder/lookups/ovi.rb +0 -62
- data/lib/geocoder/results/okf.rb +0 -106
- data/lib/geocoder/results/ovi.rb +0 -71
|
@@ -11,34 +11,34 @@ module Geocoder::Result
|
|
|
11
11
|
@data['formatted_address']
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def state
|
|
15
|
-
province
|
|
16
|
-
end
|
|
17
|
-
|
|
18
14
|
def province
|
|
19
|
-
@data['addressComponent']['province']
|
|
15
|
+
@data['addressComponent'] and @data['addressComponent']['province'] or ""
|
|
20
16
|
end
|
|
21
17
|
|
|
18
|
+
alias_method :state, :province
|
|
19
|
+
|
|
22
20
|
def city
|
|
23
|
-
@data['addressComponent']['city']
|
|
21
|
+
@data['addressComponent'] and @data['addressComponent']['city'] or ""
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def district
|
|
27
|
-
@data['addressComponent']['district']
|
|
25
|
+
@data['addressComponent'] and @data['addressComponent']['district'] or ""
|
|
28
26
|
end
|
|
29
27
|
|
|
30
28
|
def street
|
|
31
|
-
@data['addressComponent']['street']
|
|
29
|
+
@data['addressComponent'] and @data['addressComponent']['street'] or ""
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
def street_number
|
|
35
|
-
@data['addressComponent']['street_number']
|
|
33
|
+
@data['addressComponent'] and @data['addressComponent']['street_number']
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
def formatted_address
|
|
39
|
-
@data['formatted_address']
|
|
37
|
+
@data['formatted_address'] or ""
|
|
40
38
|
end
|
|
41
39
|
|
|
40
|
+
alias_method :address, :formatted_address
|
|
41
|
+
|
|
42
42
|
def address_components
|
|
43
43
|
@data['addressComponent']
|
|
44
44
|
end
|
|
@@ -20,8 +20,20 @@ module Geocoder
|
|
|
20
20
|
##
|
|
21
21
|
# A string in the given format.
|
|
22
22
|
#
|
|
23
|
+
# This default implementation dumbly follows the United States address
|
|
24
|
+
# format and will return incorrect results for most countries. Some APIs
|
|
25
|
+
# return properly formatted addresses and those should be funneled
|
|
26
|
+
# through this method.
|
|
27
|
+
#
|
|
23
28
|
def address(format = :full)
|
|
24
|
-
|
|
29
|
+
if state_code.to_s != ""
|
|
30
|
+
s = ", #{state_code}"
|
|
31
|
+
elsif state.to_s != ""
|
|
32
|
+
s = ", #{state}"
|
|
33
|
+
else
|
|
34
|
+
s = ""
|
|
35
|
+
end
|
|
36
|
+
"#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, '')
|
|
25
37
|
end
|
|
26
38
|
|
|
27
39
|
##
|
|
@@ -7,11 +7,6 @@ module Geocoder::Result
|
|
|
7
7
|
['latitude', 'longitude'].map{ |coordinate_name| @data[coordinate_name] }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def address(format = :full)
|
|
11
|
-
s = state_code.to_s == "" ? "" : ", #{state_code}"
|
|
12
|
-
"#{city}#{s} #{zip_code}, #{country_name}".sub(/^[ ,]*/, "")
|
|
13
|
-
end
|
|
14
|
-
|
|
15
10
|
def city
|
|
16
11
|
@data['city']
|
|
17
12
|
end
|
|
@@ -3,11 +3,6 @@ require 'geocoder/results/base'
|
|
|
3
3
|
module Geocoder::Result
|
|
4
4
|
class Freegeoip < 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
|
|
@@ -16,17 +16,17 @@ module Geocoder::Result
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def city
|
|
19
|
-
@data['city']
|
|
19
|
+
@data['city'] or (@data['standard'] and @data['standard']['city']) or ""
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def state
|
|
23
|
-
@data['prov']
|
|
23
|
+
@data['prov'] or (@data['standard'] and @data['standard']['prov']) or ""
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
alias_method :state_code, :state
|
|
27
27
|
|
|
28
28
|
def postal_code
|
|
29
|
-
@data['postal']
|
|
29
|
+
@data['postal'] or (@data['standard'] and @data['standard']['postal']) or ""
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def country
|
|
@@ -3,10 +3,6 @@ require 'geocoder/results/base'
|
|
|
3
3
|
module Geocoder
|
|
4
4
|
module Result
|
|
5
5
|
class Geoip2 < Base
|
|
6
|
-
def address(format = :full)
|
|
7
|
-
s = state.to_s == '' ? '' : ", #{state_code}"
|
|
8
|
-
"#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, '')
|
|
9
|
-
end
|
|
10
6
|
|
|
11
7
|
def coordinates
|
|
12
8
|
%w[latitude longitude].map do |l|
|
|
@@ -62,12 +58,12 @@ module Geocoder
|
|
|
62
58
|
@language ||= default_language
|
|
63
59
|
end
|
|
64
60
|
|
|
65
|
-
private
|
|
66
|
-
|
|
67
61
|
def data
|
|
68
62
|
@data.to_hash
|
|
69
63
|
end
|
|
70
64
|
|
|
65
|
+
private
|
|
66
|
+
|
|
71
67
|
def default_language
|
|
72
68
|
@default_language = Geocoder.config[:language].to_s
|
|
73
69
|
end
|
|
@@ -59,11 +59,13 @@ module Geocoder::Result
|
|
|
59
59
|
private
|
|
60
60
|
|
|
61
61
|
def geolocalized?
|
|
62
|
-
try_to_extract('coordinates', geomlonlat)
|
|
62
|
+
!!try_to_extract('coordinates', geomlonlat)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def try_to_extract(key,
|
|
66
|
-
|
|
65
|
+
def try_to_extract(key, hash)
|
|
66
|
+
if hash.is_a?(Hash) and hash.include?(key)
|
|
67
|
+
hash[key]
|
|
68
|
+
end
|
|
67
69
|
end
|
|
68
70
|
end
|
|
69
71
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Ip2location < Base
|
|
5
|
+
|
|
6
|
+
def address(format = :full)
|
|
7
|
+
"#{city_name} #{zip_code}, #{country_name}".sub(/^[ ,]*/, '')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.response_attributes
|
|
11
|
+
%w[country_code country_name region_name city_name latitude longitude
|
|
12
|
+
zip_code time_zone isp domain net_speed idd_code area_code usage_type
|
|
13
|
+
weather_station_code weather_station_name mcc mnc mobile_brand elevation]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
response_attributes.each do |attr|
|
|
17
|
+
define_method attr do
|
|
18
|
+
@data[attr] || ""
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -3,11 +3,6 @@ require 'geocoder/results/base'
|
|
|
3
3
|
module Geocoder::Result
|
|
4
4
|
class IpdataCo < 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,60 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Ipstack < Base
|
|
5
|
+
|
|
6
|
+
def address(format = :full)
|
|
7
|
+
s = region_code.empty? ? "" : ", #{region_code}"
|
|
8
|
+
"#{city}#{s} #{zip}, #{country_name}".sub(/^[ ,]*/, "")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def state
|
|
12
|
+
@data['region_name']
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def state_code
|
|
16
|
+
@data['region_code']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def country
|
|
20
|
+
@data['country_name']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def postal_code
|
|
24
|
+
@data['zip'] || @data['zipcode'] || @data['zip_code']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.response_attributes
|
|
28
|
+
[
|
|
29
|
+
['ip', ''],
|
|
30
|
+
['hostname', ''],
|
|
31
|
+
['continent_code', ''],
|
|
32
|
+
['continent_name', ''],
|
|
33
|
+
['country_code', ''],
|
|
34
|
+
['country_name', ''],
|
|
35
|
+
['region_code', ''],
|
|
36
|
+
['region_name', ''],
|
|
37
|
+
['city', ''],
|
|
38
|
+
['zip', ''],
|
|
39
|
+
['latitude', 0],
|
|
40
|
+
['longitude', 0],
|
|
41
|
+
['location', {}],
|
|
42
|
+
['time_zone', {}],
|
|
43
|
+
['currency', {}],
|
|
44
|
+
['connection', {}],
|
|
45
|
+
['security', {}],
|
|
46
|
+
]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
response_attributes.each do |attr, default|
|
|
50
|
+
define_method attr do
|
|
51
|
+
@data[attr] || default
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def metro_code
|
|
56
|
+
Geocoder.log(:warn, "Ipstack does not implement `metro_code` in api results. Please discontinue use.")
|
|
57
|
+
0 # no longer implemented by ipstack
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -87,11 +87,6 @@ module Geocoder::Result
|
|
|
87
87
|
[data_hash[:latitude].to_f, data_hash[:longitude].to_f]
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
def address(format = :full)
|
|
91
|
-
s = state_code.to_s == "" ? "" : ", #{state_code}"
|
|
92
|
-
"#{city}#{s} #{postal_code}, #{country_code}".sub(/^[ ,]*/, "")
|
|
93
|
-
end
|
|
94
|
-
|
|
95
90
|
def city
|
|
96
91
|
data_hash[:city_name]
|
|
97
92
|
end
|
|
@@ -3,11 +3,6 @@ require 'geocoder/results/base'
|
|
|
3
3
|
module Geocoder::Result
|
|
4
4
|
class MaxmindLocal < Base
|
|
5
5
|
|
|
6
|
-
def address(format = :full)
|
|
7
|
-
s = state.to_s == "" ? "" : ", #{state}"
|
|
8
|
-
"#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def coordinates
|
|
12
7
|
[@data[:latitude], @data[:longitude]]
|
|
13
8
|
end
|
|
@@ -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,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
|
|
@@ -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/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
|
data/lib/geocoder/version.rb
CHANGED
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.5.0
|
|
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-
|
|
11
|
+
date: 2018-07-31 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,
|
|
@@ -68,9 +68,11 @@ files:
|
|
|
68
68
|
- lib/geocoder/lookups/google_places_search.rb
|
|
69
69
|
- lib/geocoder/lookups/google_premier.rb
|
|
70
70
|
- lib/geocoder/lookups/here.rb
|
|
71
|
+
- lib/geocoder/lookups/ip2location.rb
|
|
71
72
|
- lib/geocoder/lookups/ipapi_com.rb
|
|
72
73
|
- lib/geocoder/lookups/ipdata_co.rb
|
|
73
74
|
- lib/geocoder/lookups/ipinfo_io.rb
|
|
75
|
+
- lib/geocoder/lookups/ipstack.rb
|
|
74
76
|
- lib/geocoder/lookups/latlon.rb
|
|
75
77
|
- lib/geocoder/lookups/location_iq.rb
|
|
76
78
|
- lib/geocoder/lookups/mapbox.rb
|
|
@@ -80,13 +82,12 @@ files:
|
|
|
80
82
|
- lib/geocoder/lookups/maxmind_geoip2.rb
|
|
81
83
|
- lib/geocoder/lookups/maxmind_local.rb
|
|
82
84
|
- lib/geocoder/lookups/nominatim.rb
|
|
83
|
-
- lib/geocoder/lookups/okf.rb
|
|
84
85
|
- lib/geocoder/lookups/opencagedata.rb
|
|
85
|
-
- lib/geocoder/lookups/ovi.rb
|
|
86
86
|
- lib/geocoder/lookups/pelias.rb
|
|
87
87
|
- lib/geocoder/lookups/pickpoint.rb
|
|
88
88
|
- lib/geocoder/lookups/pointpin.rb
|
|
89
89
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
|
90
|
+
- lib/geocoder/lookups/postcodes_io.rb
|
|
90
91
|
- lib/geocoder/lookups/smarty_streets.rb
|
|
91
92
|
- lib/geocoder/lookups/telize.rb
|
|
92
93
|
- lib/geocoder/lookups/test.rb
|
|
@@ -119,9 +120,11 @@ files:
|
|
|
119
120
|
- lib/geocoder/results/google_places_search.rb
|
|
120
121
|
- lib/geocoder/results/google_premier.rb
|
|
121
122
|
- lib/geocoder/results/here.rb
|
|
123
|
+
- lib/geocoder/results/ip2location.rb
|
|
122
124
|
- lib/geocoder/results/ipapi_com.rb
|
|
123
125
|
- lib/geocoder/results/ipdata_co.rb
|
|
124
126
|
- lib/geocoder/results/ipinfo_io.rb
|
|
127
|
+
- lib/geocoder/results/ipstack.rb
|
|
125
128
|
- lib/geocoder/results/latlon.rb
|
|
126
129
|
- lib/geocoder/results/location_iq.rb
|
|
127
130
|
- lib/geocoder/results/mapbox.rb
|
|
@@ -131,13 +134,12 @@ files:
|
|
|
131
134
|
- lib/geocoder/results/maxmind_geoip2.rb
|
|
132
135
|
- lib/geocoder/results/maxmind_local.rb
|
|
133
136
|
- lib/geocoder/results/nominatim.rb
|
|
134
|
-
- lib/geocoder/results/okf.rb
|
|
135
137
|
- lib/geocoder/results/opencagedata.rb
|
|
136
|
-
- lib/geocoder/results/ovi.rb
|
|
137
138
|
- lib/geocoder/results/pelias.rb
|
|
138
139
|
- lib/geocoder/results/pickpoint.rb
|
|
139
140
|
- lib/geocoder/results/pointpin.rb
|
|
140
141
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
|
142
|
+
- lib/geocoder/results/postcodes_io.rb
|
|
141
143
|
- lib/geocoder/results/smarty_streets.rb
|
|
142
144
|
- lib/geocoder/results/telize.rb
|
|
143
145
|
- lib/geocoder/results/test.rb
|
|
@@ -159,7 +161,11 @@ licenses:
|
|
|
159
161
|
metadata:
|
|
160
162
|
source_code_uri: https://github.com/alexreisner/geocoder
|
|
161
163
|
changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
|
|
162
|
-
post_install_message:
|
|
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
|
+
|
|
163
169
|
rdoc_options: []
|
|
164
170
|
require_paths:
|
|
165
171
|
- lib
|
|
@@ -167,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
167
173
|
requirements:
|
|
168
174
|
- - ">="
|
|
169
175
|
- !ruby/object:Gem::Version
|
|
170
|
-
version:
|
|
176
|
+
version: 2.0.0
|
|
171
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
178
|
requirements:
|
|
173
179
|
- - ">="
|
data/lib/geocoder/lookups/okf.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require 'geocoder/lookups/base'
|
|
2
|
-
require "geocoder/results/okf"
|
|
3
|
-
|
|
4
|
-
module Geocoder::Lookup
|
|
5
|
-
class Okf < Base
|
|
6
|
-
|
|
7
|
-
def name
|
|
8
|
-
"Okf"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def query_url(query)
|
|
12
|
-
"#{protocol}://data.okf.fi/gis/1/geocode/json?" + url_query_string(query)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private # ---------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
def valid_response?(response)
|
|
18
|
-
json = parse_json(response.body)
|
|
19
|
-
status = json["status"] if json
|
|
20
|
-
super(response) and ['OK', 'ZERO_RESULTS'].include?(status)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def results(query)
|
|
24
|
-
return [] unless doc = fetch_data(query)
|
|
25
|
-
case doc['status']; when "OK" # OK status implies >0 results
|
|
26
|
-
return doc['results']
|
|
27
|
-
end
|
|
28
|
-
return []
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def query_url_okf_params(query)
|
|
32
|
-
params = {
|
|
33
|
-
(query.reverse_geocode? ? :latlng : :address) => query.sanitized_text,
|
|
34
|
-
:sensor => "false",
|
|
35
|
-
:language => (query.language || configuration.language)
|
|
36
|
-
}
|
|
37
|
-
params
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def query_url_params(query)
|
|
41
|
-
query_url_okf_params(query).merge(super)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
data/lib/geocoder/lookups/ovi.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
require 'geocoder/lookups/base'
|
|
2
|
-
require 'geocoder/results/ovi'
|
|
3
|
-
|
|
4
|
-
module Geocoder::Lookup
|
|
5
|
-
class Ovi < Base
|
|
6
|
-
|
|
7
|
-
def name
|
|
8
|
-
"Ovi"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def required_api_key_parts
|
|
12
|
-
[]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def query_url(query)
|
|
16
|
-
"#{protocol}://lbs.ovi.com/search/6.2/#{if query.reverse_geocode? then 'reverse' end}geocode.json?" + url_query_string(query)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private # ---------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
def results(query)
|
|
22
|
-
return [] unless doc = fetch_data(query)
|
|
23
|
-
return [] unless doc['Response'] && doc['Response']['View']
|
|
24
|
-
if r=doc['Response']['View']
|
|
25
|
-
return [] if r.nil? || !r.is_a?(Array) || r.empty?
|
|
26
|
-
return r.first['Result']
|
|
27
|
-
end
|
|
28
|
-
[]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def query_url_params(query)
|
|
32
|
-
options = {
|
|
33
|
-
:gen=>1,
|
|
34
|
-
:app_id=>api_key,
|
|
35
|
-
:app_code=>api_code
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if query.reverse_geocode?
|
|
39
|
-
super.merge(options).merge(
|
|
40
|
-
:prox=>query.sanitized_text,
|
|
41
|
-
:mode=>:retrieveAddresses
|
|
42
|
-
)
|
|
43
|
-
else
|
|
44
|
-
super.merge(options).merge(
|
|
45
|
-
:searchtext=>query.sanitized_text
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def api_key
|
|
51
|
-
if a=configuration.api_key
|
|
52
|
-
return a.first if a.is_a?(Array)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def api_code
|
|
57
|
-
if a=configuration.api_key
|
|
58
|
-
return a.last if a.is_a?(Array)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
data/lib/geocoder/results/okf.rb
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require 'geocoder/results/base'
|
|
2
|
-
|
|
3
|
-
module Geocoder::Result
|
|
4
|
-
class Okf < Base
|
|
5
|
-
|
|
6
|
-
def coordinates
|
|
7
|
-
['lat', 'lng'].map{ |i| geometry['location'][i] }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def address(format = :full)
|
|
11
|
-
formatted_address
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def city
|
|
15
|
-
fields = [:locality, :sublocality,
|
|
16
|
-
:administrative_area_level_3,
|
|
17
|
-
:administrative_area_level_2]
|
|
18
|
-
fields.each do |f|
|
|
19
|
-
if entity = address_components_of_type(f).first
|
|
20
|
-
return entity['long_name']
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
return nil # no appropriate components found
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def state
|
|
27
|
-
""
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def sub_state
|
|
31
|
-
""
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def state_code
|
|
35
|
-
""
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def country
|
|
39
|
-
if country = address_components_of_type(:country).first
|
|
40
|
-
country['long_name']
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def country_code
|
|
45
|
-
if country = address_components_of_type(:country).first
|
|
46
|
-
country['short_name']
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def postal_code
|
|
51
|
-
if postal = address_components_of_type(:postal_code).first
|
|
52
|
-
postal['long_name']
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def route
|
|
57
|
-
if route = address_components_of_type(:route).first
|
|
58
|
-
route['long_name']
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def street_number
|
|
63
|
-
if street_number = address_components_of_type(:street_number).first
|
|
64
|
-
street_number['long_name']
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def street_address
|
|
69
|
-
[route, street_number].compact.join(' ')
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def types
|
|
73
|
-
@data['types']
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def formatted_address
|
|
77
|
-
@data['formatted_address']
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def address_components
|
|
81
|
-
@data['address_components']
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
##
|
|
85
|
-
# Get address components of a given type. Valid types are defined in
|
|
86
|
-
# Google's Geocoding API documentation and include (among others):
|
|
87
|
-
#
|
|
88
|
-
# :street_number
|
|
89
|
-
# :locality
|
|
90
|
-
# :neighborhood
|
|
91
|
-
# :route
|
|
92
|
-
# :postal_code
|
|
93
|
-
#
|
|
94
|
-
def address_components_of_type(type)
|
|
95
|
-
address_components.select{ |c| c['types'].include?(type.to_s) }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def geometry
|
|
99
|
-
@data['geometry']
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def precision
|
|
103
|
-
geometry['location_type'] if geometry
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|