aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm185
-rwxr-xr-xtemplates/web/default/around/display_location.html (renamed from templates/website/map)0
-rwxr-xr-xweb/index.cgi362
3 files changed, 364 insertions, 183 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 6a6e82d02..4cdf07dad 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -54,8 +54,189 @@ sub around_index : Path : Args(0) {
warn "FIXME - implement";
# Show the nearby reports
- die "show nearby reports";
-
+ $c->forward('display_location');
+
+}
+
+=head2 display_location
+
+Display a specific lat/lng location (which may have come from a pc search).
+
+=cut
+
+sub display_location : Private {
+ my ( $self, $c ) = @_;
+
+# # Deal with pin hiding/age
+# my ( $hide_link, $hide_text, $all_link, $all_text, $interval );
+# if ( $input{all_pins} ) {
+# $all_link =
+# NewURL( $q, -retain => 1, no_pins => undef, all_pins => undef );
+# $all_text = _('Hide stale reports');
+# }
+# else {
+# $all_link = NewURL( $q, -retain => 1, no_pins => undef, all_pins => 1 );
+# $all_text = _('Include stale reports');
+# $interval = '6 months';
+# }
+
+# my ( $on_map_all, $on_map, $around_map, $dist ) =
+# FixMyStreet::Map::map_features( $q, $latitude, $longitude, $interval );
+# my @pins;
+# foreach (@$on_map_all) {
+# push @pins,
+# [
+# $_->{latitude}, $_->{longitude},
+# ( $_->{state} eq 'fixed' ? 'green' : 'red' ), $_->{id}
+# ];
+# }
+# my $on_list = '';
+# foreach (@$on_map) {
+# my $report_url = NewURL( $q, -url => '/report/' . $_->{id} );
+# $report_url = Cobrand::url( $cobrand, $report_url, $q );
+# $on_list .= '<li><a href="' . $report_url . '">';
+# $on_list .= ent( $_->{title} ) . '</a> <small>(';
+# $on_list .= Page::prettify_epoch( $q, $_->{time}, 1 ) . ')</small>';
+# $on_list .= ' <small>' . _('(fixed)') . '</small>'
+# if $_->{state} eq 'fixed';
+# $on_list .= '</li>';
+# }
+# $on_list = $q->li( _('No problems have been reported yet.') )
+# unless $on_list;
+#
+# my $around_list = '';
+# foreach (@$around_map) {
+# my $report_url =
+# Cobrand::url( $cobrand, NewURL( $q, -url => '/report/' . $_->{id} ),
+# $q );
+# $around_list .= '<li><a href="' . $report_url . '">';
+# my $dist = int( $_->{distance} * 10 + 0.5 );
+# $dist = $dist / 10;
+# $around_list .= ent( $_->{title} ) . '</a> <small>(';
+# $around_list .= Page::prettify_epoch( $q, $_->{time}, 1 ) . ', ';
+# $around_list .= $dist . 'km)</small>';
+# $around_list .= ' <small>' . _('(fixed)') . '</small>'
+# if $_->{state} eq 'fixed';
+# $around_list .= '</li>';
+# push @pins,
+# [
+# $_->{latitude}, $_->{longitude},
+# ( $_->{state} eq 'fixed' ? 'green' : 'red' ), $_->{id}
+# ];
+# }
+# $around_list = $q->li( _('No problems found.') )
+# unless $around_list;
+
+# 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>";
+# if ( mySociety::Config::get('COUNTRY') eq 'GB' ) {
+# $map_links .=
+# " | <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}'>";
+# }
+# else {
+# $map_links .= "</p>";
+# }
+
+# # truncate the lat,lon for nicer rss urls, and strings for outputting
+# my ( $short_lat, $short_lon ) =
+# map { Utils::truncate_coordinate($_) } #
+# ( $latitude, $longitude );
+#
+# my $url_skip = NewURL(
+# $q,
+# -url => '/report/new',
+# -retain => 1,
+# x => undef,
+# y => undef,
+# latitude => $short_lat,
+# longitude => $short_lon,
+# submit_map => 1,
+# skipped => 1
+# );
+#
+# my $pc_h = ent( $q->param('pc') || '' );
+#
+# my $rss_url;
+# if ($pc_h) {
+# $rss_url = "/rss/pc/" . URI::Escape::uri_escape_utf8($pc_h);
+# }
+# else {
+# $rss_url = "/rss/l/$short_lat,$short_lon";
+# }
+# $rss_url = Cobrand::url( $cobrand, NewURL( $q, -url => $rss_url ), $q );
+#
+# my %vars = (
+# 'map' => FixMyStreet::Map::display_map(
+# $q,
+# latitude => $short_lat,
+# longitude => $short_lon,
+# type => 1,
+# pins => \@pins,
+# post => $map_links
+# ),
+# map_end => FixMyStreet::Map::display_map_end(1),
+# url_home => Cobrand::url( $cobrand, '/', $q ),
+# url_rss => $rss_url,
+# url_email => Cobrand::url(
+# $cobrand,
+# NewURL(
+# $q,
+# lat => $short_lat,
+# lon => $short_lon,
+# -url => '/alert',
+# feed => "local:$short_lat:$short_lon"
+# ),
+# $q
+# ),
+# url_skip => $url_skip,
+# email_me => _('Email me new local problems'),
+# rss_alt => _('RSS feed'),
+# rss_title => _('RSS feed of recent local problems'),
+# reports_on_around => $on_list,
+# reports_nearby => $around_list,
+# heading_problems => _('Problems in this area'),
+# heading_on_around => _('Reports on and around the map'),
+# heading_closest => sprintf(
+# _('Closest nearby problems <small>(within&nbsp;%skm)</small>'),
+# $dist
+# ),
+# distance => $dist,
+# pc_h => $pc_h,
+# errors => @errors
+# ? '<ul class="error"><li>' . join( '</li><li>', @errors ) . '</li></ul>'
+# : '',
+# text_to_report => _(
+# 'To report a problem, simply
+# <strong>click on the map</strong> at the correct location.'
+# ),
+# text_skip => sprintf(
+# _(
+# "<small>If you cannot see the map, <a href='%s' rel='nofollow'>skip this
+# step</a>.</small>"
+# ),
+# $url_skip
+# ),
+# );
+#
+# my %params = (
+# rss => [ _('Recent local problems, FixMyStreet'), $rss_url ],
+# js => FixMyStreet::Map::header_js(),
+# robots => 'noindex,nofollow',
+# );
+#
+# return (
+# Page::template_include( 'map', $q, Page::template_root($q), %vars ),
+# %params );
}
=head2 determine_location_from_coords
diff --git a/templates/website/map b/templates/web/default/around/display_location.html
index f54c68aba..f54c68aba 100755
--- a/templates/website/map
+++ b/templates/web/default/around/display_location.html
diff --git a/web/index.cgi b/web/index.cgi
index 8a25c39b4..00415c8bf 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -841,187 +841,187 @@ sub redirect_from_osgb_to_wgs84 {
return '';
}
-sub display_location {
- my ($q, @errors) = @_;
- my $cobrand = Page::get_cobrand($q);
- my @vars = qw(pc x y lat lon all_pins no_pins);
-
- my %input = ();
- my %input_h = ();
-
- foreach my $key (@vars) {
- my $val = $q->param($key);
- $input{$key} = defined($val) ? $val : ''; # '0' is valid for longitude
- $input_h{$key} = ent( $input{$key} );
- }
-
- my $latitude = $input{lat};
- my $longitude = $input{lon};
-
- # 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}
- || ( $latitude ne '' && $longitude ne '' );
-
- if ( $x && $y ) {
-
- # Convert the tile co-ordinates to real ones.
- ( $latitude, $longitude ) =
- FixMyStreet::Map::tile_xy_to_wgs84( $x, $y );
- }
- elsif ( $latitude && $longitude ) {
-
- # Don't need to do anything
- }
- else {
- my $error;
- try {
- ( $latitude, $longitude, $error ) =
- FixMyStreet::Geocode::lookup( $input{pc}, $q );
-
- debug 'Looked up postcode "%s": lat: "%s", lon: "%s", error: "%s"',
- $input{pc}, $latitude, $longitude, $error;
- }
- 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;
- }
-
- # Check this location is okay to be displayed for the cobrand
- my ($success, $error_msg) = Cobrand::council_check($cobrand, { lat => $latitude, lon => $longitude }, $q, 'display_location');
- return front_page($q, $error_msg) unless $success;
-
- # Deal with pin hiding/age
- my ($hide_link, $hide_text, $all_link, $all_text, $interval);
- if ($input{all_pins}) {
- $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>undef);
- $all_text = _('Hide stale reports');
- } else {
- $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>1);
- $all_text = _('Include stale reports');
- $interval = '6 months';
- }
-
- my ($on_map_all, $on_map, $around_map, $dist) = FixMyStreet::Map::map_features($q, $latitude, $longitude, $interval);
- my @pins;
- foreach (@$on_map_all) {
- push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
- }
- my $on_list = '';
- foreach (@$on_map) {
- my $report_url = NewURL($q, -url => '/report/' . $_->{id});
- $report_url = Cobrand::url($cobrand, $report_url, $q);
- $on_list .= '<li><a href="' . $report_url . '">';
- $on_list .= ent($_->{title}) . '</a> <small>(';
- $on_list .= Page::prettify_epoch($q, $_->{time}, 1) . ')</small>';
- $on_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed';
- $on_list .= '</li>';
- }
- $on_list = $q->li(_('No problems have been reported yet.'))
- unless $on_list;
-
- my $around_list = '';
- foreach (@$around_map) {
- my $report_url = Cobrand::url($cobrand, NewURL($q, -url => '/report/' . $_->{id}), $q);
- $around_list .= '<li><a href="' . $report_url . '">';
- my $dist = int($_->{distance}*10+0.5);
- $dist = $dist / 10;
- $around_list .= ent($_->{title}) . '</a> <small>(';
- $around_list .= Page::prettify_epoch($q, $_->{time}, 1) . ', ';
- $around_list .= $dist . 'km)</small>';
- $around_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed';
- $around_list .= '</li>';
- push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
- }
- $around_list = $q->li(_('No problems found.'))
- unless $around_list;
-
- 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>";
- if (mySociety::Config::get('COUNTRY') eq 'GB') {
- $map_links .= " | <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}'>";
- } else {
- $map_links .= "</p>";
- }
-
- # truncate the lat,lon for nicer rss urls, and strings for outputting
- my ( $short_lat, $short_lon ) =
- map { Utils::truncate_coordinate($_) } #
- ( $latitude, $longitude );
-
- my $url_skip = NewURL(
- $q,
- -url => '/report/new',
- -retain => 1,
- x => undef,
- y => undef,
- latitude => $short_lat,
- longitude => $short_lon,
- submit_map => 1,
- skipped => 1
- );
-
- my $pc_h = ent($q->param('pc') || '');
-
- my $rss_url;
- if ($pc_h) {
- $rss_url = "/rss/pc/" . URI::Escape::uri_escape_utf8($pc_h);
- } else {
- $rss_url = "/rss/l/$short_lat,$short_lon";
- }
- $rss_url = Cobrand::url( $cobrand, NewURL($q, -url=> $rss_url), $q);
-
- my %vars = (
- 'map' => FixMyStreet::Map::display_map($q,
- latitude => $short_lat, longitude => $short_lon,
- type => 1,
- pins => \@pins,
- post => $map_links
- ),
- map_end => FixMyStreet::Map::display_map_end(1),
- url_home => Cobrand::url($cobrand, '/', $q),
- url_rss => $rss_url,
- url_email => Cobrand::url($cobrand, NewURL($q, lat => $short_lat, lon => $short_lon, -url=>'/alert', feed=>"local:$short_lat:$short_lon"), $q),
- url_skip => $url_skip,
- email_me => _('Email me new local problems'),
- rss_alt => _('RSS feed'),
- rss_title => _('RSS feed of recent local problems'),
- reports_on_around => $on_list,
- reports_nearby => $around_list,
- heading_problems => _('Problems in this area'),
- heading_on_around => _('Reports on and around the map'),
- heading_closest => sprintf(_('Closest nearby problems <small>(within&nbsp;%skm)</small>'), $dist),
- distance => $dist,
- pc_h => $pc_h,
- errors => @errors ? '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>' : '',
- text_to_report => _('To report a problem, simply
- <strong>click on the map</strong> at the correct location.'),
- text_skip => sprintf(_("<small>If you cannot see the map, <a href='%s' rel='nofollow'>skip this
- step</a>.</small>"), $url_skip),
- );
-
- my %params = (
- rss => [ _('Recent local problems, FixMyStreet'), $rss_url ],
- js => FixMyStreet::Map::header_js(),
- robots => 'noindex,nofollow',
- );
-
- return (Page::template_include('map', $q, Page::template_root($q), %vars), %params);
-}
+# sub display_location {
+# my ($q, @errors) = @_;
+# my $cobrand = Page::get_cobrand($q);
+# my @vars = qw(pc x y lat lon all_pins no_pins);
+#
+# my %input = ();
+# my %input_h = ();
+#
+# foreach my $key (@vars) {
+# my $val = $q->param($key);
+# $input{$key} = defined($val) ? $val : ''; # '0' is valid for longitude
+# $input_h{$key} = ent( $input{$key} );
+# }
+#
+# my $latitude = $input{lat};
+# my $longitude = $input{lon};
+#
+# # 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}
+# || ( $latitude ne '' && $longitude ne '' );
+#
+# if ( $x && $y ) {
+#
+# # Convert the tile co-ordinates to real ones.
+# ( $latitude, $longitude ) =
+# FixMyStreet::Map::tile_xy_to_wgs84( $x, $y );
+# }
+# elsif ( $latitude && $longitude ) {
+#
+# # Don't need to do anything
+# }
+# else {
+# my $error;
+# try {
+# ( $latitude, $longitude, $error ) =
+# FixMyStreet::Geocode::lookup( $input{pc}, $q );
+#
+# debug 'Looked up postcode "%s": lat: "%s", lon: "%s", error: "%s"',
+# $input{pc}, $latitude, $longitude, $error;
+# }
+# 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;
+# }
+#
+# # Check this location is okay to be displayed for the cobrand
+# my ($success, $error_msg) = Cobrand::council_check($cobrand, { lat => $latitude, lon => $longitude }, $q, 'display_location');
+# return front_page($q, $error_msg) unless $success;
+#
+# # Deal with pin hiding/age
+# my ($hide_link, $hide_text, $all_link, $all_text, $interval);
+# if ($input{all_pins}) {
+# $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>undef);
+# $all_text = _('Hide stale reports');
+# } else {
+# $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>1);
+# $all_text = _('Include stale reports');
+# $interval = '6 months';
+# }
+#
+# my ($on_map_all, $on_map, $around_map, $dist) = FixMyStreet::Map::map_features($q, $latitude, $longitude, $interval);
+# my @pins;
+# foreach (@$on_map_all) {
+# push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
+# }
+# my $on_list = '';
+# foreach (@$on_map) {
+# my $report_url = NewURL($q, -url => '/report/' . $_->{id});
+# $report_url = Cobrand::url($cobrand, $report_url, $q);
+# $on_list .= '<li><a href="' . $report_url . '">';
+# $on_list .= ent($_->{title}) . '</a> <small>(';
+# $on_list .= Page::prettify_epoch($q, $_->{time}, 1) . ')</small>';
+# $on_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed';
+# $on_list .= '</li>';
+# }
+# $on_list = $q->li(_('No problems have been reported yet.'))
+# unless $on_list;
+#
+# my $around_list = '';
+# foreach (@$around_map) {
+# my $report_url = Cobrand::url($cobrand, NewURL($q, -url => '/report/' . $_->{id}), $q);
+# $around_list .= '<li><a href="' . $report_url . '">';
+# my $dist = int($_->{distance}*10+0.5);
+# $dist = $dist / 10;
+# $around_list .= ent($_->{title}) . '</a> <small>(';
+# $around_list .= Page::prettify_epoch($q, $_->{time}, 1) . ', ';
+# $around_list .= $dist . 'km)</small>';
+# $around_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed';
+# $around_list .= '</li>';
+# push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
+# }
+# $around_list = $q->li(_('No problems found.'))
+# unless $around_list;
+#
+# 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>";
+# if (mySociety::Config::get('COUNTRY') eq 'GB') {
+# $map_links .= " | <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}'>";
+# } else {
+# $map_links .= "</p>";
+# }
+#
+# # truncate the lat,lon for nicer rss urls, and strings for outputting
+# my ( $short_lat, $short_lon ) =
+# map { Utils::truncate_coordinate($_) } #
+# ( $latitude, $longitude );
+#
+# my $url_skip = NewURL(
+# $q,
+# -url => '/report/new',
+# -retain => 1,
+# x => undef,
+# y => undef,
+# latitude => $short_lat,
+# longitude => $short_lon,
+# submit_map => 1,
+# skipped => 1
+# );
+#
+# my $pc_h = ent($q->param('pc') || '');
+#
+# my $rss_url;
+# if ($pc_h) {
+# $rss_url = "/rss/pc/" . URI::Escape::uri_escape_utf8($pc_h);
+# } else {
+# $rss_url = "/rss/l/$short_lat,$short_lon";
+# }
+# $rss_url = Cobrand::url( $cobrand, NewURL($q, -url=> $rss_url), $q);
+#
+# my %vars = (
+# 'map' => FixMyStreet::Map::display_map($q,
+# latitude => $short_lat, longitude => $short_lon,
+# type => 1,
+# pins => \@pins,
+# post => $map_links
+# ),
+# map_end => FixMyStreet::Map::display_map_end(1),
+# url_home => Cobrand::url($cobrand, '/', $q),
+# url_rss => $rss_url,
+# url_email => Cobrand::url($cobrand, NewURL($q, lat => $short_lat, lon => $short_lon, -url=>'/alert', feed=>"local:$short_lat:$short_lon"), $q),
+# url_skip => $url_skip,
+# email_me => _('Email me new local problems'),
+# rss_alt => _('RSS feed'),
+# rss_title => _('RSS feed of recent local problems'),
+# reports_on_around => $on_list,
+# reports_nearby => $around_list,
+# heading_problems => _('Problems in this area'),
+# heading_on_around => _('Reports on and around the map'),
+# heading_closest => sprintf(_('Closest nearby problems <small>(within&nbsp;%skm)</small>'), $dist),
+# distance => $dist,
+# pc_h => $pc_h,
+# errors => @errors ? '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>' : '',
+# text_to_report => _('To report a problem, simply
+# <strong>click on the map</strong> at the correct location.'),
+# text_skip => sprintf(_("<small>If you cannot see the map, <a href='%s' rel='nofollow'>skip this
+# step</a>.</small>"), $url_skip),
+# );
+#
+# my %params = (
+# rss => [ _('Recent local problems, FixMyStreet'), $rss_url ],
+# js => FixMyStreet::Map::header_js(),
+# robots => 'noindex,nofollow',
+# );
+#
+# return (Page::template_include('map', $q, Page::template_root($q), %vars), %params);
+# }
sub display_problem {
my ($q, $errors, $field_errors) = @_;