]> git.openstreetmap.org Git - rails.git/commitdiff
Accept coordinates with a slash in search
authornertc <davidtsiklauri7@gmail.com>
Tue, 2 Jul 2024 10:17:23 +0000 (14:17 +0400)
committernertc <davidtsiklauri7@gmail.com>
Tue, 2 Jul 2024 19:48:55 +0000 (23:48 +0400)
app/controllers/geocoder_controller.rb
test/controllers/geocoder_controller_test.rb

index 4a593f86a76a23250dd294f0141db07ea8399859..ee3c3479c49bf260fb56d02db8fd4711d97f70ee 100644 (file)
@@ -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]
         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[:latlon_digits] = true unless params[:whereami]
index 029ccbbd52e093ddb932a90cf025afc552519b18..d32521c3bf42565e7663a0a529666ed3ffb537c5 100644 (file)
@@ -37,9 +37,11 @@ class GeocoderControllerTest < ActionDispatch::IntegrationTest
   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"
     ].each do |code|
       latlon_check code, 50.06773, 14.37742
     end