diff options
Diffstat (limited to 'web')
-rwxr-xr-x | web/alert.cgi | 5 | ||||
-rwxr-xr-x | web/import.cgi | 4 | ||||
-rwxr-xr-x | web/index.cgi | 17 | ||||
-rwxr-xr-x | web/rss.cgi | 10 |
4 files changed, 26 insertions, 10 deletions
diff --git a/web/alert.cgi b/web/alert.cgi index d5d7cff13..896ca9ccc 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -24,6 +24,7 @@ use mySociety::MaPit; use mySociety::VotingArea; use mySociety::Web qw(ent); use Cobrand; +use Utils; sub main { my $q = shift; @@ -87,6 +88,10 @@ sub alert_list { $error = shift; }; } + + # truncate the lat,lon for nicer urls + ( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon ); + return FixMyStreet::Geocode::list_choices($error, '/alert', $q) if ref($error) eq 'ARRAY'; return alert_front_page($q, $error) if $error; diff --git a/web/import.cgi b/web/import.cgi index 0f807ecb0..e7746f589 100755 --- a/web/import.cgi +++ b/web/import.cgi @@ -16,7 +16,7 @@ use mySociety::AuthToken; use mySociety::Config; use mySociety::EmailUtil; use mySociety::EvEl; -use mySociety::GeoUtil qw(national_grid_to_wgs84); +use mySociety::GeoUtil; sub main { my $q = shift; @@ -41,7 +41,7 @@ sub main { ) { ( $latitude, $longitude ) = - national_grid_to_wgs84( $input{easting}, $input{northing}, 'G' ); + Utils::convert_en_to_latlon( $input{easting}, $input{northing}); } my $fh = $q->upload('photo'); # MUST come before $q->header, don't know why! diff --git a/web/index.cgi b/web/index.cgi index 41f913dd1..62a882e6b 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -24,13 +24,14 @@ use mySociety::AuthToken; use mySociety::Config; use mySociety::DBHandle qw(select_all); use mySociety::EmailUtil; -use mySociety::GeoUtil qw(national_grid_to_wgs84); +use mySociety::GeoUtil; use mySociety::Locale; use mySociety::MaPit; use mySociety::PostcodeUtil; use mySociety::Random; use mySociety::VotingArea; use mySociety::Web qw(ent NewURL); +use Utils; sub debug (@) { return; @@ -792,7 +793,7 @@ sub redirect_from_osgb_to_wgs84 { my $e = $q->param('e'); my $n = $q->param('n'); - my ( $lat, $lon ) = national_grid_to_wgs84( $e, $n, 'G' ); + my ( $lat, $lon ) = Utils::convert_en_to_latlon_truncated( $e, $n ); my $lat_lon_url = NewURL( $q, @@ -929,6 +930,12 @@ sub display_location { 'submit_map'=>1, skipped=>1 ); my $pc_h = ent($q->param('pc') || ''); + + # truncate the lat,lon for nicer rss urls + my ( $short_lat, $short_lon ) = + map { Utils::truncate_coordinate($_) } # + ( $latitude, $longitude ); + my %vars = ( 'map' => FixMyStreet::Map::display_map($q, latitude => $latitude, longitude => $longitude, @@ -938,8 +945,8 @@ sub display_location { ), map_end => FixMyStreet::Map::display_map_end(1), url_home => Cobrand::url($cobrand, '/', $q), - url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/l/$latitude,$longitude", pc => undef, x => undef, y => undef, lat => undef, lon => undef ), $q), - url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, lat => $latitude, lon => $longitude, -url=>'/alert', feed=>"local:$latitude:$longitude"), $q), + url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/l/$short_lat,$short_lon", pc => undef, x => undef, y => undef, lat => undef, lon => undef ), $q), + url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, lat => $short_lat, lon => $short_lon, -url=>'/alert', feed=>"local:$short_lat:$short_lon"), $q), url_skip => $url_skip, email_me => _('Email me new local problems'), rss_alt => _('RSS feed'), @@ -959,7 +966,7 @@ sub display_location { ); my %params = ( - rss => [ _('Recent local problems, FixMyStreet'), "/rss/l/$latitude,$longitude" ], + rss => [ _('Recent local problems, FixMyStreet'), "/rss/l/$short_lat,$short_lon" ], robots => 'noindex,nofollow', ); diff --git a/web/rss.cgi b/web/rss.cgi index 9dcd9a3b4..9a9b4ce18 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -17,6 +17,7 @@ use FixMyStreet::Geocode; use mySociety::MaPit; use mySociety::GeoUtil; use mySociety::Gaze; +use Utils; sub main { my $q = shift; @@ -87,11 +88,11 @@ sub rss_local_problems { # 5000/31 as initial scale factor for these RSS feeds, now variable so redirect. $e = int( ($x * 5000/31) + 0.5 ); $n = int( ($y * 5000/31) + 0.5 ); - ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); + ($lat, $lon) = Utils::convert_en_to_latlon($e, $n); print $q->redirect(-location => "$base/rss/l/$lat,$lon$d_str$state_qs"); return ''; } elsif ($e && $n) { - ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); + ($lat, $lon) = Utils::convert_en_to_latlon($e, $n); print $q->redirect(-location => "$base/rss/l/$lat,$lon$d_str$state_qs"); return ''; } elsif ($pc) { @@ -110,7 +111,10 @@ sub rss_local_problems { } else { die "Missing E/N, x/y, lat/lon, or postcode parameter in RSS feed"; } - + + # truncate the lat,lon for nicer urls + ( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon ); + my $qs = "?lat=$lat;lon/=$lon"; if ($d) { |