Accept coordinates with a slash in search
This commit is contained in:
parent
7ce5dffb6d
commit
4b593412c2
2 changed files with 4 additions and 2 deletions
|
@ -218,7 +218,7 @@ class GeocoderController < ApplicationController
|
||||||
query.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([EW])$/).try(:captures) # degrees, minutes, decimal seconds [NSEW]
|
query.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([EW])$/).try(:captures) # degrees, minutes, decimal seconds [NSEW]
|
||||||
params.merge!(dms_to_decdeg(latlon)).delete(:query)
|
params.merge!(dms_to_decdeg(latlon)).delete(:query)
|
||||||
|
|
||||||
elsif latlon = query.match(/^([+-]?\d+(\.\d*)?)(?:\s+|\s*,\s*)([+-]?\d+(\.\d*)?)$/)
|
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].to_f, :lon => latlon[3].to_f).delete(:query)
|
||||||
|
|
||||||
params[:latlon_digits] = true unless params[:whereami]
|
params[:latlon_digits] = true unless params[:whereami]
|
||||||
|
|
|
@ -37,9 +37,11 @@ class GeocoderControllerTest < ActionDispatch::IntegrationTest
|
||||||
def test_identify_latlon_basic
|
def test_identify_latlon_basic
|
||||||
[
|
[
|
||||||
"50.06773 14.37742",
|
"50.06773 14.37742",
|
||||||
|
"50.06773/14.37742",
|
||||||
"50.06773, 14.37742",
|
"50.06773, 14.37742",
|
||||||
"+50.06773 +14.37742",
|
"+50.06773 +14.37742",
|
||||||
"+50.06773, +14.37742"
|
"+50.06773, +14.37742",
|
||||||
|
"+50.06773/+14.37742"
|
||||||
].each do |code|
|
].each do |code|
|
||||||
latlon_check code, 50.06773, 14.37742
|
latlon_check code, 50.06773, 14.37742
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue