From d1c38a2bdbe5891fa63bde40e398e3cc33881566 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 23 Jun 2020 14:32:42 +0100 Subject: 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. --- t/geocode/bing.t | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 t/geocode/bing.t (limited to 't/geocode') diff --git a/t/geocode/bing.t b/t/geocode/bing.t new file mode 100644 index 000000000..32cffaa4e --- /dev/null +++ b/t/geocode/bing.t @@ -0,0 +1,24 @@ +use FixMyStreet::Test; +use FixMyStreet::Geocode::Bing; +use Catalyst::Test 'FixMyStreet::App'; +use t::Mock::Bing; + +my $c = ctx_request('/'); + +FixMyStreet::override_config { + GEOCODING_DISAMBIGUATION => { bing_culture => 'en-GB' } +}, sub { + my $r = FixMyStreet::Geocode::Bing->string('a result', $c); + ok $r->{latitude}; + ok $r->{longitude}; +}; + +FixMyStreet::override_config { + GEOCODING_DISAMBIGUATION => { bing_country => 'United Kingdom' } +}, sub { + my $r = FixMyStreet::Geocode::Bing->string('two results', $c); + is scalar @{$r->{error}}, 2; + is $r->{error}[1]{address}, 'Constitution Hill again, London'; +}; + +done_testing; -- cgit v1.2.3 From 7359a017d4386c96cf681bb694f207138ebf0bc9 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Mon, 2 Nov 2020 11:20:12 +0000 Subject: Ignore Low Bing geocoder results if any higher. --- t/geocode/bing.t | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't/geocode') diff --git a/t/geocode/bing.t b/t/geocode/bing.t index 32cffaa4e..156f983e1 100644 --- a/t/geocode/bing.t +++ b/t/geocode/bing.t @@ -21,4 +21,10 @@ FixMyStreet::override_config { is $r->{error}[1]{address}, 'Constitution Hill again, London'; }; +my $r = FixMyStreet::Geocode::Bing->string('two results andalow', $c); +is scalar @{$r->{error}}, 2; + +$r = FixMyStreet::Geocode::Bing->string('two results onlylow', $c); +is scalar @{$r->{error}}, 3; + done_testing; -- cgit v1.2.3