diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-06-23 14:32:42 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-06-25 09:35:02 +0100 |
commit | d1c38a2bdbe5891fa63bde40e398e3cc33881566 (patch) | |
tree | a3be291dccfde91d912e3ff5b4e3e3635e9aeb92 /perllib/FixMyStreet/Geocode/Bing.pm | |
parent | 2b462f20d2479649c14efead2680a49543ca32d0 (diff) |
Improve Bing geocoder results.
Add a couple of parameters to hopefully improve results, and make
sure the returned locality is included in the summary address.
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Bing.pm')
-rw-r--r-- | perllib/FixMyStreet/Geocode/Bing.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm index 1d39d911f..1b947abee 100644 --- a/perllib/FixMyStreet/Geocode/Bing.pm +++ b/perllib/FixMyStreet/Geocode/Bing.pm @@ -36,6 +36,8 @@ sub string { $url .= '&userMapView=' . join(',', @{$params->{bounds}}) if $params->{bounds}; $url .= '&userLocation=' . $params->{centre} if $params->{centre}; + $url .= '&userIp=127.0.0.1'; # So server location does not affect results + $url .= '&maxResults=10'; # Match what is said in the front end $url .= '&c=' . $params->{bing_culture} if $params->{bing_culture}; $c->stash->{geocoder_url} = $url; @@ -52,7 +54,13 @@ sub string { foreach (@$results) { my $address = $_->{name}; - next if $params->{bing_country} && $_->{address}->{countryRegion} ne $params->{bing_country}; + if ($params->{bing_country}) { + next if $_->{address}->{countryRegion} ne $params->{bing_country}; + $address =~ s/, $params->{bing_country}$//; + } + if ($address !~ /$_->{address}->{locality}/) { + $address .= ", $_->{address}->{locality}"; + } # Getting duplicate, yet different, results from Bing sometimes next if @valid_locations |