broken-geocoder 1.3.4
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 +7 -0
- data/CHANGELOG.md +467 -0
- data/LICENSE +20 -0
- data/README.md +1193 -0
- data/bin/geocode +5 -0
- data/examples/autoexpire_cache_dalli.rb +62 -0
- data/examples/autoexpire_cache_redis.rb +28 -0
- data/examples/cache_bypass.rb +48 -0
- data/examples/reverse_geocode_job.rb +40 -0
- data/lib/generators/geocoder/config/config_generator.rb +14 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +21 -0
- data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +28 -0
- data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +28 -0
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +30 -0
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb +17 -0
- data/lib/geocoder.rb +48 -0
- data/lib/geocoder/cache.rb +90 -0
- data/lib/geocoder/calculations.rb +431 -0
- data/lib/geocoder/cli.rb +121 -0
- data/lib/geocoder/configuration.rb +129 -0
- data/lib/geocoder/configuration_hash.rb +11 -0
- data/lib/geocoder/esri_token.rb +38 -0
- data/lib/geocoder/exceptions.rb +37 -0
- data/lib/geocoder/ip_address.rb +13 -0
- data/lib/geocoder/kernel_logger.rb +25 -0
- data/lib/geocoder/logger.rb +47 -0
- data/lib/geocoder/lookup.rb +110 -0
- data/lib/geocoder/lookups/baidu.rb +59 -0
- data/lib/geocoder/lookups/baidu_ip.rb +59 -0
- data/lib/geocoder/lookups/base.rb +325 -0
- data/lib/geocoder/lookups/bing.rb +80 -0
- data/lib/geocoder/lookups/dstk.rb +20 -0
- data/lib/geocoder/lookups/esri.rb +64 -0
- data/lib/geocoder/lookups/freegeoip.rb +51 -0
- data/lib/geocoder/lookups/geocoder_ca.rb +53 -0
- data/lib/geocoder/lookups/geocoder_us.rb +43 -0
- data/lib/geocoder/lookups/geocodio.rb +42 -0
- data/lib/geocoder/lookups/geoip2.rb +45 -0
- data/lib/geocoder/lookups/geoportail_lu.rb +65 -0
- data/lib/geocoder/lookups/google.rb +91 -0
- data/lib/geocoder/lookups/google_places_details.rb +50 -0
- data/lib/geocoder/lookups/google_premier.rb +47 -0
- data/lib/geocoder/lookups/here.rb +62 -0
- data/lib/geocoder/lookups/ipapi_com.rb +86 -0
- data/lib/geocoder/lookups/ipinfo_io.rb +55 -0
- data/lib/geocoder/lookups/latlon.rb +59 -0
- data/lib/geocoder/lookups/mapbox.rb +53 -0
- data/lib/geocoder/lookups/mapquest.rb +59 -0
- data/lib/geocoder/lookups/mapzen.rb +15 -0
- data/lib/geocoder/lookups/maxmind.rb +90 -0
- data/lib/geocoder/lookups/maxmind_geoip2.rb +69 -0
- data/lib/geocoder/lookups/maxmind_local.rb +65 -0
- data/lib/geocoder/lookups/nominatim.rb +52 -0
- data/lib/geocoder/lookups/okf.rb +44 -0
- data/lib/geocoder/lookups/opencagedata.rb +58 -0
- data/lib/geocoder/lookups/ovi.rb +62 -0
- data/lib/geocoder/lookups/pelias.rb +64 -0
- data/lib/geocoder/lookups/pointpin.rb +68 -0
- data/lib/geocoder/lookups/postcode_anywhere_uk.rb +51 -0
- data/lib/geocoder/lookups/smarty_streets.rb +50 -0
- data/lib/geocoder/lookups/telize.rb +55 -0
- data/lib/geocoder/lookups/test.rb +44 -0
- data/lib/geocoder/lookups/yandex.rb +58 -0
- data/lib/geocoder/models/active_record.rb +50 -0
- data/lib/geocoder/models/base.rb +39 -0
- data/lib/geocoder/models/mongo_base.rb +62 -0
- data/lib/geocoder/models/mongo_mapper.rb +26 -0
- data/lib/geocoder/models/mongoid.rb +32 -0
- data/lib/geocoder/query.rb +111 -0
- data/lib/geocoder/railtie.rb +26 -0
- data/lib/geocoder/request.rb +83 -0
- data/lib/geocoder/results/baidu.rb +79 -0
- data/lib/geocoder/results/baidu_ip.rb +62 -0
- data/lib/geocoder/results/base.rb +67 -0
- data/lib/geocoder/results/bing.rb +52 -0
- data/lib/geocoder/results/dstk.rb +6 -0
- data/lib/geocoder/results/esri.rb +75 -0
- data/lib/geocoder/results/freegeoip.rb +45 -0
- data/lib/geocoder/results/geocoder_ca.rb +60 -0
- data/lib/geocoder/results/geocoder_us.rb +39 -0
- data/lib/geocoder/results/geocodio.rb +70 -0
- data/lib/geocoder/results/geoip2.rb +62 -0
- data/lib/geocoder/results/geoportail_lu.rb +69 -0
- data/lib/geocoder/results/google.rb +139 -0
- data/lib/geocoder/results/google_places_details.rb +35 -0
- data/lib/geocoder/results/google_premier.rb +6 -0
- data/lib/geocoder/results/here.rb +71 -0
- data/lib/geocoder/results/ipapi_com.rb +45 -0
- data/lib/geocoder/results/ipinfo_io.rb +48 -0
- data/lib/geocoder/results/latlon.rb +71 -0
- data/lib/geocoder/results/mapbox.rb +47 -0
- data/lib/geocoder/results/mapquest.rb +48 -0
- data/lib/geocoder/results/mapzen.rb +5 -0
- data/lib/geocoder/results/maxmind.rb +135 -0
- data/lib/geocoder/results/maxmind_geoip2.rb +9 -0
- data/lib/geocoder/results/maxmind_local.rb +49 -0
- data/lib/geocoder/results/nominatim.rb +99 -0
- data/lib/geocoder/results/okf.rb +106 -0
- data/lib/geocoder/results/opencagedata.rb +90 -0
- data/lib/geocoder/results/ovi.rb +71 -0
- data/lib/geocoder/results/pelias.rb +58 -0
- data/lib/geocoder/results/pointpin.rb +40 -0
- data/lib/geocoder/results/postcode_anywhere_uk.rb +42 -0
- data/lib/geocoder/results/smarty_streets.rb +106 -0
- data/lib/geocoder/results/telize.rb +45 -0
- data/lib/geocoder/results/test.rb +33 -0
- data/lib/geocoder/results/yandex.rb +92 -0
- data/lib/geocoder/sql.rb +107 -0
- data/lib/geocoder/stores/active_record.rb +305 -0
- data/lib/geocoder/stores/base.rb +116 -0
- data/lib/geocoder/stores/mongo_base.rb +58 -0
- data/lib/geocoder/stores/mongo_mapper.rb +13 -0
- data/lib/geocoder/stores/mongoid.rb +13 -0
- data/lib/geocoder/version.rb +3 -0
- data/lib/hash_recursive_merge.rb +74 -0
- data/lib/maxmind_database.rb +109 -0
- data/lib/tasks/geocoder.rake +38 -0
- data/lib/tasks/maxmind.rake +73 -0
- metadata +167 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class BaiduIp < Base
|
|
5
|
+
def coordinates
|
|
6
|
+
[point['y'].to_f, point['x'].to_f]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def address
|
|
10
|
+
@data['address']
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def state
|
|
14
|
+
province
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def province
|
|
18
|
+
address_detail['province']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def city
|
|
22
|
+
address_detail['city']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def district
|
|
26
|
+
address_detail['district']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def street
|
|
30
|
+
address_detail['street']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def street_number
|
|
34
|
+
address_detail['street_number']
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def state_code
|
|
38
|
+
""
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def postal_code
|
|
42
|
+
""
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def country
|
|
46
|
+
"China"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def country_code
|
|
50
|
+
"CN"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
def address_detail
|
|
55
|
+
@data['address_detail']
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def point
|
|
59
|
+
@data['point']
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Geocoder
|
|
2
|
+
module Result
|
|
3
|
+
class Base
|
|
4
|
+
|
|
5
|
+
# data (hash) fetched from geocoding service
|
|
6
|
+
attr_accessor :data
|
|
7
|
+
|
|
8
|
+
# true if result came from cache, false if from request to geocoding
|
|
9
|
+
# service; nil if cache is not configured
|
|
10
|
+
attr_accessor :cache_hit
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# Takes a hash of data from a parsed geocoding service response.
|
|
14
|
+
#
|
|
15
|
+
def initialize(data)
|
|
16
|
+
@data = data
|
|
17
|
+
@cache_hit = nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# A string in the given format.
|
|
22
|
+
#
|
|
23
|
+
def address(format = :full)
|
|
24
|
+
fail
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# A two-element array: [lat, lon].
|
|
29
|
+
#
|
|
30
|
+
def coordinates
|
|
31
|
+
[@data['latitude'].to_f, @data['longitude'].to_f]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def latitude
|
|
35
|
+
coordinates[0]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def longitude
|
|
39
|
+
coordinates[1]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def state
|
|
43
|
+
fail
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def province
|
|
47
|
+
state
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def state_code
|
|
51
|
+
fail
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def province_code
|
|
55
|
+
state_code
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def country
|
|
59
|
+
fail
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def country_code
|
|
63
|
+
fail
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Bing < Base
|
|
5
|
+
|
|
6
|
+
def address(format = :full)
|
|
7
|
+
@data['address']['formattedAddress']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def city
|
|
11
|
+
@data['address']['locality']
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def state_code
|
|
15
|
+
@data['address']['adminDistrict']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
alias_method :state, :state_code
|
|
19
|
+
|
|
20
|
+
def country
|
|
21
|
+
@data['address']['countryRegion']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
alias_method :country_code, :country
|
|
25
|
+
|
|
26
|
+
def postal_code
|
|
27
|
+
@data['address']['postalCode']
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def coordinates
|
|
31
|
+
@data['point']['coordinates']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def address_data
|
|
35
|
+
@data['address']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def viewport
|
|
39
|
+
@data['bbox']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.response_attributes
|
|
43
|
+
%w[bbox name confidence entityType]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
response_attributes.each do |a|
|
|
47
|
+
define_method a do
|
|
48
|
+
@data[a]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Esri < Base
|
|
5
|
+
|
|
6
|
+
def address
|
|
7
|
+
address_key = reverse_geocode? ? 'Address' : 'Match_addr'
|
|
8
|
+
attributes[address_key]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def city
|
|
12
|
+
if !reverse_geocode? && is_city?
|
|
13
|
+
place_name
|
|
14
|
+
else
|
|
15
|
+
attributes['City']
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def state_code
|
|
20
|
+
attributes['Region']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
alias_method :state, :state_code
|
|
24
|
+
|
|
25
|
+
def country
|
|
26
|
+
country_key = reverse_geocode? ? "CountryCode" : "Country"
|
|
27
|
+
attributes[country_key]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
alias_method :country_code, :country
|
|
31
|
+
|
|
32
|
+
def postal_code
|
|
33
|
+
attributes['Postal']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def place_name
|
|
37
|
+
place_name_key = reverse_geocode? ? "Address" : "PlaceName"
|
|
38
|
+
attributes[place_name_key]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def place_type
|
|
42
|
+
reverse_geocode? ? "Address" : attributes['Type']
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def coordinates
|
|
46
|
+
[geometry["y"], geometry["x"]]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def viewport
|
|
50
|
+
north = attributes['Ymax']
|
|
51
|
+
south = attributes['Ymin']
|
|
52
|
+
east = attributes['Xmax']
|
|
53
|
+
west = attributes['Xmin']
|
|
54
|
+
[south, west, north, east]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def attributes
|
|
60
|
+
reverse_geocode? ? @data['address'] : @data['locations'].first['feature']['attributes']
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def geometry
|
|
64
|
+
reverse_geocode? ? @data["location"] : @data['locations'].first['feature']["geometry"]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def reverse_geocode?
|
|
68
|
+
@data['locations'].nil?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def is_city?
|
|
72
|
+
['City', 'State Capital', 'National Capital'].include?(place_type)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Freegeoip < Base
|
|
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
|
+
def city
|
|
12
|
+
@data['city']
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def state
|
|
16
|
+
@data['region_name']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def state_code
|
|
20
|
+
@data['region_code']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def country
|
|
24
|
+
@data['country_name']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def country_code
|
|
28
|
+
@data['country_code']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def postal_code
|
|
32
|
+
@data['zipcode'] || @data['zip_code']
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.response_attributes
|
|
36
|
+
%w[metro_code ip]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
response_attributes.each do |a|
|
|
40
|
+
define_method a do
|
|
41
|
+
@data[a]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class GeocoderCa < Base
|
|
5
|
+
|
|
6
|
+
def coordinates
|
|
7
|
+
[@data['latt'].to_f, @data['longt'].to_f]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def address(format = :full)
|
|
11
|
+
"#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def street_address
|
|
15
|
+
"#{@data['stnumber']} #{@data['staddress']}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def city
|
|
19
|
+
@data['city']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def state
|
|
23
|
+
@data['prov']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
alias_method :state_code, :state
|
|
27
|
+
|
|
28
|
+
def postal_code
|
|
29
|
+
@data['postal']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def country
|
|
33
|
+
country_code == 'CA' ? 'Canada' : 'United States'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def country_code
|
|
37
|
+
return nil if state.nil? || state == ""
|
|
38
|
+
canadian_province_abbreviations.include?(state) ? "CA" : "US"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.response_attributes
|
|
42
|
+
%w[latt longt inlatt inlongt distance stnumber staddress prov
|
|
43
|
+
NearRoad NearRoadDistance betweenRoad1 betweenRoad2
|
|
44
|
+
intersection major_intersection]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
response_attributes.each do |a|
|
|
48
|
+
define_method a do
|
|
49
|
+
@data[a]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
private # ----------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
def canadian_province_abbreviations
|
|
57
|
+
%w[ON QC NS NB MB BC PE SK AB NL]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class GeocoderUs < Base
|
|
5
|
+
def coordinates
|
|
6
|
+
[@data[0].to_f, @data[1].to_f]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def address(format = :full)
|
|
10
|
+
"#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def street_address
|
|
14
|
+
@data[2]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def city
|
|
18
|
+
@data[3]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def state
|
|
22
|
+
@data[4]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
alias_method :state_code, :state
|
|
26
|
+
|
|
27
|
+
def postal_code
|
|
28
|
+
@data[5]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def country
|
|
32
|
+
'United States'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def country_code
|
|
36
|
+
'US'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'geocoder/results/base'
|
|
2
|
+
|
|
3
|
+
module Geocoder::Result
|
|
4
|
+
class Geocodio < Base
|
|
5
|
+
def number
|
|
6
|
+
address_components["number"]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def street
|
|
10
|
+
address_components["street"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def suffix
|
|
14
|
+
address_components["suffix"]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def street_address
|
|
18
|
+
[number, address_components["formatted_street"]].compact.join(' ')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def state
|
|
22
|
+
address_components["state"]
|
|
23
|
+
end
|
|
24
|
+
alias_method :state_code, :state
|
|
25
|
+
|
|
26
|
+
def zip
|
|
27
|
+
address_components["zip"]
|
|
28
|
+
end
|
|
29
|
+
alias_method :postal_code, :zip
|
|
30
|
+
|
|
31
|
+
def country
|
|
32
|
+
"United States" # Geocodio only supports the US
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def country_code
|
|
36
|
+
"US" # Geocodio only supports the US
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def city
|
|
40
|
+
address_components["city"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def postdirectional
|
|
44
|
+
address_components["postdirectional"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def location
|
|
48
|
+
@data['location']
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def coordinates
|
|
52
|
+
['lat', 'lng'].map{ |i| location[i].to_f } if location
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def accuracy
|
|
56
|
+
@data['accuracy'].to_f if @data.key?('accuracy')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def formatted_address(format = :full)
|
|
60
|
+
@data['formatted_address']
|
|
61
|
+
end
|
|
62
|
+
alias_method :address, :formatted_address
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def address_components
|
|
67
|
+
@data['address_components'] || {}
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|