Skip to content

Commit

Permalink
If possible, use Geo::GeoNames to guess country if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jun 19, 2024
1 parent 8a79c6a commit c53feff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gedcom
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ if($opts{'v'}) {

my $geocoder;
my $textgeocoder;
my $geonames;

if(((!$opts{'r'}) && (!$opts{'O'} && (!$opts{'S'}))) || $opts{'v'}) {
$geocoder = Geo::Coder::List->new($gopts)->push(Geo::Coder::Free::Local->new());

Expand Down Expand Up @@ -2202,6 +2204,16 @@ sub print_person
} elsif(my $b = Locale::Object::Country->new(name => $c)) {
# Country is found, nothing to be done
# $death_country = $b->name();
} elsif(my $user = $ENV{'GEONAMES_USER'}) {
$geonames //= Geo::GeoNames->new(username => $user);
$geonames->ua($cached_browser);
my $result = $geonames->search(q => $placeofdeath, style => 'FULL');
$result = @{$result}[0];
if(my $death_country = $result->{'countryName'}) {
# complain({ person => $person, warning => "$c: Assuming country of death is $death_country" });
} else {
complain({ person => $person, warning => "Unknown death country: '$c' in '$placeofdeath'" });
}
} else {
complain({ person => $person, warning => "Unknown death country: '$c' in '$placeofdeath'" });
}
Expand Down

0 comments on commit c53feff

Please sign in to comment.