Sha256: 3046bc484b9d181d390f6df4f078c09e367660171872ad09622836c7d8f117d0

Contents?: true

Size: 1.37 KB

Versions: 21

Compression:

Stored size: 1.37 KB

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class Ovi < Base

    ##
    # A string in the given format.
    #
    def address(format = :full)
      address_data['Label']
    end

    ##
    # A two-element array: [lat, lon].
    #
    def coordinates
      fail unless d = @data['Location']['DisplayPosition']
      [d['Latitude'].to_f, d['Longitude'].to_f]
    end

    def state
      address_data['County']
    end

    def province
      address_data['County']
    end

    def postal_code
      address_data['PostalCode']
    end

    def city
      address_data['City']
    end

    def state_code
      address_data['State']
    end

    def province_code
      address_data['State']
    end

    def country
      fail unless d = address_data['AdditionalData']
      if v = d.find{|ad| ad['key']=='CountryName'}
        return v['value']
      end
    end

    def country_code
      address_data['Country']
    end

    def viewport
      map_view = data['Location']['MapView'] || fail
      south = map_view['BottomRight']['Latitude']
      west = map_view['TopLeft']['Longitude']
      north = map_view['TopLeft']['Latitude']
      east = map_view['BottomRight']['Longitude']
      [south, west, north, east]
    end

    private # ----------------------------------------------------------------

    def address_data
      @data['Location']['Address'] || fail
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
geocoder-1.4.9 lib/geocoder/results/ovi.rb
geocoder-1.4.8 lib/geocoder/results/ovi.rb
geocoder-1.4.7 lib/geocoder/results/ovi.rb
geocoder-1.4.6 lib/geocoder/results/ovi.rb
geocoder-1.4.5 lib/geocoder/results/ovi.rb
geocoder-1.4.4 lib/geocoder/results/ovi.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/geocoder-1.4.3/lib/geocoder/results/ovi.rb
geocoder-1.4.3 lib/geocoder/results/ovi.rb
geocoder-1.4.2 lib/geocoder/results/ovi.rb
geocoder-1.4.1 lib/geocoder/results/ovi.rb
geocoder-1.4.0 lib/geocoder/results/ovi.rb
geocoder-1.3.7 lib/geocoder/results/ovi.rb
geocoder-1.3.6 lib/geocoder/results/ovi.rb
geocoder-1.3.5 lib/geocoder/results/ovi.rb
broken-geocoder-1.3.6 lib/geocoder/results/ovi.rb
broken-geocoder-1.3.5 lib/geocoder/results/ovi.rb
broken-geocoder-1.3.4 lib/geocoder/results/ovi.rb
geocoder-1.3.4 lib/geocoder/results/ovi.rb
geocoder-1.3.3 lib/geocoder/results/ovi.rb
geocoder-1.3.2 lib/geocoder/results/ovi.rb