<p></p>
<p><b>@tomhughes</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#discussion_r1747387670">test/controllers/geocoder_controller_test.rb</a>:</p>
<pre style='color:#555'>> @@ -57,6 +88,7 @@ def test_identify_latlon_ne_d
       "50.06773N, 14.37742E"
     ].each do |code|
       latlon_check code, 50.06773, 14.37742
+      assert_nil @controller.params[:latlon_digits]
</pre>
<p dir="auto">Why do we want to assert this? The only thing this test should be concerned about is what results it gets from the controller method - how the controller does that internally is none of it's concern?</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#discussion_r1747395426">app/controllers/geocoder_controller.rb</a>:</p>
<pre style='color:#555'>> -
-    ew = captures.fetch("ew").casecmp?("w") ? -1 : 1
-    ewd = BigDecimal(captures.fetch("ewd", "0"))
-    ewm = BigDecimal(captures.fetch("ewm", "0"))
-    ews = BigDecimal(captures.fetch("ews", "0"))
-
-    lat = ns * (nsd + (nsm / 60) + (nss / 3600))
-    lon = ew * (ewd + (ewm / 60) + (ews / 3600))
-
-    { :lat => lat.round(6).to_s("F"), :lon => lon.round(6).to_s("F") }
+  def dms_to_decdeg(prefix, directions, captures)
+    extract_number = ->(suffix) { captures.fetch("#{prefix}#{suffix}", "0").sub(",", ".") }
+
+    positive_direction, negative_direction = directions.chars
+    sign = captures.fetch(prefix, positive_direction).casecmp?(negative_direction) ? "-" : ""
+    deg = if captures["#{prefix}m"] || captures["#{prefix}s"]
</pre>
<p dir="auto">Why do we need to special case the case when there are only degrees? What was wrong with the old way of doing it?</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#discussion_r1747405138">test/controllers/geocoder_controller_test.rb</a>:</p>
<pre style='color:#555'>> +    [
+      "25.79° -80.27°",
+      "25.79°/-80.27°",
+      "25.79°, -80.27°",
+      "+25.79° -80.27°",
+      "+25.79°/-80.27°",
+      "+25.79°, -80.27°"
+    ].each do |code|
+      latlon_check code, 25.79, -80.27
+      assert @controller.params[:latlon_digits]
+    end
+  end
+
+  ##
+  # Test identification of basic lat/lon pairs with degrees/mins
+  def test_identify_latlon_basic_dm
</pre>
<p dir="auto">Should we not have a dms version as well?</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#discussion_r1747416364">app/controllers/geocoder_controller.rb</a>:</p>
<pre style='color:#555'>> -      if latlon = query.match(/^(?<ns>[NS])\s*#{dms_regexp('ns')}\W*(?<ew>[EW])\s*#{dms_regexp('ew')}$/) ||
-                  query.match(/^#{dms_regexp('ns')}\s*(?<ns>[NS])\W*#{dms_regexp('ew')}\s*(?<ew>[EW])$/)
-        params.merge!(to_decdeg(latlon.named_captures.compact)).delete(:query)
-
-      elsif latlon = query.match(%r{^(?<lat>[+-]?\d+(?:\.\d+)?)(?:\s+|\s*[,/]\s*)(?<lon>[+-]?\d+(?:\.\d+)?)$})
-        params.merge!(:lat => latlon["lat"], :lon => latlon["lon"]).delete(:query)
-
+      if match = query.match(/^(?<ns>[NS])\s*#{dms_regexp('ns')}\W*(?<ew>[EW])\s*#{dms_regexp('ew')}$/) ||
+                 query.match(/^#{dms_regexp('ns')}\s*(?<ns>[NS])\W*#{dms_regexp('ew')}\s*(?<ew>[EW])$/)
+        captures = match.named_captures.compact
+        params.merge! :lat => dms_to_decdeg("ns", "ns", captures),
+                      :lon => dms_to_decdeg("ew", "ew", captures)
+        params.delete(:query)
+
+      elsif match = query.match(%r{^
+                      (?<ns>[+-]?)\s*#{dms_regexp('ns', :comma => false)}
</pre>
<p dir="auto">Why not allow commas in this case? Is it because it conflicts with the comma separating lat and lon? Having to exclude it in this case makes things a lot more ugly :-(</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#discussion_r1747417495">app/controllers/geocoder_controller.rb</a>:</p>
<pre style='color:#555'>> -    ns = captures.fetch("ns").casecmp?("s") ? -1 : 1
-    nsd = BigDecimal(captures.fetch("nsd", "0"))
-    nsm = BigDecimal(captures.fetch("nsm", "0"))
-    nss = BigDecimal(captures.fetch("nss", "0"))
-
-    ew = captures.fetch("ew").casecmp?("w") ? -1 : 1
-    ewd = BigDecimal(captures.fetch("ewd", "0"))
-    ewm = BigDecimal(captures.fetch("ewm", "0"))
-    ews = BigDecimal(captures.fetch("ews", "0"))
-
-    lat = ns * (nsd + (nsm / 60) + (nss / 3600))
-    lon = ew * (ewd + (ewm / 60) + (ews / 3600))
-
-    { :lat => lat.round(6).to_s("F"), :lon => lon.round(6).to_s("F") }
+  def dms_to_decdeg(prefix, directions, captures)
+    extract_number = ->(suffix) { captures.fetch("#{prefix}#{suffix}", "0").sub(",", ".") }
</pre>
<p dir="auto">Is this really better than just adding the <code class="notranslate">.sub</code> to the four fetches? I understand it's removing duplication but it does make the code much harder to read and understand.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5147#pullrequestreview-2286679715">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLOWQ4HEQHPL2LH6YOTZVHK6HAVCNFSM6AAAAABNPLEZFKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEOBWGY3TSNZRGU">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJKB7SNVNKFE7GCG23ZVHK6HA5CNFSM6AAAAABNPLEZFKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUIJP3KG.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5147/review/2286679715</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5147#pullrequestreview-2286679715",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5147#pullrequestreview-2286679715",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>