aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-11-02 11:20:12 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-11-08 22:12:46 +0000
commit7359a017d4386c96cf681bb694f207138ebf0bc9 (patch)
tree54f48f0eedef6778ae8f065ab17bd03d08debdbd /perllib
parente08f14c4501f315b46c2a45b2f63b572ab650691 (diff)
Ignore Low Bing geocoder results if any higher.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 1b947abee..8c5366d3d 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -7,6 +7,7 @@
package FixMyStreet::Geocode::Bing;
use strict;
+use warnings;
use FixMyStreet::Geocode;
use Utils;
@@ -52,6 +53,19 @@ sub string {
my $results = $js->{resourceSets}->[0]->{resources};
my ( $error, @valid_locations, $latitude, $longitude );
+ # If there are any High/Medium confidence results, don't include Low ones
+ my $exclude_low;
+ foreach (@$results) {
+ my $confidence = $_->{confidence};
+ if ($confidence eq 'High' || $confidence eq 'Medium') {
+ $exclude_low = 1;
+ last;
+ }
+ }
+ if ($exclude_low) {
+ @$results = grep { $_->{confidence} ne 'Low' } @$results;
+ }
+
foreach (@$results) {
my $address = $_->{name};
if ($params->{bing_country}) {