aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/httpd.conf2
-rw-r--r--perllib/Page.pm2
-rwxr-xr-xweb/alert.cgi8
-rwxr-xr-xweb/index.cgi23
-rwxr-xr-xweb/rss.cgi18
5 files changed, 35 insertions, 18 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf
index b4d7c3dfd..1e6b8979e 100644
--- a/conf/httpd.conf
+++ b/conf/httpd.conf
@@ -47,8 +47,10 @@ RewriteRule ^/rss/([0-9]+)$ /rss.cgi?type=new_updates;id=$1 [QSA]
# RSS feeds for new local problems
RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2 [QSA]
+RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2 [QSA]
RewriteRule ^/rss/l/([0-9.-]+)[,/]([0-9.-]+)$ /rss.cgi?type=local_problems;lat=$1;lon=$2 [QSA]
RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2;d=$3 [QSA]
+RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2;d=$3 [QSA]
RewriteRule ^/rss/l/([0-9.-]+)[,/]([0-9.-]+)/([0-9]+)$ /rss.cgi?type=local_problems;lat=$1;lon=$2;d=$3 [QSA]
RewriteRule ^/rss/pc/(.*)$ /rss.cgi?type=local_problems;pc=$1 [QSA]
RewriteRule ^/rss/problems$ /rss.cgi?type=new_problems [QSA]
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 470625749..0a3d755a7 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -637,7 +637,7 @@ sub os_to_tile {
return $_[0] / SCALE_FACTOR;
}
sub tile_to_os {
- return $_[0] * SCALE_FACTOR;
+ return int($_[0] * SCALE_FACTOR + 0.5);
}
sub click_to_tile {
diff --git a/web/alert.cgi b/web/alert.cgi
index c755c9715..0992dfe43 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -243,10 +243,10 @@ EOF
$out .= " <a href='$rss_feed'><img src='/i/feed.png' width='16' height='16' title='"
. _('RSS feed of nearby problems') . "' alt='" . _('RSS feed') . "' border='0'></a>";
$out .= '</p> <p id="rss_local_alt">' . _('(alternatively the RSS feed can be customised, within');
- my $rss_feed_2k = Cobrand::url($cobrand, "/rss/$x,$y/2", $q);
- my $rss_feed_5k = Cobrand::url($cobrand, "/rss/$x,$y/5", $q);
- my $rss_feed_10k = Cobrand::url($cobrand, "/rss/$x,$y/10", $q);
- my $rss_feed_20k = Cobrand::url($cobrand, "/rss/$x,$y/20", $q);
+ my $rss_feed_2k = Cobrand::url($cobrand, "/rss/n/$e,$n/2", $q);
+ my $rss_feed_5k = Cobrand::url($cobrand, "/rss/n/$e,$n/5", $q);
+ my $rss_feed_10k = Cobrand::url($cobrand, "/rss/n/$e,$n/10", $q);
+ my $rss_feed_20k = Cobrand::url($cobrand, "/rss/n/$e,$n/20", $q);
$out .= <<EOF;
<a href="$rss_feed_2k">2km</a> / <a href="$rss_feed_5k">5km</a>
/ <a href="$rss_feed_10k">10km</a> / <a href="$rss_feed_20k">20km</a>)
diff --git a/web/index.cgi b/web/index.cgi
index 355f8f8e6..b2fa73c68 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -513,7 +513,7 @@ sub display_form {
my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types);
# Let cobrand do a check
- my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'submit_problem');
+ my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'submit_problem');
if (!$success){
return front_page($q, $error_msg);
}
@@ -801,15 +801,18 @@ sub display_location {
}
return Page::geocode_choice($error, '/', $q) if (ref($error) eq 'ARRAY');
return front_page($q, $error) if ($error);
- my $parent_types = $mySociety::VotingArea::council_parent_types;
- if ($easting && $northing) {
- my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types);
- my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'display_location');
- if (!$success){
- return front_page($q, $error_msg);
- }
+
+ if (!$easting || !$northing) {
+ $easting = Page::tile_to_os($x);
+ $northing = Page::tile_to_os($y);
}
+ # Check this location is okay to be displayed for the cobrand
+ my $parent_types = $mySociety::VotingArea::council_parent_types;
+ my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types);
+ my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'display_location');
+ return front_page($q, $error_msg) unless $success;
+
# Deal with pin hiding/age
my ($hide_link, $hide_text, $all_link, $all_text, $interval);
if ($input{all_pins}) {
@@ -863,7 +866,7 @@ sub display_location {
'map' => Page::display_map($q, x => $x, 'y' => $y, type => 1, pins => $pins, post => $map_links ),
map_end => Page::display_map_end(1),
url_home => Cobrand::url($cobrand, '/', $q),
- url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/$x,$y", pc => undef, x => undef, 'y' => undef), $q),
+ url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/n/$easting,$northing", pc => undef, x => undef, 'y' => undef), $q),
url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, -url=>'/alert', x=>$x, 'y'=>$y, feed=>"local:$x:$y"), $q),
url_skip => $url_skip,
email_me => _('Email me new local problems'),
@@ -884,7 +887,7 @@ sub display_location {
);
my %params = (
- rss => [ _('Recent local problems, FixMyStreet'), "/rss/$x,$y" ]
+ rss => [ _('Recent local problems, FixMyStreet'), "/rss/n/$easting,$northing" ]
);
return (Page::template_include('map', $q, Page::template_root($q), %vars), %params);
diff --git a/web/rss.cgi b/web/rss.cgi
index 44bb24be7..81daa89ce 100755
--- a/web/rss.cgi
+++ b/web/rss.cgi
@@ -65,11 +65,23 @@ sub rss_local_problems {
my $y = $q->param('y');
my $lat = $q->param('lat');
my $lon = $q->param('lon');
+ my $e = $q->param('e');
+ my $n = $q->param('n');
my $cobrand = Page::get_cobrand($q);
my $base = Cobrand::base_url($cobrand);
- my ($e, $n);
if ($lat) { # In the UK, it'll never be 0 :)
($e, $n) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G');
+ $e = int($e + 0.5);
+ $n = int($n + 0.5);
+ print $q->redirect(-location => "$base/rss/n/$e,$n");
+ return '';
+ } elsif ($x && $y) {
+ # 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 );
+ print $q->redirect(-location => "$base/rss/n/$e,$n");
+ return '';
+ } elsif ($e && $n) {
$x = int(Page::os_to_tile($e));
$y = int(Page::os_to_tile($n));
print $q->redirect(-location => "$base/rss/$x/$y");
@@ -86,11 +98,11 @@ sub rss_local_problems {
$error = shift;
};
unless ($error) {
- print $q->redirect(-location => "$base/rss/$x/$y");
+ print $q->redirect(-location => "$base/rss/n/$e,$n");
}
return '';
} else {
- die "Missing x/y, lat/lon, or postcode parameter in RSS feed";
+ die "Missing E/N, x/y, lat/lon, or postcode parameter in RSS feed";
}
my $qs = "?x=$x;y=$y";
my $d = $q->param('d');