aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-03-28 11:24:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-03-28 11:24:20 +0100
commit5b1b93d60f6e6e4b9f6abca461beb91f206806c7 (patch)
tree111296599249278a15aff6cd07aa8f2751a86f5c
parent139bf14adb2c41ef836aeb7ba37339e8126ad51b (diff)
Ignore some 'duplicate' results in geocoding.
-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 };
}