diff --git a/lib/geocoder/lookups/yandex.rb b/lib/geocoder/lookups/yandex.rb index daa150e91b0c9c03914046b71e5f29db87201daa..2d9ffd3b9e7e2b38b7f9df7b1d5a5a75c243108c 100644 --- a/lib/geocoder/lookups/yandex.rb +++ b/lib/geocoder/lookups/yandex.rb @@ -47,12 +47,16 @@ module Geocoder::Lookup else q = query.sanitized_text end - { + params = { :geocode => q, :format => "json", :plng => "#{query.language || configuration.language}", # supports ru, uk, be :key => configuration.api_key - }.merge(super) + } + unless (bounds = query.options[:bounds]).nil? + params[:bbox] = bounds.map{ |point| "%f,%f" % point }.join('~') + end + params.merge(super) end end end diff --git a/test/unit/lookups/yandex_test.rb b/test/unit/lookups/yandex_test.rb index 9bf36c80342076bb03229df8654bc6e19443f0df..09be792944e3823e10539f508d484c94571940f3 100644 --- a/test/unit/lookups/yandex_test.rb +++ b/test/unit/lookups/yandex_test.rb @@ -19,4 +19,13 @@ class YandexTest < GeocoderTestCase assert_equal "", result.country_code assert_equal "", result.country end + + def test_yandex_query_url_contains_bbox + lookup = Geocoder::Lookup::Google.new + url = lookup.query_url(Geocoder::Query.new( + "Some Intersection", + :bounds => [[40.0, -120.0], [39.0, -121.0]] + )) + assert_match(/bbox=40.0+%2C-120.0+%7E39.0+%2C-121.0+/, url) + end end