Class: Geocoder::Result::Azure

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/azure.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



5
6
7
# File 'lib/geocoder/results/azure.rb', line 5

def address
  @data['address']['freeformAddress']
end

#building_numberObject



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

def building_number
  @data['address']['buildingNumber']
end

#cityObject



13
14
15
# File 'lib/geocoder/results/azure.rb', line 13

def city
  @data['address']['municipality']
end

#coordinatesObject



17
18
19
20
21
22
23
# File 'lib/geocoder/results/azure.rb', line 17

def coordinates
  if @data['position'].is_a?(String) # reverse geocoding result
    @data['position'].split(',').map(&:to_f)
  elsif @data['position'].is_a?(Hash) # forward geocoding result
    [@data['position']['lat'], @data['position']['lon']]
  end
end

#countryObject



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

def country
  @data['address']['country']
end

#country_codeObject



29
30
31
# File 'lib/geocoder/results/azure.rb', line 29

def country_code
  @data['address']['countryCode']
end

#districtObject



33
34
35
# File 'lib/geocoder/results/azure.rb', line 33

def district
  @data['address']['municipalitySubdivision']
end

#postal_codeObject



37
38
39
# File 'lib/geocoder/results/azure.rb', line 37

def postal_code
  @data['address']['postalCode']
end

#provinceObject



41
42
43
# File 'lib/geocoder/results/azure.rb', line 41

def province
  @data['address']['countrySubdivision']
end

#stateObject



45
46
47
# File 'lib/geocoder/results/azure.rb', line 45

def state
  @data['address']['countrySubdivision']
end

#state_codeObject



49
50
51
# File 'lib/geocoder/results/azure.rb', line 49

def state_code
  @data['address']['countrySubdivisionCode']
end

#street_nameObject



53
54
55
# File 'lib/geocoder/results/azure.rb', line 53

def street_name
  @data['address']['streetName']
end

#street_numberObject



57
58
59
# File 'lib/geocoder/results/azure.rb', line 57

def street_number
  @data['address']['streetNumber']
end

#viewportObject



61
62
63
# File 'lib/geocoder/results/azure.rb', line 61

def viewport
  @data['viewport'] || {}
end