aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index f00cf9671..83fde0c2c 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -59,10 +59,18 @@ sub string {
foreach (@$results) {
my $address = $_->{name};
next unless $_->{address}->{countryRegion} eq $params->{bing_country};
+
+ # Getting duplicate, yet different, results from Bing sometimes
+ next if @valid_locations
+ && $valid_locations[-1]{address}{postalCode} eq $_->{address}{postalCode}
+ && ( $valid_locations[-1]{address}{locality} eq $_->{address}{adminDistrict2}
+ || $valid_locations[-1]{address}{adminDistrict2} eq $_->{address}{locality} );
+
( $latitude, $longitude ) = @{ $_->{point}->{coordinates} };
push (@$error, { address => $address, latitude => $latitude, longitude => $longitude });
push (@valid_locations, $_);
}
+
return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
return { error => $error };
}