Skip to content

Commit

Permalink
Add Layer::GetFeatureCount method
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Oct 24, 2023
1 parent b3c7b76 commit 41bb348
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/Geo/GDAL/FFI/Layer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ sub GetFeature {
return bless \$f, 'Geo::GDAL::FFI::Feature';
}

sub GetFeatureCount {
my ($self, $force) = @_;
Geo::GDAL::FFI::OGR_L_GetFeatureCount($$self, !!$force);
}

sub SetFeature {
my ($self, $f) = @_;
Geo::GDAL::FFI::OGR_L_SetFeature($$self, $$f);
Expand Down
9 changes: 8 additions & 1 deletion t/layer.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ $f->SetGeomField([WKT => 'POLYGON ((2 1, 2 2, 4 2, 4 1, 2 1))']);

$method->CreateFeature($f);

{
my $feature_count = $layer->GetFeatureCount;
is $feature_count, 1, 'Got correct feature count';
$feature_count = $layer->GetFeatureCount (1);
is $feature_count, 1, 'Got correct feature count with force arg=true';
}

my $progress;

my $result;
Expand Down Expand Up @@ -136,7 +143,7 @@ is_deeply $layer->GetExtent(1), $exp_extent, 'Got correct layer extent when forc
{
#local $TODO = 'sql DISTINCT not yet working, despite following GDAL doc example';
is_deeply (\@items, ['one','ten'], 'got correct distinct items');
}
}

my $result = eval {
$ds->ExecuteSQL (qq{CREATE SPATIAL INDEX ON "$layer_name"});
Expand Down

0 comments on commit 41bb348

Please sign in to comment.