Skip to content
Snippets Groups Projects
Commit 438f87e9 authored by Shinya Kitamura's avatar Shinya Kitamura
Browse files

Add Pelias (Mapzen) reverse geocoding

parent 04c9eca2
No related branches found
No related tags found
No related merge requests found
...@@ -23,11 +23,19 @@ module Geocoder::Lookup ...@@ -23,11 +23,19 @@ module Geocoder::Lookup
private private
def query_url_params(query) def query_url_params(query)
{ params = {
api_key: configuration.api_key, api_key: configuration.api_key,
text: query.text,
size: 1 size: 1
}.merge(super(query)) }.merge(super)
if query.reverse_geocode?
lat,lon = query.coordinates
params[:'point.lat'] = lat
params[:'point.lon'] = lon
else
params[:text] = query.text
end
params
end end
def results(query) def results(query)
......
...@@ -21,4 +21,10 @@ class PeliasTest < GeocoderTestCase ...@@ -21,4 +21,10 @@ class PeliasTest < GeocoderTestCase
query = Geocoder::Query.new('Madison Square Garden, New York, NY') query = Geocoder::Query.new('Madison Square Garden, New York, NY')
assert_match 'size=1', query.url assert_match 'size=1', query.url
end end
def test_query_for_reverse_geocode
lookup = Geocoder::Lookup::Mapzen.new
url = lookup.query_url(Geocoder::Query.new([45.423733, -75.676333]))
assert_match(/point.lat=45.423733&point.lon=-75.676333&size=1/, url)
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