diff options
-rwxr-xr-x | bin/send-reports | 10 | ||||
-rw-r--r-- | perllib/Cobrands/Barnet/Util.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Bing.pm | 71 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/BingOL.pm | 71 | ||||
-rw-r--r-- | perllib/Page.pm | 6 | ||||
-rwxr-xr-x | web/confirm.cgi | 4 | ||||
-rwxr-xr-x | web/index.cgi | 4 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 96 | ||||
-rw-r--r-- | web/js/map-bing.js | 21 | ||||
-rwxr-xr-x | web/rss.cgi | 10 |
10 files changed, 271 insertions, 24 deletions
diff --git a/bin/send-reports b/bin/send-reports index c91de5e33..d61269d96 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -43,8 +43,6 @@ BEGIN { ); } -use mySociety::Dress; # Has to come after the BEGIN, my poor coding - # Set up site, language etc. my ($verbose, $nomail) = CronFns::options(); my $base_url = mySociety::Config::get('BASE_URL'); @@ -96,13 +94,7 @@ foreach my $row (@$unsent) { $h{fuzzy} = $row->{used_map} ? _('To view a map of the precise location of this issue') : _('The user could not locate the problem on a map, but to see the area around the location they entered'); $h{closest_address} = ''; - my ($address, $distance) = mySociety::Dress::find_nearest($row->{easting}, $row->{northing}); - if ($address) { - $h{closest_address} = sprintf(_("The closest address, as the crow flies, to the location of this problem, %.0fm away, is: %s - please note that this is automatically generated, so ensure that you check it against the details provided by the user and, if possible, the map.") . "\n\n", - $distance, $address); - ($h{closest_address_machine} = $h{closest_address}) =~ s/is: /is:\n\n/; - $h{closest_address_machine} =~ s/ - please note/\n\n - please note/; - } + $h{closest_address_machine} = ''; my (@to, @recips, $template, $areas_info); if ($site eq 'emptyhomes') { diff --git a/perllib/Cobrands/Barnet/Util.pm b/perllib/Cobrands/Barnet/Util.pm index e59e9118f..32973c10c 100644 --- a/perllib/Cobrands/Barnet/Util.pm +++ b/perllib/Cobrands/Barnet/Util.pm @@ -81,7 +81,7 @@ sub council_check { $url .= 'alert' if $context eq 'alert'; $url .= '?pc=' . URI::Escape::uri_escape_utf8($q->param('pc')) if $q->param('pc'); my $error_msg = "That location is not covered by Barnet. -Please visit <a href='$url'>the main FixMyStreet site</a>."; +Please visit <a href=\"$url\">the main FixMyStreet site</a>."; return (0, $error_msg); } diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm new file mode 100644 index 000000000..8446a10fd --- /dev/null +++ b/perllib/FixMyStreet/Map/Bing.pm @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# +# FixMyStreet:Map::Bing +# Bing maps on FixMyStreet. +# +# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ + +package FixMyStreet::Map; + +use strict; +use mySociety::GeoUtil; +use mySociety::Web qw(ent); + +sub header_js { + return ' +<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=en-GB"></script> +<script type="text/javascript" src="/js/map-bing.js"></script> +'; +} + +# display_map Q 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 +# PINS is array of pins to show, location and colour +# PRE/POST are HTML to show above/below map +sub display_map { + my ($q, %params) = @_; + $params{pre} ||= ''; + $params{post} ||= ''; + + foreach my $pin (@{$params{pins}}) { + } + + my $out = FixMyStreet::Map::header($q, $params{type}); + my ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($params{easting}, $params{northing}, 'G'); + my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); + $out .= <<EOF; +<script type="text/javascript"> +var fixmystreet = { + 'lat': $lat, + 'lon': $lon +} +</script> +<div id="map_box"> + $params{pre} + <div id="map"></div> + <p id="copyright">$copyright</p> + $params{post} +</div> +<div id="side"> +EOF + return $out; +} + +sub display_map_end { + my ($type) = @_; + my $out = '</div>'; + $out .= '</form>' if ($type); + return $out; +} + +sub display_pin { +} + +sub map_pins { +} + +1; diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/BingOL.pm new file mode 100644 index 000000000..3939a710f --- /dev/null +++ b/perllib/FixMyStreet/Map/BingOL.pm @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# +# FixMyStreet:Map::Bing +# Bing maps on FixMyStreet. +# +# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ + +package FixMyStreet::Map; + +use strict; +use mySociety::Web qw(ent); + +sub header_js { + return ' +<!-- <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=en-GB"></script> --> +<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script> +<script type="text/javascript" src="/js/map-bing-ol.js"></script> +<script type="text/javascript" src="/js/OpenLayers.Projection.OrdnanceSurvey.js"></script> +'; +} + +# display_map Q 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 +# PINS is array of pins to show, location and colour +# PRE/POST are HTML to show above/below map +sub display_map { + my ($q, %params) = @_; + $params{pre} ||= ''; + $params{post} ||= ''; + + foreach my $pin (@{$params{pins}}) { + } + + my $out = FixMyStreet::Map::header($q, $params{type}); + my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010. Microsoft'); + $out .= <<EOF; +<script type="text/javascript"> +var fixmystreet = { + 'easting': $params{easting}, + 'northing': $params{northing} +} +</script> +<div id="map_box"> + $params{pre} + <div id="map"></div> + <p id="copyright">$copyright</p> + $params{post} +</div> +<div id="side"> +EOF + return $out; +} + +sub display_map_end { + my ($type) = @_; + my $out = '</div>'; + $out .= '</form>' if ($type); + return $out; +} + +sub display_pin { +} + +sub map_pins { +} + +1; diff --git a/perllib/Page.pm b/perllib/Page.pm index 1b94f5c2b..917fc6991 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -33,7 +33,6 @@ use mySociety::EvEl; use mySociety::Locale; use mySociety::MaPit; use mySociety::TempFiles; -use mySociety::Tracking; use mySociety::WatchUpdate; use mySociety::Web qw(ent); @@ -315,7 +314,6 @@ sub header ($%) { =cut sub footer { my ($q, %params) = @_; - my $extra = $params{extra}; if ($q->{site} ne 'fixmystreet') { my $template = template($q, %params) . '-footer'; @@ -330,8 +328,6 @@ sub footer { my $pc = $q->param('pc') || ''; $pc = "?pc=" . ent($pc) if $pc; - $extra = $q->{scratch} if $q->{scratch}; # Overrides - my $track = mySociety::Tracking::code($q, $extra); my $piwik = ""; if (mySociety::Config::get('BASE_URL') eq "http://www.fixmystreet.com") { @@ -375,8 +371,6 @@ $orglogo <p id="footer">$creditline</p> -$track - $piwik </body> diff --git a/web/confirm.cgi b/web/confirm.cgi index 1ee37c034..925b64ed2 100755 --- a/web/confirm.cgi +++ b/web/confirm.cgi @@ -20,7 +20,6 @@ sub main { my $q = shift; my $cobrand = Page::get_cobrand($q); my $out = ''; - my $extra; my $token = $q->param('token'); my $type = $q->param('type') || ''; my $tokentype = $type eq 'questionnaire' ? 'update' : $type; @@ -30,7 +29,6 @@ sub main { $out = confirm_update($q, $data); } elsif ($type eq 'problem') { $out = confirm_problem($q, $data); - $extra = 'added-problem'; } elsif ($type eq 'questionnaire') { $out = add_questionnaire($q, $data, $token); } @@ -50,7 +48,7 @@ EOF print Page::header($q, title=>_('Confirmation')); print $out; - print Page::footer($q, extra => $extra); + print Page::footer($q); } Page::do_fastcgi(\&main); diff --git a/web/index.cgi b/web/index.cgi index 1864eba6f..83b3b421c 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -931,8 +931,8 @@ sub display_problem { my $google_link = Cobrand::base_url_for_emails($cobrand, $extra_data) . '/report/' . $problem->{id}; my ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($problem->{easting}, $problem->{northing}, 'G'); - my $map_links = "<p id='sub_map_links'><a href='http://maps.google.co.uk/maps?output=embed&z=16&q=" - . URI::Escape::uri_escape_utf8($problem->{title} . ' - ' . $google_link) . "\@$lat,$lon'>View on Google Maps</a></p>"; + my $map_links = "<p id='sub_map_links'><a href=\"http://maps.google.co.uk/maps?output=embed&z=16&q=" + . URI::Escape::uri_escape_utf8($problem->{title} . ' - ' . $google_link) . "\@$lat,$lon\">View on Google Maps</a></p>"; my $banner; if ($q->{site} ne 'emptyhomes' && $problem->{state} eq 'confirmed' && $problem->{duration} > 8*7*24*60*60) { diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js new file mode 100644 index 000000000..ba9445326 --- /dev/null +++ b/web/js/map-bing-ol.js @@ -0,0 +1,96 @@ +YAHOO.util.Event.onContentReady('map', function() { + var map = new OpenLayers.Map("map", { + controls: [ + new OpenLayers.Control.ArgParser(), + //new OpenLayers.Control.LayerSwitcher(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanZoom() + ], + displayProjection: new OpenLayers.Projection("EPSG:4326") + }); + var bing = new OpenLayers.Layer.Bing("", { + zoomOffset: 13, + numZoomLevels: 4 + }); + map.addLayer(bing); + + var centre = new OpenLayers.LonLat( fixmystreet.easting, fixmystreet.northing ); + centre.transform( + new OpenLayers.Projection("EPSG:27700"), + map.getProjectionObject() + ); + map.setCenter(centre, 3); +}); + +OpenLayers.Util.OS = {}; +OpenLayers.Util.OS.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png"; +OpenLayers.Util.OS.originalOnImageLoadError = OpenLayers.Util.onImageLoadError; +OpenLayers.Util.onImageLoadError = function() { + OpenLayers.Util.OS.originalOnImageLoadError; +}; + +OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { + initialize: function(name, options) { + var url = []; + options = OpenLayers.Util.extend({ + /* Below line added to OSM's file in order to allow minimum zoom level */ + maxResolution: 156543.0339/Math.pow(2, options.zoomOffset || 0), + numZoomLevels: 18, + transitionEffect: "resize", + sphericalMercator: true, + attribution: "© Microsoft / OS 2010" + }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); + }, + + get_quadkey: function(x, y, level) { + var key = ''; + for (var i = level; i > 0; i--) { + var digit = 0; + var mask = 1 << (i - 1); + if ((x & mask) != 0) { + digit++; + } + if ((y & mask) != 0) { + digit += 2; + } + key += digit; + } + return key; + }, + + getURL: function (bounds) { + var res = this.map.getResolution(); + var x = Math.round((bounds.left - this.maxExtent.left) + / (res * this.tileSize.w)); + var y = Math.round((this.maxExtent.top - bounds.top) + / (res * this.tileSize.h)); + var z = this.serverResolutions != null ? + OpenLayers.Util.indexOf(this.serverResolutions, res) : + this.map.getZoom() + this.zoomOffset; + + if (z == 16) { + var url = [ + "http://a.os.openstreetmap.org/sv/${z}/${x}/${y}.png", + "http://b.os.openstreetmap.org/sv/${z}/${x}/${y}.png", + "http://c.os.openstreetmap.org/sv/${z}/${x}/${y}.png" + ]; + } else { + var url = [ + "http://ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=587&productSet=mmOS", + "http://ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=587&productSet=mmOS", + "http://ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=587&productSet=mmOS", + "http://ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=587&productSet=mmOS" + ]; + } + var s = '' + x + y + z; + url = this.selectUrl(s, url); + + var id = this.get_quadkey(x, y, z); + var path = OpenLayers.String.format(url, {'id': id, 'x': x, 'y': y, 'z': z}); + return path; + }, + + CLASS_NAME: "OpenLayers.Layer.Bing" +}); diff --git a/web/js/map-bing.js b/web/js/map-bing.js new file mode 100644 index 000000000..fbbbcc676 --- /dev/null +++ b/web/js/map-bing.js @@ -0,0 +1,21 @@ +YAHOO.util.Event.onContentReady('map', function() { + var centre = new Microsoft.Maps.Location( fixmystreet.lat, fixmystreet.lon ); + var map = new Microsoft.Maps.Map(document.getElementById("map"), { + mapTypeId: Microsoft.Maps.MapTypeId.ordnanceSurvey, + center: centre, + zoom: 15, + enableClickableLogo: false, + enableSearchLogo: false, + showCopyright: false, + showDashboard: true, + showLogo: false, + showScalebar: false + }); + //minZoomLevel: 14, + //numZoomLevels: 4 + + Microsoft.Maps.Events.addHandler(map, "viewchangestart", function(e) { + /* Doesn't work */ + if (map.getTargetZoom() < 12) return false; + }); +}); diff --git a/web/rss.cgi b/web/rss.cgi index 6b43aeacb..a716d93e9 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -74,6 +74,10 @@ sub rss_local_problems { $d_str = "/$d" if $d; my $state = $q->param('state') || 'all'; $state = 'all' unless $state =~ /^(all|open|fixed)$/; + + # state is getting lost in the redirects. Add it on to the end as a query + my $state_qs = "?state=$state" unless $state eq 'all'; + $state = 'confirmed' if $state eq 'open'; my $cobrand = Page::get_cobrand($q); @@ -82,13 +86,13 @@ sub rss_local_problems { ($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$d_str"); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); 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$d_str"); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); return ''; } elsif ($e && $n) { ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); @@ -100,7 +104,7 @@ sub rss_local_problems { $error = shift; }; unless ($error) { - print $q->redirect(-location => "$base/rss/n/$e,$n$d_str"); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); } return ''; } else { |