| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::GDAL::FFI::FeatureDefn; |
|
2
|
5
|
|
|
5
|
|
65
|
use v5.10; |
|
|
5
|
|
|
|
|
18
|
|
|
3
|
5
|
|
|
5
|
|
29
|
use strict; |
|
|
5
|
|
|
|
|
15
|
|
|
|
5
|
|
|
|
|
99
|
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
210
|
|
|
5
|
5
|
|
|
5
|
|
51
|
use Carp; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
7210
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.0800; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
3
|
|
|
3
|
1
|
33
|
my ($class, $args) = @_; |
|
11
|
3
|
|
50
|
|
|
16
|
$args //= {}; |
|
12
|
3
|
|
50
|
|
|
26
|
my $name = $args->{Name} // ''; |
|
13
|
3
|
|
|
|
|
25
|
my $self = bless \Geo::GDAL::FFI::OGR_FD_Create($name), $class; |
|
14
|
3
|
50
|
|
|
|
12
|
if ($args->{Fields}) { |
|
15
|
0
|
|
|
|
|
0
|
for my $field (@{$args->{Fields}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
16
|
0
|
|
|
|
|
0
|
$self->AddField(Geo::GDAL::FFI::FieldDefn->new($field)); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
} |
|
19
|
3
|
50
|
|
|
|
7
|
if ($args->{GeometryFields}) { |
|
20
|
0
|
|
|
|
|
0
|
my $first = 1; |
|
21
|
0
|
|
|
|
|
0
|
for my $field (@{$args->{GeometryFields}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
22
|
0
|
0
|
|
|
|
0
|
if ($first) { |
|
23
|
0
|
|
|
|
|
0
|
my $d = bless \Geo::GDAL::FFI::OGR_FD_GetGeomFieldDefn($$self, 0), |
|
24
|
|
|
|
|
|
|
'Geo::GDAL::FFI::GeomFieldDefn'; |
|
25
|
0
|
0
|
|
|
|
0
|
$d->SetName($field->{Name}) if defined $field->{Name}; |
|
26
|
0
|
|
|
|
|
0
|
$self->SetGeomType($field->{Type}); |
|
27
|
0
|
0
|
|
|
|
0
|
$d->SetSpatialRef($field->{SpatialReference}) if $field->{SpatialReference}; |
|
28
|
0
|
0
|
|
|
|
0
|
$d->SetNullable(0) if $field->{NotNullable}; |
|
29
|
0
|
|
|
|
|
0
|
$first = 0; |
|
30
|
|
|
|
|
|
|
} else { |
|
31
|
0
|
|
|
|
|
0
|
$self->AddGeomField(Geo::GDAL::FFI::GeomFieldDefn->new($field)); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} else { |
|
35
|
3
|
|
|
|
|
13
|
$self->SetGeomType($args->{GeometryType}); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
3
|
50
|
|
|
|
14
|
$self->SetStyleIgnored if $args->{StyleIgnored}; |
|
38
|
3
|
|
|
|
|
10
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub DESTROY { |
|
42
|
7
|
|
|
7
|
|
408
|
my $self = shift; |
|
43
|
|
|
|
|
|
|
#Geo::GDAL::FFI::OGR_FD_Release($$self); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub GetSchema { |
|
47
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
48
|
0
|
|
|
|
|
0
|
my $schema = {Name => $self->GetName}; |
|
49
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < Geo::GDAL::FFI::OGR_FD_GetFieldCount($$self); $i++) { |
|
50
|
0
|
|
|
|
|
0
|
push @{$schema->{Fields}}, $self->GetFieldDefn($i)->GetSchema; |
|
|
0
|
|
|
|
|
0
|
|
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < Geo::GDAL::FFI::OGR_FD_GetGeomFieldCount($$self); $i++) { |
|
53
|
0
|
|
|
|
|
0
|
push @{$schema->{GeometryFields}}, $self->GetGeomFieldDefn($i)->GetSchema; |
|
|
0
|
|
|
|
|
0
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
0
|
|
|
|
0
|
$schema->{StyleIgnored} = 1 if $self->IsStyleIgnored; |
|
56
|
0
|
|
|
|
|
0
|
return $schema; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub GetName { |
|
60
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
|
61
|
0
|
|
|
|
|
0
|
return Geo::GDAL::FFI::OGR_FD_GetName($$self); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub GetFieldDefn { |
|
65
|
1
|
|
|
1
|
1
|
4
|
my ($self, $fname) = @_; |
|
66
|
1
|
|
50
|
|
|
4
|
my $i = $fname // 0; |
|
67
|
1
|
50
|
|
|
|
4
|
$i = Geo::GDAL::FFI::OGR_FD_GetFieldIndex($$self, $i) unless Geo::GDAL::FFI::isint($i); |
|
68
|
1
|
|
|
|
|
7
|
my $d = Geo::GDAL::FFI::OGR_FD_GetFieldDefn($$self, $i); |
|
69
|
1
|
50
|
|
|
|
5
|
confess "No such field: $fname." unless $d; |
|
70
|
1
|
|
|
|
|
5
|
++$Geo::GDAL::FFI::immutable{$d}; |
|
71
|
1
|
|
|
|
|
4
|
return bless \$d, 'Geo::GDAL::FFI::FieldDefn'; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub GetFieldDefns { |
|
75
|
3
|
|
|
3
|
1
|
13
|
my $self = shift; |
|
76
|
3
|
|
|
|
|
6
|
my @retval; |
|
77
|
3
|
|
|
|
|
16
|
for my $i (0..Geo::GDAL::FFI::OGR_FD_GetFieldCount($$self)-1) { |
|
78
|
1
|
|
|
|
|
6
|
push @retval, $self->GetFieldDefn($i); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
3
|
|
|
|
|
19
|
return @retval; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub GetGeomFieldDefn { |
|
84
|
7
|
|
|
7
|
1
|
13
|
my ($self, $fname) = @_; |
|
85
|
7
|
|
50
|
|
|
17
|
my $i = $fname // 0; |
|
86
|
7
|
50
|
|
|
|
20
|
$i = Geo::GDAL::FFI::OGR_FD_GetGeomFieldIndex($$self, $i) unless Geo::GDAL::FFI::isint($i); |
|
87
|
7
|
|
|
|
|
25
|
my $d = Geo::GDAL::FFI::OGR_FD_GetGeomFieldDefn($$self, $i); |
|
88
|
7
|
50
|
|
|
|
17
|
confess "No such field: $fname." unless $d; |
|
89
|
7
|
|
|
|
|
24
|
++$Geo::GDAL::FFI::immutable{$d}; |
|
90
|
7
|
|
|
|
|
21
|
return bless \$d, 'Geo::GDAL::FFI::GeomFieldDefn'; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub GetGeomFieldDefns { |
|
94
|
5
|
|
|
5
|
1
|
13
|
my $self = shift; |
|
95
|
5
|
|
|
|
|
9
|
my @retval; |
|
96
|
5
|
|
|
|
|
24
|
for my $i (0..Geo::GDAL::FFI::OGR_FD_GetGeomFieldCount($$self)-1) { |
|
97
|
7
|
|
|
|
|
18
|
push @retval, $self->GetGeomFieldDefn($i); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
5
|
|
|
|
|
17
|
return @retval; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub AddFieldDefn { |
|
103
|
13
|
|
|
13
|
0
|
23
|
my ($self, $d) = @_; |
|
104
|
13
|
|
|
|
|
77
|
Geo::GDAL::FFI::OGR_FD_AddFieldDefn($$self, $$d); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub AddGeomFieldDefn { |
|
108
|
2
|
|
|
2
|
0
|
5
|
my ($self, $d) = @_; |
|
109
|
2
|
|
|
|
|
22
|
Geo::GDAL::FFI::OGR_FD_AddGeomFieldDefn($$self, $$d); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub DeleteFieldDefn { |
|
113
|
1
|
|
|
1
|
0
|
4
|
my ($self, $i) = @_; |
|
114
|
1
|
|
50
|
|
|
4
|
$i //= 0; |
|
115
|
1
|
50
|
|
|
|
6
|
$i = $self->GetFieldIndex($i) unless Geo::GDAL::FFI::isint($i); |
|
116
|
1
|
|
|
|
|
12
|
Geo::GDAL::FFI::OGR_FD_DeleteFieldDefn($$self, $i); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub DeleteGeomFieldDefn { |
|
120
|
1
|
|
|
1
|
0
|
3
|
my ($self, $i) = @_; |
|
121
|
1
|
|
50
|
|
|
5
|
$i //= 0; |
|
122
|
1
|
50
|
|
|
|
4
|
$i = $self->GetGeomFieldIndex($i) unless Geo::GDAL::FFI::isint($i); |
|
123
|
1
|
|
|
|
|
9
|
Geo::GDAL::FFI::OGR_FD_DeleteGeomFieldDefn($$self, $i); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub GetGeomType { |
|
127
|
2
|
|
|
2
|
0
|
22
|
my ($self) = @_; |
|
128
|
2
|
|
|
|
|
28
|
return $Geo::GDAL::FFI::geometry_types_reverse{Geo::GDAL::FFI::OGR_FD_GetGeomType($$self)}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub SetGeomType { |
|
132
|
4
|
|
|
4
|
0
|
14
|
my ($self, $type) = @_; |
|
133
|
4
|
|
100
|
|
|
19
|
$type //= 'Unknown'; |
|
134
|
4
|
|
|
|
|
10
|
my $tmp = $Geo::GDAL::FFI::geometry_types{$type}; |
|
135
|
4
|
50
|
|
|
|
10
|
confess "Unknown geometry type: $type." unless defined $tmp; |
|
136
|
4
|
|
|
|
|
21
|
Geo::GDAL::FFI::OGR_FD_SetGeomType($$self, $tmp); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub IsGeometryIgnored { |
|
140
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
|
141
|
2
|
|
|
|
|
13
|
Geo::GDAL::FFI::OGR_FD_IsGeometryIgnored($$self); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub SetGeometryIgnored { |
|
145
|
2
|
|
|
2
|
1
|
6
|
my ($self, $i) = @_; |
|
146
|
2
|
|
50
|
|
|
7
|
$i //= 1; |
|
147
|
2
|
|
|
|
|
13
|
Geo::GDAL::FFI::OGR_FD_SetGeometryIgnored($$self, $i); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub IsStyleIgnored { |
|
151
|
2
|
|
|
2
|
0
|
6
|
my ($self) = @_; |
|
152
|
2
|
|
|
|
|
11
|
Geo::GDAL::FFI::OGR_FD_IsStyleIgnored($$self); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub SetStyleIgnored { |
|
156
|
2
|
|
|
2
|
0
|
6
|
my ($self, $i) = @_; |
|
157
|
2
|
|
50
|
|
|
7
|
$i //= 1; |
|
158
|
2
|
|
|
|
|
14
|
Geo::GDAL::FFI::OGR_FD_SetStyleIgnored($$self, $i); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=pod |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=encoding UTF-8 |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 NAME |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Geo::GDAL::FFI::FeatureDefn - A GDAL feature schema |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 METHODS |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 new |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$defn = Geo::GDAL::FFI::FeatureDefn->new({Fields => [...], GeometryType => 'Point'}); |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Create a new FeatureDefn object. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
The named arguments (optional) are the following. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=over 4 |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item C |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Optional; the name for this feature class; default is the empty |
|
190
|
|
|
|
|
|
|
string. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item C |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Optional, a reference to an array of FieldDefn objects or schemas. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item C |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Optional, a reference to an array of GeomFieldDefn objects or schemas. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item C |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Optional, the type for the first geometry field; default is |
|
203
|
|
|
|
|
|
|
Unknown. Note that this argument is ignored if GeometryFields is |
|
204
|
|
|
|
|
|
|
given. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item C |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=back |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 GetSchema |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Returns the definition as a perl data structure. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 GetFieldDefn |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
my $field_defn = $defn->GetFieldDefn($name); |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Get the specified non spatial field object. If the argument is |
|
219
|
|
|
|
|
|
|
explicitly an integer and not a string, it is taken as the field |
|
220
|
|
|
|
|
|
|
index. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head2 GetFieldDefns |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my @field_defns = $defn->GetFieldDefns; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 GetGeomFieldDefn |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
my $geom_field_defn = $defn->GetGeomFieldDefn($name); |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Get the specified spatial field object. If the argument is explicitly |
|
231
|
|
|
|
|
|
|
an integer and not a string, it is taken as the field index. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 GetGeomFieldDefns |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
my @geom_field_defns = $defn->GetGeomFieldDefns; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 SetGeometryIgnored |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
$defn->SetGeometryIgnored($arg); |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Ignore the first geometry field when reading features from a layer. To |
|
242
|
|
|
|
|
|
|
not ignore the first geometry field call this method with defined but |
|
243
|
|
|
|
|
|
|
false (0) argument. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 IsGeometryIgnored |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my $is = $defn->IsGeometryIgnored; |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Is the first geometry field ignored when reading features from a |
|
250
|
|
|
|
|
|
|
layer. |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 LICENSE |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This software is released under the Artistic License. See |
|
255
|
|
|
|
|
|
|
L. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 AUTHOR |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Ari Jolma - Ari.Jolma at gmail.com |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
L |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L, L, L |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
__END__; |