aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-reports
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-07-12 19:09:45 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-07-12 19:09:45 +0100
commitd2d54ea0d9844833ab8544c3df34f9043b21a6a7 (patch)
treeda892b606e08b798d0023683f18db4ca043ac779 /bin/send-reports
parent42a92773a123d2b0fa1eaed93201fa45a8b7e436 (diff)
Factor out find_closest from send-reports, initial OSM.pm from osm_road_info branch, needs altering before it will work.
Diffstat (limited to 'bin/send-reports')
-rwxr-xr-xbin/send-reports33
1 files changed, 4 insertions, 29 deletions
diff --git a/bin/send-reports b/bin/send-reports
index b55447e8a..1af3ba1ea 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -88,7 +88,10 @@ while (my $row = $unsent->next) {
= "Easting: $h{easting}\n\n" #
. "Northing: $h{northing}\n\n";
- $h{closest_address} = find_closest($row, $h{latitude}, $h{longitude});
+ }
+
+ if ( $row->used_map ) {
+ $h{closest_address} = $cobrand->find_closest( $h{latitude}, $h{longitude} );
}
my (@to, @recips, $template, $areas_info);
@@ -422,34 +425,6 @@ sub post_london_report {
# Nearest things
-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);
- 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);
- 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;
-}
-
sub london_lookup {
my $org = shift;
my $str = "Unknown ($org)";