| 1 | package Geo::GDAL::FFI::Driver; | ||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use base 'Geo::GDAL::FFI::Object'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 13 | our $VERSION = '0.15'; | |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | sub GetName { | ||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
GetName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 12 | 0 | return $self->GetDescription; | |||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | sub Create { | ||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | my ($self, $name, $args, $h) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
Create: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $name //= ''; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name //= ""
MC/DC0%0/1
$name //= ""
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | $args //= {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args //= {}
MC/DC0%0/1
$args //= {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | $args = {Width => $args, Height => $h} unless ref $args; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | 0 | my $o = 0; | |||||||||||||||||||||||||||||||||
| 21 | 0 | for my $key (keys %{$args->{Options}}) { | |||||||||||||||||||||||||||||||||
| 22 | 0 | $o = Geo::GDAL::FFI::CSLAddString($o, "$key=$args->{Options}{$key}"); | |||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||
| 24 | 0 | my $ds; | |||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if ($args->{Source}) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 26 | 0 | my $src = ${$args->{Source}}; | |||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $s = $args->{Strict} // 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"Strict"} // 0
MC/DC0%0/1
$args->{"Strict"} // 0
$args->{"Strict"}
Truth table0%0/2
A
A= $args->{"Strict"}
| |||||||||||||||||||||||||||||||||||
| 28 | 0 | my $ffi = FFI::Platypus->new; | |||||||||||||||||||||||||||||||||
| 29 | 0 | my $p = $ffi->closure($args->{Progress}); | |||||||||||||||||||||||||||||||||
| 30 | 0 | $ds = Geo::GDAL::FFI::GDALCreateCopy($$self, $name, $src, $s, $o, $p, $args->{ProgressData}); | |||||||||||||||||||||||||||||||||
| 31 | } elsif (not $args->{Width}) { | ||||||||||||||||||||||||||||||||||
| 32 | 0 | $ds = Geo::GDAL::FFI::GDALCreate($$self, $name, 0, 0, 0, 0, $o); | |||||||||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||||||||
| 34 | 0 | my $w = $args->{Width}; | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $h //= $args->{Height} // $w; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$h //= $args->{"Height"} // $w
$args->{"Height"} // $w
MC/DC0%0/3
$h //= $args->{"Height"} // $w
$h
$args->{"Height"}
$w
Truth table0%0/4
A //= B // C
A= $hB= $args->{"Height"}C= $w
| |||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $b = $args->{Bands} // 1; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"Bands"} // 1
MC/DC0%0/1
$args->{"Bands"} // 1
$args->{"Bands"}
Truth table0%0/2
A
A= $args->{"Bands"}
| |||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $dt = $args->{DataType} // 'Byte'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"DataType"} // "Byte"
MC/DC0%0/1
$args->{"DataType"} // "Byte"
$args->{"DataType"}
Truth table0%0/2
A
A= $args->{"DataType"}
| |||||||||||||||||||||||||||||||||||
| 38 | 0 | my $tmp = $Geo::GDAL::FFI::data_types{$dt}; | |||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless (defined $tmp) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 40 | 0 | confess "Unknown constant: $dt."; | |||||||||||||||||||||||||||||||||
| 41 | 0 | Geo::GDAL::FFI::CSLDestroy($o); | |||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||
| 43 | 0 | $ds = Geo::GDAL::FFI::GDALCreate($$self, $name, $w, $h, $b, $tmp, $o); | |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | 0 | Geo::GDAL::FFI::CSLDestroy($o); | |||||||||||||||||||||||||||||||||
| 46 | 0 | my $msg = Geo::GDAL::FFI::error_msg(); | |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (!$ds || $msg) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $ds or $msg
MC/DC0%0/2
not $ds or $msg
not $ds
$msg
Truth table0%0/3
not(A) or B
A= not $dsB= $msg
| |||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $msg //= "Driver " . $self->Name . " failed to create dataset '$name'."; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$msg //= 'Driver ' . $self->Name . " failed to create dataset '${name}'."
MC/DC0%0/1
$msg //= 'Driver ' . $self->Name . " failed to create dataset '${name}'."
$msg
Truth table0%0/2
A
A= $msg
| |||||||||||||||||||||||||||||||||||
| 49 | 0 | confess $msg; | |||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||
| 51 | 0 | return bless \$ds, 'Geo::GDAL::FFI::Dataset'; | |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 13 | 1; | |||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | =pod | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | Geo::GDAL::FFI::Driver - A GDAL data access driver | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | A format driver. Use the Driver method of a Geo::GDAL::FFI object to | ||||||||||||||||||||||||||||||||||
| 69 | obtain one. | ||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | =head2 GetName | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | my $name = $driver->GetName; | ||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | Returns the name of the driver. | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | =head2 Create | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | my $name = $driver->Create($name, {Width => 100, ...}); | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | Create a dataset. $name is the name for the dataset to create. Named | ||||||||||||||||||||||||||||||||||
| 84 | arguments are the following. | ||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | =over 4 | ||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | =item C<Width> | ||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | Optional, but required to create a raster dataset. | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | =item C<Height> | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | Optional, default is the same as width. | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | =item C<Bands> | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | Optional, the number of raster bands in the dataset, default is one. | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | =item C<DataType> | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | Optional, the data type (a string) for the raster cells, default is | ||||||||||||||||||||||||||||||||||
| 103 | 'Byte'. | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | =item C<Source> | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | Optional, the dataset to copy. | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =item C<Progress> | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | Optional, used only in dataset copy, a reference to a subroutine. The | ||||||||||||||||||||||||||||||||||
| 112 | subroutine is called with three arguments C<($fraction, $msg, $data)>, | ||||||||||||||||||||||||||||||||||
| 113 | where C<$fraction> is a number, C<$msg> is a string, and C<$data> is a | ||||||||||||||||||||||||||||||||||
| 114 | pointer that is given as the progress data argument. | ||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | =item C<ProgressData> | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | Optional, used only in dataset copy, a reference. | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | =item C<Strict> | ||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | Optional, used only in dataset copy, default is false (0). | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | =item C<Options> | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | Optional, driver specific creation options, default is reference to an | ||||||||||||||||||||||||||||||||||
| 127 | empty hash. | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | =back | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | my $name = $driver->Create($name, $width); | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | A simple syntax for calling Create to create a raster dataset. | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | This software is released under the Artistic License. See | ||||||||||||||||||||||||||||||||||
| 138 | L<perlartistic>. | ||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | Ari Jolma - Ari.Jolma at gmail.com | ||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | L<Geo::GDAL::FFI> | ||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org> | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | __END__; | ||||||||||||||||||||||||||||||||||