Class: Geocoder::Result::Nominatim

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

Direct Known Subclasses

LocationIq, Pickpoint

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



96
97
98
99
# File 'lib/geocoder/results/nominatim.rb', line 96

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

Instance Method Details

#addressObject



15
16
17
# File 'lib/geocoder/results/nominatim.rb', line 15

def address
  @data['display_name']
end

#cityObject



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

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

#city_districtObject



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

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

#coordinatesObject



79
80
81
# File 'lib/geocoder/results/nominatim.rb', line 79

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

#countryObject



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

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

#country_codeObject



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

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

#countyObject



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

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

#house_numberObject



11
12
13
# File 'lib/geocoder/results/nominatim.rb', line 11

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

#neighbourhoodObject



75
76
77
# File 'lib/geocoder/results/nominatim.rb', line 75

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

#place_classObject



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

def place_class
  @data['class']
end

#place_typeObject



87
88
89
# File 'lib/geocoder/results/nominatim.rb', line 87

def place_type
  @data['type']
end

#poiObject



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

def poi
  return @data['address'][place_type] if @data['address'].key?(place_type)
  return nil
end

#postal_codeObject



47
48
49
# File 'lib/geocoder/results/nominatim.rb', line 47

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

#stateObject Also known as: state_code



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

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

#state_districtObject



71
72
73
# File 'lib/geocoder/results/nominatim.rb', line 71

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

#streetObject



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

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

#suburbObject



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

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

#townObject



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

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

#viewportObject



91
92
93
94
# File 'lib/geocoder/results/nominatim.rb', line 91

def viewport
  south, north, west, east = @data['boundingbox'].map(&:to_f)
  [south, west, north, east]
end

#villageObject



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

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