aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/Bing.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-03-28 11:24:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-03-30 17:27:46 +0100
commit8454ac8ce05202b21e1f46e99cbc729cc5cd5853 (patch)
treeeadb36603d116a405632c14f27a703456356a879 /perllib/FixMyStreet/Geocode/Bing.pm
parent5700e9cdc070bd62c0c82ab35dec61a34955fbaf (diff)
Ignore some 'duplicate' results in geocoding.
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Bing.pm')
-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 };
}