lib/geocoder/results/nominatim.rb in geocoder-1.1.2 vs lib/geocoder/results/nominatim.rb in geocoder-1.1.3
- old
+ new
@@ -1,24 +1,36 @@
require 'geocoder/results/base'
module Geocoder::Result
class Nominatim < Base
+ def poi
+ %w[stadium bus_stop tram_stop].each do |key|
+ @data['address'][key] if @data['address'].key?(key)
+ end
+ end
+
def house_number
@data['address']['house_number']
end
def address
@data['display_name']
end
def street
- @data['address']['road']
+ %w[road pedestrian highway].each do |key|
+ return @data['address'][key] if @data['address'].key?(key)
+ end
+ return nil
end
def city
- @data['address']['city']
+ %w[city town village hamlet].each do |key|
+ return @data['address'][key] if @data['address'].key?(key)
+ end
+ return nil
end
def village
@data['address']['village']
end
@@ -47,16 +59,20 @@
def country_code
@data['address']['country_code']
end
+ def suburb
+ @data['address']['suburb']
+ end
+
def coordinates
[@data['lat'].to_f, @data['lon'].to_f]
end
def self.response_attributes
- %w[place_id, osm_type, osm_id, boundingbox, license,
- polygonpoints, display_name, class, type, stadium, suburb]
+ %w[place_id osm_type osm_id boundingbox license
+ polygonpoints display_name class type stadium]
end
response_attributes.each do |a|
define_method a do
@data[a]