aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-11 13:20:26 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-11 13:20:26 +0100
commit2b93b526a5e8acf48e4ee112e2f5feb8436be1d2 (patch)
treeec10fdced7c8748684f3cd16a07f6eb23e324b11 /perllib/FixMyStreet/Geocode
parent5accaad402d24f37851d8b85084fda2859b1ae16 (diff)
parentbeca2f7f8c96260541387d7135235f72ac86565b (diff)
Merge remote-tracking branch 'origin/bromley' into bromley
Diffstat (limited to 'perllib/FixMyStreet/Geocode')
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 4ba00dbfe..0a7fc38dc 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -44,8 +44,6 @@ sub string {
if (!$js) {
return { error => _('Sorry, we could not parse that location. Please try again.') };
- } elsif ($js =~ /BT\d/ && $params->{bing_country} eq 'United Kingdom') {
- return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
}
$js = JSON->new->utf8->allow_nonref->decode($js);
@@ -54,11 +52,15 @@ sub string {
}
my $results = $js->{resourceSets}->[0]->{resources};
- my ( $error, @valid_locations, $latitude, $longitude );
+ my ( $error, @valid_locations, $latitude, $longitude, $ni );
foreach (@$results) {
my $address = $_->{name};
next unless $_->{address}->{countryRegion} eq $params->{bing_country};
+ if ($params->{bing_country} eq 'United Kingdom' && $_->{address}{adminDistrict} eq 'Northern Ireland') {
+ $ni = 1;
+ next;
+ }
# Getting duplicate, yet different, results from Bing sometimes
next if @valid_locations
@@ -73,6 +75,10 @@ sub string {
push (@valid_locations, $_);
}
+ if ($ni && !scalar @valid_locations) {
+ return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
+ }
+
return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
return { error => $error };
}