diff options
author | Jonas Oberg <jonas@morus.se> | 2012-12-04 14:21:14 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2014-03-11 16:36:22 +0000 |
commit | 2a6151fd04b39bbdc07e944ea6384e41712ec9e4 (patch) | |
tree | 4660c5c9382362777496eb404711141695c6056e /perllib/FixMyStreet/Geocode | |
parent | 7f89289b6fef0d8406099b2ddc4ed5008165df25 (diff) |
Updated with small bug fixes
Diffstat (limited to 'perllib/FixMyStreet/Geocode')
-rw-r--r-- | perllib/FixMyStreet/Geocode/OSM.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm index 170eb8c78..f4f2fba95 100644 --- a/perllib/FixMyStreet/Geocode/OSM.pm +++ b/perllib/FixMyStreet/Geocode/OSM.pm @@ -73,6 +73,8 @@ sub string { foreach (@$js) { # These co-ordinates are output as query parameters in a URL, make sure they have a "." next unless $_->{type} eq "town" || + $_->{type} eq "locality" || + $_->{type} eq "suburb" || $_->{type} eq "village" || $_->{type} eq "city" || $_->{type} eq "secondary" || @@ -80,13 +82,19 @@ sub string { $_->{type} eq "primary" || $_->{type} eq "unclassified" || $_->{type} eq "residential"; + my $address = $_->{address}->{road}.", ".$_->{address}->{administrative}; + $address = $_->{address}->{locality}.", ".$_->{address}->{administrative} if $_->{type} eq "locality"; + $address = $_->{address}->{suburb}.", ".$_->{address}->{administrative} if $_->{type} eq "suburb"; + $address = $_->{address}->{town}.", ".$_->{address}->{state} if $_->{type} eq "town"; + $address = $_->{address}->{village}.", ".$_->{address}->{administrative} if $_->{type} eq "village"; + + # address => ($_->{address}->{postcode})? +#($_->{address}->{road}.", ".$_->{address}->{postcode}." ".$_->{address}->{administrative}):($_->{address}->{road}.", ".$_->{address}->{administrative}) , ( $latitude, $longitude ) = ( $_->{lat}, $_->{lon} ); mySociety::Locale::in_gb_locale { push (@$error, { - # address => ($_->{address}->{postcode})? -#($_->{address}->{road}.", ".$_->{address}->{postcode}." ".$_->{address}->{administrative}):($_->{address}->{road}.", ".$_->{address}->{administrative}) , - address => $_->{address}->{road}.", ".$_->{address}->{administrative}, + address => $address, latitude => sprintf('%0.6f', $latitude), longitude => sprintf('%0.6f', $longitude) }); @@ -99,6 +107,7 @@ sub string { my @final_valid_locations = grep { $seen{$_->{address}}++ } @{$error}; return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1 or scalar keys %seen == 1; + return { error => _('Sorry, we could not find that location.') } if scalar keys %seen == 0; return { error => $error }; } |