Skip to content

Commit

Permalink
Merge pull request #886 from shawnlaffan/issue_885_GetFeatureCount
Browse files Browse the repository at this point in the history
Feature data imports: use GetFeatureCount for progress dialogue
  • Loading branch information
shawnlaffan authored Oct 23, 2023
2 parents ba58867 + 679b01b commit 4219622
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/Biodiverse/BaseData/Import.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1134,15 +1134,17 @@ sub import_data_shapefile {
}
}

# not yet a Geo::GDAL::FFI exported method
#my $shape_count = $layer->GetFeatureCount();
# interim solution
my $shape_count = 0;
while ($layer->GetNextFeature) {
$shape_count++;
my $shape_count = Geo::GDAL::FFI::OGR_L_GetFeatureCount($$layer);
# fallback
if ($shape_count < 0) {
$shape_count = 0;
$shape_count++ while $layer->GetNextFeature;
$layer->ResetReading;
}
$layer->ResetReading;
say "File has $shape_count shapes";

%fld_names = %fld_names{@field_names_used_lc};

# iterate over shapes
Expand Down

0 comments on commit 4219622

Please sign in to comment.