Class: Geocoder::Result::Nominatim
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Nominatim
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
Class Method Details
.response_attributes ⇒ Object
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
#address ⇒ Object
15
16
17
|
# File 'lib/geocoder/results/nominatim.rb', line 15
def address
@data['display_name']
end
|
#city ⇒ Object
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_district ⇒ Object
67
68
69
|
# File 'lib/geocoder/results/nominatim.rb', line 67
def city_district
address_data['city_district']
end
|
#coordinates ⇒ Object
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
|
#country ⇒ Object
55
56
57
|
# File 'lib/geocoder/results/nominatim.rb', line 55
def country
address_data['country']
end
|
#country_code ⇒ Object
59
60
61
|
# File 'lib/geocoder/results/nominatim.rb', line 59
def country_code
address_data['country_code']
end
|
#county ⇒ Object
51
52
53
|
# File 'lib/geocoder/results/nominatim.rb', line 51
def county
address_data['county']
end
|
#house_number ⇒ Object
11
12
13
|
# File 'lib/geocoder/results/nominatim.rb', line 11
def house_number
address_data['house_number']
end
|
#municipality ⇒ Object
79
80
81
|
# File 'lib/geocoder/results/nominatim.rb', line 79
def municipality
address_data['municipality']
end
|
#neighbourhood ⇒ Object
75
76
77
|
# File 'lib/geocoder/results/nominatim.rb', line 75
def neighbourhood
address_data['neighbourhood']
end
|
#place_class ⇒ Object
89
90
91
|
# File 'lib/geocoder/results/nominatim.rb', line 89
def place_class
@data['class']
end
|
#place_type ⇒ Object
93
94
95
|
# File 'lib/geocoder/results/nominatim.rb', line 93
def place_type
@data['type']
end
|
#poi ⇒ Object
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_code ⇒ Object
47
48
49
|
# File 'lib/geocoder/results/nominatim.rb', line 47
def postal_code
address_data['postcode']
end
|
#state ⇒ Object
Also known as:
state_code
41
42
43
|
# File 'lib/geocoder/results/nominatim.rb', line 41
def state
address_data['state']
end
|
#state_district ⇒ Object
71
72
73
|
# File 'lib/geocoder/results/nominatim.rb', line 71
def state_district
address_data['state_district']
end
|
#street ⇒ Object
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
|
#suburb ⇒ Object
63
64
65
|
# File 'lib/geocoder/results/nominatim.rb', line 63
def suburb
address_data['suburb']
end
|
#town ⇒ Object
37
38
39
|
# File 'lib/geocoder/results/nominatim.rb', line 37
def town
address_data['town']
end
|
#viewport ⇒ Object
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
|
#village ⇒ Object
33
34
35
|
# File 'lib/geocoder/results/nominatim.rb', line 33
def village
address_data['village']
end
|