Class: Geocoder::Result::Nominatim

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

Constructor Details

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

Class Method Details

.response_attributesObject



81
82
83
84
# File 'lib/geocoder/results/nominatim.rb', line 81

def self.response_attributes
  %w[place_id osm_type osm_id boundingbox license
     polygonpoints display_name class type stadium]
end

Instance Method Details

#addressObject



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

def address
  @data['display_name']
end

#cityObject



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

def city
  %w[city town village hamlet].each do |key|
    return @data['address'][key] if @data['address'].key?(key)
  end
  return nil
end

#coordinatesObject



69
70
71
# File 'lib/geocoder/results/nominatim.rb', line 69

def coordinates
  [@data['lat'].to_f, @data['lon'].to_f]
end

#countryObject



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

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

#country_codeObject



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

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

#countyObject



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

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

#house_numberObject



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

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

#place_classObject



73
74
75
# File 'lib/geocoder/results/nominatim.rb', line 73

def place_class
  @data['class']
end

#place_typeObject



77
78
79
# File 'lib/geocoder/results/nominatim.rb', line 77

def place_type
  @data['type']
end

#poiObject



6
7
8
9
10
11
# File 'lib/geocoder/results/nominatim.rb', line 6

def poi
  %w[stadium bus_stop tram_stop].each do |key|
    return @data['address'][key] if @data['address'].key?(key)
  end
  return nil
end

#postal_codeObject



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

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

#stateObject Also known as: state_code



43
44
45
# File 'lib/geocoder/results/nominatim.rb', line 43

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

#streetObject



21
22
23
24
25
26
# File 'lib/geocoder/results/nominatim.rb', line 21

def street
  %w[road pedestrian highway].each do |key|
    return @data['address'][key] if @data['address'].key?(key)
  end
  return nil
end

#suburbObject



65
66
67
# File 'lib/geocoder/results/nominatim.rb', line 65

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

#townObject



39
40
41
# File 'lib/geocoder/results/nominatim.rb', line 39

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

#villageObject



35
36
37
# File 'lib/geocoder/results/nominatim.rb', line 35

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