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
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
#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 @data['address'][key] if @data['address'].key?(key)
end
return nil
end
|
#city_district ⇒ Object
67
68
69
|
# File 'lib/geocoder/results/nominatim.rb', line 67
def city_district
@data['address']['city_district']
end
|
#coordinates ⇒ Object
79
80
81
|
# File 'lib/geocoder/results/nominatim.rb', line 79
def coordinates
[@data['lat'].to_f, @data['lon'].to_f]
end
|
#country ⇒ Object
55
56
57
|
# File 'lib/geocoder/results/nominatim.rb', line 55
def country
@data['address']['country']
end
|
#country_code ⇒ Object
59
60
61
|
# File 'lib/geocoder/results/nominatim.rb', line 59
def country_code
@data['address']['country_code']
end
|
#county ⇒ Object
51
52
53
|
# File 'lib/geocoder/results/nominatim.rb', line 51
def county
@data['address']['county']
end
|
#house_number ⇒ Object
11
12
13
|
# File 'lib/geocoder/results/nominatim.rb', line 11
def house_number
@data['address']['house_number']
end
|
#neighbourhood ⇒ Object
75
76
77
|
# File 'lib/geocoder/results/nominatim.rb', line 75
def neighbourhood
@data['address']['neighbourhood']
end
|
#place_class ⇒ Object
83
84
85
|
# File 'lib/geocoder/results/nominatim.rb', line 83
def place_class
@data['class']
end
|
#place_type ⇒ Object
87
88
89
|
# File 'lib/geocoder/results/nominatim.rb', line 87
def place_type
@data['type']
end
|
#poi ⇒ Object
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_code ⇒ Object
47
48
49
|
# File 'lib/geocoder/results/nominatim.rb', line 47
def postal_code
@data['address']['postcode']
end
|
#state ⇒ Object
Also known as:
state_code
41
42
43
|
# File 'lib/geocoder/results/nominatim.rb', line 41
def state
@data['address']['state']
end
|
#state_district ⇒ Object
71
72
73
|
# File 'lib/geocoder/results/nominatim.rb', line 71
def state_district
@data['address']['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 @data['address'][key] if @data['address'].key?(key)
end
return nil
end
|
#suburb ⇒ Object
63
64
65
|
# File 'lib/geocoder/results/nominatim.rb', line 63
def suburb
@data['address']['suburb']
end
|
#town ⇒ Object
37
38
39
|
# File 'lib/geocoder/results/nominatim.rb', line 37
def town
@data['address']['town']
end
|
#viewport ⇒ Object
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
|
#village ⇒ Object
33
34
35
|
# File 'lib/geocoder/results/nominatim.rb', line 33
def village
@data['address']['village']
end
|