aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/send-reports16
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 96f259d5c..5bfee00ac 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -355,15 +355,21 @@ sub find_closest {
# 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";
+ if ($j) {
+ $j = JSON->new->utf8->allow_nonref->decode($j);
+ if ($j->{resourceSets}[0]{resources}[0]{name}) {
+ $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";
+ if ($j) {
+ $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;
}