aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Page.pm14
-rw-r--r--web/css.css4
-rwxr-xr-xweb/index.cgi89
-rw-r--r--web/js.js18
4 files changed, 70 insertions, 55 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index f3063b960..3a3fa9ca8 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.7 2006-09-20 14:16:21 matthew Exp $
+# $Id: Page.pm,v 1.8 2006-09-20 16:47:51 matthew Exp $
#
package Page;
@@ -114,14 +114,14 @@ sub error_page ($$) {
sub compass ($$$) {
my ($pc, $x, $y) = @_;
- my $nw = url($pc, $x-1, $y-1);
- my $n = url($pc, $x, $y-1);
- my $ne = url($pc, $x+1, $y-1);
+ my $nw = url($pc, $x-1, $y+1);
+ my $n = url($pc, $x, $y+1);
+ my $ne = url($pc, $x+1, $y+1);
my $w = url($pc, $x-1,$y);
my $e = url($pc, $x+1,$y);
- my $sw = url($pc, $x-1, $y+1);
- my $s = url($pc, $x, $y+1);
- my $se = url($pc, $x+1, $y+1);
+ my $sw = url($pc, $x-1, $y-1);
+ my $s = url($pc, $x, $y-1);
+ my $se = url($pc, $x+1, $y-1);
return <<EOF;
<table cellpadding="0" cellspacing="0" border="0" id="compass">
<tr valign="bottom">
diff --git a/web/css.css b/web/css.css
index e8fba38b8..a265bd359 100644
--- a/web/css.css
+++ b/web/css.css
@@ -46,8 +46,8 @@ a:hover, a:active {
#map {
border: solid 1px #000000;
- width: 500px;
- height: 500px;
+ width: 508px;
+ height: 508px;
position: relative;
top: 0;
overflow: hidden;
diff --git a/web/index.cgi b/web/index.cgi
index f3c0a8e64..33bf4b00b 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.11 2006-09-20 16:12:06 matthew Exp $
+# $Id: index.cgi,v 1.12 2006-09-20 16:47:51 matthew Exp $
use strict;
require 5.8.0;
@@ -17,6 +17,8 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use Error qw(:try);
use HTML::Entities;
+use LWP::Simple;
+use RABX;
use Page;
use mySociety::Config;
@@ -73,60 +75,72 @@ EOF
return $out;
}
-# This should use postcode, not x/y!
sub display {
my $q = shift;
my $pc = $q->param('pc');
+ my $x = $q->param('x') || 0;
+ my $y = $q->param('y') || 0;
+ $x+=0;
+ $y+=0;
- my $areas;
- my $error;
+ my($error, $name, $lbo);
try {
+ my $areas;
$areas = mySociety::MaPit::get_voting_areas($pc);
+
+ # Check for London Borough
+ throw RABX::Error("I'm afraid that postcode isn't in our covered area.", 123456) if (!$areas || !$areas->{LBO});
+
+ # Check for Lewisham or Newham
+ $lbo = $areas->{LBO};
+ throw RABX::Error("I'm afraid that postcode isn't in our covered London boroughs.", 123457) unless ($lbo == 2510 || $lbo == 2492);
+
+ my $area_info = mySociety::MaPit::get_voting_area_info($lbo);
+ $name = $area_info->{name};
+
+ if (!$x && !$y) {
+ my $location = mySociety::MaPit::get_location($pc);
+ my $northing = $location->{northing};
+ my $easting = $location->{easting};
+ $x = int($easting / (5000/31));
+ $y = int($northing/ (5000/31));
+ }
} catch RABX::Error with {
my $e = shift;
if ($e->value() == mySociety::MaPit::BAD_POSTCODE
- || $e->value() == mySociety::MaPit::POSTCODE_NOT_FOUND) {
+ || $e->value() == mySociety::MaPit::POSTCODE_NOT_FOUND) {
$error = 'That postcode was not recognised, sorry.';
} else {
- $e->throw();
+ $error = $e;
}
};
return front_page($error) if ($error);
- # Check for London Borough
- return front_page('I\'m afraid that postcode isn\'t in our covered area.') if (!$areas || !$areas->{LBO});
-
- # Check for Lewisham or Newham
- my $lbo = $areas->{LBO};
- return front_page('I\'m afraid that postcode isn\'t in our covered London boroughs.') unless ($lbo == 2510 || $lbo == 2492);
-
- my $area_info = mySociety::MaPit::get_voting_area_info($lbo);
- my $name = $area_info->{name};
-
- my $location = mySociety::MaPit::get_location($pc);
-
my $out = <<EOF;
<h2>$name</h2>
<p>Now, please select the location of the problem on the map below.
Use the arrows to the left of the map to scroll around.</p>
EOF
- my @ps = $q->param;
- foreach (@ps) {
- my $x = $q->param($_) if /\.x$/;
- my $y = $q->param($_) if /\.y$/;
- }
+
+# XXX: This is for when they click on the map
+# my @ps = $q->param;
+# foreach (@ps) {
+# my $x = $q->param($_) if /\.x$/;
+# my $y = $q->param($_) if /\.y$/;
+# }
- my $x = $q->param('x') || 628;
- my $y = $q->param('y') || 1724;
- my $dir = mySociety::Config::get('TILES_URL');
- my $tl = $x . '.' . $y;
- my $tr = ($x+1) . '.' . $y;
- my $bl = $x . '.' . ($y+1);
- my $br = ($x+1) . '.' . ($y+1);
- my $tl_src = $dir . $tl . '.png';
- my $tr_src = $dir . $tr . '.png';
- my $bl_src = $dir . $bl . '.png';
- my $br_src = $dir . $br . '.png';
+ my $url = mySociety::Config::get('TILES_URL');
+ my $tiles = $url . $x . '-' . ($x+1) . ',' . $y . '-' . ($y+1) . '/RABX';
+ $tiles = LWP::Simple::get($tiles);
+ my $tileids = RABX::unserialise($tiles);
+ my $tl = $x . '.' . ($y+1);
+ my $tr = ($x+1) . '.' . ($y+1);
+ my $bl = $x . '.' . $y;
+ my $br = ($x+1) . '.' . $y;
+ my $tl_src = $url . $tileids->[0][0];
+ my $tr_src = $url . $tileids->[0][1];
+ my $bl_src = $url . $tileids->[1][0];
+ my $br_src = $url . $tileids->[1][1];
$pc = encode_entities($pc);
$out .= <<EOF;
<form action"=./" method="get">
@@ -136,7 +150,7 @@ EOF
<input type="hidden" name="y" value="$y">
<input type="hidden" name="pc" value="$pc">
<input type="hidden" name="lbo" value="$lbo">
- <input type="image" id="2.2" name="$tl" src="$tl_src" style="top:0px; left:0px;"><input type="image" id="3.2" name="$tr" src="$tr_src" style="top:0px; left:250px;"><br><input type="image" id="2.3" name="$bl" src="$bl_src" style="top:250px; left:0px;"><input type="image" id="3.3" name="$br" src="$br_src" style="top:250px; left:250px;">
+ <input type="image" id="2.2" name="tile_$tl" src="$tl_src" style="top:0px; left:0px;"><input type="image" id="3.2" name="tile_$tr" src="$tr_src" style="top:0px; left:254px;"><br><input type="image" id="2.3" name="tile_$bl" src="$bl_src" style="top:254px; left:0px;"><input type="image" id="3.3" name="tile_$br" src="$br_src" style="top:254px; left:254px;">
</div>
EOF
$out .= Page::compass($pc, $x, $y);
@@ -156,8 +170,8 @@ EOF
6 => 'Abandoned car',
);
foreach (sort keys %current) {
- my $px = int(rand(500)) - 6;
- my $py = int(rand(500)) - 20;
+ my $px = int(rand(508)) - 6;
+ my $py = int(rand(508)) - 20;
$out .= '<li><a href="/?id=' . $_ . '">';
$out .= '<img src="/i/pin_red.png" alt="Problem"';
$out .= ' style="top:'.$py.'px; right:'.$px.'px">';
@@ -189,3 +203,4 @@ to describe the location of your problem instead.</p>
EOF
return $out;
}
+
diff --git a/web/js.js b/web/js.js
index 81b979b7a..076aef790 100644
--- a/web/js.js
+++ b/web/js.js
@@ -13,9 +13,9 @@ function Map(m) {
this.pos = YAHOO.util.Dom.getXY(this.map);
this.width = this.map.offsetWidth - 2;
this.height = this.map.offsetHeight - 2;
- this.tilewidth = 250;
- this.tileheight = 250;
- if (this.width != 500 || this.height != 500) {
+ this.tilewidth = 254;
+ this.tileheight = 254;
+ if (this.width != 508 || this.height != 508) {
return false;
}
this.point = new Point();
@@ -82,11 +82,11 @@ function Map(m) {
function image_rotate(img, x, y) {
if (x) {
- img.style.left = (img.offsetLeft + x*250) + 'px';
+ img.style.left = (img.offsetLeft + x*254) + 'px';
img.xx += x;
}
if (y) {
- img.style.top = (img.offsetTop + y*250) + 'px';
+ img.style.top = (img.offsetTop + y*254) + 'px';
img.yy += y;
}
var url = img.xx + '.' + img.yy + '.png';
@@ -121,13 +121,13 @@ function Map(m) {
if (!img.xx) { img.xx = xx; }
if (!img.yy) { img.yy = yy; }
if (!img.galleryimg) { img.galleryimg = false; }
- if (drag_x + img.offsetLeft > 750) {
+ if (drag_x + img.offsetLeft > 762) {
image_rotate(img, -6, 0);
- } else if (drag_x + img.offsetLeft < -500) {
+ } else if (drag_x + img.offsetLeft < -508) {
image_rotate(img, 6, 0);
- } else if (drag_y + img.offsetTop > 750) {
+ } else if (drag_y + img.offsetTop > 762) {
image_rotate(img, 0, -6);
- } else if (drag_y + img.offsetTop < -500) {
+ } else if (drag_y + img.offsetTop < -508) {
image_rotate(img, 0, 6);
}
continue;