aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/Bing.pm
diff options
context:
space:
mode:
authorFixMyStreet <fixmystreet@vps29.(none)>2012-04-14 16:10:54 +1000
committerFixMyStreet <fixmystreet@vps29.(none)>2012-04-14 16:10:54 +1000
commite825ad07a72383ac1bc55c61314775176c753989 (patch)
tree191f12803105432bac52808b602d80cfebf25ae9 /perllib/FixMyStreet/Geocode/Bing.pm
parentf20925047fcd543a6be2622f1566e7746c8596fb (diff)
parent81a92715f2317b27d36e945b59d2fb3e4d845abc (diff)
Merge remote branch 'upstream/master'
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Bing.pm')
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index f00cf9671..4ba00dbfe 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -59,10 +59,20 @@ 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
+ && $_->{address}{postalCode} && $valid_locations[-1]{address}{postalCode} eq $_->{address}{postalCode}
+ && ( $valid_locations[-1]{address}{locality} eq $_->{address}{adminDistrict2}
+ || $valid_locations[-1]{address}{adminDistrict2} eq $_->{address}{locality}
+ || $valid_locations[-1]{address}{locality} 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 };
}