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



102
103
104
105
# File 'lib/geocoder/results/nominatim.rb', line 102

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 address_data[key] if address_data.key?(key)
  end
  return nil
end

#city_districtObject



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

def city_district
  address_data['city_district']
end

#coordinatesObject



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

def coordinates
  return [] unless @data['lat'] && @data['lon']

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

#countryObject



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

def country
  address_data['country']
end

#country_codeObject



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

def country_code
  address_data['country_code']
end

#countyObject



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

def county
  address_data['county']
end

#house_numberObject



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

def house_number
  address_data['house_number']
end

#municipalityObject



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

def municipality
  address_data['municipality']
end

#neighbourhoodObject



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

def neighbourhood
  address_data['neighbourhood']
end

#place_classObject



89
90
91
# File 'lib/geocoder/results/nominatim.rb', line 89

def place_class
  @data['class']
end

#place_typeObject



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

def place_type
  @data['type']
end

#poiObject



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

def poi
  return address_data[place_type] if address_data.key?(place_type)
  return nil
end

#postal_codeObject



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

def postal_code
  address_data['postcode']
end

#stateObject Also known as: state_code



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

def state
  address_data['state']
end

#state_districtObject



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

def state_district
  address_data['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 address_data[key] if address_data.key?(key)
  end
  return nil
end

#suburbObject



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

def suburb
  address_data['suburb']
end

#townObject



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

def town
  address_data['town']
end

#viewportObject



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

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
  address_data['village']
end