aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/Default.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Default.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm40
1 files changed, 29 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 69718f613..1e87468ac 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -4,6 +4,7 @@ use strict;
use warnings;
use FixMyStreet;
use URI;
+use Digest::MD5 qw(md5_hex);
use Carp;
use mySociety::MaPit;
@@ -547,17 +548,10 @@ sub find_closest {
my ( $self, $latitude, $longitude ) = @_;
my $str = '';
- # Get nearest road-type thing from Bing
- my $key = mySociety::Config::get('BING_MAPS_API_KEY', '');
- if ($key) {
- my $url = "http://dev.virtualearth.net/REST/v1/Locations/$latitude,$longitude?c=en-GB&key=$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 .= sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"),
- $j->{resourceSets}[0]{resources}[0]{name}) . "\n\n";
- }
+ if ( my $j = FixMyStreet::Geocode::Bing::reverse( $latitude, $longitude ) ) {
+ if ($j->{resourceSets}[0]{resources}[0]{name}) {
+ $str .= sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"),
+ $j->{resourceSets}[0]{resources}[0]{name}) . "\n\n";
}
}
@@ -575,6 +569,30 @@ sub find_closest {
return $str;
}
+=head2 find_closest_address_for_rss
+
+Used by rss feeds to provide a bit more context
+
+=cut
+
+sub find_closest_address_for_rss {
+ my ( $self, $latitude, $longitude ) = @_;
+ my $str = '';
+
+ if ( my $j = FixMyStreet::Geocode::Bing::reverse( $latitude, $longitude, 1 ) ) {
+ if ($j->{resourceSets}[0]{resources}[0]{name}) {
+ my $address = $j->{resourceSets}[0]{resources}[0]{address};
+ my @address;
+ push @address, $address->{addressLine} if $address->{addressLine} ne 'Street';
+ push @address, $address->{locality};
+ $str .= sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"),
+ join( ', ', @address ) );
+ }
+ }
+
+ return $str;
+}
+
=head2 council_check
Paramters are COUNCILS, QUERY, CONTEXT. Return a boolean indicating whether