diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-20 08:04:28 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-20 08:04:28 +0100 |
commit | 873ea570cc429b378eb33c8de90570a10414264c (patch) | |
tree | 094b86743e3e0267ec04fb36cb3f2245d402f163 | |
parent | 85ae59fdd1d8690efc569a193853072eb2519c89 (diff) | |
parent | e133cdcfda4b25e3fd04db6febf663009add05bc (diff) |
Merge branch 'issues/commercial/1064-main-road-br5'
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/OSM.pm | 2 | ||||
-rw-r--r-- | t/Mock/Nominatim.pm | 2 | ||||
-rw-r--r-- | t/app/controller/alert.t | 3 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 17 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 1 |
8 files changed, 30 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cd45d1996..350f738b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Cobrand hook to allow extra login conditions #2092 - Front end improvements: - Simplify footer CSS. #2107 + - Keep commas in geocode lookups. - Bugfixes: - Don't remove automated fields when editing contacts #2163 - Remove small border to left of Fixed banner. #2156 diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 36a3e3d5f..0f2f37654 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -37,18 +37,24 @@ sub disambiguate_location { # a different Priory Avenue in Petts Wood # From Google maps search, "BR6 0PL" is a valid postcode for Old Priory Avenue if ($string =~/^old\s+priory\s+av\w*$/i) { - $string = 'Ramsden Road'; - $town = ', BR6 0PL'; + $town = 'BR6 0PL'; } # White Horse Hill is on boundary with Greenwich, so need a # specific postcode - $string = 'BR7 6DH' if $string =~ /^white\s+horse/i; + $town = 'BR7 6DH' if $string =~ /^white\s+horse/i; $town = '' if $string =~ /orpington/i; + $string =~ s/(, *)?br[12]$//i; + $town = 'Beckenham' if $string =~ s/(, *)?br3$//i; + $town = 'West Wickham' if $string =~ s/(, *)?br4$//i; + $town = 'Orpington' if $string =~ s/(, *)?br[56]$//i; + $town = 'Chislehurst' if $string =~ s/(, *)?br7$//i; + $town = 'Swanley' if $string =~ s/(, *)?br8$//i; return { %{ $self->SUPER::disambiguate_location() }, + string => $string, town => $town, centre => '51.366836,0.040623', span => '0.154963,0.24347', diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index aeac0ab6d..d552afaa5 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -59,7 +59,7 @@ sub string { sub escape { my ($s, $c) = @_; $s = lc($s); - $s =~ s/[^-&\w ']/ /g; + $s =~ s/[^-&\w ',]/ /g; $s =~ s/\s+/ /g; $s = URI::Escape::uri_escape_utf8($s); $s =~ s/%20/+/g; diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm index 4d57007c5..0d296f299 100644 --- a/perllib/FixMyStreet/Geocode/OSM.pm +++ b/perllib/FixMyStreet/Geocode/OSM.pm @@ -30,7 +30,7 @@ sub string { $s = $params->{string} if $params->{string}; $s = FixMyStreet::Geocode::escape($s); - $s .= '+' . $params->{town} if $params->{town} and $s !~ /$params->{town}/i; + $s .= '%2C+' . $params->{town} if $params->{town} and $s !~ /$params->{town}/i; my $url = "${nominatimbase}search?"; my %query_params = ( diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm index 1f4e248d2..806ebbfd3 100644 --- a/t/Mock/Nominatim.pm +++ b/t/Mock/Nominatim.pm @@ -39,6 +39,6 @@ sub query { return []; } - +LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org'); __PACKAGE__->run_if_script; diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t index ce3c2ef9b..57e73e5ec 100644 --- a/t/app/controller/alert.t +++ b/t/app/controller/alert.t @@ -1,5 +1,3 @@ -use LWP::Protocol::PSGI; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -39,7 +37,6 @@ FixMyStreet::override_config { $mech->content_contains('ward:2651:20728:Edinburgh:City_Centre'); subtest "Test Nominatim lookup" => sub { - LWP::Protocol::PSGI->register(t::Mock::Nominatim->run_if_script, host => 'nominatim.openstreetmap.org'); $mech->get_ok('/alert/list?pc=High Street'); $mech->content_contains('We found more than one match for that location'); }; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index d62a0ad0f..6ee4be282 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -194,4 +194,21 @@ subtest 'check display of TfL reports' => sub { $mech->content_like(qr{<a title="Test Test[^>]*bromley.example.org[^>]*><img[^>]*yellow}); }; +subtest 'check geolocation overrides' => sub { + my $cobrand = FixMyStreet::Cobrand::Bromley->new; + foreach my $test ( + { query => 'Main Rd, BR1', town => 'Bromley', string => 'Main Rd' }, + { query => 'Main Rd, BR3', town => 'Beckenham', string => 'Main Rd' }, + { query => 'Main Rd, BR4', town => 'West Wickham', string => 'Main Rd' }, + { query => 'Main Rd, BR5', town => 'Orpington', string => 'Main Rd' }, + { query => 'Main Rd, BR7', town => 'Chislehurst', string => 'Main Rd' }, + { query => 'Main Rd, BR8', town => 'Swanley', string => 'Main Rd' }, + { query => 'Old Priory Avenue', town => 'BR6 0PL', string => 'Old Priory Avenue' }, + ) { + my $res = $cobrand->disambiguate_location($test->{query}); + is $res->{town}, $test->{town}, "Town matches $test->{town}"; + is $res->{string}, $test->{string}, "String matches $test->{string}"; + } +}; + done_testing(); diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 0aa264660..d1f1dcec4 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -5,7 +5,6 @@ use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; use t::Mock::Nominatim; -LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org'); # Front page test |