Class: Geocoder::Result::Baidu
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Baidu
show all
- Defined in:
- lib/geocoder/results/baidu.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province_code
Class Method Details
.response_attributes ⇒ Object
Get address components of a given type. Valid types are defined in Baidu’s Geocoding API documentation and include (among others):
:business
:cityCode
69
70
71
|
# File 'lib/geocoder/results/baidu.rb', line 69
def self.response_attributes
%w[business cityCode]
end
|
Instance Method Details
#address ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/baidu.rb', line 10
def address
@data['formatted_address']
end
|
#address_components ⇒ Object
42
43
44
|
# File 'lib/geocoder/results/baidu.rb', line 42
def address_components
@data['addressComponent']
end
|
#city ⇒ Object
22
23
24
|
# File 'lib/geocoder/results/baidu.rb', line 22
def city
@data['addressComponent']['city']
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/baidu.rb', line 6
def coordinates
['lat', 'lng'].map{ |i| @data['location'][i] }
end
|
#country ⇒ Object
54
55
56
|
# File 'lib/geocoder/results/baidu.rb', line 54
def country
"China"
end
|
#country_code ⇒ Object
58
59
60
|
# File 'lib/geocoder/results/baidu.rb', line 58
def country_code
"CN"
end
|
#district ⇒ Object
26
27
28
|
# File 'lib/geocoder/results/baidu.rb', line 26
def district
@data['addressComponent']['district']
end
|
38
39
40
|
# File 'lib/geocoder/results/baidu.rb', line 38
def formatted_address
@data['formatted_address']
end
|
#postal_code ⇒ Object
50
51
52
|
# File 'lib/geocoder/results/baidu.rb', line 50
def postal_code
""
end
|
#province ⇒ Object
18
19
20
|
# File 'lib/geocoder/results/baidu.rb', line 18
def province
@data['addressComponent']['province']
end
|
#state ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/baidu.rb', line 14
def state
province
end
|
#state_code ⇒ Object
46
47
48
|
# File 'lib/geocoder/results/baidu.rb', line 46
def state_code
""
end
|
#street ⇒ Object
30
31
32
|
# File 'lib/geocoder/results/baidu.rb', line 30
def street
@data['addressComponent']['street']
end
|
#street_number ⇒ Object
34
35
36
|
# File 'lib/geocoder/results/baidu.rb', line 34
def street_number
@data['addressComponent']['street_number']
end
|