aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-01-07 17:34:44 +0000
committerMatthew Somerville <matthew@mysociety.org>2013-01-07 17:34:44 +0000
commit37ae388673a4898426ac2ea502b14ab2b6ca18e3 (patch)
tree7635b827942765564cba4a188171abcd83969034 /perllib/FixMyStreet/Geocode
parent7981e2acd299846bd4aede377d4ade54e1a0fac3 (diff)
Autocomplete of Zurich street names (2beb264 plus tweaks).
Diffstat (limited to 'perllib/FixMyStreet/Geocode')
-rw-r--r--perllib/FixMyStreet/Geocode/Zurich.pm14
1 files changed, 10 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Geocode/Zurich.pm b/perllib/FixMyStreet/Geocode/Zurich.pm
index 5aaca2c8e..0fc84c0ef 100644
--- a/perllib/FixMyStreet/Geocode/Zurich.pm
+++ b/perllib/FixMyStreet/Geocode/Zurich.pm
@@ -52,8 +52,13 @@ sub setup_soap {
# string STRING CONTEXT
# Looks up on Zurich web service a user-inputted location.
# Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or
-# an array of matches if there are more than one. The information in the query
-# may be used to disambiguate the location in cobranded versions of the site.
+# an array of matches if there are more than one.
+# If there is no ambiguity, returns only a {lat,long} hash, unless allow_single_match_string is true
+# (because the auto-complete use of this (in /around) should send the matched name even though it's not ambiguous).
+#
+# The information in the query may be used to disambiguate the location in cobranded
+# versions of the site.
+
sub string {
my ( $s, $c ) = @_;
@@ -98,8 +103,9 @@ sub string {
push (@valid_locations, $_);
last if lc($_->{text}) eq lc($s);
}
-
- return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
+ if (scalar @valid_locations == 1 && ! $c->stash->{allow_single_geocode_match_strings} ) {
+ return { latitude => $latitude, longitude => $longitude };
+ }
return { error => $error };
}