aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm25
-rw-r--r--perllib/Open311/PopulateServiceList.pm6
2 files changed, 28 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index 416fb942a..3869ef8d3 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -6,6 +6,7 @@ BEGIN {extends 'Catalyst::Controller'; }
use Encode;
use FixMyStreet::Geocode;
+use Geo::OLC;
use Try::Tiny;
use Utils;
@@ -74,6 +75,30 @@ sub determine_location_from_pc : Private {
map { Utils::truncate_coordinate($_) } ($1, $2);
return $c->forward( 'check_location' );
}
+
+ if (Geo::OLC::is_full($pc)) {
+ my $ref = Geo::OLC::decode($pc);
+ ($c->stash->{latitude}, $c->stash->{longitude}) =
+ map { Utils::truncate_coordinate($_) } @{$ref->{center}};
+ return $c->forward( 'check_location' );
+ }
+
+ if ($pc =~ /^\s*([2-9CFGHJMPQRVWX]{4,6}\+[2-9CFGHJMPQRVWX]{2,3})\s+(.*)$/i) {
+ my ($code, $rest) = ($1, $2);
+ my ($lat, $lon, $error) = FixMyStreet::Geocode::lookup($rest, $c);
+ if (ref($error) eq 'ARRAY') { # Just take the first result
+ $lat = $error->[0]{latitude};
+ $lon = $error->[0]{longitude};
+ }
+ if (defined $lat && defined $lon) {
+ $code = Geo::OLC::recover_nearest($code, $lat, $lon);
+ my $ref = Geo::OLC::decode($code);
+ ($c->stash->{latitude}, $c->stash->{longitude}) =
+ map { Utils::truncate_coordinate($_) } @{$ref->{center}};
+ return $c->forward( 'check_location' );
+ }
+ }
+
if ( $c->cobrand->country eq 'GB' && $pc =~ /^([A-Z])([A-Z])([\d\s]{4,})$/i) {
if (my $convert = gridref_to_latlon( $1, $2, $3 )) {
($c->stash->{latitude}, $c->stash->{longitude}) =
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 9be17946e..20fca90b3 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -350,10 +350,10 @@ sub _delete_contacts_not_in_service_list {
);
if ($self->_current_body->can_be_devolved) {
- # If the body has can_be_devolved switched on, it's most likely a
- # combination of Open311/email, so ignore any email addresses.
+ # If the body has can_be_devolved switched on, ignore any
+ # contact with its own send method
$found_contacts = $found_contacts->search(
- { email => { -not_like => '%@%' } }
+ { send_method => [ "", undef ] },
);
}