#!/usr/bin/perl -w # index.pl: # Main code for BCI - not really. # # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # # $Id: index.cgi,v 1.2 2006-09-19 16:24:22 francis Exp $ use strict; use CGI::Fast qw(-no_xhtml); use Error qw(:try); my $q; try { while ($q = new CGI::Fast()) { print $q->header(); my $x = $q->param('x') || 62; my $y = $q->param('y') || 171; my $zoom = $q->param('z') || 250; my $dir; if ($zoom == 25) { $dir = 'tl/'; } else { $dir = 't/'; } my $tl = $dir.$x.'.'.$y.'.png'; my $tr = $dir.($x+1).'.'.$y.'.png'; my $bl = $dir.$x.'.'.($y+1).'.png'; my $br = $dir.($x+1).'.'.($y+1).'.png'; my $url = sub { my ($x, $y, $z) = @_; $z = $zoom unless $z; return '?x=' . $x . '&y=' . $y . '&z=' . $z; }; my $nw = &$url($x-1, $y-1); my $n = &$url($x, $y-1); my $ne = &$url($x+1, $y-1); my $w = &$url($x-1,$y); my $e = &$url($x+1,$y); my $sw = &$url($x-1, $y+1); my $s = &$url($x, $y+1); my $se = &$url($x+1, $y+1); print < MapOS testing

MapOS

Drag to move, double-click to centre, or use the arrows. Zoom's a bit of a jump (250,000:1 to 25,000:1 and back) but should be okay - if you double-click just before a zoom in, that's probably best. Bugs: None at this immediate moment

NW N NE
W E
SW S SE

EOF if ($zoom != 250) { printf('Zoom out', &$url(round($x/10)-1,round($y/10)-1,250) ); } if ($zoom != 25) { print 'Zoom in'; } print <


EOF } } catch Error::Simple with { my $E = shift; my $msg = sprintf('%s:%d: %s', $E->file(), $E->line(), $E->text()); warn "caught fatal exception: $msg"; warn "aborting"; encode_entities($msg); print "Status: 500\nContent-Type: text/html; charset=iso-8859-1\n\n", q(

Unfortunately, something went wrong. The text of the error was:

), qq(
$msg
), q(

Please try again later.); };