lib/geocoder/lookups/yandex.rb in geocoder-1.1.3 vs lib/geocoder/lookups/yandex.rb in geocoder-1.1.4
- old
+ new
@@ -8,12 +8,12 @@
"http://maps.yandex.ru/?ll=#{coordinates.reverse.join(',')}"
end
private # ---------------------------------------------------------------
- def results(query, reverse = false)
- return [] unless doc = fetch_data(query, reverse)
+ def results(query)
+ return [] unless doc = fetch_data(query)
if err = doc['error']
warn "Yandex Geocoding API error: #{err['status']} (#{err['message']})."
return []
end
if doc = doc['response']['GeoObjectCollection']
@@ -23,17 +23,24 @@
warn "Yandex Geocoding API error: unexpected response format."
return []
end
end
- def query_url(query, reverse = false)
- query = query.split(",").reverse.join(",") if reverse
- params = {
- :geocode => query,
+ def query_url_params(query)
+ if query.reverse_geocode?
+ q = query.coordinates.reverse.join(",")
+ else
+ q = query.sanitized_text
+ end
+ super.merge(
+ :geocode => q,
:format => "json",
:plng => "#{Geocoder::Configuration.language}", # supports ru, uk, be
:key => Geocoder::Configuration.api_key
- }
- "http://geocode-maps.yandex.ru/1.x/?" + hash_to_query(params)
+ )
+ end
+
+ def query_url(query)
+ "http://geocode-maps.yandex.ru/1.x/?" + url_query_string(query)
end
end
end