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

Anton Khorev notifications at github.com
Tue Jul 9 13:05:45 UTC 2024


@AntonKhorev requested changes on this pull request.



> +    assert_in_delta lat, @controller.params[:lat].to_f
+    assert_in_delta lon, @controller.params[:lon].to_f

```suggestion
    assert_match(/^[+-]?\d+(\.\d*)?$/, @controller.params[:lat])
    assert_match(/^[+-]?\d+(\.\d*)?$/, @controller.params[:lon])
    assert_in_delta lat, @controller.params[:lat].to_f
    assert_in_delta lon, @controller.params[:lon].to_f
```

> +    assert_in_delta lat, @controller.params[:lat].to_f
+    assert_in_delta lon, @controller.params[:lon].to_f

```suggestion
    assert_match(/^[+-]?\d+(\.\d*)?$/, @controller.params[:lat])
    assert_match(/^[+-]?\d+(\.\d*)?$/, @controller.params[:lon])
    assert_in_delta lat, @controller.params[:lat].to_f
    assert_in_delta lon, @controller.params[:lon].to_f
```

On test/controllers/geocoder_controller_test.rb:

Shouldn't we test near-zero latlon values?

```ruby
  ##
  # Test identification of lat/lon pairs with values close to zero
  def test_identify_latlon_close_to_zero
    [
      "0.00001 -0.00002",
      "+0.00001 -0.00002"
    ].each do |code|
      latlon_check code, 0.00001, -0.00002
    end
  end
```

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

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


More information about the rails-dev mailing list