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/Mock/Bing.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 't/Mock/Bing.pm') diff --git a/t/Mock/Bing.pm b/t/Mock/Bing.pm index 3dfb8fbe0..77045950f 100644 --- a/t/Mock/Bing.pm +++ b/t/Mock/Bing.pm @@ -14,6 +14,36 @@ has json => ( sub dispatch_request { my $self = shift; + sub (GET + /REST/v1/Locations + ?*) { + my ($self, $query) = @_; + my $results = [ { + point => { coordinates => [ 51, -1 ] }, + name => 'Constitution Hill, London, SW1A', + address => { + addressLine => 'Constitution Hill', + locality => 'London', + countryRegion => 'United Kingdom', + } + } ]; + if ($query->{q} =~ /two results/) { + push @$results, { + point => { coordinates => [ 51, -1 ] }, + name => 'Constitution Hill again, United Kingdom', + address => { + addressLine => 'Constitution Hill again', + locality => 'London', + countryRegion => 'United Kingdom', + } + }; + } + my $data = { + statusCode => 200, + resourceSets => [ { resources => $results } ], + }; + my $json = $self->json->encode($data); + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, + sub (GET + /REST/v1/Locations/* + ?*) { my ($self, $location, $query) = @_; my $data = { -- 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/Mock/Bing.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/Mock/Bing.pm') diff --git a/t/Mock/Bing.pm b/t/Mock/Bing.pm index 77045950f..cc4dab845 100644 --- a/t/Mock/Bing.pm +++ b/t/Mock/Bing.pm @@ -19,6 +19,7 @@ sub dispatch_request { my $results = [ { point => { coordinates => [ 51, -1 ] }, name => 'Constitution Hill, London, SW1A', + confidence => 'High', address => { addressLine => 'Constitution Hill', locality => 'London', @@ -29,6 +30,7 @@ sub dispatch_request { push @$results, { point => { coordinates => [ 51, -1 ] }, name => 'Constitution Hill again, United Kingdom', + confidence => 'High', address => { addressLine => 'Constitution Hill again', locality => 'London', @@ -36,6 +38,21 @@ sub dispatch_request { } }; } + if ($query->{q} =~ /low/) { + push @$results, { + point => { coordinates => [ 52, -2 ] }, + name => 'Constitution Hill elsewhere, United Kingdom', + confidence => 'Low', + address => { + addressLine => 'Constitution Hill elsewhere', + locality => 'London', + countryRegion => 'United Kingdom', + } + }; + } + if ($query->{q} =~ /onlylow/) { + @$results = map { $_->{confidence} = 'Low'; $_ } @$results; + } my $data = { statusCode => 200, resourceSets => [ { resources => $results } ], -- cgit v1.2.3