line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::GDAL::FFI::Driver; |
2
|
5
|
|
|
5
|
|
61
|
use v5.10; |
|
5
|
|
|
|
|
18
|
|
3
|
5
|
|
|
5
|
|
38
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
99
|
|
4
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
155
|
|
5
|
5
|
|
|
5
|
|
39
|
use Carp; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
352
|
|
6
|
5
|
|
|
5
|
|
34
|
use base 'Geo::GDAL::FFI::Object'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
2822
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.0800; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub GetName { |
11
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
12
|
1
|
|
|
|
|
18
|
return $self->GetDescription; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub Create { |
16
|
13
|
|
|
13
|
1
|
183
|
my ($self, $name, $args, $h) = @_; |
17
|
13
|
|
100
|
|
|
70
|
$name //= ''; |
18
|
13
|
|
100
|
|
|
52
|
$args //= {}; |
19
|
13
|
100
|
|
|
|
61
|
$args = {Width => $args, Height => $h} unless ref $args; |
20
|
13
|
|
|
|
|
35
|
my $o = 0; |
21
|
13
|
|
|
|
|
26
|
for my $key (keys %{$args->{Options}}) { |
|
13
|
|
|
|
|
65
|
|
22
|
0
|
|
|
|
|
0
|
$o = Geo::GDAL::FFI::CSLAddString($o, "$key=$args->{Options}{$key}"); |
23
|
|
|
|
|
|
|
} |
24
|
13
|
|
|
|
|
29
|
my $ds; |
25
|
13
|
100
|
|
|
|
61
|
if ($args->{Source}) { |
|
|
100
|
|
|
|
|
|
26
|
1
|
|
|
|
|
3
|
my $src = ${$args->{Source}}; |
|
1
|
|
|
|
|
3
|
|
27
|
1
|
|
50
|
|
|
14
|
my $s = $args->{Strict} // 0; |
28
|
1
|
|
|
|
|
17
|
my $ffi = FFI::Platypus->new; |
29
|
1
|
|
|
|
|
1452
|
my $p = $ffi->closure($args->{Progress}); |
30
|
1
|
|
|
|
|
37
|
$ds = Geo::GDAL::FFI::GDALCreateCopy($$self, $name, $src, $s, $o, $p, $args->{ProgressData}); |
31
|
|
|
|
|
|
|
} elsif (not $args->{Width}) { |
32
|
4
|
|
|
|
|
1381
|
$ds = Geo::GDAL::FFI::GDALCreate($$self, $name, 0, 0, 0, 0, $o); |
33
|
|
|
|
|
|
|
} else { |
34
|
8
|
|
|
|
|
23
|
my $w = $args->{Width}; |
35
|
8
|
|
66
|
|
|
85
|
$h //= $args->{Height} // $w; |
|
|
|
33
|
|
|
|
|
36
|
8
|
|
50
|
|
|
40
|
my $b = $args->{Bands} // 1; |
37
|
8
|
|
50
|
|
|
50
|
my $dt = $args->{DataType} // 'Byte'; |
38
|
8
|
|
|
|
|
31
|
my $tmp = $Geo::GDAL::FFI::data_types{$dt}; |
39
|
8
|
50
|
|
|
|
27
|
unless (defined $tmp) { |
40
|
0
|
|
|
|
|
0
|
confess "Unknown constant: $dt."; |
41
|
0
|
|
|
|
|
0
|
Geo::GDAL::FFI::CSLDestroy($o); |
42
|
|
|
|
|
|
|
} |
43
|
8
|
|
|
|
|
18485
|
$ds = Geo::GDAL::FFI::GDALCreate($$self, $name, $w, $h, $b, $tmp, $o); |
44
|
|
|
|
|
|
|
} |
45
|
13
|
|
|
|
|
4440
|
Geo::GDAL::FFI::CSLDestroy($o); |
46
|
13
|
|
|
|
|
65
|
my $msg = Geo::GDAL::FFI::error_msg(); |
47
|
13
|
50
|
33
|
|
|
92
|
if (!$ds || $msg) { |
48
|
0
|
|
0
|
|
|
0
|
$msg //= "Driver " . $self->Name . " failed to create dataset '$name'."; |
49
|
0
|
|
|
|
|
0
|
confess $msg; |
50
|
|
|
|
|
|
|
} |
51
|
13
|
|
|
|
|
118
|
return bless \$ds, 'Geo::GDAL::FFI::Dataset'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
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 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Optional, but required to create a raster dataset. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item C |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Optional, default is the same as width. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Optional, the number of raster bands in the dataset, default is one. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Optional, the data type (a string) for the raster cells, default is |
103
|
|
|
|
|
|
|
'Byte'. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Optional, the dataset to copy. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item C |
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 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Optional, used only in dataset copy, a reference. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item C |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Optional, used only in dataset copy, default is false (0). |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C |
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. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Ari Jolma - Ari.Jolma at gmail.com |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SEE ALSO |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L, L, L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__END__; |