-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from shawnlaffan/dataset_getlayer_method
add a Dataset::GetLayerCount method
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use v5.10; | ||
use strict; | ||
use warnings; | ||
use Carp; | ||
use Geo::GDAL::FFI qw/GetDriver HaveGEOS/; | ||
use Test::More; | ||
use Test::Exception; | ||
use Data::Dumper; | ||
|
||
my $ds = GetDriver('GPKG')->Create('test.gpkg'); | ||
my $sr = Geo::GDAL::FFI::SpatialReference->new(EPSG => 3067); | ||
foreach my $i (1..3) { | ||
my $l = $ds->CreateLayer({ | ||
Name => "test$i", | ||
SpatialReference => $sr, | ||
GeometryType => 'Point', | ||
}); | ||
my $d = $l->GetDefn(); | ||
my $f = Geo::GDAL::FFI::Feature->new($d); | ||
$l->CreateFeature($f); | ||
} | ||
|
||
|
||
is ($ds->GetLayerCount, 3, 'Got expected number of layers'); | ||
|
||
dies_ok ( | ||
sub {$ds->GetLayer ('not_exists')}, | ||
'GetLayer exception for non-existent layer name', | ||
); | ||
dies_ok ( | ||
sub {$ds->GetLayer (23)}, | ||
'GetLayer exception for too large index', | ||
); | ||
dies_ok ( | ||
sub {$ds->GetLayer (-1)}, | ||
'GetLayer exception for negative index', | ||
); | ||
|
||
|
||
done_testing(); |