From 8454ac8ce05202b21e1f46e99cbc729cc5cd5853 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 28 Mar 2012 11:24:20 +0100 Subject: Ignore some 'duplicate' results in geocoding. --- perllib/FixMyStreet/Geocode/Bing.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'perllib/FixMyStreet/Geocode/Bing.pm') 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 }; } -- cgit v1.2.3 From d3159038445f2b78915abfbe4ec07fcd99cedf06 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 29 Mar 2012 12:35:47 +0100 Subject: Also treat as same if just same locality and postalcode. --- perllib/FixMyStreet/Geocode/Bing.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/Geocode/Bing.pm') diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm index 83fde0c2c..99197a5f9 100644 --- a/perllib/FixMyStreet/Geocode/Bing.pm +++ b/perllib/FixMyStreet/Geocode/Bing.pm @@ -64,7 +64,9 @@ sub string { 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} ); + || $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 }); -- cgit v1.2.3 From 435b09e7b908afa224a6e972c33379fb6c756b1f Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 30 Mar 2012 17:34:01 +0100 Subject: Make sure postalCode is present in result. --- perllib/FixMyStreet/Geocode/Bing.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/Geocode/Bing.pm') diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm index 99197a5f9..4ba00dbfe 100644 --- a/perllib/FixMyStreet/Geocode/Bing.pm +++ b/perllib/FixMyStreet/Geocode/Bing.pm @@ -62,7 +62,7 @@ sub string { # Getting duplicate, yet different, results from Bing sometimes next if @valid_locations - && $valid_locations[-1]{address}{postalCode} eq $_->{address}{postalCode} + && $_->{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} -- cgit v1.2.3