really-broken-geocoder 1.5.1
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 +557 -0
- data/LICENSE +20 -0
- data/README.md +3 -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 +22 -0
- data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +30 -0
- data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +30 -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/generators/geocoder/migration_version.rb +15 -0
- data/lib/geocoder.rb +48 -0
- data/lib/geocoder/cache.rb +94 -0
- data/lib/geocoder/calculations.rb +420 -0
- data/lib/geocoder/cli.rb +121 -0
- data/lib/geocoder/configuration.rb +137 -0
- data/lib/geocoder/configuration_hash.rb +11 -0
- data/lib/geocoder/esri_token.rb +38 -0
- data/lib/geocoder/exceptions.rb +40 -0
- data/lib/geocoder/ip_address.rb +26 -0
- data/lib/geocoder/kernel_logger.rb +25 -0
- data/lib/geocoder/logger.rb +47 -0
- data/lib/geocoder/lookup.rb +118 -0
- data/lib/geocoder/lookups/amap.rb +63 -0
- data/lib/geocoder/lookups/baidu.rb +63 -0
- data/lib/geocoder/lookups/baidu_ip.rb +30 -0
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +130 -0
- data/lib/geocoder/lookups/base.rb +348 -0
- data/lib/geocoder/lookups/bing.rb +82 -0
- data/lib/geocoder/lookups/db_ip_com.rb +52 -0
- data/lib/geocoder/lookups/dstk.rb +22 -0
- data/lib/geocoder/lookups/esri.rb +95 -0
- data/lib/geocoder/lookups/freegeoip.rb +60 -0
- data/lib/geocoder/lookups/geocoder_ca.rb +53 -0
- data/lib/geocoder/lookups/geocoder_us.rb +51 -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 +95 -0
- data/lib/geocoder/lookups/google_places_details.rb +50 -0
- data/lib/geocoder/lookups/google_places_search.rb +33 -0
- data/lib/geocoder/lookups/google_premier.rb +57 -0
- data/lib/geocoder/lookups/here.rb +77 -0
- data/lib/geocoder/lookups/ip2location.rb +75 -0
- data/lib/geocoder/lookups/ipapi_com.rb +82 -0
- data/lib/geocoder/lookups/ipdata_co.rb +62 -0
- data/lib/geocoder/lookups/ipinfo_io.rb +44 -0
- data/lib/geocoder/lookups/ipstack.rb +63 -0
- data/lib/geocoder/lookups/latlon.rb +59 -0
- data/lib/geocoder/lookups/location_iq.rb +50 -0
- data/lib/geocoder/lookups/mapbox.rb +59 -0
- data/lib/geocoder/lookups/mapquest.rb +58 -0
- data/lib/geocoder/lookups/maxmind.rb +90 -0
- data/lib/geocoder/lookups/maxmind_geoip2.rb +70 -0
- data/lib/geocoder/lookups/maxmind_local.rb +65 -0
- data/lib/geocoder/lookups/nominatim.rb +64 -0
- data/lib/geocoder/lookups/opencagedata.rb +65 -0
- data/lib/geocoder/lookups/pelias.rb +63 -0
- data/lib/geocoder/lookups/pickpoint.rb +41 -0
- data/lib/geocoder/lookups/pointpin.rb +69 -0
- data/lib/geocoder/lookups/postcode_anywhere_uk.rb +50 -0
- data/lib/geocoder/lookups/postcodes_io.rb +31 -0
- data/lib/geocoder/lookups/smarty_streets.rb +63 -0
- data/lib/geocoder/lookups/telize.rb +75 -0
- data/lib/geocoder/lookups/tencent.rb +59 -0
- data/lib/geocoder/lookups/test.rb +44 -0
- data/lib/geocoder/lookups/yandex.rb +62 -0
- data/lib/geocoder/models/active_record.rb +51 -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 +125 -0
- data/lib/geocoder/railtie.rb +26 -0
- data/lib/geocoder/request.rb +114 -0
- data/lib/geocoder/results/amap.rb +87 -0
- data/lib/geocoder/results/baidu.rb +79 -0
- data/lib/geocoder/results/baidu_ip.rb +62 -0
- data/lib/geocoder/results/ban_data_gouv_fr.rb +257 -0
- data/lib/geocoder/results/base.rb +79 -0
- data/lib/geocoder/results/bing.rb +52 -0
- data/lib/geocoder/results/db_ip_com.rb +58 -0
- data/lib/geocoder/results/dstk.rb +6 -0
- data/lib/geocoder/results/esri.rb +75 -0
- data/lib/geocoder/results/freegeoip.rb +40 -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 +78 -0
- data/lib/geocoder/results/geoip2.rb +76 -0
- data/lib/geocoder/results/geoportail_lu.rb +71 -0
- data/lib/geocoder/results/google.rb +150 -0
- data/lib/geocoder/results/google_places_details.rb +39 -0
- data/lib/geocoder/results/google_places_search.rb +52 -0
- data/lib/geocoder/results/google_premier.rb +6 -0
- data/lib/geocoder/results/here.rb +79 -0
- data/lib/geocoder/results/ip2location.rb +22 -0
- data/lib/geocoder/results/ipapi_com.rb +45 -0
- data/lib/geocoder/results/ipdata_co.rb +40 -0
- data/lib/geocoder/results/ipinfo_io.rb +48 -0
- data/lib/geocoder/results/ipstack.rb +60 -0
- data/lib/geocoder/results/latlon.rb +71 -0
- data/lib/geocoder/results/location_iq.rb +6 -0
- data/lib/geocoder/results/mapbox.rb +57 -0
- data/lib/geocoder/results/mapquest.rb +48 -0
- data/lib/geocoder/results/maxmind.rb +130 -0
- data/lib/geocoder/results/maxmind_geoip2.rb +9 -0
- data/lib/geocoder/results/maxmind_local.rb +44 -0
- data/lib/geocoder/results/nominatim.rb +109 -0
- data/lib/geocoder/results/opencagedata.rb +100 -0
- data/lib/geocoder/results/pelias.rb +58 -0
- data/lib/geocoder/results/pickpoint.rb +6 -0
- data/lib/geocoder/results/pointpin.rb +40 -0
- data/lib/geocoder/results/postcode_anywhere_uk.rb +42 -0
- data/lib/geocoder/results/postcodes_io.rb +40 -0
- data/lib/geocoder/results/smarty_streets.rb +142 -0
- data/lib/geocoder/results/telize.rb +40 -0
- data/lib/geocoder/results/tencent.rb +72 -0
- data/lib/geocoder/results/test.rb +33 -0
- data/lib/geocoder/results/yandex.rb +134 -0
- data/lib/geocoder/sql.rb +110 -0
- data/lib/geocoder/stores/active_record.rb +328 -0
- data/lib/geocoder/stores/base.rb +115 -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 +54 -0
- data/lib/tasks/maxmind.rake +73 -0
- metadata +186 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Amap < Base
|
5
|
+
|
6
|
+
def coordinates
|
7
|
+
location = @data['location'] || @data['roadinters'].try(:first).try(:[], 'location') \
|
8
|
+
|| address_components.try(:[], 'streetNumber').try(:[], 'location')
|
9
|
+
location.to_s.split(",").reverse.map(&:to_f)
|
10
|
+
end
|
11
|
+
|
12
|
+
def address
|
13
|
+
formatted_address
|
14
|
+
end
|
15
|
+
|
16
|
+
def state
|
17
|
+
province
|
18
|
+
end
|
19
|
+
|
20
|
+
def province
|
21
|
+
address_components['province']
|
22
|
+
end
|
23
|
+
|
24
|
+
def city
|
25
|
+
address_components['city'] == [] ? province : address_components["city"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def district
|
29
|
+
address_components['district']
|
30
|
+
end
|
31
|
+
|
32
|
+
def street
|
33
|
+
if address_components["neighborhood"]["name"] != []
|
34
|
+
return address_components["neighborhood"]["name"]
|
35
|
+
elsif address_components['township'] != []
|
36
|
+
return address_components["township"]
|
37
|
+
else
|
38
|
+
return @data['street'] || address_components['streetNumber'].try(:[], 'street')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def street_number
|
43
|
+
@data['number'] || address_components['streetNumber'].try(:[], 'number')
|
44
|
+
end
|
45
|
+
|
46
|
+
def formatted_address
|
47
|
+
@data['formatted_address']
|
48
|
+
end
|
49
|
+
|
50
|
+
def address_components
|
51
|
+
@data['addressComponent'] || @data
|
52
|
+
end
|
53
|
+
|
54
|
+
def state_code
|
55
|
+
""
|
56
|
+
end
|
57
|
+
|
58
|
+
def postal_code
|
59
|
+
""
|
60
|
+
end
|
61
|
+
|
62
|
+
def country
|
63
|
+
"China"
|
64
|
+
end
|
65
|
+
|
66
|
+
def country_code
|
67
|
+
"CN"
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Get address components of a given type. Valid types are defined in
|
72
|
+
# Baidu's Geocoding API documentation and include (among others):
|
73
|
+
#
|
74
|
+
# :business
|
75
|
+
# :cityCode
|
76
|
+
#
|
77
|
+
def self.response_attributes
|
78
|
+
%w[roads pois roadinters]
|
79
|
+
end
|
80
|
+
|
81
|
+
response_attributes.each do |a|
|
82
|
+
define_method a do
|
83
|
+
@data[a]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Baidu < Base
|
5
|
+
|
6
|
+
def coordinates
|
7
|
+
['lat', 'lng'].map{ |i| @data['location'][i] }
|
8
|
+
end
|
9
|
+
|
10
|
+
def address
|
11
|
+
@data['formatted_address']
|
12
|
+
end
|
13
|
+
|
14
|
+
def province
|
15
|
+
@data['addressComponent'] and @data['addressComponent']['province'] or ""
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :state, :province
|
19
|
+
|
20
|
+
def city
|
21
|
+
@data['addressComponent'] and @data['addressComponent']['city'] or ""
|
22
|
+
end
|
23
|
+
|
24
|
+
def district
|
25
|
+
@data['addressComponent'] and @data['addressComponent']['district'] or ""
|
26
|
+
end
|
27
|
+
|
28
|
+
def street
|
29
|
+
@data['addressComponent'] and @data['addressComponent']['street'] or ""
|
30
|
+
end
|
31
|
+
|
32
|
+
def street_number
|
33
|
+
@data['addressComponent'] and @data['addressComponent']['street_number']
|
34
|
+
end
|
35
|
+
|
36
|
+
def formatted_address
|
37
|
+
@data['formatted_address'] or ""
|
38
|
+
end
|
39
|
+
|
40
|
+
alias_method :address, :formatted_address
|
41
|
+
|
42
|
+
def address_components
|
43
|
+
@data['addressComponent']
|
44
|
+
end
|
45
|
+
|
46
|
+
def state_code
|
47
|
+
""
|
48
|
+
end
|
49
|
+
|
50
|
+
def postal_code
|
51
|
+
""
|
52
|
+
end
|
53
|
+
|
54
|
+
def country
|
55
|
+
"China"
|
56
|
+
end
|
57
|
+
|
58
|
+
def country_code
|
59
|
+
"CN"
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Get address components of a given type. Valid types are defined in
|
64
|
+
# Baidu's Geocoding API documentation and include (among others):
|
65
|
+
#
|
66
|
+
# :business
|
67
|
+
# :cityCode
|
68
|
+
#
|
69
|
+
def self.response_attributes
|
70
|
+
%w[business cityCode]
|
71
|
+
end
|
72
|
+
|
73
|
+
response_attributes.each do |a|
|
74
|
+
define_method a do
|
75
|
+
@data[a]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -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,257 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'geocoder/results/base'
|
3
|
+
|
4
|
+
module Geocoder::Result
|
5
|
+
class BanDataGouvFr < Base
|
6
|
+
|
7
|
+
#### BASE METHODS ####
|
8
|
+
|
9
|
+
def self.response_attributes
|
10
|
+
%w[limit attribution version licence type features]
|
11
|
+
end
|
12
|
+
|
13
|
+
response_attributes.each do |a|
|
14
|
+
unless method_defined?(a)
|
15
|
+
define_method a do
|
16
|
+
@data[a]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#### BEST RESULT ####
|
22
|
+
|
23
|
+
def result
|
24
|
+
features[0] if features.any?
|
25
|
+
end
|
26
|
+
|
27
|
+
#### GEOMETRY ####
|
28
|
+
|
29
|
+
def geometry
|
30
|
+
result['geometry'] if result
|
31
|
+
end
|
32
|
+
|
33
|
+
def precision
|
34
|
+
geometry['type'] if geometry
|
35
|
+
end
|
36
|
+
|
37
|
+
def coordinates
|
38
|
+
coords = geometry["coordinates"]
|
39
|
+
return [coords[1].to_f, coords[0].to_f]
|
40
|
+
end
|
41
|
+
|
42
|
+
#### PROPERTIES ####
|
43
|
+
|
44
|
+
# List of raw attrbutes returned by BAN data gouv fr API:
|
45
|
+
#
|
46
|
+
# :id => [string] UUID of the result, said to be not stable
|
47
|
+
# atm, based on IGN reference (Institut national de
|
48
|
+
# l'information géographique et forestière)
|
49
|
+
#
|
50
|
+
# :type => [string] result type (housenumber, street, city,
|
51
|
+
# town, village, locality)
|
52
|
+
#
|
53
|
+
# :score => [float] value between 0 and 1 giving result's
|
54
|
+
# relevancy
|
55
|
+
#
|
56
|
+
# :housenumber => [string] street number and extra information
|
57
|
+
# (bis, ter, A, B)
|
58
|
+
#
|
59
|
+
# :street => [string] street name
|
60
|
+
#
|
61
|
+
# :name => [string] housenumber and street name
|
62
|
+
#
|
63
|
+
# :postcode => [string] city post code (used for mails by La Poste,
|
64
|
+
# beware many cities got severeal postcodes)
|
65
|
+
#
|
66
|
+
# :citycode => [string] city code (INSEE reference,
|
67
|
+
# consider it as a french institutional UUID)
|
68
|
+
#
|
69
|
+
# :city => [string] city name
|
70
|
+
#
|
71
|
+
# :context => [string] department code, department name and
|
72
|
+
# region code
|
73
|
+
#
|
74
|
+
# :label => [string] full address without state, country name
|
75
|
+
# and country code
|
76
|
+
#
|
77
|
+
# CITIES ONLY PROPERTIES
|
78
|
+
#
|
79
|
+
# :adm_weight => [string] administrative weight (importance) of
|
80
|
+
# the city
|
81
|
+
#
|
82
|
+
# :population => [float] number of inhabitants with a 1000 factor
|
83
|
+
#
|
84
|
+
# For up to date doc (in french only) : https://adresse.data.gouv.fr/api/
|
85
|
+
#
|
86
|
+
def properties
|
87
|
+
result['properties'] if result
|
88
|
+
end
|
89
|
+
|
90
|
+
# List of usable Geocoder results' methods
|
91
|
+
#
|
92
|
+
# score => [float] result relevance 0 to 1
|
93
|
+
#
|
94
|
+
# location_id => [string] location's IGN UUID
|
95
|
+
#
|
96
|
+
# result_type => [string] housenumber / street / city
|
97
|
+
# / town / village / locality
|
98
|
+
#
|
99
|
+
# international_address => [string] full address with country code
|
100
|
+
#
|
101
|
+
# national_address => [string] full address with country code
|
102
|
+
#
|
103
|
+
# street_address => [string] housenumber + extra inf
|
104
|
+
# + street name
|
105
|
+
#
|
106
|
+
# street_number => [string] housenumber + extra inf
|
107
|
+
# (bis, ter, etc)
|
108
|
+
#
|
109
|
+
# street_name => [string] street's name
|
110
|
+
#
|
111
|
+
# city_name => [string] city's name
|
112
|
+
#
|
113
|
+
# city_code => [string] city's INSEE UUID
|
114
|
+
#
|
115
|
+
# postal_code => [string] city's postal code (used for mails)
|
116
|
+
#
|
117
|
+
# context => [string] city's department code, department
|
118
|
+
# name and region name
|
119
|
+
#
|
120
|
+
# demartment_name => [string] city's department name
|
121
|
+
#
|
122
|
+
# department_code => [string] city's department INSEE UUID
|
123
|
+
#
|
124
|
+
# region_name => [string] city's region name
|
125
|
+
#
|
126
|
+
# population => [string] city's inhabitants count
|
127
|
+
#
|
128
|
+
# administrative_weight => [integer] city's importance on a scale
|
129
|
+
# from 6 (capital city) to 1 (regular village)
|
130
|
+
#
|
131
|
+
def score
|
132
|
+
properties['score']
|
133
|
+
end
|
134
|
+
|
135
|
+
def location_id
|
136
|
+
properties['id']
|
137
|
+
end
|
138
|
+
|
139
|
+
# Types
|
140
|
+
#
|
141
|
+
# housenumber
|
142
|
+
# street
|
143
|
+
# city
|
144
|
+
# town
|
145
|
+
# village
|
146
|
+
# locality
|
147
|
+
#
|
148
|
+
def result_type
|
149
|
+
properties['type']
|
150
|
+
end
|
151
|
+
|
152
|
+
def international_address
|
153
|
+
"#{national_address}, #{country}"
|
154
|
+
end
|
155
|
+
|
156
|
+
def national_address
|
157
|
+
properties['label']
|
158
|
+
end
|
159
|
+
|
160
|
+
def street_address
|
161
|
+
properties['name']
|
162
|
+
end
|
163
|
+
|
164
|
+
def street_number
|
165
|
+
properties['housenumber']
|
166
|
+
end
|
167
|
+
|
168
|
+
def street_name
|
169
|
+
properties['street']
|
170
|
+
end
|
171
|
+
|
172
|
+
def city_name
|
173
|
+
properties['city']
|
174
|
+
end
|
175
|
+
|
176
|
+
def city_code
|
177
|
+
properties['citycode']
|
178
|
+
end
|
179
|
+
|
180
|
+
def postal_code
|
181
|
+
properties['postcode']
|
182
|
+
end
|
183
|
+
|
184
|
+
def context
|
185
|
+
properties['context'].split(/,/).map(&:strip)
|
186
|
+
end
|
187
|
+
|
188
|
+
def department_code
|
189
|
+
context[0] if context.length > 0
|
190
|
+
end
|
191
|
+
|
192
|
+
# Monkey logic to handle fact Paris is both a city and a department
|
193
|
+
# in Île-de-France region
|
194
|
+
def department_name
|
195
|
+
if context.length > 1
|
196
|
+
if context[1] == "Île-de-France"
|
197
|
+
"Paris"
|
198
|
+
else
|
199
|
+
context[1]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def region_name
|
205
|
+
if context.length == 2 && context[1] == "Île-de-France"
|
206
|
+
context[1]
|
207
|
+
elsif context.length > 2
|
208
|
+
context[2]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def country
|
213
|
+
"France"
|
214
|
+
end
|
215
|
+
|
216
|
+
# Country code types
|
217
|
+
# FR : France
|
218
|
+
# GF : Guyane Française
|
219
|
+
# RE : Réunion
|
220
|
+
# NC : Nouvelle-Calédonie
|
221
|
+
# GP : Guadeloupe
|
222
|
+
# MQ : Martinique
|
223
|
+
# MU : Maurice
|
224
|
+
# PF : Polynésie française
|
225
|
+
#
|
226
|
+
# Will need refacto to handle different country codes, but BAN API
|
227
|
+
# is currently mainly designed for geocode FR country code addresses
|
228
|
+
def country_code
|
229
|
+
"FR"
|
230
|
+
end
|
231
|
+
|
232
|
+
#### ALIAS METHODS ####
|
233
|
+
|
234
|
+
alias_method :address, :international_address
|
235
|
+
alias_method :street, :street_name
|
236
|
+
alias_method :city, :city_name
|
237
|
+
alias_method :state, :region_name
|
238
|
+
alias_method :state_code, :state
|
239
|
+
|
240
|
+
#### CITIES' METHODS ####
|
241
|
+
|
242
|
+
def population
|
243
|
+
(properties['population'].to_f * 1000).to_i if city?(result_type)
|
244
|
+
end
|
245
|
+
|
246
|
+
def administrative_weight
|
247
|
+
properties['adm_weight'].to_i if city?(result_type)
|
248
|
+
end
|
249
|
+
|
250
|
+
private
|
251
|
+
|
252
|
+
def city?(result_type)
|
253
|
+
%w(village town city).include?(result_type)
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
end
|