Skip to content
Snippets Groups Projects
Commit 234746b4 authored by Christian Aust's avatar Christian Aust
Browse files

Add support for ovi.com, aka. Nokia maps. No reverse geocoding so far

parent 16fd4bad
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ module Geocoder
:yandex,
:nominatim,
:mapquest,
:ovi,
:test
]
end
......
# ovi.com store
require 'geocoder/lookups/base'
require "geocoder/results/ovi"
module Geocoder::Lookup
class Ovi < Base
private # ---------------------------------------------------------------
def results(query)
return [] unless doc = fetch_data(query)
return [] unless doc['Response']
doc['Response']['View'].first['Result']
end
def query_url_params(query)
{
:searchtext => query.sanitized_text
}
end
def query_url(query)
"http://lbs.ovi.com/search/6.2/geocode.json?" + url_query_string(query)
end
end
end
require 'geocoder/results/base'
module Geocoder::Result
class Ovi < Base
##
# A string in the given format.
#
def address(format = :full)
fail unless d = @data['Location']['Address']
d['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
fail unless d = @data['Location']['Address']
d['State']
end
def province
fail unless d = @data['Location']['Address']
d['County']
end
def state_code
fail
end
def province_code
fail
end
def country
fail unless d = @data['Location']['Address']['AdditionalData']
d.find{|ad| ad['value'] if ad['key']=='CountryName'}
end
def country_code
fail unless d = @data['Location']['Address']
d['Country']
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment