Class: Geocoder::Result::Photon

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

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

#boundsObject



73
74
75
# File 'lib/geocoder/results/photon.rb', line 73

def bounds
  properties['extent']
end

#cityObject



40
41
42
# File 'lib/geocoder/results/photon.rb', line 40

def city
  properties['city']
end

#coordinatesObject



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

#countryObject



52
53
54
# File 'lib/geocoder/results/photon.rb', line 52

def country
  properties['country']
end

#country_codeObject



56
57
58
# File 'lib/geocoder/results/photon.rb', line 56

def country_code
  ''
end

#geometryObject



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_numberObject



28
29
30
# File 'lib/geocoder/results/photon.rb', line 28

def house_number
  properties['housenumber']
end

#nameObject



5
6
7
# File 'lib/geocoder/results/photon.rb', line 5

def name
  properties['name']
end

#osm_idObject



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

def osm_id
  properties['osm_id']
end

#osm_tagObject



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_codeObject



36
37
38
# File 'lib/geocoder/results/photon.rb', line 36

def postal_code
  properties['postcode']
end

#stateObject



44
45
46
# File 'lib/geocoder/results/photon.rb', line 44

def state
  properties['state']
end

#state_codeObject



48
49
50
# File 'lib/geocoder/results/photon.rb', line 48

def state_code
  ''
end

#streetObject



32
33
34
# File 'lib/geocoder/results/photon.rb', line 32

def street
  properties['street']
end

#street_addressObject



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

#typeObject

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