aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/Bing.pm
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-04-29 18:14:32 +0100
committerDave Whiteland <dave@mysociety.org>2012-04-29 18:14:32 +0100
commit16061e060354affb25701a8c6111ee30df2ac19c (patch)
treea2d0f949b532f582becff31ef7f79b5deacc4186 /perllib/FixMyStreet/Geocode/Bing.pm
parentb38ba427f7facd6e8042ae667b5b3bac1724803a (diff)
parent1fc50dcc7f65ae04055a803579445a9397e3ffdf (diff)
Merge branch 'master' into barnet-integration
(prior to go-live... amongst other things, the Barnet web templates had changed. NB conflict with carton.lock, accepted master in full) Conflicts: carton.lock
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 };
}