Class: Geocoder::Result::Amap
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Amap
show all
- Defined in:
- lib/geocoder/results/amap.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
75
76
77
|
# File 'lib/geocoder/results/amap.rb', line 75
def self.response_attributes
%w[roads pois roadinters]
end
|
Instance Method Details
#address ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/amap.rb', line 10
def address
@data['formatted_address']
end
|
#address_components ⇒ Object
48
49
50
|
# File 'lib/geocoder/results/amap.rb', line 48
def address_components
@data['addressComponent']
end
|
#city ⇒ Object
22
23
24
|
# File 'lib/geocoder/results/amap.rb', line 22
def city
address_components['city'] == [] ? province : address_components["city"]
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/amap.rb', line 6
def coordinates
@data["roadinters"]['location'].split(",")
end
|
#country ⇒ Object
60
61
62
|
# File 'lib/geocoder/results/amap.rb', line 60
def country
"China"
end
|
#country_code ⇒ Object
64
65
66
|
# File 'lib/geocoder/results/amap.rb', line 64
def country_code
"CN"
end
|
#district ⇒ Object
26
27
28
|
# File 'lib/geocoder/results/amap.rb', line 26
def district
address_components['district']
end
|
44
45
46
|
# File 'lib/geocoder/results/amap.rb', line 44
def formatted_address
@data['formatted_address']
end
|
#postal_code ⇒ Object
56
57
58
|
# File 'lib/geocoder/results/amap.rb', line 56
def postal_code
""
end
|
#province ⇒ Object
18
19
20
|
# File 'lib/geocoder/results/amap.rb', line 18
def province
address_components['province']
end
|
#state ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/amap.rb', line 14
def state
province
end
|
#state_code ⇒ Object
52
53
54
|
# File 'lib/geocoder/results/amap.rb', line 52
def state_code
""
end
|
#street ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/geocoder/results/amap.rb', line 30
def street
if address_components["neighborhood"]["name"] != []
return address_components["neighborhood"]["name"]
elsif address_components["streetNumber"]["street"] != []
return address_components["streetNumber"]["street"]
else
return address_components["township"]
end
end
|
#street_number ⇒ Object
40
41
42
|
# File 'lib/geocoder/results/amap.rb', line 40
def street_number
address_components['streetNumber']["number"]
end
|