[openstreetmap/openstreetmap-website] Avoid use of scientific notation in geocoder results (PR #4961)

Tom Hughes notifications at github.com
Thu Jul 11 17:01:10 UTC 2024


@tomhughes commented on this pull request.



>  
-  def dms_to_decdeg(captures)
-    begin
-      Float(captures[0])
-      lat = captures[4].casecmp("s").zero? ? -(captures[0].to_f + ((captures[1].to_f + (captures[2].to_f / 60)) / 60)) : captures[0].to_f + ((captures[1].to_f + (captures[2].to_f / 60)) / 60)
-      lon = captures[9].casecmp("w").zero? ? -(captures[5].to_f + ((captures[6].to_f + (captures[7].to_f / 60)) / 60)) : captures[5].to_f + ((captures[6].to_f + (captures[7].to_f / 60)) / 60)
-    rescue StandardError
-      lat = captures[0].casecmp("s").zero? ? -(captures[1].to_f + ((captures[2].to_f + (captures[3].to_f / 60)) / 60)) : captures[1].to_f + ((captures[2].to_f + (captures[3].to_f / 60)) / 60)
-      lon = captures[5].casecmp("w").zero? ? -(captures[6].to_f + ((captures[7].to_f + (captures[8].to_f / 60)) / 60)) : captures[6].to_f + ((captures[7].to_f + (captures[8].to_f / 60)) / 60)
-    end
-    { :lat => lat, :lon => lon }
+    lat = ns * (nsd + (nsm / 60) + (nss / 3600))
+    lon = ew * (ewd + (ewm / 60) + (ews / 3600))
+
+    { :lat => lat.to_s("F"), :lon => lon.to_s("F") }

Fixed... 
![image](https://github.com/openstreetmap/openstreetmap-website/assets/147741/e367ee1f-133a-4372-b709-8e7405d81d94)


-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4961#discussion_r1674367685
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4961/review/2172497594 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240711/35a121c5/attachment.htm>


More information about the rails-dev mailing list