line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::GDAL::FFI::FieldDefn; |
2
|
5
|
|
|
5
|
|
66
|
use v5.10; |
|
5
|
|
|
|
|
19
|
|
3
|
5
|
|
|
5
|
|
49
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
136
|
|
4
|
5
|
|
|
5
|
|
37
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
127
|
|
5
|
5
|
|
|
5
|
|
35
|
use Carp; |
|
5
|
|
|
|
|
52
|
|
|
5
|
|
|
|
|
6689
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.0700; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
16
|
|
|
16
|
0
|
186
|
my ($class, $args) = @_; |
11
|
16
|
|
50
|
|
|
40
|
my $name = $args->{Name} // 'Unnamed'; |
12
|
16
|
|
50
|
|
|
31
|
my $type = $args->{Type} // 'String'; |
13
|
16
|
|
|
|
|
33
|
my $tmp = $Geo::GDAL::FFI::field_types{$type}; |
14
|
16
|
50
|
|
|
|
32
|
confess "Unknown field type: '$type'." unless defined $tmp; |
15
|
16
|
|
|
|
|
84
|
my $self = bless \Geo::GDAL::FFI::OGR_Fld_Create($name, $tmp), $class; |
16
|
16
|
50
|
|
|
|
40
|
$self->SetDefault($args->{Default}) if defined $args->{Default}; |
17
|
16
|
50
|
|
|
|
370
|
$self->SetSubtype($args->{Subtype}) if defined $args->{Subtype}; |
18
|
16
|
50
|
|
|
|
34
|
$self->SetJustify($args->{Justify}) if defined $args->{Justify}; |
19
|
16
|
50
|
|
|
|
41
|
$self->SetWidth($args->{Width}) if defined $args->{Width}; |
20
|
16
|
50
|
|
|
|
31
|
$self->SetPrecision($args->{Precision}) if defined $args->{Precision}; |
21
|
16
|
50
|
|
|
|
47
|
$self->SetNullable(0) if $args->{NotNullable}; |
22
|
16
|
|
|
|
|
56
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub DESTROY { |
26
|
17
|
|
|
17
|
|
31
|
my $self = shift; |
27
|
|
|
|
|
|
|
#say STDERR "destroy $self => $$self"; |
28
|
17
|
100
|
|
|
|
41
|
if ($Geo::GDAL::FFI::immutable{$$self}) { |
29
|
|
|
|
|
|
|
#say STDERR "remove it from immutable"; |
30
|
1
|
|
|
|
|
3
|
$Geo::GDAL::FFI::immutable{$$self}--; |
31
|
1
|
50
|
|
|
|
9
|
delete $Geo::GDAL::FFI::immutable{$$self} if $Geo::GDAL::FFI::immutable{$$self} == 0; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
#say STDERR "destroy it"; |
34
|
16
|
|
|
|
|
71
|
Geo::GDAL::FFI::OGR_Fld_Destroy($$self); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub GetSchema { |
39
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
40
|
0
|
|
|
|
|
0
|
my $schema = { |
41
|
|
|
|
|
|
|
Name => $self->GetName, |
42
|
|
|
|
|
|
|
Type => $self->GetType, |
43
|
|
|
|
|
|
|
Subtype => $self->GetSubtype, |
44
|
|
|
|
|
|
|
Justify => $self->GetJustify, |
45
|
|
|
|
|
|
|
Width => $self->GetWidth, |
46
|
|
|
|
|
|
|
Precision => $self->GetPrecision, |
47
|
|
|
|
|
|
|
}; |
48
|
0
|
|
|
|
|
0
|
my $default = $self->GetDefault; |
49
|
0
|
0
|
|
|
|
0
|
$schema->{Default} = $default if defined $default; |
50
|
0
|
0
|
|
|
|
0
|
$schema->{NotNullable} = 1 unless $self->IsNullable; |
51
|
0
|
|
|
|
|
0
|
return $schema; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub SetName { |
55
|
1
|
|
|
1
|
0
|
4
|
my ($self, $name) = @_; |
56
|
1
|
50
|
|
|
|
6
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
57
|
1
|
|
50
|
|
|
3
|
$name //= ''; |
58
|
1
|
|
|
|
|
12
|
Geo::GDAL::FFI::OGR_Fld_SetName($$self, $name); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub GetName { |
62
|
2
|
|
|
2
|
0
|
9
|
my ($self) = @_; |
63
|
2
|
|
|
|
|
17
|
return Geo::GDAL::FFI::OGR_Fld_GetNameRef($$self); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub SetType { |
67
|
1
|
|
|
1
|
0
|
4
|
my ($self, $type) = @_; |
68
|
1
|
50
|
|
|
|
5
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
69
|
1
|
|
50
|
|
|
3
|
$type //= 'String'; |
70
|
1
|
|
|
|
|
3
|
my $tmp = $Geo::GDAL::FFI::field_types{$type}; |
71
|
1
|
50
|
|
|
|
4
|
confess "Unknown field type: $type." unless defined $tmp; |
72
|
1
|
|
|
|
|
2
|
$type = $tmp; |
73
|
1
|
|
|
|
|
12
|
Geo::GDAL::FFI::OGR_Fld_SetType($$self, $type); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub GetType { |
77
|
2
|
|
|
2
|
0
|
5
|
my ($self) = @_; |
78
|
2
|
|
|
|
|
16
|
return $Geo::GDAL::FFI::field_types_reverse{Geo::GDAL::FFI::OGR_Fld_GetType($$self)}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub GetDefault { |
82
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
83
|
0
|
|
|
|
|
0
|
return Geo::GDAL::FFI::OGR_Fld_GetDefault($$self) |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub SetDefault { |
87
|
0
|
|
|
0
|
0
|
0
|
my ($self, $default) = @_; |
88
|
0
|
|
|
|
|
0
|
Geo::GDAL::FFI::OGR_Fld_SetDefault($$self, $default); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub IsDefaultDriverSpecific { |
92
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
93
|
0
|
|
|
|
|
0
|
return Geo::GDAL::FFI::OGR_Fld_IsDefaultDriverSpecific($$self); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub SetSubtype { |
97
|
1
|
|
|
1
|
0
|
4
|
my ($self, $subtype) = @_; |
98
|
1
|
50
|
|
|
|
4
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
99
|
1
|
|
50
|
|
|
4
|
$subtype //= 'None'; |
100
|
1
|
|
|
|
|
4
|
my $tmp = $Geo::GDAL::FFI::field_subtypes{$subtype}; |
101
|
1
|
50
|
|
|
|
4
|
confess "Unknown field subtype: $subtype." unless defined $tmp; |
102
|
1
|
|
|
|
|
2
|
$subtype = $tmp; |
103
|
1
|
|
|
|
|
10
|
Geo::GDAL::FFI::OGR_Fld_SetSubType($$self, $subtype); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub GetSubtype { |
107
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
108
|
1
|
|
|
|
|
8
|
return $Geo::GDAL::FFI::field_subtypes_reverse{Geo::GDAL::FFI::OGR_Fld_GetSubType($$self)}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub SetJustify { |
112
|
1
|
|
|
1
|
0
|
4
|
my ($self, $justify) = @_; |
113
|
1
|
50
|
|
|
|
5
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
114
|
1
|
|
50
|
|
|
3
|
$justify //= 'Undefined'; |
115
|
1
|
|
|
|
|
3
|
my $tmp = $Geo::GDAL::FFI::justification{$justify}; |
116
|
1
|
50
|
|
|
|
4
|
confess "Unknown justify: $justify." unless defined $tmp; |
117
|
1
|
|
|
|
|
3
|
$justify = $tmp; |
118
|
1
|
|
|
|
|
5
|
Geo::GDAL::FFI::OGR_Fld_SetJustify($$self, $justify); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub GetJustify { |
122
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
123
|
1
|
|
|
|
|
17
|
return $Geo::GDAL::FFI::justification_reverse{Geo::GDAL::FFI::OGR_Fld_GetJustify($$self)}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub SetWidth { |
127
|
1
|
|
|
1
|
0
|
4
|
my ($self, $width) = @_; |
128
|
1
|
50
|
|
|
|
6
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
129
|
1
|
|
50
|
|
|
5
|
$width //= ''; |
130
|
1
|
|
|
|
|
7
|
Geo::GDAL::FFI::OGR_Fld_SetWidth($$self, $width); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub GetWidth { |
134
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
135
|
1
|
|
|
|
|
7
|
return Geo::GDAL::FFI::OGR_Fld_GetWidth($$self); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub SetPrecision { |
139
|
1
|
|
|
1
|
0
|
4
|
my ($self, $precision) = @_; |
140
|
1
|
50
|
|
|
|
4
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
141
|
1
|
|
50
|
|
|
3
|
$precision //= ''; |
142
|
1
|
|
|
|
|
6
|
Geo::GDAL::FFI::OGR_Fld_SetPrecision($$self, $precision); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub GetPrecision { |
146
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
147
|
1
|
|
|
|
|
20
|
return Geo::GDAL::FFI::OGR_Fld_GetPrecision($$self); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub SetIgnored { |
151
|
2
|
|
|
2
|
1
|
6
|
my ($self, $ignored) = @_; |
152
|
|
|
|
|
|
|
#confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
153
|
2
|
|
100
|
|
|
10
|
$ignored //= 1; |
154
|
2
|
|
|
|
|
10
|
Geo::GDAL::FFI::OGR_Fld_SetIgnored($$self, $ignored); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub IsIgnored { |
158
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
159
|
2
|
|
|
|
|
11
|
return Geo::GDAL::FFI::OGR_Fld_IsIgnored($$self); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub SetNullable { |
163
|
2
|
|
|
2
|
0
|
7
|
my ($self, $nullable) = @_; |
164
|
2
|
50
|
|
|
|
6
|
confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; |
165
|
2
|
|
100
|
|
|
10
|
$nullable //= 0; |
166
|
2
|
|
|
|
|
9
|
Geo::GDAL::FFI::OGR_Fld_SetNullable($$self, $nullable); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub IsNullable { |
170
|
2
|
|
|
2
|
0
|
4
|
my ($self) = @_; |
171
|
2
|
|
|
|
|
18
|
return Geo::GDAL::FFI::OGR_Fld_IsNullable($$self); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=pod |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=encoding UTF-8 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 NAME |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Geo::GDAL::FFI::FieldDefn - A field in a GDAL feature schema |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 SYNOPSIS |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 DESCRIPTION |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
There should not usually be any reason to directly access this method |
189
|
|
|
|
|
|
|
except for the ignore methods. This object is created/read from/to the |
190
|
|
|
|
|
|
|
Perl data structure in the CreateLayer method of a dataset, or in the |
191
|
|
|
|
|
|
|
constructor or schema method of FeatureDefn. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
The schema of a FieldDefn is (Name, Type, Default, Subtype, Justify, |
194
|
|
|
|
|
|
|
Width, Precision, NotNullable). |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 METHODS |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 SetIgnored |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$defn->SetIgnored($arg); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Ignore this field when reading features from a layer. To not ignore |
203
|
|
|
|
|
|
|
this field call this method with defined but false (0) argument. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 IsIgnored |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Is this field ignored when reading features from a layer. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 LICENSE |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This software is released under the Artistic License. See |
212
|
|
|
|
|
|
|
L. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 AUTHOR |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Ari Jolma - Ari.Jolma at gmail.com |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 SEE ALSO |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L, L, L |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
__END__; |