X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eab2eeaa47b2aa8c7f52371f9bfdd60711a41fb6..a3eb48385bcf1465339d473c0c1657e075cd507d:/app/controllers/geocoder_controller.rb?ds=inline diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 73422c2f0..6053cbb4b 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -1,6 +1,7 @@ # coding: utf-8 class GeocoderController < ApplicationController + require 'cgi' require 'uri' require 'net/http' require 'rexml/document' @@ -140,20 +141,25 @@ class GeocoderController < ApplicationController # get objects to excude if params[:exclude] - exclude = "&exclude_place_ids=#{params[:exclude].join(',')}" + exclude = "&exclude_place_ids=#{params[:exclude]}" end # ask nominatim response = fetch_xml("#{NOMINATIM_URL}search?format=xml&q=#{escape_query(query)}#{viewbox}#{exclude}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}") + # extract the results from the response + results = response.elements["searchresults"] + + # extract parameters from more_url + more_url_params = CGI.parse(URI.parse(results.attributes["more_url"]).query) + # create result array @results = Array.new # create parameter hash for "more results" link - @more_params = params.reverse_merge({ :exclude => [] }) - - # extract the results from the response - results = response.elements["searchresults"] + @more_params = params.merge({ + :exclude => more_url_params["exclude_place_ids"].first + }) # parse the response results.elements.each("place") do |place| @@ -181,7 +187,6 @@ class GeocoderController < ApplicationController :min_lon => min_lon, :max_lon => max_lon, :prefix => prefix, :name => name, :type => object_type, :id => object_id}) - @more_params[:exclude].push(place.attributes["place_id"].to_s) end render :action => "results"