@results = []
if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180
- @results.push(:lat => lat, :lon => lon,
+ @results.push(:lat => params[:lat], :lon => params[:lon],
:zoom => params[:zoom],
- :name => "#{lat}, #{lon}")
+ :name => "#{params[:lat]}, #{params[:lon]}")
end
if lon >= -90 && lon <= 90 && lat >= -180 && lat <= 180
- @results.push(:lat => lon, :lon => lat,
+ @results.push(:lat => params[:lon], :lon => params[:lat],
:zoom => params[:zoom],
- :name => "#{lon}, #{lat}")
+ :name => "#{params[:lon]}, #{params[:lat]}")
end
if @results.empty?
@error = "Longitude #{lon} out of range"
render :action => "error"
else
- @results = [{ :lat => lat, :lon => lon,
+ @results = [{ :lat => params[:lat], :lon => params[:lon],
:zoom => params[:zoom],
- :name => "#{lat}, #{lon}" }]
+ :name => "#{params[:lat]}, #{params[:lon]}" }]
render :action => "results"
end
params.merge!(dms_to_decdeg(latlon)).delete(:query)
elsif latlon = query.match(%r{^([+-]?\d+(\.\d*)?)(?:\s+|\s*[,/]\s*)([+-]?\d+(\.\d*)?)$})
- params.merge!(:lat => latlon[1].to_f, :lon => latlon[3].to_f).delete(:query)
+ params.merge!(:lat => latlon[1], :lon => latlon[3]).delete(:query)
params[:latlon_digits] = true
end
assert_template :layout => "map"
assert_equal %w[latlon osm_nominatim_reverse], assigns(:sources).pluck(:name)
assert_nil @controller.params[:query]
- assert_in_delta lat, @controller.params[:lat]
- assert_in_delta lon, @controller.params[:lon]
+ assert_in_delta lat, @controller.params[:lat].to_f
+ assert_in_delta lon, @controller.params[:lon].to_f
get search_path(:query => query), :xhr => true
assert_response :success
assert_template :layout => "xhr"
assert_equal %w[latlon osm_nominatim_reverse], assigns(:sources).pluck(:name)
assert_nil @controller.params[:query]
- assert_in_delta lat, @controller.params[:lat]
- assert_in_delta lon, @controller.params[:lon]
+ assert_in_delta lat, @controller.params[:lat].to_f
+ assert_in_delta lon, @controller.params[:lon].to_f
end
def search_check(query, sources)