Skip to content

Commit

Permalink
Fix Local.pm without libpostal
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 2, 2020
1 parent 938b733 commit 3db54b6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/Geo/Coder/Free/Local.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@ sub geocode {
}
}
}
} elsif($location =~ /^(.+?),\s*([\s\w]+),\s*([\s\w]+),\s*([\w\s]+)$/) {
my %addr;
$addr{'road'} = $1;
$addr{'city'} = $2;
$addr{'state'} = $3;
$addr{'country'} = $4;
$addr{'state'} =~ s/\s$//g;
$addr{'country'} =~ s/\s$//g;
if($addr{'road'} =~ /([\w\s]+),*\s+(.+)/) {
$addr{'name'} = $1;
$addr{'road'} = $2;
}
if($addr{'road'} =~ /^(\d+)\s+(.+)/) {
$addr{'number'} = $1;
$addr{'road'} = $2;
# ::diag(__LINE__, ': ', Data::Dumper->new([\%addr])->Dump());
if(my $rc = $self->_search(\%addr, ('name', 'number', 'road', 'city', 'state', 'country'))) {
return $rc;
}
} elsif(my $rc = $self->_search(\%addr, ('name', 'road', 'city', 'state', 'country'))) {
return $rc;
}
}

$location = uc($location);
Expand All @@ -378,6 +400,13 @@ sub geocode {
# ::diag(__LINE__, ": $location");
return $rc;
}
if($location =~ /(.+), (England|UK)$/i) {
$param{'location'} = "$1, GB";
if(my $rc = $self->geocode(\%param)) {
# ::diag(__LINE__, ": $location");
return $rc;
}
}
}
}
return;
Expand Down

0 comments on commit 3db54b6

Please sign in to comment.