Skip to content

Commit

Permalink
strip out invalid lat/lon values
Browse files Browse the repository at this point in the history
  • Loading branch information
ranguard committed Apr 22, 2016
1 parent f95d58c commit 43551cf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/MetaCPAN/Script/Backup.pm
Expand Up @@ -131,6 +131,27 @@ sub run_restore {

my $parent = $raw->{fields}->{_parent};

if ( $raw->{_type} eq 'author' ) {

# Hack for dodgy lat / lon's
if ( my $loc = $raw->{_source}->{location} ) {

my $lat = $loc->[1];
my $lon = $loc->[0];

if ( $lat > 90 or $lat < -90 ) {

# Invalid latitude
delete $raw->{_source}->{location};
}
elsif ( $lon > 180 or $lon < -180 ) {

# Invalid longitude
delete $raw->{_source}->{location};
}
}
}

$bulk->create(
{
id => $raw->{_id},
Expand Down

0 comments on commit 43551cf

Please sign in to comment.