diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Location.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index 8a68b2b3d..5e5349a6c 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -6,6 +6,7 @@ BEGIN {extends 'Catalyst::Controller'; } use Encode; use FixMyStreet::Geocode; +use Utils; =head1 NAME @@ -32,8 +33,8 @@ sub determine_location_from_coords : Private { my $longitude = $c->req->param('longitude') || $c->req->param('lon'); if ( defined $latitude && defined $longitude ) { - $c->stash->{latitude} = $latitude; - $c->stash->{longitude} = $longitude; + ($c->stash->{latitude}, $c->stash->{longitude}) = + map { Utils::truncate_coordinate($_) } ($latitude, $longitude); # Also save the pc if there is one if ( my $pc = $c->req->param('pc') ) { @@ -50,7 +51,7 @@ sub determine_location_from_coords : Private { User has searched for a location - try to find it for them. -Return -1 if nothing provided. +Return false if nothing provided. If one match is found returns true and lat/lng is set. @@ -64,18 +65,19 @@ sub determine_location_from_pc : Private { my ( $self, $c, $pc ) = @_; # check for something to search - $pc ||= $c->req->param('pc') || return -1; + $pc ||= $c->req->param('pc') || return; $c->stash->{pc} = $pc; # for template if ( $pc =~ /^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/ ) { - $c->stash->{latitude} = $1; - $c->stash->{longitude} = $2; + ($c->stash->{latitude}, $c->stash->{longitude}) = + map { Utils::truncate_coordinate($_) } ($1, $2); return $c->forward( 'check_location' ); } if ( $c->cobrand->country eq 'GB' && $pc =~ /^([A-Z])([A-Z])([\d\s]{4,})$/i) { if (my $convert = gridref_to_latlon( $1, $2, $3 )) { - $c->stash->{latitude} = $convert->{latitude}; - $c->stash->{longitude} = $convert->{longitude}; + ($c->stash->{latitude}, $c->stash->{longitude}) = + map { Utils::truncate_coordinate($_) } + ($convert->{latitude}, $convert->{longitude}); return $c->forward( 'check_location' ); } } |