diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-08-09 10:42:15 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-08-09 10:42:15 +0100 |
commit | ef421c31febe5219042468e3ec33654cf1e11556 (patch) | |
tree | ba2cb86e67eddaa3e6b0da58743c0508eb855b63 | |
parent | 6ab7f377e14bbf83747d434241b1f1c0a26daf80 (diff) |
Store lat/lon from multiple results and use that to prevent infinite loop on e.g. 'Clapham'.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/Bing.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/Google.pm | 2 | ||||
-rw-r--r-- | templates/web/default/alert/choose.html | 2 | ||||
-rw-r--r-- | templates/web/default/around/around_index.html | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index 9f8260768..df8a090c2 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -76,12 +76,12 @@ sub determine_location_from_pc : Private { # $error doubles up to return multiple choices by being an array if ( ref($error) eq 'ARRAY' ) { - @$error = map { - decode_utf8($_); - s/, United Kingdom//; - s/, UK//; - $_; - } @$error; + foreach (@$error) { + my $a = decode_utf8($_->{address}); + $a =~ s/, United Kingdom//; + $a =~ s/, UK//; + $_->{address} = $a; + } $c->stash->{possible_location_matches} = $error; return; } diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm index cfeffc856..90d7f98bd 100644 --- a/perllib/FixMyStreet/Geocode/Bing.pm +++ b/perllib/FixMyStreet/Geocode/Bing.pm @@ -57,7 +57,7 @@ sub string { my $address = $_->{name}; next unless $_->{address}->{countryRegion} eq 'United Kingdom'; # FIXME This is UK only ( $latitude, $longitude ) = @{ $_->{point}->{coordinates} }; - push (@$error, $address); + push (@$error, { address => $address, latitude => $latitude, longitude => $longitude }); push (@valid_locations, $_); } return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1; diff --git a/perllib/FixMyStreet/Geocode/Google.pm b/perllib/FixMyStreet/Geocode/Google.pm index c37a750a2..83b36dbcd 100644 --- a/perllib/FixMyStreet/Geocode/Google.pm +++ b/perllib/FixMyStreet/Geocode/Google.pm @@ -75,7 +75,7 @@ sub string { my $address = $_->{address}; next unless $c->cobrand->geocoded_string_check( $address ); ( $longitude, $latitude ) = @{ $_->{Point}->{coordinates} }; - push (@$error, $address); + push (@$error, { address => $address, latitude => $latitude, longitude => $longitude }); push (@valid_locations, $_); } return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1; diff --git a/templates/web/default/alert/choose.html b/templates/web/default/alert/choose.html index ef632e2d1..fad365088 100644 --- a/templates/web/default/alert/choose.html +++ b/templates/web/default/alert/choose.html @@ -6,7 +6,7 @@ <p>[% loc('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.') %]</p> <ul class="pc_alternatives"> [% FOREACH match IN possible_location_matches %] - <li><a href="[% choose_target_uri %]?pc=[% match | uri %]">[% match | html %]</a></li> + <li><a href="[% choose_target_uri %]?latitude=[% match.latitude | uri %];longitude=[% match.longitude | uri %]">[% match.address | html %]</a></li> [% END %] </ul> [% END %] diff --git a/templates/web/default/around/around_index.html b/templates/web/default/around/around_index.html index 8c144e469..3e6d96acd 100644 --- a/templates/web/default/around/around_index.html +++ b/templates/web/default/around/around_index.html @@ -33,7 +33,7 @@ <p>[% loc('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.') %]</p> <ul class="pc_alternatives"> [% FOREACH match IN possible_location_matches %] - <li><a href="/around?pc=[% match | uri %]">[% match | html %]</a></li> + <li><a href="/around?latitude=[% match.latitude | uri %];longitude=[% match.longitude | uri %]">[% match.address | html %]</a></li> [% END %] </ul> [% END %] |