Class: Geocoder::Result::Here

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/here.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #longitude

Constructor Details

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

Instance Method Details

#address(format = :full) ⇒ Object

A string in the given format.


9
10
11
# File 'lib/geocoder/results/here.rb', line 9

def address(format = :full)
  address_data['Label']
end

#cityObject


44
45
46
# File 'lib/geocoder/results/here.rb', line 44

def city
  address_data['City']
end

#coordinatesObject

A two-element array: [lat, lon].


16
17
18
19
# File 'lib/geocoder/results/here.rb', line 16

def coordinates
  fail unless d = @data['Location']['DisplayPosition']
  [d['Latitude'].to_f, d['Longitude'].to_f]
end

#countryObject


56
57
58
59
60
61
# File 'lib/geocoder/results/here.rb', line 56

def country
  fail unless d = address_data['AdditionalData']
  if v = d.find{|ad| ad['key']=='CountryName'}
    return v['value']
  end
end

#country_codeObject


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

def country_code
  address_data['Country']
end

#postal_codeObject


40
41
42
# File 'lib/geocoder/results/here.rb', line 40

def postal_code
  address_data['PostalCode']
end

#provinceObject


36
37
38
# File 'lib/geocoder/results/here.rb', line 36

def province
  address_data['County']
end

#province_codeObject


52
53
54
# File 'lib/geocoder/results/here.rb', line 52

def province_code
  address_data['State']
end

#routeObject


21
22
23
# File 'lib/geocoder/results/here.rb', line 21

def route
  address_data['Street']
end

#stateObject


29
30
31
32
33
34
# File 'lib/geocoder/results/here.rb', line 29

def state
  fail unless d = address_data['AdditionalData']
  if v = d.find{|ad| ad['key']=='StateName'}
    return v['value']
  end
end

#state_codeObject


48
49
50
# File 'lib/geocoder/results/here.rb', line 48

def state_code
  address_data['State']
end

#street_numberObject


25
26
27
# File 'lib/geocoder/results/here.rb', line 25

def street_number
  address_data['HouseNumber']
end

#viewportObject


67
68
69
70
71
72
73
74
# File 'lib/geocoder/results/here.rb', line 67

def viewport
  map_view = data['Location']['MapView'] || fail
  south = map_view['BottomRight']['Latitude']
  west = map_view['TopLeft']['Longitude']
  north = map_view['TopLeft']['Latitude']
  east = map_view['BottomRight']['Longitude']
  [south, west, north, east]
end