From 63d81be0ebf418767859f0eeeb26e92aee2ebe38 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Wed, 22 Nov 2023 08:44:58 -0500 Subject: [PATCH] Create JSON::MaybeXS objects fewer times --- createdatabase.PL | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/createdatabase.PL b/createdatabase.PL index 164cf9c8..a4d31885 100755 --- a/createdatabase.PL +++ b/createdatabase.PL @@ -1366,6 +1366,7 @@ my $inserts = 0; # my $wof_global_dbh; if(my $whosonfirst = $ENV{'WHOSONFIRST_HOME'}) { my %address_parsers; + my $j = JSON::MaybeXS->new()->utf8(); # Find all of the .geojson files in $WHOSONFIRST_HOME foreach my $geojson_file (create_tree_from_git($whosonfirst, 0)) { @@ -1374,12 +1375,12 @@ if(my $whosonfirst = $ENV{'WHOSONFIRST_HOME'}) { print "\n" if(DEBUG); $| = 0; - # Don't put instatiation outside of the loop - it creates CPANEL errors + # Don't combine these statements - it creates CPANEL usage errors # which I need to investigate - my $j = JSON::MaybeXS->new()->utf8(); my $data = File::Slurp::read_file($geojson_file); my $properties = $j->decode($data)->{'properties'}; # print 'processing ', $properties->{'wof:id'}, "\n"; + next if(exists($properties->{'wof:superseded_by'}) && scalar(@{$properties->{'wof:superseded_by'}})); next if(exists($properties->{'mz:is_current'}) && ($properties->{'mz:is_current'} == 0)); next if(exists($properties->{'src:geom'}) && ($properties->{'src:geom'} eq 'missing')); # https://github.com/whosonfirst-data/whosonfirst-data/issues/1346