aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm6
-rw-r--r--perllib/FixMyStreet/Map/Bing.pm10
-rw-r--r--perllib/FixMyStreet/Map/BingOL.pm10
-rw-r--r--perllib/FixMyStreet/Map/Google.pm10
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm18
-rw-r--r--perllib/FixMyStreet/Map/OSM/StreetView.pm10
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm10
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm10
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original.pm49
12 files changed, 46 insertions, 93 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 054f83a35..38e6025db 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -187,7 +187,7 @@ sub display_location : Private {
{ # FIXME - ideally this indented code should be in the templates
$c->stash->{map_html} = FixMyStreet::Map::display_map(
- $c, $c->fake_q,
+ $c,
latitude => $latitude,
longitude => $longitude,
type => 1,
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 0fafcdc2e..96650a1c6 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -209,7 +209,7 @@ sub display : Private {
$c->stash->{updates} = $updates;
$c->stash->{map_start_html} = FixMyStreet::Map::display_map(
- $c, $c->fake_q,
+ $c,
latitude => $problem->latitude,
longitude => $problem->longitude,
pins => [ [ $problem->latitude, $problem->longitude, $problem->state eq 'fixed' ? 'green' : 'red' ] ],
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index a0e5d44c4..ae3dd5291 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -151,7 +151,7 @@ sub generate_map_tags : Private {
my $problem = $c->stash->{problem};
$c->stash->{map_start_html} = FixMyStreet::Map::display_map(
- $c, $c->fake_q,
+ $c,
latitude => $problem->latitude,
longitude => $problem->longitude,
type => 0,
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 817cee11e..bbf125833 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -418,8 +418,8 @@ sub determine_location_from_tile_click : Private {
return unless $pin_x && $pin_y;
# convert the click to lat and lng
- my ( $latitude, $longitude ) = FixMyStreet::Map::click_to_wgs84( #
- $c->fake_q, #
+ my ( $latitude, $longitude ) = FixMyStreet::Map::click_to_wgs84(
+ $c,
$pin_tile_x, $pin_x, $pin_tile_y, $pin_y
);
@@ -904,7 +904,7 @@ sub generate_map : Private {
# Don't do anything if the user skipped the map
unless ( $c->req->param('skipped') ) {
$c->stash->{map_html} = FixMyStreet::Map::display_map(
- $c, $c->fake_q,
+ $c,
latitude => $latitude,
longitude => $longitude,
type => 1,
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm
index ccd57221f..0db1a51c3 100644
--- a/perllib/FixMyStreet/Map/Bing.pm
+++ b/perllib/FixMyStreet/Map/Bing.pm
@@ -18,15 +18,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/BingOL.pm
index 4d1e0a270..2f3ae92d2 100644
--- a/perllib/FixMyStreet/Map/BingOL.pm
+++ b/perllib/FixMyStreet/Map/BingOL.pm
@@ -20,15 +20,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/Google.pm b/perllib/FixMyStreet/Map/Google.pm
index 92eda0a7b..c50019099 100644
--- a/perllib/FixMyStreet/Map/Google.pm
+++ b/perllib/FixMyStreet/Map/Google.pm
@@ -18,15 +18,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 73742d0d3..4786ed59b 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -25,24 +25,22 @@ sub map_type {
return 'OpenLayers.Layer.OSM.Mapnik';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
# latitude, longitude for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
# Map centre may be overridden in the query string
- $params{latitude} = Utils::truncate_coordinate($q->param('lat')+0)
- if defined $q->param('lat');
- $params{longitude} = Utils::truncate_coordinate($q->param('lon')+0)
- if defined $q->param('lon');
+ $params{latitude} = Utils::truncate_coordinate($c->req->params->{lat} + 0)
+ if defined $c->req->params->{lat};
+ $params{longitude} = Utils::truncate_coordinate($c->req->params->{lon} + 0)
+ if defined $c->req->params->{lon};
- my $zoom = defined $q->param('zoom') ? $q->param('zoom') : 2;
+ my $zoom = defined $c->req->params->{zoom} ? $c->req->params->{zoom} : 2;
my $zoom_act = 14 + $zoom;
my ($x_tile, $y_tile) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $zoom_act);
diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm
index e9b86547e..9512e2013 100644
--- a/perllib/FixMyStreet/Map/OSM/StreetView.pm
+++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm
@@ -19,15 +19,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
index 08e1036bb..df334597b 100644
--- a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
+++ b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
@@ -25,15 +25,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
index bbef3c532..610e50ae6 100644
--- a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
+++ b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
@@ -25,15 +25,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
-# EASTING, NORTHING for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# latitude, longitude for the centre point of the map
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
$params{pre} ||= '';
my @pins;
diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm
index d5f92d3c9..d553b06e2 100644
--- a/perllib/FixMyStreet/Map/Tilma/Original.pm
+++ b/perllib/FixMyStreet/Map/Tilma/Original.pm
@@ -33,15 +33,13 @@ sub header_js {
';
}
-# display_map Q PARAMS
+# display_map C PARAMS
# PARAMS include:
# latitude, longitude for the centre point of the map
-# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
-# 0 if not clickable
+# TYPE is 1 if the map is clickable, 0 otherwise.
# PINS is array of pins to show, location and colour
-# PRE/POST are HTML to show above/below map
sub display_map {
- my ($self, $c, $q, %params) = @_;
+ my ($self, $c, %params) = @_;
my $mid_point = TILE_WIDTH; # Map is 2 TILE_WIDTHs in size, square.
if (my $mp = Cobrand::tilma_mid_point(Page::get_cobrand($q))) {
$mid_point = $mp;
@@ -61,11 +59,11 @@ sub display_map {
# X/Y tile co-ords may be overridden in the query string
my @vars = qw(x y);
- my %input = map { $_ => $q->param($_) || '' } @vars;
+ my %input = map { $_ => $c->req->params->{$_} || '' } @vars;
($input{x}) = $input{x} =~ /^(\d+)/; $input{x} ||= 0;
($input{y}) = $input{y} =~ /^(\d+)/; $input{y} ||= 0;
- my ($x, $y, $px, $py) = os_to_px_with_adjust($q, $params{easting}, $params{northing}, $input{x}, $input{y});
+ my ($x, $y, $px, $py) = os_to_px_with_adjust($c, $params{easting}, $params{northing}, $input{x}, $input{y});
my @pins;
foreach my $pin (@{$params{pins}}) {
@@ -223,7 +221,7 @@ sub click_to_os {
# tile they were), convert to WGS84 and return.
sub click_to_wgs84 {
my $self = shift;
- my $q = shift;
+ my $c = shift;
my ( $easting, $northing ) = click_to_os(@_);
my ( $lat, $lon ) = mySociety::GeoUtil::national_grid_to_wgs84( $easting, $northing, 'G' );
return ( $lat, $lon );
@@ -233,7 +231,7 @@ sub click_to_wgs84 {
# of the map (either to get the point near the middle, or the override X,Y),
# and the pixel co-ords of the point, relative to that map.
sub os_to_px_with_adjust {
- my ($q, $easting, $northing, $in_x, $in_y) = @_;
+ my ($c, $easting, $northing, $in_x, $in_y) = @_;
my $x = os_to_tile($easting);
my $y = os_to_tile($northing);
@@ -250,7 +248,7 @@ sub os_to_px_with_adjust {
my $px = os_to_px($easting, $x_tile);
my $py = os_to_px($northing, $y_tile, 1);
- if ($q->{site} eq 'barnet') { # Map is 380px, so might need to adjust
+ if ($c->cobrand->tilma_mid_point == 189) { # Map is 380px, so might need to adjust
if (!$in_x && $px > 380) {
$x_tile++;
$px = os_to_px($easting, $x_tile);
@@ -264,35 +262,4 @@ sub os_to_px_with_adjust {
return ($x_tile, $y_tile, $px, $py);
}
-sub compass ($$$) {
- my ( $q, $x, $y ) = @_;
- my @compass;
- for ( my $i = $x - 1 ; $i <= $x + 1 ; $i++ ) {
- for ( my $j = $y - 1 ; $j <= $y + 1 ; $j++ ) {
- $compass[$i][$j] = NewURL( $q, x => $i, y => $j );
- }
- }
- my $recentre = NewURL($q);
- my $host = Page::base_url_with_lang( $q, undef );
- return <<EOF;
-<table cellpadding="0" cellspacing="0" border="0" id="compass">
-<tr valign="bottom">
-<td align="right"><a rel="nofollow" href="${compass[$x-1][$y+1]}"><img src="$host/i/arrow-northwest.gif" alt="NW" width=11 height=11></a></td>
-<td align="center"><a rel="nofollow" href="${compass[$x][$y+1]}"><img src="$host/i/arrow-north.gif" vspace="3" alt="N" width=13 height=11></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y+1]}"><img src="$host/i/arrow-northeast.gif" alt="NE" width=11 height=11></a></td>
-</tr>
-<tr>
-<td><a rel="nofollow" href="${compass[$x-1][$y]}"><img src="$host/i/arrow-west.gif" hspace="3" alt="W" width=11 height=13></a></td>
-<td align="center"><a rel="nofollow" href="$recentre"><img src="$host/i/rose.gif" alt="Recentre" width=35 height=34></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y]}"><img src="$host/i/arrow-east.gif" hspace="3" alt="E" width=11 height=13></a></td>
-</tr>
-<tr valign="top">
-<td align="right"><a rel="nofollow" href="${compass[$x-1][$y-1]}"><img src="$host/i/arrow-southwest.gif" alt="SW" width=11 height=11></a></td>
-<td align="center"><a rel="nofollow" href="${compass[$x][$y-1]}"><img src="$host/i/arrow-south.gif" vspace="3" alt="S" width=13 height=11></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y-1]}"><img src="$host/i/arrow-southeast.gif" alt="SE" width=11 height=11></a></td>
-</tr>
-</table>
-EOF
-}
-
1;