aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-24 13:14:45 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-24 13:14:45 +0100
commit7b0d984bd9607e5b7e12184f1d91bc52a0280417 (patch)
tree342d688dc4315a1821052111cd1bd45a3ac5c4f2 /perllib/FixMyStreet/Geocode.pm
parent3697d6efaa4c11908b2c051b1986a98643c199ac (diff)
google maps don't seem to pay as much attention to region hinting as they once did so make sure we add UK on to the end.
also update tests to take into account changed results because of this.
Diffstat (limited to 'perllib/FixMyStreet/Geocode.pm')
-rw-r--r--perllib/FixMyStreet/Geocode.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index c06c3bb55..cbfa3c4e7 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -126,8 +126,20 @@ sub string {
if (-s $cache_file) {
$js = File::Slurp::read_file($cache_file);
} else {
- $url .= ',+UK' unless $url =~ /united\++kingdom$/ || $url =~ /uk$/i
- || mySociety::Config::get('COUNTRY') ne 'GB';
+ # For some reason adding gl=uk is no longer sufficient to make google
+ # think we are in the UK for some locations so we explictly add UK to
+ # the address. We do it here so as not to invalidate existing cache
+ # entries
+ if ( mySociety::Config::get('COUNTRY') eq 'GB'
+ && $url !~ /,\+UK/
+ && $url !~ /united\++kingdom$/ )
+ {
+ if ( $url =~ /&/ ) {
+ $url =~ s/&/,+UK&/;
+ } else {
+ $url .= ',+UK';
+ }
+ }
$url .= '&sensor=false&key=' . mySociety::Config::get('GOOGLE_MAPS_API_KEY');
$js = LWP::Simple::get($url);
$js = encode_utf8($js) if utf8::is_utf8($js);