Class: Geocoder::Result::Tencent
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Tencent
show all
- Defined in:
- lib/geocoder/results/tencent.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province_code
Instance Method Details
#address ⇒ Object
10
11
12
13
14
|
# File 'lib/geocoder/results/tencent.rb', line 10
def address
"#{province}#{city}#{district}#{street}#{street_number}"
end
|
#address_components ⇒ Object
51
52
53
|
# File 'lib/geocoder/results/tencent.rb', line 51
def address_components
@data['address_components'] or @data['address_component']
end
|
#city ⇒ Object
27
28
29
30
31
|
# File 'lib/geocoder/results/tencent.rb', line 27
def city
@data['address_components'] and (@data['address_components']['city']) or
(@data['address_component'] and @data['address_component']['city']) or
""
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/tencent.rb', line 6
def coordinates
['lat', 'lng'].map{ |i| @data['location'][i] }
end
|
#country ⇒ Object
63
64
65
|
# File 'lib/geocoder/results/tencent.rb', line 63
def country
"China"
end
|
#country_code ⇒ Object
67
68
69
|
# File 'lib/geocoder/results/tencent.rb', line 67
def country_code
"CN"
end
|
#district ⇒ Object
33
34
35
36
37
|
# File 'lib/geocoder/results/tencent.rb', line 33
def district
@data['address_components'] and (@data['address_components']['district']) or
(@data['address_component'] and @data['address_component']['district']) or
""
end
|
#postal_code ⇒ Object
59
60
61
|
# File 'lib/geocoder/results/tencent.rb', line 59
def postal_code
""
end
|
#province ⇒ Object
Also known as:
state
NOTE: The Tencent reverse geocoding API has the field named ‘address_component’ compared to ‘address_components’ in the regular geocoding API.
19
20
21
22
23
|
# File 'lib/geocoder/results/tencent.rb', line 19
def province
@data['address_components'] and (@data['address_components']['province']) or
(@data['address_component'] and @data['address_component']['province']) or
""
end
|
#state_code ⇒ Object
55
56
57
|
# File 'lib/geocoder/results/tencent.rb', line 55
def state_code
""
end
|
#street ⇒ Object
39
40
41
42
43
|
# File 'lib/geocoder/results/tencent.rb', line 39
def street
@data['address_components'] and (@data['address_components']['street']) or
(@data['address_component'] and @data['address_component']['street']) or
""
end
|
#street_number ⇒ Object
45
46
47
48
49
|
# File 'lib/geocoder/results/tencent.rb', line 45
def street_number
@data['address_components'] and (@data['address_components']['street_number']) or
(@data['address_component'] and @data['address_component']['street_number']) or
""
end
|