Skip to content

Commit

Permalink
[TfL] Quicker search for Victoria Coach Station.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 8, 2024
1 parent 44913bd commit 0a17904
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions perllib/FixMyStreet/Cobrand/TfL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ sub disambiguate_location {
my $self = shift;
my $string = shift;

if ($string =~ /victoria coach station|vcs/i) {
return { result => { latitude => 51.49228, longitude => -0.1488 } };
}

return {
%{ $self->SUPER::disambiguate_location() },
town => "London",
};
}

sub geocoder_munge_results {
my ($self, $result) = @_;
$result->{display_name} =~ s/, London, Greater London, England//;
}

=item * We use OpenStreetMap for geocoding
=cut
Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Geocode/OSM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ sub string {
my ( $cls, $s, $c ) = @_;

my $params = $c->cobrand->disambiguate_location($s);
return $params->{result} if $params->{result};

# Allow cobrand to fixup the user input
$s = $params->{string} if $params->{string};

Expand Down
1 change: 1 addition & 0 deletions t/Mock/MapIt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ my @PLACES = (
[ '?', 51.566667, -0.766667, 163793, 'Buckinghamshire Council', 'CTY', 2255, 'Wycombe District Council', 'DIS', 2752, 'Marlow South East', 'DIW', 143427, 'Marlow', 'CED' ],
[ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ],
[ '?', 51.507461, -0.126890, 2504, 'Westminster City Council', 'LBO' ],
[ '?', 51.49228, -0.1488, 2504, 'Westminster City Council', 'LBO' ],
[ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ],
[ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX16 9UP', 52.038712, -1.346397, 2237, 'Oxfordshire County Council', 'CTY', 2419, 'Cherwell District Council', 'DIS', 151767, "Banbury, Calthorpe & Easington", "DIW" ],
Expand Down
17 changes: 15 additions & 2 deletions t/cobrand/tfl.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ FixMyStreet::DB->resultset('BodyArea')->find_or_create({
area_id => 2508, # Hackney
body_id => $body->id,
});
FixMyStreet::DB->resultset('BodyArea')->find_or_create({
area_id => 2504, # Westminster
body_id => $body->id,
});
my $superuser = $mech->create_user_ok('[email protected]', name => 'Super User', is_superuser => 1);
my $staffuser = $mech->create_user_ok('[email protected]', name => 'Council User', from_body => $body, password => 'password');

Expand Down Expand Up @@ -277,6 +281,15 @@ subtest "creating a user on TfL creates tfl_password extra_metadata" => sub {
}
};

subtest "test Victoria Coach Station" => sub {
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'VCS', } }, "submit location" );
$mech->content_contains('data-latitude=51.49228');
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'victoria coach station', } }, "submit location" );
$mech->content_contains('data-longitude=-0.1488');
};

subtest "test report creation anonymously by button" => sub {
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'BR1 3UH', } }, "submit location" );
Expand Down Expand Up @@ -1483,14 +1496,14 @@ FixMyStreet::override_config {
$mech->content_contains('Hounslow');
$mech->content_lacks('Auriol'); # 2457
$mech->content_lacks('Brownswood'); # 2508
$mech->content_contains('data-area="2482,2483,2508"'); # No 2457
$mech->content_contains('data-area="2482,2483,2504,2508"'); # No 2457
$mech->host('fixmystreet.com');
$mech->get_ok('/reports/TfL');
$mech->content_contains('Bromley');
$mech->content_contains('Hounslow');
$mech->content_lacks('Auriol'); # 2457
$mech->content_lacks('Brownswood'); # 2508
$mech->content_contains('data-area="2482,2483,2508"'); # No 2457
$mech->content_contains('data-area="2482,2483,2504,2508"'); # No 2457
};
};

Expand Down

0 comments on commit 0a17904

Please sign in to comment.