aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrands/Fiksgatami/Util.pm7
-rw-r--r--perllib/FixMyStreet/Geocode.pm22
2 files changed, 19 insertions, 10 deletions
diff --git a/perllib/Cobrands/Fiksgatami/Util.pm b/perllib/Cobrands/Fiksgatami/Util.pm
index e119039d1..15a649eba 100644
--- a/perllib/Cobrands/Fiksgatami/Util.pm
+++ b/perllib/Cobrands/Fiksgatami/Util.pm
@@ -27,7 +27,12 @@ sub enter_postcode_text {
return _('Enter a nearby postcode, or street name and area:');
}
-# XXX Will need sub disambiguate_location presumably
+# Is also adding language parameter
+sub disambiguate_location {
+ my ($self, $s, $q) = @_;
+ $s = "hl=no&gl=no&$s";
+ return $s;
+}
1;
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index 14cedbaeb..2c583311b 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -39,15 +39,18 @@ BEGIN {
sub lookup {
my ($s, $q) = @_;
my ($latitude, $longitude, $error);
- if ($s =~ /^\d+$/) {
- $error = 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.';
- } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) {
- my $location = mySociety::MaPit::call('postcode', $s);
- unless ($error = Page::mapit_check_error($location)) {
- $latitude = $location->{wgs84_lat};
- $longitude = $location->{wgs84_lon};
+ if (mySociety::Config::get('COUNTRY') eq 'GB') {
+ if ($s =~ /^\d+$/) {
+ $error = 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.';
+ } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) {
+ my $location = mySociety::MaPit::call('postcode', $s);
+ unless ($error = Page::mapit_check_error($location)) {
+ $latitude = $location->{wgs84_lat};
+ $longitude = $location->{wgs84_lon};
+ }
}
- } else {
+ }
+ unless ($error || defined $latitude) {
($latitude, $longitude, $error) = FixMyStreet::Geocode::string($s, $q);
}
return ($latitude, $longitude, $error);
@@ -94,7 +97,8 @@ sub string {
if (-s $cache_file) {
$js = File::Slurp::read_file($cache_file);
} else {
- $url .= ',+UK' unless $url =~ /united\++kingdom$/ || $url =~ /uk$/i;
+ $url .= ',+UK' unless $url =~ /united\++kingdom$/ || $url =~ /uk$/i
+ || mySociety::Config::get('COUNTRY') ne 'GB';
$url .= '&sensor=false&gl=uk&key=' . mySociety::Config::get('GOOGLE_MAPS_API_KEY');
$js = LWP::Simple::get($url);
File::Path::mkpath($cache_dir);