Skip to content

Commit

Permalink
Try hearder to guess birth country
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Sep 4, 2024
1 parent dd2496e commit f652a37
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions gedcom
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,16 @@ sub print_person
$birth_country = 'Slovenia';
} elsif(my $b = Locale::Object::Country->new(name => $c)) {
$birth_country = $b->name();
} elsif(my $user = $ENV{'GEONAMES_USER'}) {
$geonames //= Geo::GeoNames->new(username => $user);
$geonames->ua($cached_browser);
my $result = $geonames->search(q => $placeofbirth, style => 'FULL');
$result = @{$result}[0];
if($birth_country = $result->{'countryName'}) {
complain({ person => $person, warning => "$c: Assuming country of birth is $birth_country" });
} else {
complain({ person => $person, warning => "Unknown birth country: '$c' in '$placeofbirth'" });
}
} else {
complain({ person => $person, warning => "Unknown birth country: '$c' in '$placeofbirth'" });
}
Expand Down Expand Up @@ -2408,7 +2418,7 @@ sub print_person
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" });
complain({ person => $person, warning => "$c: Assuming country of death is $death_country" });
} else {
complain({ person => $person, warning => "Unknown death country: '$c' in '$placeofdeath'" });
}
Expand Down Expand Up @@ -6397,7 +6407,7 @@ sub print_person
next;
}
if(my $e = $events[$index]) {
if(ref($e) && ($e->type() eq 'Departure') && $event->date() && $e->date()) {
if(ref($e) && defined($e->type()) && ($e->type() eq 'Arrival') && $event->date() && $e->date()) {
$previous = $event;
$prev_type = $event->type();
# FIXME: not all locations will be noted or notes printed
Expand Down Expand Up @@ -7468,8 +7478,7 @@ sub print_person
});
}
foreach my $event(@events) {
if($event->can('type')) {
my $type = $event->type();
if($event->can('type') && defined(my $type = $event->type())) {
my $year;
if($type =~ /^Census U[KS] (\d{4})$/) {
$year = $1;
Expand Down Expand Up @@ -13772,7 +13781,7 @@ sub get_params

my %rc;

if(scalar(@_) % 2 == 0) {
if((scalar(@_) % 2) == 0) {
%rc = @_;
} elsif(scalar(@_) == 1) {
if(defined($default)) {
Expand Down

0 comments on commit f652a37

Please sign in to comment.