blob: 8df7b880f8f1750a751611a7be6565182c806f04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package FixMyStreet::App::Controller::Around;
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller'; }
use FixMyStreet::Map;
use List::MoreUtils qw(any);
=head1 NAME
FixMyStreet::App::Controller::Around - Catalyst Controller
=head1 DESCRIPTION
Allow the user to search for reports around a particular location.
=head1 METHODS
=head2 around
Find the location search and display nearby reports (for pc or lat,lon).
For x,y searches convert to lat,lon and 301 redirect to them.
If no search redirect back to the homepage.
=cut
sub around_index : Path : Args(0) {
my ( $self, $c ) = @_;
# check for x,y requests and redirect them to lat,lon
my $x = $c->req->param('x');
my $y = $c->req->param('y');
if ( $x || $y ) {
my ( $lat, $lon ) = FixMyStreet::Map::tile_xy_to_wgs84( $x, $y );
my $ll_uri = $c->uri_for( '/around', { lat => $lat, lon => $lon } );
$c->res->redirect( $ll_uri, 301 );
return;
}
# if there was no search then redirect to the homepage
if ( !any { $c->req->param($_) } qw(pc lat lon) ) {
return $c->res->redirect( $c->uri_for('/') );
}
}
__PACKAGE__->meta->make_immutable;
1;
|