aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/send-reports30
-rwxr-xr-xtemplates/website/faq-en-gb2
-rwxr-xr-xweb/index.cgi2
3 files changed, 30 insertions, 4 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 297cdf4ec..6fc1f74ec 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -18,6 +18,8 @@ use lib "$FindBin::Bin/../commonlib/perllib";
use Encode;
use Error qw(:try);
use File::Slurp;
+use JSON;
+use LWP::Simple;
use CGI; # Trying awkward kludge
use CronFns;
@@ -97,9 +99,8 @@ 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} = '';
- $h{closest_address_machine} = '';
- # If we are in the UK include eastings and northings
+ # If we are in the UK include eastings and northings, and nearest stuff
$h{easting_northing} = '';
if ( mySociety::Config::get('COUNTRY') eq 'GB' ) {
@@ -109,7 +110,10 @@ foreach my $row (@$unsent) {
$h{easting_northing} #
= "Easting: $h{easting}\n\n" #
. "Northing: $h{northing}\n\n";
+
+ $h{closest_address} = find_closest($row, $h{latitude}, $h{longitude});
}
+ $h{closest_address_machine} = $h{closest_address};
my (@to, @recips, $template, $areas_info);
if ($site eq 'emptyhomes') {
@@ -342,3 +346,25 @@ sub post_easthants_message {
return $return;
}
+sub find_closest {
+ my ($row, $latitude, $longitude) = @_;
+ my $str = '';
+
+ return unless $row->{used_map};
+
+ # Get nearest road-type thing from Bing
+ my $url = "http://dev.virtualearth.net/REST/v1/Locations/$latitude,$longitude?c=en-GB&key=" . mySociety::Config::get('BING_MAPS_API_KEY');
+ my $j = LWP::Simple::get($url);
+ $j = JSON->new->utf8->allow_nonref->decode($j);
+ $str .= "Nearest road to the pin placed on the map (automatically generated by Bing Maps): $j->{resourceSets}[0]{resources}[0]{name}\n\n";
+
+ # Get nearest postcode from Matthew's random gazetteer (put in MaPit? Or elsewhere?)
+ $url = "http://gazetteer.dracos.vm.bytemark.co.uk/point/$latitude,$longitude.json";
+ $j = LWP::Simple::get($url);
+ $j = JSON->new->utf8->allow_nonref->decode($j);
+ if ($j->{postcode}) {
+ $str .= "Nearest postcode to the pin placed on the map (automatically generated): $j->{postcode}[0] ($j->{postcode}[1]m away)\n\n";
+ }
+ return $str;
+}
+
diff --git a/templates/website/faq-en-gb b/templates/website/faq-en-gb
index 0c5fa7aea..4656adb2a 100755
--- a/templates/website/faq-en-gb
+++ b/templates/website/faq-en-gb
@@ -107,7 +107,7 @@ dragging an empty square.</dd>
this might mean that you&rsquo;ll need to pan around to figure out where the
problem is if you&rsquo;re not familiar with the area. If you&rsquo;re from the
council then the emailed version of the problem report will contain the
- closest postal address to the pin on the map.</dd>
+ closest road to the pin on the map.</dd>
<dt>This site is great – why aren&rsquo;t you better publicised?</dt>
<dd>As a tiny charity we simply don&rsquo;t have a publicity budget, and we
diff --git a/web/index.cgi b/web/index.cgi
index f741e5f5a..c86ac6ad1 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -1063,7 +1063,7 @@ sub display_problem {
map_start => FixMyStreet::Map::display_map($q,
latitude => $problem->{latitude}, longitude => $problem->{longitude},
type => 0,
- pins => [ [ $problem->{latitude}, $problem->{longitude}, 'blue' ] ],
+ pins => $problem->{used_map} ? [ [ $problem->{latitude}, $problem->{longitude}, 'blue' ] ] : [],
post => $map_links
),
map_end => FixMyStreet::Map::display_map_end(0),