Skip to content

Commit

Permalink
Sanity check to MaxMind records
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 5, 2020
1 parent 8746753 commit 4f7c77e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Geo-Coder-Free

0.24
Sanity check to MaxMind records

0.23
Save database in Redis server as well if REDIS_SERVER is set
Fixed reverse_geocode in Local.pm for UK addresses
Expand Down
4 changes: 4 additions & 0 deletions lib/Geo/Coder/Free/MaxMind.pm
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ sub geocode {
my @locations;

foreach my $l(@rc) {
if(!exists($l->{'latitude'})) {
Carp::carp(__PACKAGE__, ": $location has latitude of 0");
return;
}
push @locations, Geo::Location::Point->new({
'lat' => $l->{'latitude'},
'long' => $l->{'longitude'},
Expand Down
4 changes: 2 additions & 2 deletions t/admin1.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ CITIES: {
my $admin1 = new_ok('Geo::Coder::Free::DB::MaxMind::admin1' => [logger => new_ok('MyLogger'), no_entry => 1]);

my $england = $admin1->fetchrow_hashref({ concatenated_codes => 'GB.ENG' });
ok($england->{asciiname} eq 'England');
is($england->{asciiname}, 'England');

$england = $admin1->fetchrow_hashref({ asciiname => 'England' });
ok($england->{concatenated_codes} eq 'GB.ENG');
is($england->{concatenated_codes}, 'GB.ENG');
}

0 comments on commit 4f7c77e

Please sign in to comment.