aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-05-18 20:12:16 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-05-18 20:12:16 +0100
commit675744156c56d7b5ea5c8866fdd59a1c3cbcee1b (patch)
tree9ac7bb95f77ed5c473f9dd2a62be70959a4508b0 /perllib
parent61eb613ddc31943e9d6504050c0e96f91340f752 (diff)
[UK] Stop nearest request with scientific notation
If the longitude was very close to 0, it was being sent as e.g. 1e-6 in the request to MapIt. Mock out the Bing query so that this can be tested (the closest.t tests were previously always being skipped).
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index 46891f906..1a5682dad 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -5,6 +5,7 @@ use strict;
use JSON::MaybeXS;
use mySociety::MaPit;
use mySociety::VotingArea;
+use Utils;
sub country { return 'GB'; }
sub area_types { [ 'DIS', 'LBO', 'MTD', 'UTA', 'CTY', 'COI', 'LGD' ] }
@@ -122,7 +123,8 @@ sub find_closest {
my $data = $self->SUPER::find_closest($problem, $as_data);
my $mapit_url = FixMyStreet->config('MAPIT_URL');
- my $url = $mapit_url . "nearest/4326/" . $problem->longitude . ',' . $problem->latitude;
+ my ($lat, $lon) = map { Utils::truncate_coordinate($_) } $problem->latitude, $problem->longitude;
+ my $url = $mapit_url . "nearest/4326/$lon,$lat";
my $j = LWP::Simple::get($url);
if ($j) {
$j = JSON->new->utf8->allow_nonref->decode($j);