From 239da9b505eb76e2ea4aef7cbcc6fb8f7f43f9fc Mon Sep 17 00:00:00 2001 From: Pete Brumm <pete@petebrumm.com> Date: Tue, 22 Jul 2014 21:01:22 -0500 Subject: [PATCH] json coming from geocodio now has strings instead of floats. this fixes it --- lib/geocoder/results/geocodio.rb | 2 +- test/fixtures/geocodio_1101_pennsylvania_ave | 2 +- test/unit/lookups/geocodio_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/geocoder/results/geocodio.rb b/lib/geocoder/results/geocodio.rb index e80c750f..cd5b32be 100644 --- a/lib/geocoder/results/geocodio.rb +++ b/lib/geocoder/results/geocodio.rb @@ -45,7 +45,7 @@ module Geocoder::Result end def coordinates - ['lat', 'lng'].map{ |i| location[i] } if location + ['lat', 'lng'].map{ |i| location[i].to_f } if location end def accuracy diff --git a/test/fixtures/geocodio_1101_pennsylvania_ave b/test/fixtures/geocodio_1101_pennsylvania_ave index c89bf170..f77e8045 100644 --- a/test/fixtures/geocodio_1101_pennsylvania_ave +++ b/test/fixtures/geocodio_1101_pennsylvania_ave @@ -1 +1 @@ -{"input":{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC"},"results":[{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":38.895019,"lng":-77.028095},"accuracy":1},{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":38.895016122449,"lng":-77.028084377551},"accuracy":0.8}]} \ No newline at end of file +{"input":{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC"},"results":[{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":"38.895019","lng":"-77.028095"},"accuracy":1},{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":"38.895016122449","lng":"-77.028084377551"},"accuracy":0.8}]} \ No newline at end of file diff --git a/test/unit/lookups/geocodio_test.rb b/test/unit/lookups/geocodio_test.rb index c1ac2c74..b773a921 100644 --- a/test/unit/lookups/geocodio_test.rb +++ b/test/unit/lookups/geocodio_test.rb @@ -19,7 +19,7 @@ class GeocodioTest < GeocoderTestCase assert_equal "NW", result.postdirectional assert_equal "Washington", result.city assert_equal "1101 Pennsylvania Ave NW, Washington DC, 20004", result.formatted_address - assert_equal({ "lat" => 38.895019, "lng" => -77.028095 }, result.location) + assert_equal({ "lat" => "38.895019", "lng" => "-77.028095" }, result.location) end def test_no_results -- GitLab