Class: Geocoder::Result::Photon
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Photon
show all
- Defined in:
- lib/geocoder/results/photon.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province, #province_code
Instance Method Details
#address(_format = :full) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/geocoder/results/photon.rb', line 9
def address(_format = :full)
parts = []
parts << name if name
parts << street_address if street_address
parts << city
parts << state if state
parts << postal_code
parts << country
parts.join(', ')
end
|
#bounds ⇒ Object
73
74
75
|
# File 'lib/geocoder/results/photon.rb', line 73
def bounds
properties['extent']
end
|
#city ⇒ Object
40
41
42
|
# File 'lib/geocoder/results/photon.rb', line 40
def city
properties['city']
end
|
#coordinates ⇒ Object
60
61
62
63
64
65
|
# File 'lib/geocoder/results/photon.rb', line 60
def coordinates
return unless geometry
return unless geometry[:coordinates]
geometry[:coordinates].reverse
end
|
#country ⇒ Object
52
53
54
|
# File 'lib/geocoder/results/photon.rb', line 52
def country
properties['country']
end
|
#country_code ⇒ Object
56
57
58
|
# File 'lib/geocoder/results/photon.rb', line 56
def country_code
''
end
|
#geometry ⇒ Object
67
68
69
70
71
|
# File 'lib/geocoder/results/photon.rb', line 67
def geometry
return unless data['geometry']
symbol_hash data['geometry']
end
|
#house_number ⇒ Object
28
29
30
|
# File 'lib/geocoder/results/photon.rb', line 28
def house_number
properties['housenumber']
end
|
#name ⇒ Object
5
6
7
|
# File 'lib/geocoder/results/photon.rb', line 5
def name
properties['name']
end
|
#osm_id ⇒ Object
91
92
93
|
# File 'lib/geocoder/results/photon.rb', line 91
def osm_id
properties['osm_id']
end
|
#osm_tag ⇒ Object
96
97
98
99
100
101
|
# File 'lib/geocoder/results/photon.rb', line 96
def osm_tag
return unless properties['osm_key']
return properties['osm_key'] unless properties['osm_value']
"#{properties['osm_key']}=#{properties['osm_value']}"
end
|
#postal_code ⇒ Object
36
37
38
|
# File 'lib/geocoder/results/photon.rb', line 36
def postal_code
properties['postcode']
end
|
#state ⇒ Object
44
45
46
|
# File 'lib/geocoder/results/photon.rb', line 44
def state
properties['state']
end
|
#state_code ⇒ Object
48
49
50
|
# File 'lib/geocoder/results/photon.rb', line 48
def state_code
''
end
|
#street ⇒ Object
32
33
34
|
# File 'lib/geocoder/results/photon.rb', line 32
def street
properties['street']
end
|
#street_address ⇒ Object
21
22
23
24
25
26
|
# File 'lib/geocoder/results/photon.rb', line 21
def street_address
return unless street
return street unless house_number
"#{house_number} #{street}"
end
|
#type ⇒ Object
Type of the result (OSM object type), one of:
:node
:way
:relation
83
84
85
86
87
88
89
|
# File 'lib/geocoder/results/photon.rb', line 83
def type
{
'N' => :node,
'W' => :way,
'R' => :relation
}[properties['osm_type']]
end
|