Skip to content

Commit

Permalink
Create JSON::MaybeXS objects fewer times
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Nov 22, 2023
1 parent 8e578c0 commit 63d81be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions createdatabase.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand Down

0 comments on commit 63d81be

Please sign in to comment.