aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/Bing.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-01-22 15:57:45 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2015-02-13 11:44:07 +0000
commitda63f72c27e16d491f9103b9a8cbdb2fd96d2b59 (patch)
treecfd6df35b4c41028943d8a1e669345b81be41913 /perllib/FixMyStreet/Geocode/Bing.pm
parent04117b8be30b5d82d50cdc047ac4e7c19864f8ed (diff)
Make sure all co-ordinates are stringified.
This includes MapIt postcode lookups, geocoding, query parameters, tile clicks. Stringifying truncates them to six decimal places, which means we no longer need any "short" versions anywhere, and the JSON response will always uses a decimal point regardless of locale.
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Bing.pm')
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm19
1 files changed, 9 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 702e19814..61e04d3d5 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -13,7 +13,7 @@ use File::Path ();
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
-use mySociety::Locale;
+use Utils;
# string STRING CONTEXT
# Looks up on Bing Maps API, and caches, a user-inputted location.
@@ -71,15 +71,14 @@ sub string {
|| $valid_locations[-1]{address}{locality} eq $_->{address}{locality}
);
- ( $latitude, $longitude ) = @{ $_->{point}->{coordinates} };
- # These co-ordinates are output as query parameters in a URL, make sure they have a "."
- mySociety::Locale::in_gb_locale {
- push (@$error, {
- address => $address,
- latitude => sprintf('%0.6f', $latitude),
- longitude => sprintf('%0.6f', $longitude)
- });
- };
+ ( $latitude, $longitude ) =
+ map { Utils::truncate_coordinate($_) }
+ @{ $_->{point}->{coordinates} };
+ push (@$error, {
+ address => $address,
+ latitude => $latitude,
+ longitude => $longitude
+ });
push (@valid_locations, $_);
}