aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-25 16:43:40 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-25 16:43:40 +0100
commitd974cc0258d26a366262bce7b456d39b0c71a40b (patch)
tree03534cbf86dcf83a36df3839ff49e70cbf458b5b
parent6a679dbe9f0d7021f176ca23106a74bc2475539e (diff)
parentc5ace4f09cb6a31942a4be688f883ca141ca6649 (diff)
Merge branch 'migrate_to_catalyst' of ssh://git.mysociety.org/data/git/public/fixmystreet into migrate_to_catalyst
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm11
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm6
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm25
-rw-r--r--perllib/FixMyStreet/Map/OSM/CycleMap.pm4
-rw-r--r--perllib/FixMyStreet/Map/OSM/StreetView.pm40
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original.pm23
-rw-r--r--templates/web/default/around/around_index.html2
-rw-r--r--templates/web/default/maps/osm.html14
-rw-r--r--templates/web/default/maps/tilma/original.html2
-rw-r--r--templates/web/default/report/display.html2
12 files changed, 61 insertions, 80 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 38e6025db..ac665055b 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -180,10 +180,13 @@ sub display_location : Private {
$c->stash->{distance} = $distance;
# create a list of all the pins
- my @pins = map {
- my $pin_colour = $_->{state} eq 'fixed' ? 'green' : 'red';
- [ $_->{latitude}, $_->{longitude}, $pin_colour, $_->{id}, $_->{title} ];
- } @$on_map_all, @$around_map;
+ my @pins = map { {
+ latitude => $_->{latitude},
+ longitude => $_->{longitude},
+ colour => $_->{state} eq 'fixed' ? 'green' : 'red',
+ id => $_->{id},
+ title => $_->{title},
+ } } @$on_map_all, @$around_map;
{ # FIXME - ideally this indented code should be in the templates
$c->stash->{map_html} = FixMyStreet::Map::display_map(
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 7169bc9e7..f46b98510 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -260,7 +260,11 @@ sub display : Private {
$c,
latitude => $problem->latitude,
longitude => $problem->longitude,
- pins => [ [ $problem->latitude, $problem->longitude, $problem->state eq 'fixed' ? 'green' : 'red' ] ],
+ pins => [ {
+ latitude => $problem->latitude,
+ longitude => $problem->longitude,
+ colour => $problem->state eq 'fixed' ? 'green' : 'red',
+ } ],
);
$c->stash->{map_js} = FixMyStreet::Map::header_js();
$c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('questionnaireForm');
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index ae3dd5291..82f553d71 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -156,7 +156,11 @@ sub generate_map_tags : Private {
longitude => $problem->longitude,
type => 0,
pins => $problem->used_map
- ? [ [ $problem->latitude, $problem->longitude, 'blue' ] ]
+ ? [ {
+ latitude => $problem->latitude,
+ longitude => $problem->longitude,
+ colour => 'blue',
+ } ]
: [],
);
$c->stash->{map_js} = FixMyStreet::Map::header_js();
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index bbf125833..2bba93cd4 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -908,7 +908,11 @@ sub generate_map : Private {
latitude => $latitude,
longitude => $longitude,
type => 1,
- pins => [ [ $latitude, $longitude, 'purple' ] ],
+ pins => [ {
+ latitude => $latitude,
+ longitude => $longitude,
+ colour => 'purple',
+ } ],
);
}
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 9ccbac017..aeece3960 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -10,7 +10,6 @@ package FixMyStreet::Map::OSM;
use strict;
use Math::Trig;
-use mySociety::Web qw(ent NewURL);
use Utils;
sub header_js {
@@ -25,6 +24,14 @@ sub map_type {
return 'OpenLayers.Layer.OSM.Mapnik';
}
+sub base_tile_url {
+ return 'tile.openstreetmap.org';
+}
+
+sub copyright {
+ return _('Map &copy; <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>');
+}
+
# display_map C PARAMS
# PARAMS include:
# latitude, longitude for the centre point of the map
@@ -45,18 +52,8 @@ sub display_map {
my $zoom_act = 14 + $zoom;
my ($x_tile, $y_tile) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $zoom_act);
- my @pins;
foreach my $pin (@{$params{pins}}) {
- my ($px, $py) = latlon_to_px($pin->[0], $pin->[1], $x_tile, $y_tile, $zoom_act);
- push @pins, {
- lat => $pin->[0],
- lon => $pin->[1],
- px => $px,
- py => $py,
- col => $pin->[2],
- id => $pin->[3],
- title => $pin->[4],
- };
+ ($pin->{px}, $pin->{py}) = latlon_to_px($pin->{latitude}, $pin->{longitude}, $x_tile, $y_tile, $zoom_act);
}
my $compass = {
@@ -72,11 +69,13 @@ sub display_map {
latitude => $params{latitude},
longitude => $params{longitude},
map_type => $self->map_type(),
+ tile_url => $self->base_tile_url(),
+ copyright => $self->copyright(),
x_tile => $x_tile,
y_tile => $y_tile,
zoom => $zoom,
zoom_act => $zoom_act,
- pins => \@pins,
+ pins => $params{pins},
compass => $compass,
};
}
diff --git a/perllib/FixMyStreet/Map/OSM/CycleMap.pm b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
index 06b07ae20..71b86de8f 100644
--- a/perllib/FixMyStreet/Map/OSM/CycleMap.pm
+++ b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
@@ -15,4 +15,8 @@ sub map_type {
return 'OpenLayers.Layer.OSM.CycleMap';
}
+sub base_tile_url {
+ return 'tile.opencyclemap.org/cycle';
+}
+
1;
diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm
index 9512e2013..ba7134c1e 100644
--- a/perllib/FixMyStreet/Map/OSM/StreetView.pm
+++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm
@@ -7,9 +7,9 @@
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
package FixMyStreet::Map::OSM::StreetView;
+use base 'FixMyStreet::Map::OSM';
use strict;
-use mySociety::Web qw(ent);
sub header_js {
return '
@@ -19,38 +19,16 @@ sub header_js {
';
}
-# display_map C PARAMS
-# PARAMS include:
-# 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
-sub display_map {
- my ($self, $c, %params) = @_;
- $params{pre} ||= '';
-
- my @pins;
- foreach my $pin (@{$params{pins}}) {
- $pin->[3] ||= '';
- push @pins, "[ $pin->[0], $pin->[1], '$pin->[2]', '$pin->[3]' ]";
- }
- my $pins_js = join(",\n", @pins);
+sub map_type {
+ return '""';
+}
- my $out = '';
- my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
- $out .= <<EOF;
-<script type="text/javascript">
-var fixmystreet = {
- 'latitude': $params{latitude},
- 'longitude': $params{longitude},
- 'pins': [ $pins_js ]
+sub base_tile_url {
+ return 'os.openstreetmap.org/sv';
}
-</script>
-<div id="map_box">
- $params{pre}
- <div id="map"></div>
- <p id="copyright">$copyright</p>
-EOF
- return $out;
+
+sub copyright {
+ return _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
}
1;
diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm
index 7ba0afab5..c7ff5a52f 100644
--- a/perllib/FixMyStreet/Map/Tilma/Original.pm
+++ b/perllib/FixMyStreet/Map/Tilma/Original.pm
@@ -49,14 +49,6 @@ sub display_map {
( $params{easting}, $params{northing} ) =
_ll_to_en( $params{latitude}, $params{longitude} );
- # FIXME - convert all pins to lat, lng
- # all the pins are currently [lat, lng, colour] - convert them
- foreach my $pin ( @{ $params{pins} ||= [] } ) {
- my ( $lat, $lon ) = ( $pin->[0], $pin->[1] );
- my ( $e, $n ) = _ll_to_en( $lat, $lon );
- ( $pin->[0], $pin->[1] ) = ( $e, $n );
- }
-
# X/Y tile co-ords may be overridden in the query string
my @vars = qw(x y);
my %input = map { $_ => $c->req->params->{$_} || '' } @vars;
@@ -65,17 +57,10 @@ sub display_map {
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}}) {
- my $pin_x = os_to_px($pin->[0], $x);
- my $pin_y = os_to_px($pin->[1], $y, 1);
- push @pins, {
- px => $pin_x,
- py => $pin_y,
- col => $pin->[2],
- id => $pin->[3],
- title => $pin->[4],
- };
+ my ( $e, $n ) = _ll_to_en( $pin->{latitude}, $pin->{longitude} );
+ $pin->{px} = os_to_px($e, $x);
+ $pin->{py} = os_to_px($n, $y, 1);
}
$px = defined($px) ? $mid_point - $px : 0;
@@ -88,7 +73,7 @@ sub display_map {
my $tileids = RABX::unserialise($tiles);
$c->stash->{map} = {
type => 'tilma/original',
- pins => \@pins,
+ pins => $params{pins},
tiles => $tiles,
clickable => $params{type},
url => $url,
diff --git a/templates/web/default/around/around_index.html b/templates/web/default/around/around_index.html
index 38d692db2..8c144e469 100644
--- a/templates/web/default/around/around_index.html
+++ b/templates/web/default/around/around_index.html
@@ -33,7 +33,7 @@
<p>[% loc('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.') %]</p>
<ul class="pc_alternatives">
[% FOREACH match IN possible_location_matches %]
- <li><a href="/?pc=[% match | uri %]">[% match | html %]</a></li>
+ <li><a href="/around?pc=[% match | uri %]">[% match | html %]</a></li>
[% END %]
</ul>
[% END %]
diff --git a/templates/web/default/maps/osm.html b/templates/web/default/maps/osm.html
index 4c1c23166..5f8336c52 100644
--- a/templates/web/default/maps/osm.html
+++ b/templates/web/default/maps/osm.html
@@ -11,7 +11,7 @@ var fixmystreet = {
'longitude': [% map.longitude %],
'pins': [
[% FOR pin IN map.pins -%]
- [ [% pin.lat %], [% pin.lon %], '[% pin.col %]', '[% pin.id %]', '[% pin.title %]' ]
+ [ [% pin.latitude %], [% pin.longitude %], '[% pin.colour %]', '[% pin.id %]', '[% pin.title %]' ]
[%- IF !loop.last %],[% END %]
[% END %] ],
'map_type': [% map.map_type %]
@@ -23,25 +23,25 @@ var fixmystreet = {
<div id="drag"><[% map.img_type %]
alt="NW map tile" id="t2.2"
name="tile_[% map.x_tile - 1 %].[% map.y_tile - 1 %]"
- src="http://a.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile - 1 %].png"
+ src="http://a.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile - 1 %].png"
style="top:0; left:0;"><[% map.img_type %]
alt="NE map tile" id="t2.3"
name="tile_[% map.x_tile %].[% map.y_tile - 1 %]"
- src="http://b.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile - 1 %].png"
+ src="http://b.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile - 1 %].png"
style="top:0px; left:256px;"><br><[% map.img_type %]
alt="SW map tile" id="t3.2"
name="tile_[% map.x_tile - 1 %].[% map.y_tile %]"
- src="http://c.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile %].png"
+ src="http://c.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile %].png"
style="top:256px; left:0;"><[% map.img_type %]
alt="SE map tile" id="t3.3"
name="tile_[% map.x_tile %].[% map.y_tile %]"
- src="http://tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile %].png"
+ src="http://[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile %].png"
style="top:256px; left:256px;"></div>
<div id="pins">[% FOR pin IN map.pins %][% INCLUDE pin %][% END %]</div>
[% INCLUDE compass %]
</noscript></div>
<p id="copyright">
- [% loc('Map &copy; <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>') %]
+ [% map.copyright %]
</p>
@@ -78,7 +78,7 @@ var fixmystreet = {
[% IF pin.id %]
<a title="[% pin.title | html %]" href="[% c.uri_for('/report/' _ pin.id) %]">
[%- END -%]
-<img border="0" class="pin" src="[% c.uri_for('/i/pin' _ cols.${pin.col} _ '.gif') %]"
+<img border="0" class="pin" src="[% c.uri_for('/i/pin' _ cols.${pin.colour} _ '.gif') %]"
alt="[% loc('Problem') %]" style="top:[% pin.py - 59 %]px; left:[% pin.px %]px; position: absolute;">
[%- IF pin.id -%]
</a>
diff --git a/templates/web/default/maps/tilma/original.html b/templates/web/default/maps/tilma/original.html
index 6e3c34a86..546e027dc 100644
--- a/templates/web/default/maps/tilma/original.html
+++ b/templates/web/default/maps/tilma/original.html
@@ -51,7 +51,7 @@ var fixmystreet = {
[% IF pin.id %]
<a title="[% pin.title | html %]" href="[% c.uri_for('/report/' _ pin.id) %]">
[%- END -%]
-<img class="pin" src="[% c.uri_for('/i/pin' _ cols.${pin.col} _ num _ '.gif') %]"
+<img class="pin" src="[% c.uri_for('/i/pin' _ cols.${pin.colour} _ num _ '.gif') %]"
alt="[% loc('Problem') %]" style="top:[% pin.py - 59 %]px; left:[% pin.px %]px; position: absolute;">
[%- IF pin.id -%]
</a>
diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html
index 1461ffc39..ef51dca01 100644
--- a/templates/web/default/report/display.html
+++ b/templates/web/default/report/display.html
@@ -33,7 +33,7 @@
</p>
<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right">
- <a href="[% c.uri_for( '/', { lat => short_latitude, lon => short_longitude } ) %]">[% loc( 'More problems nearby' ) %]</a>
+ <a href="[% c.uri_for( '/around', { lat => short_latitude, lon => short_longitude } ) %]">[% loc( 'More problems nearby' ) %]</a>
</p>
<div id="alert_links">