Skip to content

Commit

Permalink
Use Geonames to guess birth country
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jul 16, 2024
1 parent d55c819 commit 9714ba1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ged2site
Original file line number Diff line number Diff line change
Expand Up @@ -8986,6 +8986,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
4 changes: 4 additions & 0 deletions tests/test-all-static
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -ex

unset GMAP_KEY
unset REDIS_SERVER
unset HTTP_PROXY
unset http_proxy

for i in $(find ~/gedcoms/* -name \*ged -o -name \*GED); do
# for i in tests/gedcoms/*.ged; do
rm -rf dynamic-site/data dynamic-site/img static-site/
Expand Down

0 comments on commit 9714ba1

Please sign in to comment.