diff options
author | Matthew Somerville <matthew@balti.ukcod.org.uk> | 2010-11-24 16:23:38 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@balti.ukcod.org.uk> | 2010-11-24 16:23:38 +0000 |
commit | f76785b0ad5a2f55254fb8106e742a7f7f703204 (patch) | |
tree | 2042da0d94485ef714c4e5c9b55725274f924410 | |
parent | 8690e19d0fb7cc88f8e13a3f6cc46681c1ee95a4 (diff) |
Pushing as much maps stuff into Maps as possible.
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 127 | ||||
-rwxr-xr-x | web/index.cgi | 147 | ||||
-rw-r--r-- | web/js.js | 2 | ||||
-rwxr-xr-x | web/questionnaire.cgi | 12 | ||||
-rwxr-xr-x | web/rss.cgi | 10 |
5 files changed, 167 insertions, 131 deletions
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index c3608b390..0aae808b9 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -26,25 +26,39 @@ use constant SCALE_FACTOR => TIF_SIZE_M / (TIF_SIZE_PX / TILE_WIDTH); # display_map Q PARAMS # PARAMS include: -# X,Y is bottom left tile of 2x2 grid +# 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 HTML of pins to show -# PX,PY are coordinates of pin +# 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{pins} ||= ''; $params{pre} ||= ''; $params{post} ||= ''; my $mid_point = TILE_WIDTH; # Map is 2 TILE_WIDTHs in size, square. if ($q->{site} eq 'barnet') { # Map is c. 380px wide $mid_point = 189; } - my $px = defined($params{px}) ? $mid_point - $params{px} : 0; - my $py = defined($params{py}) ? $mid_point - $params{py} : 0; - my $x = int($params{x})<=0 ? 0 : $params{x}; - my $y = int($params{y})<=0 ? 0 : $params{y}; + + # X/Y tile co-ords may be overridden in the query string + my @vars = qw(x y); + my %input = map { $_ => $q->param($_) || '' } @vars; + ($input{x}) = $input{x} =~ /^(\d+)/; $input{x} ||= 0; + ($input{y}) = $input{y} =~ /^(\d+)/; $input{y} ||= 0; + + my ($x, $y, $px, $py) = FixMyStreet::Map::os_to_px_with_adjust($q, $params{easting}, $params{northing}, $input{x}, $input{y}); + + my $pins = ''; + foreach my $pin (@{$params{pins}}) { + my $pin_x = FixMyStreet::Map::os_to_px($pin->[0], $x); + my $pin_y = FixMyStreet::Map::os_to_px($pin->[1], $y, 1); + $pins .= FixMyStreet::Map::display_pin($q, $pin_x, $pin_y, $pin->[2]); + } + + $px = defined($px) ? $mid_point - $px : 0; + $py = defined($py) ? $mid_point - $py : 0; + $x = int($x)<=0 ? 0 : $x; + $y = int($y)<=0 ? 0 : $y; my $url = mySociety::Config::get('TILES_URL'); my $tiles_url = $url . ($x-1) . '-' . $x . ',' . ($y-1) . '-' . $y . '/RABX'; my $tiles = LWP::Simple::get($tiles_url); @@ -103,7 +117,7 @@ var fixmystreet = { $params{pre} <div id="map"><div id="drag"> $img_type alt="NW map tile" id="t2.2" name="tile_$tl" src="$tl_src" style="top:0px; left:0;">$img_type alt="NE map tile" id="t2.3" name="tile_$tr" src="$tr_src" style="top:0px; left:$imgw;"><br>$img_type alt="SW map tile" id="t3.2" name="tile_$bl" src="$bl_src" style="top:$imgw; left:0;">$img_type alt="SE map tile" id="t3.3" name="tile_$br" src="$br_src" style="top:$imgw; left:$imgw;"> - <div id="pins">$params{pins}</div> + <div id="pins">$pins</div> </div> EOF if (Cobrand::show_watermark($cobrand) && mySociety::Config::get('TILES_TYPE') ne 'streetview') { @@ -156,35 +170,30 @@ sub display_pin { return $out; } -sub map_pins { - my ($q, $x, $y, $sx, $sy, $interval) = @_; +sub map_features { + my ($q, $easting, $northing, $interval) = @_; - my $pins = ''; - my $min_e = FixMyStreet::Map::tile_to_os($x-3); # Extra space to left/below due to rounding, I think + my $xx = FixMyStreet::Map::os_to_tile($easting); + my $yy = FixMyStreet::Map::os_to_tile($northing); + my $x = int($xx); + my $y = int($yy); + $x += 1 if ($xx - $x > 0.5); + $y += 1 if ($yy - $y > 0.5); + + my $min_e = FixMyStreet::Map::tile_to_os($x-3); # Due to when the front-end AJAX look ups pins my $min_n = FixMyStreet::Map::tile_to_os($y-3); my $mid_e = FixMyStreet::Map::tile_to_os($x); my $mid_n = FixMyStreet::Map::tile_to_os($y); my $max_e = FixMyStreet::Map::tile_to_os($x+2); my $max_n = FixMyStreet::Map::tile_to_os($y+2); - my $cobrand = Page::get_cobrand($q); + # list of problems aoround map can be limited, but should show all pins - my $around_limit = Cobrand::on_map_list_limit($cobrand); - my $around_map; - my $around_map_list = Problems::around_map($min_e, $max_e, $min_n, $max_n, $interval, $around_limit); - if ($around_limit) { + my ($around_map, $around_map_list); + if (my $around_limit = Cobrand::on_map_list_limit(Page::get_cobrand($q))) { + $around_map_list = Problems::around_map($min_e, $max_e, $min_n, $max_n, $interval, $around_limit); $around_map = Problems::around_map($min_e, $max_e, $min_n, $max_n, $interval, undef); } else { - $around_map = $around_map_list; - } - my @ids = (); - foreach (@$around_map_list) { - push(@ids, $_->{id}); - } - foreach (@$around_map) { - my $px = FixMyStreet::Map::os_to_px($_->{easting}, $sx); - my $py = FixMyStreet::Map::os_to_px($_->{northing}, $sy, 1); - my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; - $pins .= FixMyStreet::Map::display_pin($q, $px, $py, $col); + $around_map = $around_map_list = Problems::around_map($min_e, $max_e, $min_n, $max_n, $interval, undef); } my $dist; @@ -194,8 +203,28 @@ sub map_pins { }; $dist = int($dist*10+0.5)/10; - my $limit = 20; # - @$current_map; + my $limit = 20; + my @ids = map { $_->{id} } @$around_map_list; my $nearby = Problems::nearby($dist, join(',', @ids), $limit, $mid_e, $mid_n, $interval); + + return ($around_map, $around_map_list, $nearby, $dist); +} + +sub map_pins { + my ($q, $x, $y, $sx, $sy, $interval) = @_; + + my $e = FixMyStreet::Map::tile_to_os($x); + my $n = FixMyStreet::Map::tile_to_os($y); + my ($around_map, $around_map_list, $nearby, $dist) = FixMyStreet::Map::map_features($q, $e, $n, $interval); + + my $pins = ''; + foreach (@$around_map) { + my $px = FixMyStreet::Map::os_to_px($_->{easting}, $sx); + my $py = FixMyStreet::Map::os_to_px($_->{northing}, $sy, 1); + my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; + $pins .= FixMyStreet::Map::display_pin($q, $px, $py, $col); + } + foreach (@$nearby) { my $px = FixMyStreet::Map::os_to_px($_->{easting}, $sx); my $py = FixMyStreet::Map::os_to_px($_->{northing}, $sy, 1); @@ -271,6 +300,20 @@ sub click_to_tile { return $pin_tile + $pin / TILE_WIDTH; } +# Given some click co-ords (the tile they were on, and where in the +# tile they were), convert to OSGB36 and return. +sub click_to_os { + my ($pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_; + my $tile_x = FixMyStreet::Map::click_to_tile($pin_tile_x, $pin_x); + my $tile_y = FixMyStreet::Map::click_to_tile($pin_tile_y, $pin_y, 1); + my $easting = FixMyStreet::Map::tile_to_os($tile_x); + my $northing = FixMyStreet::Map::tile_to_os($tile_y); + return ($easting, $northing); +} + +# Given (E,N) and potential override (X,Y), return the X/Y tile for the centre +# 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) = @_; @@ -278,19 +321,29 @@ sub os_to_px_with_adjust { my $y = FixMyStreet::Map::os_to_tile($northing); my $x_tile = $in_x || int($x); my $y_tile = $in_y || int($y); + + # Try and have point near centre of map + if (!$in_x && $x - $x_tile > 0.5) { + $x_tile += 1; + } + if (!$in_y && $y - $y_tile > 0.5) { + $y_tile += 1; + } + my $px = FixMyStreet::Map::os_to_px($easting, $x_tile); my $py = FixMyStreet::Map::os_to_px($northing, $y_tile, 1); - if ($q->{site} eq 'barnet') { # Map is 380px - if ($py > 380) { - $y_tile--; - $py = FixMyStreet::Map::os_to_px($northing, $y_tile, 1); - } - if ($px > 380) { + if ($q->{site} eq 'barnet') { # Map is 380px, so might need to adjust + if (!$in_x && $px > 380) { $x_tile++; $px = FixMyStreet::Map::os_to_px($easting, $x_tile); } + if (!$in_y && $py > 380) { + $y_tile--; + $py = FixMyStreet::Map::os_to_px($northing, $y_tile, 1); + } } - return ($x, $y, $x_tile, $y_tile, $px, $py); + + return ($x_tile, $y_tile, $px, $py); } 1; diff --git a/web/index.cgi b/web/index.cgi index 63b1e938b..6901fbe99 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -81,7 +81,7 @@ sub main { } elsif ($q->param('id')) { ($out, %params) = display_problem($q, [], {}); $params{title} .= ' - ' . _('Viewing a problem'); - } elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) { + } elsif ($q->param('pc') || ($q->param('x') && $q->param('y')) || ($q->param('e') && $q->param('n'))) { ($out, %params) = display_location($q); $params{title} = _('Viewing a location'); } else { @@ -458,31 +458,23 @@ sub display_form { return display_location($q, @errors) unless ($pin_x && $pin_y) || ($input{easting} && $input{northing}) - || ($input{skipped} && $input{x} && $input{y}) || ($input{skipped} && $input{pc}) || ($input{partial} && $input{pc}); # Work out some co-ordinates from whatever we've got - my ($px, $py, $easting, $northing); + my ($easting, $northing); if ($input{skipped}) { # Map is being skipped - if ($input{x} && $input{y}) { - $easting = FixMyStreet::Map::tile_to_os($input{x}); - $northing = FixMyStreet::Map::tile_to_os($input{y}); + if ($input{easting} && $input{northing}) { + $easting = $input{easting}; + $northing = $input{northing}; } else { my ($e, $n, $error) = FixMyStreet::Geocode::lookup($input{pc}, $q); $easting = $e; $northing = $n; } } elsif ($pin_x && $pin_y) { - # Map was clicked on - $pin_x = FixMyStreet::Map::click_to_tile($pin_tile_x, $pin_x); - $pin_y = FixMyStreet::Map::click_to_tile($pin_tile_y, $pin_y, 1); - $input{x} ||= int($pin_x); - $input{y} ||= int($pin_y); - $px = FixMyStreet::Map::tile_to_px($pin_x, $input{x}); - $py = FixMyStreet::Map::tile_to_px($pin_y, $input{y}, 1); - $easting = FixMyStreet::Map::tile_to_os($pin_x); - $northing = FixMyStreet::Map::tile_to_os($pin_y); + # tilma map was clicked on + ($easting, $northing) = FixMyStreet::Map::click_to_os($pin_tile_x, $pin_x, $pin_tile_y, $pin_y); } elsif ($input{partial} && $input{pc} && !$input{easting} && !$input{northing}) { my $error; try { @@ -492,16 +484,8 @@ sub display_form { }; return FixMyStreet::Geocode::list_choices($error, '/', $q) if ref($error) eq 'ARRAY'; return front_page($q, $error) if $error; - $input{x} = int(FixMyStreet::Map::os_to_tile($easting)); - $input{y} = int(FixMyStreet::Map::os_to_tile($northing)); - $px = FixMyStreet::Map::os_to_px($easting, $input{x}); - $py = FixMyStreet::Map::os_to_px($northing, $input{y}, 1); } else { # Normal form submission - my ($x, $y, $tile_x, $tile_y); - ($x, $y, $tile_x, $tile_y, $px, $py) = FixMyStreet::Map::os_to_px_with_adjust($q, $input{easting}, $input{northing}, undef, undef); - $input{x} = $tile_x; - $input{y} = $tile_y; $easting = $input_h{easting}; $northing = $input_h{northing}; } @@ -590,22 +574,22 @@ please specify the closest point on land.')) unless %$all_councils; $vars{form_start} = <<EOF; <form action="$form_action" method="post" name="mapSkippedForm"$enctype> <input type="hidden" name="pc" value="$input_h{pc}"> -<input type="hidden" name="x" value="$input_h{x}"> -<input type="hidden" name="y" value="$input_h{y}"> <input type="hidden" name="skipped" value="1"> $cobrand_form_elements <div id="skipped-map"> EOF } else { - my $pins = FixMyStreet::Map::display_pin($q, $px, $py, 'purple'); my $type; if ($allow_photo_upload) { $type = 2; } else { $type = 1; } - $vars{form_start} = FixMyStreet::Map::display_map($q, x => $input{x}, 'y' => $input{y}, type => $type, - pins => $pins, px => $px, py => $py ); + $vars{form_start} = FixMyStreet::Map::display_map($q, + easting => $easting, northing => $northing, + type => $type, + pins => [ [ $easting, $northing, 'purple' ] ], + ); my $partial_id; if (my $token = $input{partial}) { $partial_id = mySociety::AuthToken::retrieve('partial', $token); @@ -781,37 +765,33 @@ EOF sub display_location { my ($q, @errors) = @_; my $cobrand = Page::get_cobrand($q); - my @vars = qw(pc x y all_pins no_pins); + my @vars = qw(pc x y e n all_pins no_pins); my %input = map { $_ => $q->param($_) || '' } @vars; my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars; - if ($input{y} =~ /favicon/) { - my $base = mySociety::Config::get('BASE_URL'); - print $q->redirect(-location => $base . '/favicon.ico', -status => 301); - return ''; - } - my($error, $easting, $northing); + + (my $easting) = $input{e} =~ /^(\d+)/; $easting ||= 0; + (my $northing) = $input{n} =~ /^(\d+)/; $northing ||= 0; + + # X/Y referring to tiles old-school (my $x) = $input{x} =~ /^(\d+)/; $x ||= 0; (my $y) = $input{y} =~ /^(\d+)/; $y ||= 0; - return front_page($q, @errors) unless $x || $y || $input{pc}; - if (!$x && !$y) { + return front_page($q, @errors) unless $x || $y || $input{pc} || $easting || $northing; + + if ($x && $y) { + # Convert the tile co-ordinates to real ones. + $easting = FixMyStreet::Map::tile_to_os($x); + $northing = FixMyStreet::Map::tile_to_os($y); + } elsif ($easting && $northing) { + # Don't need to do anything + } else { + my $error; try { ($easting, $northing, $error) = FixMyStreet::Geocode::lookup($input{pc}, $q); - my $xx = FixMyStreet::Map::os_to_tile($easting); - my $yy = FixMyStreet::Map::os_to_tile($northing); - $x = int($xx); - $y = int($yy); - $x += 1 if ($xx - $x > 0.5); - $y += 1 if ($yy - $y > 0.5); } catch Error::Simple with { $error = shift; }; - } - return FixMyStreet::Geocode::list_choices($error, '/', $q) if (ref($error) eq 'ARRAY'); - return front_page($q, $error) if ($error); - - if (!$easting || !$northing) { - $easting = FixMyStreet::Map::tile_to_os($x); - $northing = FixMyStreet::Map::tile_to_os($y); + return FixMyStreet::Geocode::list_choices($error, '/', $q) if (ref($error) eq 'ARRAY'); + return front_page($q, $error) if $error; } # Check this location is okay to be displayed for the cobrand @@ -828,16 +808,12 @@ sub display_location { $all_text = _('Include stale reports'); $interval = '6 months'; } - my ($pins, $on_map, $around_map, $dist) = FixMyStreet::Map::map_pins($q, $x, $y, $x, $y, $interval); - if ($input{no_pins}) { - $hide_link = NewURL($q, -retain=>1, no_pins=>undef); - $hide_text = _('Show pins'); - $pins = ''; - } else { - $hide_link = NewURL($q, -retain=>1, no_pins=>1); - $hide_text = _('Hide pins'); + + my ($on_map_all, $on_map, $around_map, $dist) = FixMyStreet::Map::map_features($q, $easting, $northing, $interval); + my @pins; + foreach (@$on_map_all) { + push @pins, [ $_->{easting}, $_->{northing}, $_->{state} eq 'fixed' ? 'green' : 'red' ]; } - my $map_links = "<p id='sub_map_links'><a id='hide_pins_link' rel='nofollow' href='$hide_link'>$hide_text</a> | <a id='all_pins_link' rel='nofollow' href='$all_link'>$all_text</a></p> <input type='hidden' id='all_pins' name='all_pins' value='$input_h{all_pins}'>"; my $on_list = ''; foreach (@$on_map) { my $report_url = NewURL($q, -retain => 1, -url => '/report/' . $_->{id}, pc => undef, x => undef, 'y' => undef); @@ -861,14 +837,34 @@ sub display_location { $around_list .= '</a>'; $around_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed'; $around_list .= '</li>'; + push @pins, [ $_->{easting}, $_->{northing}, $_->{state} eq 'fixed' ? 'green' : 'red' ]; } $around_list = $q->li(_('No problems found.')) unless $around_list; - my $url_skip = NewURL($q, -retain=>1, 'submit_map'=>1, skipped=>1); + if ($input{no_pins}) { + $hide_link = NewURL($q, -retain=>1, no_pins=>undef); + $hide_text = _('Show pins'); + @pins = (); + } else { + $hide_link = NewURL($q, -retain=>1, no_pins=>1); + $hide_text = _('Hide pins'); + } + my $map_links = "<p id='sub_map_links'><a id='hide_pins_link' rel='nofollow' href='$hide_link'>$hide_text</a> | <a id='all_pins_link' rel='nofollow' href='$all_link'>$all_text</a></p> <input type='hidden' id='all_pins' name='all_pins' value='$input_h{all_pins}'>"; + + my $url_skip = NewURL($q, -retain=>1, pc => undef, + x => undef, 'y' => undef, + easting => $easting, northing => $northing, + 'submit_map'=>1, skipped=>1 + ); my $pc_h = ent($q->param('pc') || ''); my %vars = ( - 'map' => FixMyStreet::Map::display_map($q, x => $x, 'y' => $y, type => 1, pins => $pins, post => $map_links ), + 'map' => FixMyStreet::Map::display_map($q, + easting => $easting, northing => $northing, + type => 1, + pins => \@pins, + post => $map_links + ), map_end => FixMyStreet::Map::display_map_end(1), url_home => Cobrand::url($cobrand, '/', $q), url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/n/$easting,$northing", pc => undef, x => undef, 'y' => undef), $q), @@ -905,7 +901,7 @@ sub display_problem { my $cobrand = Page::get_cobrand($q); push @errors, _('There were problems with your update. Please see below.') if (scalar keys %field_errors); - my @vars = qw(id name rznvy update fixed add_alert upload_fileid x y submit_update); + my @vars = qw(id name rznvy update fixed add_alert upload_fileid submit_update); my %input = map { $_ => $q->param($_) || '' } @vars; my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars; my $base = Cobrand::base_url($cobrand); @@ -929,27 +925,12 @@ sub display_problem { return display_location($q, _('Unknown problem ID')) unless $problem; return front_page($q, _('That report has been removed from FixMyStreet.'), '410 Gone') if $problem->{state} eq 'hidden'; - ($input{x}) = $input{x} =~ /^(\d+)/; $input{x} ||= 0; - ($input{y}) = $input{y} =~ /^(\d+)/; $input{y} ||= 0; - my ($x, $y, $x_tile, $y_tile, $px, $py) = FixMyStreet::Map::os_to_px_with_adjust($q, $problem->{easting}, $problem->{northing}, $input{x}, $input{y}); - - # Try and have pin near centre of map - if (!$input{x} && $x - $x_tile > 0.5) { - $x_tile += 1; - $px = FixMyStreet::Map::os_to_px($problem->{easting}, $x_tile); - } - if (!$input{y} && $y - $y_tile > 0.5) { - $y_tile += 1; - $py = FixMyStreet::Map::os_to_px($problem->{northing}, $y_tile, 1); - } - my $extra_data = Cobrand::extra_data($cobrand, $q); 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 $pins = FixMyStreet::Map::display_pin($q, $px, $py, 'blue'); my $banner; if ($q->{site} ne 'emptyhomes' && $problem->{state} eq 'confirmed' && $problem->{duration} > 8*7*24*60*60) { @@ -960,12 +941,20 @@ sub display_problem { } my $contact_url = Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, -url=>'/contact?id=' . $input{id}), $q); - my $back = Cobrand::url($cobrand, NewURL($q, -url => '/', 'x' => $x_tile, 'y' => $y_tile, -retain => 1, pc => undef, id => undef ), $q); + my $back = Cobrand::url($cobrand, NewURL($q, -url => '/', + 'e' => int($problem->{easting}), 'n' => int($problem->{northing}), + -retain => 1, pc => undef, x => undef, 'y' => undef, id => undef + ), $q); my $fixed = ($input{fixed}) ? ' checked' : ''; my %vars = ( banner => $banner, - map_start => FixMyStreet::Map::display_map($q, x => $x_tile, 'y' => $y_tile, type => 0, pins => $pins, px => $px, py => $py, post => $map_links ), + map_start => FixMyStreet::Map::display_map($q, + easting => $problem->{easting}, northing => $problem->{northing}, + type => 0, + pins => [ [ $problem->{easting}, $problem->{northing}, 'blue' ] ], + post => $map_links + ), map_end => FixMyStreet::Map::display_map_end(0), problem_title => ent($problem->{title}), problem_meta => Page::display_problem_meta_line($q, $problem), @@ -313,7 +313,7 @@ function load_pins(x, y) { 'y=' + (y+3), 'all_pins=' + all_pins ]; - if (document.getElementById('extra_param')) { + if (document.getElementById('extra_param')) { ajax_params.push(document.getElementById('extra_param').name + '=' + document.getElementById('extra_param').value); } diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi index 9184ad103..c45b5d186 100755 --- a/web/questionnaire.cgi +++ b/web/questionnaire.cgi @@ -213,16 +213,18 @@ sub display_questionnaire { return $error; } my $reported_date_time = Page::prettify_epoch($q, $problem->{time}); - my ($x, $y, $x_tile, $y_tile, $px, $py) = FixMyStreet::Map::os_to_px_with_adjust($q, $problem->{easting}, $problem->{northing}, undef, undef); - - my $pins = FixMyStreet::Map::display_pin($q, $px, $py, $problem->{state} eq 'fixed'?'green':'red'); my $problem_text = Page::display_problem_text($q, $problem); my $updates = Page::display_problem_updates($problem->{id}, $q); my %vars = ( input_h => \%input_h, - map_start => FixMyStreet::Map::display_map($q, x => $x_tile, y => $y_tile, pins => $pins, - px => $px, py => $py, pre => $problem_text, post => $updates ), + map_start => FixMyStreet::Map::display_map($q, + easting => $problem->{easting}, northing => $problem->{northing}, + pins => [ + [ $problem->{easting}, $problem->{northing}, $problem->{state} eq 'fixed'?'green':'red' ], + ], + pre => $problem_text, post => $updates + ), map_end => FixMyStreet::Map::display_map_end(0), heading => _('Questionnaire'), yes => _('Yes'), diff --git a/web/rss.cgi b/web/rss.cgi index 867f050fd..abbcf1955 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -88,19 +88,11 @@ sub rss_local_problems { print $q->redirect(-location => "$base/rss/n/$e,$n$d_str"); return ''; } elsif ($e && $n) { - $x = int(FixMyStreet::Map::os_to_tile($e)); - $y = int(FixMyStreet::Map::os_to_tile($n)); ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); } elsif ($pc) { my $error; try { ($e, $n, $error) = FixMyStreet::Geocode::lookup($pc, $q); - my $xx = FixMyStreet::Map::os_to_tile($e);¬ - my $yy = FixMyStreet::Map::os_to_tile($n);¬ - $x = int($xx);¬ - $y = int($yy);¬ - $x += 1 if ($xx - $x > 0.5);¬ - $y += 1 if ($yy - $y > 0.5);¬ } catch Error::Simple with { $error = shift; }; @@ -111,7 +103,7 @@ sub rss_local_problems { } else { die "Missing E/N, x/y, lat/lon, or postcode parameter in RSS feed"; } - my $qs = "?x=$x;y=$y"; + my $qs = '?e=' . int($e) . ';n=' . int($n); if ($d) { $qs .= ";d=$d"; $d = 100 if $d > 100; |