aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@fury.ukcod.org.uk>2011-03-29 13:25:35 +0100
committerMatthew Somerville <matthew@fury.ukcod.org.uk>2011-03-29 13:25:35 +0100
commitc818efaf43ca7fa25d8a3c44299f21f23ad795fc (patch)
tree61060c8bbfc4fdefcd4cec9efc11c0e86dcda07a /bin
parent7d77d31a628b2a06ae3600a1463e6d5bf8340778 (diff)
Don't error/show if no result returned.
Diffstat (limited to 'bin')
-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;
}