Class: Geocoder::Result::Tencent

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Instance Method Details

#addressObject



10
11
12
13
14
# File 'lib/geocoder/results/tencent.rb', line 10

def address
  "#{province}#{city}#{district}#{street}#{street_number}"

  #@data['title'] or @data['address']
end

#address_componentsObject



51
52
53
# File 'lib/geocoder/results/tencent.rb', line 51

def address_components
  @data['address_components'] or @data['address_component']
end

#cityObject



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

#coordinatesObject



6
7
8
# File 'lib/geocoder/results/tencent.rb', line 6

def coordinates
  ['lat', 'lng'].map{ |i| @data['location'][i] }
end

#countryObject



63
64
65
# File 'lib/geocoder/results/tencent.rb', line 63

def country
  "China"
end

#country_codeObject



67
68
69
# File 'lib/geocoder/results/tencent.rb', line 67

def country_code
  "CN"
end

#districtObject



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_codeObject



59
60
61
# File 'lib/geocoder/results/tencent.rb', line 59

def postal_code
  ""
end

#provinceObject 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_codeObject



55
56
57
# File 'lib/geocoder/results/tencent.rb', line 55

def state_code
  ""
end

#streetObject



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_numberObject



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