line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was automatically generated by SWIG (http://www.swig.org). |
2
|
|
|
|
|
|
|
# Version 3.0.5 |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Do not make changes to this file unless you know what you are doing--modify |
5
|
|
|
|
|
|
|
# the SWIG interface file instead. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Geo::OGR; |
8
|
6
|
|
|
6
|
|
30
|
use base qw(Exporter); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
434
|
|
9
|
6
|
|
|
6
|
|
29
|
use base qw(DynaLoader); |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
4408
|
|
10
|
|
|
|
|
|
|
require Geo::OSR; |
11
|
|
|
|
|
|
|
require Geo::GDAL; |
12
|
|
|
|
|
|
|
package Geo::OGRc; |
13
|
|
|
|
|
|
|
bootstrap Geo::OGR; |
14
|
|
|
|
|
|
|
package Geo::OGR; |
15
|
|
|
|
|
|
|
@EXPORT = qw(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ---------- BASE METHODS ------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Geo::OGR; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub TIEHASH { |
22
|
0
|
|
|
0
|
|
0
|
my ($classname,$obj) = @_; |
23
|
0
|
|
|
|
|
0
|
return bless $obj, $classname; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
0
|
|
|
sub CLEAR { } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
0
|
|
|
sub FIRSTKEY { } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
0
|
|
|
sub NEXTKEY { } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub FETCH { |
33
|
0
|
|
|
0
|
|
0
|
my ($self,$field) = @_; |
34
|
0
|
|
|
|
|
0
|
my $member_func = "swig_${field}_get"; |
35
|
0
|
|
|
|
|
0
|
$self->$member_func(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub STORE { |
39
|
0
|
|
|
0
|
|
0
|
my ($self,$field,$newval) = @_; |
40
|
0
|
|
|
|
|
0
|
my $member_func = "swig_${field}_set"; |
41
|
0
|
|
|
|
|
0
|
$self->$member_func($newval); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub this { |
45
|
0
|
|
|
0
|
0
|
0
|
my $ptr = shift; |
46
|
0
|
|
|
|
|
0
|
return tied(%$ptr); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# ------- FUNCTION WRAPPERS -------- |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Geo::OGR; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
*callback_d_cp_vp = *Geo::OGRc::callback_d_cp_vp; |
55
|
|
|
|
|
|
|
*UseExceptions = *Geo::OGRc::UseExceptions; |
56
|
|
|
|
|
|
|
*DontUseExceptions = *Geo::OGRc::DontUseExceptions; |
57
|
|
|
|
|
|
|
*CreateGeometryFromWkb = *Geo::OGRc::CreateGeometryFromWkb; |
58
|
|
|
|
|
|
|
*CreateGeometryFromWkt = *Geo::OGRc::CreateGeometryFromWkt; |
59
|
|
|
|
|
|
|
*CreateGeometryFromGML = *Geo::OGRc::CreateGeometryFromGML; |
60
|
|
|
|
|
|
|
*CreateGeometryFromJson = *Geo::OGRc::CreateGeometryFromJson; |
61
|
|
|
|
|
|
|
*BuildPolygonFromEdges = *Geo::OGRc::BuildPolygonFromEdges; |
62
|
|
|
|
|
|
|
*ApproximateArcAngles = *Geo::OGRc::ApproximateArcAngles; |
63
|
|
|
|
|
|
|
*ForceToPolygon = *Geo::OGRc::ForceToPolygon; |
64
|
|
|
|
|
|
|
*ForceToLineString = *Geo::OGRc::ForceToLineString; |
65
|
|
|
|
|
|
|
*ForceToMultiPolygon = *Geo::OGRc::ForceToMultiPolygon; |
66
|
|
|
|
|
|
|
*ForceToMultiPoint = *Geo::OGRc::ForceToMultiPoint; |
67
|
|
|
|
|
|
|
*ForceToMultiLineString = *Geo::OGRc::ForceToMultiLineString; |
68
|
|
|
|
|
|
|
*ForceTo = *Geo::OGRc::ForceTo; |
69
|
|
|
|
|
|
|
*GetDriverCount = *Geo::OGRc::GetDriverCount; |
70
|
|
|
|
|
|
|
*GetOpenDSCount = *Geo::OGRc::GetOpenDSCount; |
71
|
|
|
|
|
|
|
*SetGenerate_DB2_V72_BYTE_ORDER = *Geo::OGRc::SetGenerate_DB2_V72_BYTE_ORDER; |
72
|
|
|
|
|
|
|
*RegisterAll = *Geo::OGRc::RegisterAll; |
73
|
|
|
|
|
|
|
*GeometryTypeToName = *Geo::OGRc::GeometryTypeToName; |
74
|
|
|
|
|
|
|
*GetFieldTypeName = *Geo::OGRc::GetFieldTypeName; |
75
|
|
|
|
|
|
|
*GetFieldSubTypeName = *Geo::OGRc::GetFieldSubTypeName; |
76
|
|
|
|
|
|
|
*GT_Flatten = *Geo::OGRc::GT_Flatten; |
77
|
|
|
|
|
|
|
*GT_SetZ = *Geo::OGRc::GT_SetZ; |
78
|
|
|
|
|
|
|
*GT_SetModifier = *Geo::OGRc::GT_SetModifier; |
79
|
|
|
|
|
|
|
*GT_HasZ = *Geo::OGRc::GT_HasZ; |
80
|
|
|
|
|
|
|
*GT_IsSubClassOf = *Geo::OGRc::GT_IsSubClassOf; |
81
|
|
|
|
|
|
|
*GT_IsCurve = *Geo::OGRc::GT_IsCurve; |
82
|
|
|
|
|
|
|
*GT_IsSurface = *Geo::OGRc::GT_IsSurface; |
83
|
|
|
|
|
|
|
*GT_IsNonLinear = *Geo::OGRc::GT_IsNonLinear; |
84
|
|
|
|
|
|
|
*GT_GetCollection = *Geo::OGRc::GT_GetCollection; |
85
|
|
|
|
|
|
|
*GT_GetCurve = *Geo::OGRc::GT_GetCurve; |
86
|
|
|
|
|
|
|
*GT_GetLinear = *Geo::OGRc::GT_GetLinear; |
87
|
|
|
|
|
|
|
*SetNonLinearGeometriesEnabledFlag = *Geo::OGRc::SetNonLinearGeometriesEnabledFlag; |
88
|
|
|
|
|
|
|
*GetNonLinearGeometriesEnabledFlag = *Geo::OGRc::GetNonLinearGeometriesEnabledFlag; |
89
|
|
|
|
|
|
|
*GetOpenDS = *Geo::OGRc::GetOpenDS; |
90
|
|
|
|
|
|
|
*Open = *Geo::OGRc::Open; |
91
|
|
|
|
|
|
|
*OpenShared = *Geo::OGRc::OpenShared; |
92
|
|
|
|
|
|
|
*GetDriverByName = *Geo::OGRc::GetDriverByName; |
93
|
|
|
|
|
|
|
*_GetDriver = *Geo::OGRc::_GetDriver; |
94
|
|
|
|
|
|
|
*GeneralCmdLineProcessor = *Geo::OGRc::GeneralCmdLineProcessor; |
95
|
|
|
|
|
|
|
*TermProgress_nocb = *Geo::OGRc::TermProgress_nocb; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
############# Class : Geo::OGR::StyleTable ############## |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package Geo::OGR::StyleTable; |
100
|
6
|
|
|
6
|
|
36
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
2416
|
|
101
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
102
|
|
|
|
|
|
|
%OWNER = (); |
103
|
|
|
|
|
|
|
%ITERATORS = (); |
104
|
|
|
|
|
|
|
sub new { |
105
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
106
|
0
|
|
|
|
|
0
|
my $self = Geo::OGRc::new_StyleTable(@_); |
107
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub DESTROY { |
111
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
112
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
113
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
114
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
115
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
116
|
0
|
|
|
|
|
0
|
Geo::OGRc::delete_StyleTable($self); |
117
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
*AddStyle = *Geo::OGRc::StyleTable_AddStyle; |
122
|
|
|
|
|
|
|
*LoadStyleTable = *Geo::OGRc::StyleTable_LoadStyleTable; |
123
|
|
|
|
|
|
|
*SaveStyleTable = *Geo::OGRc::StyleTable_SaveStyleTable; |
124
|
|
|
|
|
|
|
*Find = *Geo::OGRc::StyleTable_Find; |
125
|
|
|
|
|
|
|
*ResetStyleStringReading = *Geo::OGRc::StyleTable_ResetStyleStringReading; |
126
|
|
|
|
|
|
|
*GetNextStyle = *Geo::OGRc::StyleTable_GetNextStyle; |
127
|
|
|
|
|
|
|
*GetLastStyleName = *Geo::OGRc::StyleTable_GetLastStyleName; |
128
|
|
|
|
|
|
|
sub DISOWN { |
129
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
130
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
131
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub ACQUIRE { |
135
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
136
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
137
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
############# Class : Geo::OGR::Driver ############## |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
package Geo::OGR::Driver; |
144
|
6
|
|
|
6
|
|
32
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1551
|
|
145
|
|
|
|
|
|
|
@ISA = qw( Geo::GDAL::MajorObject Geo::OGR ); |
146
|
|
|
|
|
|
|
%OWNER = (); |
147
|
|
|
|
|
|
|
%ITERATORS = (); |
148
|
|
|
|
|
|
|
*swig_name_get = *Geo::OGRc::Driver_name_get; |
149
|
|
|
|
|
|
|
*swig_name_set = *Geo::OGRc::Driver_name_set; |
150
|
|
|
|
|
|
|
*CreateDataSource = *Geo::OGRc::Driver_CreateDataSource; |
151
|
|
|
|
|
|
|
*CopyDataSource = *Geo::OGRc::Driver_CopyDataSource; |
152
|
|
|
|
|
|
|
*Open = *Geo::OGRc::Driver_Open; |
153
|
|
|
|
|
|
|
*DeleteDataSource = *Geo::OGRc::Driver_DeleteDataSource; |
154
|
|
|
|
|
|
|
*_TestCapability = *Geo::OGRc::Driver__TestCapability; |
155
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::Driver_GetName; |
156
|
|
|
|
|
|
|
*Register = *Geo::OGRc::Driver_Register; |
157
|
|
|
|
|
|
|
*Deregister = *Geo::OGRc::Driver_Deregister; |
158
|
|
|
|
|
|
|
sub DISOWN { |
159
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
160
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
161
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub ACQUIRE { |
165
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
166
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
167
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
############# Class : Geo::OGR::DataSource ############## |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
package Geo::OGR::DataSource; |
174
|
6
|
|
|
6
|
|
30
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3084
|
|
175
|
|
|
|
|
|
|
@ISA = qw( Geo::GDAL::MajorObject Geo::OGR ); |
176
|
|
|
|
|
|
|
%OWNER = (); |
177
|
|
|
|
|
|
|
%ITERATORS = (); |
178
|
|
|
|
|
|
|
*swig_name_get = *Geo::OGRc::DataSource_name_get; |
179
|
|
|
|
|
|
|
*swig_name_set = *Geo::OGRc::DataSource_name_set; |
180
|
|
|
|
|
|
|
sub DESTROY { |
181
|
2
|
|
|
2
|
|
13
|
my $self; |
182
|
2
|
100
|
|
|
|
26
|
if ($_[0]->isa('SCALAR')) { |
183
|
1
|
|
|
|
|
2
|
$self = $_[0]; |
184
|
|
|
|
|
|
|
} else { |
185
|
1
|
50
|
|
|
|
5
|
return unless $_[0]->isa('HASH'); |
186
|
1
|
|
|
|
|
3
|
$self = tied(%{$_[0]}); |
|
1
|
|
|
|
|
9
|
|
187
|
1
|
50
|
|
|
|
5
|
return unless defined $self; |
188
|
|
|
|
|
|
|
} |
189
|
2
|
|
|
|
|
4
|
delete $ITERATORS{$self}; |
190
|
2
|
100
|
|
|
|
9
|
if (exists $OWNER{$self}) { |
191
|
1
|
|
|
|
|
84
|
Geo::OGRc::delete_DataSource($self); |
192
|
1
|
|
|
|
|
3
|
delete $OWNER{$self}; |
193
|
|
|
|
|
|
|
} |
194
|
2
|
|
|
|
|
17
|
$self->RELEASE_PARENTS(); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
*GetRefCount = *Geo::OGRc::DataSource_GetRefCount; |
198
|
|
|
|
|
|
|
*GetSummaryRefCount = *Geo::OGRc::DataSource_GetSummaryRefCount; |
199
|
|
|
|
|
|
|
*GetLayerCount = *Geo::OGRc::DataSource_GetLayerCount; |
200
|
|
|
|
|
|
|
*_GetDriver = *Geo::OGRc::DataSource__GetDriver; |
201
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::DataSource_GetName; |
202
|
|
|
|
|
|
|
*_DeleteLayer = *Geo::OGRc::DataSource__DeleteLayer; |
203
|
|
|
|
|
|
|
*SyncToDisk = *Geo::OGRc::DataSource_SyncToDisk; |
204
|
|
|
|
|
|
|
*FlushCache = *Geo::OGRc::DataSource_FlushCache; |
205
|
|
|
|
|
|
|
*_CreateLayer = *Geo::OGRc::DataSource__CreateLayer; |
206
|
|
|
|
|
|
|
*CopyLayer = *Geo::OGRc::DataSource_CopyLayer; |
207
|
|
|
|
|
|
|
*GetLayerByIndex = *Geo::OGRc::DataSource_GetLayerByIndex; |
208
|
|
|
|
|
|
|
*GetLayerByName = *Geo::OGRc::DataSource_GetLayerByName; |
209
|
|
|
|
|
|
|
*_TestCapability = *Geo::OGRc::DataSource__TestCapability; |
210
|
|
|
|
|
|
|
*_ExecuteSQL = *Geo::OGRc::DataSource__ExecuteSQL; |
211
|
|
|
|
|
|
|
*_ReleaseResultSet = *Geo::OGRc::DataSource__ReleaseResultSet; |
212
|
|
|
|
|
|
|
*GetStyleTable = *Geo::OGRc::DataSource_GetStyleTable; |
213
|
|
|
|
|
|
|
*SetStyleTable = *Geo::OGRc::DataSource_SetStyleTable; |
214
|
|
|
|
|
|
|
*StartTransaction = *Geo::OGRc::DataSource_StartTransaction; |
215
|
|
|
|
|
|
|
*CommitTransaction = *Geo::OGRc::DataSource_CommitTransaction; |
216
|
|
|
|
|
|
|
*RollbackTransaction = *Geo::OGRc::DataSource_RollbackTransaction; |
217
|
|
|
|
|
|
|
sub DISOWN { |
218
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
219
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
220
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub ACQUIRE { |
224
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
225
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
226
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
############# Class : Geo::OGR::Layer ############## |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
package Geo::OGR::Layer; |
233
|
6
|
|
|
6
|
|
35
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
3589
|
|
234
|
|
|
|
|
|
|
@ISA = qw( Geo::GDAL::MajorObject Geo::OGR ); |
235
|
|
|
|
|
|
|
%OWNER = (); |
236
|
|
|
|
|
|
|
*GetRefCount = *Geo::OGRc::Layer_GetRefCount; |
237
|
|
|
|
|
|
|
*SetSpatialFilter = *Geo::OGRc::Layer_SetSpatialFilter; |
238
|
|
|
|
|
|
|
*SetSpatialFilterRect = *Geo::OGRc::Layer_SetSpatialFilterRect; |
239
|
|
|
|
|
|
|
*GetSpatialFilter = *Geo::OGRc::Layer_GetSpatialFilter; |
240
|
|
|
|
|
|
|
*SetAttributeFilter = *Geo::OGRc::Layer_SetAttributeFilter; |
241
|
|
|
|
|
|
|
*ResetReading = *Geo::OGRc::Layer_ResetReading; |
242
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::Layer_GetName; |
243
|
|
|
|
|
|
|
*GetGeomType = *Geo::OGRc::Layer_GetGeomType; |
244
|
|
|
|
|
|
|
*GetGeometryColumn = *Geo::OGRc::Layer_GetGeometryColumn; |
245
|
|
|
|
|
|
|
*GetFIDColumn = *Geo::OGRc::Layer_GetFIDColumn; |
246
|
|
|
|
|
|
|
*GetFeature = *Geo::OGRc::Layer_GetFeature; |
247
|
|
|
|
|
|
|
*GetNextFeature = *Geo::OGRc::Layer_GetNextFeature; |
248
|
|
|
|
|
|
|
*SetNextByIndex = *Geo::OGRc::Layer_SetNextByIndex; |
249
|
|
|
|
|
|
|
*SetFeature = *Geo::OGRc::Layer_SetFeature; |
250
|
|
|
|
|
|
|
*CreateFeature = *Geo::OGRc::Layer_CreateFeature; |
251
|
|
|
|
|
|
|
*DeleteFeature = *Geo::OGRc::Layer_DeleteFeature; |
252
|
|
|
|
|
|
|
*SyncToDisk = *Geo::OGRc::Layer_SyncToDisk; |
253
|
|
|
|
|
|
|
*GetLayerDefn = *Geo::OGRc::Layer_GetLayerDefn; |
254
|
|
|
|
|
|
|
*GetFeatureCount = *Geo::OGRc::Layer_GetFeatureCount; |
255
|
|
|
|
|
|
|
*GetExtent = *Geo::OGRc::Layer_GetExtent; |
256
|
|
|
|
|
|
|
*_TestCapability = *Geo::OGRc::Layer__TestCapability; |
257
|
|
|
|
|
|
|
*_CreateField = *Geo::OGRc::Layer__CreateField; |
258
|
|
|
|
|
|
|
*_DeleteField = *Geo::OGRc::Layer__DeleteField; |
259
|
|
|
|
|
|
|
*ReorderField = *Geo::OGRc::Layer_ReorderField; |
260
|
|
|
|
|
|
|
*ReorderFields = *Geo::OGRc::Layer_ReorderFields; |
261
|
|
|
|
|
|
|
*_AlterFieldDefn = *Geo::OGRc::Layer__AlterFieldDefn; |
262
|
|
|
|
|
|
|
*CreateGeomField = *Geo::OGRc::Layer_CreateGeomField; |
263
|
|
|
|
|
|
|
*StartTransaction = *Geo::OGRc::Layer_StartTransaction; |
264
|
|
|
|
|
|
|
*CommitTransaction = *Geo::OGRc::Layer_CommitTransaction; |
265
|
|
|
|
|
|
|
*RollbackTransaction = *Geo::OGRc::Layer_RollbackTransaction; |
266
|
|
|
|
|
|
|
*FindFieldIndex = *Geo::OGRc::Layer_FindFieldIndex; |
267
|
|
|
|
|
|
|
*GetSpatialRef = *Geo::OGRc::Layer_GetSpatialRef; |
268
|
|
|
|
|
|
|
*GetFeaturesRead = *Geo::OGRc::Layer_GetFeaturesRead; |
269
|
|
|
|
|
|
|
*SetIgnoredFields = *Geo::OGRc::Layer_SetIgnoredFields; |
270
|
|
|
|
|
|
|
*Intersection = *Geo::OGRc::Layer_Intersection; |
271
|
|
|
|
|
|
|
*Union = *Geo::OGRc::Layer_Union; |
272
|
|
|
|
|
|
|
*SymDifference = *Geo::OGRc::Layer_SymDifference; |
273
|
|
|
|
|
|
|
*Identity = *Geo::OGRc::Layer_Identity; |
274
|
|
|
|
|
|
|
*Update = *Geo::OGRc::Layer_Update; |
275
|
|
|
|
|
|
|
*Clip = *Geo::OGRc::Layer_Clip; |
276
|
|
|
|
|
|
|
*Erase = *Geo::OGRc::Layer_Erase; |
277
|
|
|
|
|
|
|
*GetStyleTable = *Geo::OGRc::Layer_GetStyleTable; |
278
|
|
|
|
|
|
|
*SetStyleTable = *Geo::OGRc::Layer_SetStyleTable; |
279
|
|
|
|
|
|
|
sub DISOWN { |
280
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
281
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
282
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub ACQUIRE { |
286
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
287
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
288
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
############# Class : Geo::OGR::Feature ############## |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
package Geo::OGR::Feature; |
295
|
6
|
|
|
6
|
|
45
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1209
|
|
296
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
297
|
|
|
|
|
|
|
%OWNER = (); |
298
|
|
|
|
|
|
|
sub DESTROY { |
299
|
18
|
|
|
18
|
|
3518
|
my $self; |
300
|
18
|
100
|
|
|
|
97
|
if ($_[0]->isa('SCALAR')) { |
301
|
9
|
|
|
|
|
17
|
$self = $_[0]; |
302
|
|
|
|
|
|
|
} else { |
303
|
9
|
50
|
|
|
|
39
|
return unless $_[0]->isa('HASH'); |
304
|
9
|
|
|
|
|
13
|
$self = tied(%{$_[0]}); |
|
9
|
|
|
|
|
21
|
|
305
|
9
|
50
|
|
|
|
30
|
return unless defined $self; |
306
|
|
|
|
|
|
|
} |
307
|
18
|
|
|
|
|
33
|
delete $ITERATORS{$self}; |
308
|
18
|
100
|
|
|
|
54
|
if (exists $OWNER{$self}) { |
309
|
9
|
|
|
|
|
94
|
Geo::OGRc::delete_Feature($self); |
310
|
9
|
|
|
|
|
23
|
delete $OWNER{$self}; |
311
|
|
|
|
|
|
|
} |
312
|
18
|
|
|
|
|
67
|
$self->RELEASE_PARENTS(); |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
6
|
|
|
6
|
|
209
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
4284
|
|
316
|
|
|
|
|
|
|
sub new { |
317
|
18
|
|
|
18
|
|
85
|
my $pkg = shift; |
318
|
18
|
|
|
|
|
66
|
my $arg = blessed($_[0]); |
319
|
18
|
|
|
|
|
27
|
my $defn; |
320
|
18
|
50
|
33
|
|
|
108
|
if ($arg && $arg eq 'Geo::OGR::FeatureDefn') { |
321
|
18
|
|
|
|
|
32
|
$defn = $_[0]; |
322
|
|
|
|
|
|
|
} else { |
323
|
0
|
|
|
|
|
0
|
$defn = Geo::OGR::FeatureDefn->new(@_); |
324
|
|
|
|
|
|
|
} |
325
|
18
|
|
|
|
|
205
|
my $self = Geo::OGRc::new_Feature($defn); |
326
|
18
|
50
|
|
|
|
123
|
bless $self, $pkg if defined($self); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
*GetDefnRef = *Geo::OGRc::Feature_GetDefnRef; |
330
|
|
|
|
|
|
|
*_SetGeometry = *Geo::OGRc::Feature__SetGeometry; |
331
|
|
|
|
|
|
|
*SetGeometryDirectly = *Geo::OGRc::Feature_SetGeometryDirectly; |
332
|
|
|
|
|
|
|
*GetGeometryRef = *Geo::OGRc::Feature_GetGeometryRef; |
333
|
|
|
|
|
|
|
*SetGeomField = *Geo::OGRc::Feature_SetGeomField; |
334
|
|
|
|
|
|
|
*SetGeomFieldDirectly = *Geo::OGRc::Feature_SetGeomFieldDirectly; |
335
|
|
|
|
|
|
|
*GetGeomFieldRef = *Geo::OGRc::Feature_GetGeomFieldRef; |
336
|
|
|
|
|
|
|
*Clone = *Geo::OGRc::Feature_Clone; |
337
|
|
|
|
|
|
|
*Equal = *Geo::OGRc::Feature_Equal; |
338
|
|
|
|
|
|
|
*GetFieldCount = *Geo::OGRc::Feature_GetFieldCount; |
339
|
|
|
|
|
|
|
*GetFieldDefnRef = *Geo::OGRc::Feature_GetFieldDefnRef; |
340
|
|
|
|
|
|
|
*GetGeomFieldCount = *Geo::OGRc::Feature_GetGeomFieldCount; |
341
|
|
|
|
|
|
|
*GetGeomFieldDefnRef = *Geo::OGRc::Feature_GetGeomFieldDefnRef; |
342
|
|
|
|
|
|
|
*GetFieldAsString = *Geo::OGRc::Feature_GetFieldAsString; |
343
|
|
|
|
|
|
|
*GetFieldAsInteger = *Geo::OGRc::Feature_GetFieldAsInteger; |
344
|
|
|
|
|
|
|
*GetFieldAsInteger64 = *Geo::OGRc::Feature_GetFieldAsInteger64; |
345
|
|
|
|
|
|
|
*GetFieldAsDouble = *Geo::OGRc::Feature_GetFieldAsDouble; |
346
|
|
|
|
|
|
|
*GetFieldAsDateTime = *Geo::OGRc::Feature_GetFieldAsDateTime; |
347
|
|
|
|
|
|
|
*GetFieldAsIntegerList = *Geo::OGRc::Feature_GetFieldAsIntegerList; |
348
|
|
|
|
|
|
|
*GetFieldAsDoubleList = *Geo::OGRc::Feature_GetFieldAsDoubleList; |
349
|
|
|
|
|
|
|
*GetFieldAsStringList = *Geo::OGRc::Feature_GetFieldAsStringList; |
350
|
|
|
|
|
|
|
*GetFieldAsBinary = *Geo::OGRc::Feature_GetFieldAsBinary; |
351
|
|
|
|
|
|
|
*IsFieldSet = *Geo::OGRc::Feature_IsFieldSet; |
352
|
|
|
|
|
|
|
*GetFieldIndex = *Geo::OGRc::Feature_GetFieldIndex; |
353
|
|
|
|
|
|
|
*GetGeomFieldIndex = *Geo::OGRc::Feature_GetGeomFieldIndex; |
354
|
|
|
|
|
|
|
*GetFID = *Geo::OGRc::Feature_GetFID; |
355
|
|
|
|
|
|
|
*SetFID = *Geo::OGRc::Feature_SetFID; |
356
|
|
|
|
|
|
|
*DumpReadable = *Geo::OGRc::Feature_DumpReadable; |
357
|
|
|
|
|
|
|
*_UnsetField = *Geo::OGRc::Feature__UnsetField; |
358
|
|
|
|
|
|
|
*SetFieldInteger64 = *Geo::OGRc::Feature_SetFieldInteger64; |
359
|
|
|
|
|
|
|
*_SetField = *Geo::OGRc::Feature__SetField; |
360
|
|
|
|
|
|
|
*SetFieldIntegerList = *Geo::OGRc::Feature_SetFieldIntegerList; |
361
|
|
|
|
|
|
|
*SetFieldDoubleList = *Geo::OGRc::Feature_SetFieldDoubleList; |
362
|
|
|
|
|
|
|
*SetFieldStringList = *Geo::OGRc::Feature_SetFieldStringList; |
363
|
|
|
|
|
|
|
*SetFieldBinaryFromHexString = *Geo::OGRc::Feature_SetFieldBinaryFromHexString; |
364
|
|
|
|
|
|
|
*_SetFrom = *Geo::OGRc::Feature__SetFrom; |
365
|
|
|
|
|
|
|
*SetFromWithMap = *Geo::OGRc::Feature_SetFromWithMap; |
366
|
|
|
|
|
|
|
*GetStyleString = *Geo::OGRc::Feature_GetStyleString; |
367
|
|
|
|
|
|
|
*SetStyleString = *Geo::OGRc::Feature_SetStyleString; |
368
|
|
|
|
|
|
|
*GetFieldType = *Geo::OGRc::Feature_GetFieldType; |
369
|
|
|
|
|
|
|
*_Validate = *Geo::OGRc::Feature__Validate; |
370
|
|
|
|
|
|
|
*FillUnsetWithDefault = *Geo::OGRc::Feature_FillUnsetWithDefault; |
371
|
|
|
|
|
|
|
sub DISOWN { |
372
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
373
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
374
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub ACQUIRE { |
378
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
379
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
380
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
############# Class : Geo::OGR::FeatureDefn ############## |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
package Geo::OGR::FeatureDefn; |
387
|
6
|
|
|
6
|
|
32
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
1188
|
|
388
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
389
|
|
|
|
|
|
|
%OWNER = (); |
390
|
|
|
|
|
|
|
sub DESTROY { |
391
|
104
|
|
|
104
|
|
120
|
my $self; |
392
|
104
|
100
|
|
|
|
371
|
if ($_[0]->isa('SCALAR')) { |
393
|
52
|
|
|
|
|
72
|
$self = $_[0]; |
394
|
|
|
|
|
|
|
} else { |
395
|
52
|
50
|
|
|
|
165
|
return unless $_[0]->isa('HASH'); |
396
|
52
|
|
|
|
|
57
|
$self = tied(%{$_[0]}); |
|
52
|
|
|
|
|
95
|
|
397
|
52
|
50
|
|
|
|
135
|
return unless defined $self; |
398
|
|
|
|
|
|
|
} |
399
|
104
|
|
|
|
|
187
|
delete $ITERATORS{$self}; |
400
|
104
|
100
|
|
|
|
259
|
if (exists $OWNER{$self}) { |
401
|
2
|
|
|
|
|
11
|
Geo::OGRc::delete_FeatureDefn($self); |
402
|
2
|
|
|
|
|
4
|
delete $OWNER{$self}; |
403
|
|
|
|
|
|
|
} |
404
|
104
|
|
|
|
|
218
|
$self->RELEASE_PARENTS(); |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
6
|
|
|
6
|
|
29
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
148
|
|
408
|
6
|
|
|
6
|
|
40
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
161
|
|
409
|
6
|
|
|
6
|
|
60
|
use Carp; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
330
|
|
410
|
6
|
|
|
6
|
|
30
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
4370
|
|
411
|
|
|
|
|
|
|
sub new { |
412
|
2
|
|
|
2
|
|
25
|
my $pkg = shift; |
413
|
2
|
|
|
|
|
5
|
my %schema; |
414
|
2
|
50
|
33
|
|
|
21
|
if (@_ == 1 and ref($_[0]) eq 'HASH') { |
|
|
50
|
33
|
|
|
|
|
415
|
0
|
|
|
|
|
0
|
%schema = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
416
|
|
|
|
|
|
|
} elsif (@_ and @_ % 2 == 0) { |
417
|
2
|
|
|
|
|
6
|
%schema = @_; |
418
|
|
|
|
|
|
|
} |
419
|
2
|
|
|
|
|
3
|
my $fields = $schema{Fields}; |
420
|
2
|
50
|
33
|
|
|
13
|
confess "The Fields argument is not a reference to an array." if $fields and ref($fields) ne 'ARRAY'; |
421
|
2
|
50
|
|
|
|
7
|
$schema{Name} = '' unless exists $schema{Name}; |
422
|
2
|
|
|
|
|
19
|
my $self = Geo::OGRc::new_FeatureDefn($schema{Name}); |
423
|
2
|
|
|
|
|
4
|
bless $self, $pkg; |
424
|
2
|
|
|
|
|
3
|
my $gt = $schema{GeometryType}; |
425
|
2
|
50
|
|
|
|
14
|
if ($fields) { |
426
|
2
|
|
|
|
|
10
|
$self->DeleteGeomFieldDefn(0); # either default behavior or argument specified |
427
|
|
|
|
|
|
|
} else { |
428
|
0
|
0
|
|
|
|
0
|
$self->GeometryType($schema{GeometryType}) if exists $schema{GeometryType}; |
429
|
|
|
|
|
|
|
} |
430
|
2
|
50
|
|
|
|
7
|
$self->StyleIgnored($schema{StyleIgnored}) if exists $schema{StyleIgnored}; |
431
|
2
|
|
|
|
|
3
|
for my $fd (@{$fields}) { |
|
2
|
|
|
|
|
4
|
|
432
|
7
|
|
|
|
|
10
|
my $d = $fd; |
433
|
7
|
100
|
|
|
|
18
|
if (ref($fd) eq 'HASH') { |
434
|
6
|
50
|
33
|
|
|
34
|
if ($fd->{GeometryType} or exists $Geo::OGR::Geometry::TYPE_STRING2INT{$fd->{Type}}) { |
435
|
0
|
|
|
|
|
0
|
$d = Geo::OGR::GeomFieldDefn->new(%$fd); |
436
|
|
|
|
|
|
|
} else { |
437
|
6
|
|
|
|
|
24
|
$d = Geo::OGR::FieldDefn->new(%$fd); |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
} |
440
|
7
|
50
|
33
|
|
|
53
|
if (blessed($d) and $d->isa('Geo::OGR::FieldDefn')) { |
|
|
0
|
0
|
|
|
|
|
441
|
7
|
|
|
|
|
37
|
AddFieldDefn($self, $d); |
442
|
|
|
|
|
|
|
} elsif (blessed($d) and $d->isa('Geo::OGR::GeomFieldDefn')) { |
443
|
0
|
|
|
|
|
0
|
AddGeomFieldDefn($self, $d); |
444
|
|
|
|
|
|
|
} else { |
445
|
0
|
|
|
|
|
0
|
confess "Item in field list does not define a field."; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
} |
448
|
2
|
|
|
|
|
9
|
return $self; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::FeatureDefn_GetName; |
452
|
|
|
|
|
|
|
*GetFieldCount = *Geo::OGRc::FeatureDefn_GetFieldCount; |
453
|
|
|
|
|
|
|
*GetFieldDefn = *Geo::OGRc::FeatureDefn_GetFieldDefn; |
454
|
|
|
|
|
|
|
*GetFieldIndex = *Geo::OGRc::FeatureDefn_GetFieldIndex; |
455
|
|
|
|
|
|
|
*AddFieldDefn = *Geo::OGRc::FeatureDefn_AddFieldDefn; |
456
|
|
|
|
|
|
|
*GetGeomFieldCount = *Geo::OGRc::FeatureDefn_GetGeomFieldCount; |
457
|
|
|
|
|
|
|
*GetGeomFieldDefn = *Geo::OGRc::FeatureDefn_GetGeomFieldDefn; |
458
|
|
|
|
|
|
|
*GetGeomFieldIndex = *Geo::OGRc::FeatureDefn_GetGeomFieldIndex; |
459
|
|
|
|
|
|
|
*AddGeomFieldDefn = *Geo::OGRc::FeatureDefn_AddGeomFieldDefn; |
460
|
|
|
|
|
|
|
*DeleteGeomFieldDefn = *Geo::OGRc::FeatureDefn_DeleteGeomFieldDefn; |
461
|
|
|
|
|
|
|
*GetGeomType = *Geo::OGRc::FeatureDefn_GetGeomType; |
462
|
|
|
|
|
|
|
*SetGeomType = *Geo::OGRc::FeatureDefn_SetGeomType; |
463
|
|
|
|
|
|
|
*GetReferenceCount = *Geo::OGRc::FeatureDefn_GetReferenceCount; |
464
|
|
|
|
|
|
|
*IsGeometryIgnored = *Geo::OGRc::FeatureDefn_IsGeometryIgnored; |
465
|
|
|
|
|
|
|
*SetGeometryIgnored = *Geo::OGRc::FeatureDefn_SetGeometryIgnored; |
466
|
|
|
|
|
|
|
*IsStyleIgnored = *Geo::OGRc::FeatureDefn_IsStyleIgnored; |
467
|
|
|
|
|
|
|
*SetStyleIgnored = *Geo::OGRc::FeatureDefn_SetStyleIgnored; |
468
|
|
|
|
|
|
|
*IsSame = *Geo::OGRc::FeatureDefn_IsSame; |
469
|
|
|
|
|
|
|
sub DISOWN { |
470
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
471
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
472
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
sub ACQUIRE { |
476
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
477
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
478
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
############# Class : Geo::OGR::FieldDefn ############## |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
package Geo::OGR::FieldDefn; |
485
|
6
|
|
|
6
|
|
33
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
27
|
|
|
6
|
|
|
|
|
1289
|
|
486
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
487
|
|
|
|
|
|
|
%OWNER = (); |
488
|
|
|
|
|
|
|
sub DESTROY { |
489
|
660
|
|
|
660
|
|
50765
|
my $self; |
490
|
660
|
100
|
|
|
|
2524
|
if ($_[0]->isa('SCALAR')) { |
491
|
330
|
|
|
|
|
513
|
$self = $_[0]; |
492
|
|
|
|
|
|
|
} else { |
493
|
330
|
50
|
|
|
|
1093
|
return unless $_[0]->isa('HASH'); |
494
|
330
|
|
|
|
|
361
|
$self = tied(%{$_[0]}); |
|
330
|
|
|
|
|
658
|
|
495
|
330
|
50
|
|
|
|
731
|
return unless defined $self; |
496
|
|
|
|
|
|
|
} |
497
|
660
|
|
|
|
|
1152
|
delete $ITERATORS{$self}; |
498
|
660
|
100
|
|
|
|
1694
|
if (exists $OWNER{$self}) { |
499
|
98
|
|
|
|
|
486
|
Geo::OGRc::delete_FieldDefn($self); |
500
|
98
|
|
|
|
|
212
|
delete $OWNER{$self}; |
501
|
|
|
|
|
|
|
} |
502
|
660
|
|
|
|
|
1367
|
$self->RELEASE_PARENTS(); |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
6
|
|
|
6
|
|
29
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
3890
|
|
506
|
|
|
|
|
|
|
sub new { |
507
|
98
|
|
|
98
|
|
4088
|
my $pkg = shift; |
508
|
98
|
|
|
|
|
165
|
my ($name, $type) = ('unnamed', 'String'); |
509
|
98
|
|
|
|
|
124
|
my %args; |
510
|
98
|
100
|
100
|
|
|
618
|
if (@_ == 0) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
511
|
|
|
|
|
|
|
} elsif (@_ == 1) { |
512
|
0
|
|
|
|
|
0
|
$name = shift; |
513
|
|
|
|
|
|
|
} elsif (@_ == 2 and not $Geo::OGR::FieldDefn::SCHEMA_KEYS{$_[0]}) { |
514
|
84
|
|
|
|
|
140
|
$name = shift; |
515
|
84
|
|
|
|
|
134
|
$type = shift; |
516
|
|
|
|
|
|
|
} else { |
517
|
13
|
|
|
|
|
36
|
my %named = @_; |
518
|
13
|
|
|
|
|
33
|
for my $key (keys %named) { |
519
|
25
|
50
|
|
|
|
53
|
if ($Geo::OGR::FieldDefn::SCHEMA_KEYS{$key}) { |
520
|
25
|
|
|
|
|
56
|
$args{$key} = $named{$key}; |
521
|
|
|
|
|
|
|
} else { |
522
|
0
|
|
|
|
|
0
|
carp "Unrecognized argument: '$key'."; |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
} |
525
|
13
|
50
|
|
|
|
44
|
$name = $args{Name} if exists $args{Name}; |
526
|
13
|
|
|
|
|
22
|
delete $args{Name}; |
527
|
13
|
100
|
|
|
|
40
|
$type = $args{Type} if exists $args{Type}; |
528
|
13
|
|
|
|
|
30
|
delete $args{Type}; |
529
|
|
|
|
|
|
|
} |
530
|
98
|
50
|
|
|
|
272
|
confess "Unknown field type: '$type'." unless exists $Geo::OGR::FieldDefn::TYPE_STRING2INT{$type}; |
531
|
98
|
|
|
|
|
168
|
$type = $Geo::OGR::FieldDefn::TYPE_STRING2INT{$type}; |
532
|
98
|
|
|
|
|
682
|
my $self = Geo::OGRc::new_FieldDefn($name, $type); |
533
|
98
|
50
|
|
|
|
252
|
if (defined($self)) { |
534
|
98
|
|
|
|
|
165
|
bless $self, $pkg; |
535
|
98
|
|
|
|
|
275
|
$self->Schema(%args); |
536
|
|
|
|
|
|
|
} |
537
|
98
|
|
|
|
|
285
|
return $self; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::FieldDefn_GetName; |
541
|
|
|
|
|
|
|
*GetNameRef = *Geo::OGRc::FieldDefn_GetNameRef; |
542
|
|
|
|
|
|
|
*SetName = *Geo::OGRc::FieldDefn_SetName; |
543
|
|
|
|
|
|
|
*GetType = *Geo::OGRc::FieldDefn_GetType; |
544
|
|
|
|
|
|
|
*SetType = *Geo::OGRc::FieldDefn_SetType; |
545
|
|
|
|
|
|
|
*GetSubType = *Geo::OGRc::FieldDefn_GetSubType; |
546
|
|
|
|
|
|
|
*SetSubType = *Geo::OGRc::FieldDefn_SetSubType; |
547
|
|
|
|
|
|
|
*GetJustify = *Geo::OGRc::FieldDefn_GetJustify; |
548
|
|
|
|
|
|
|
*SetJustify = *Geo::OGRc::FieldDefn_SetJustify; |
549
|
|
|
|
|
|
|
*GetWidth = *Geo::OGRc::FieldDefn_GetWidth; |
550
|
|
|
|
|
|
|
*SetWidth = *Geo::OGRc::FieldDefn_SetWidth; |
551
|
|
|
|
|
|
|
*GetPrecision = *Geo::OGRc::FieldDefn_GetPrecision; |
552
|
|
|
|
|
|
|
*SetPrecision = *Geo::OGRc::FieldDefn_SetPrecision; |
553
|
|
|
|
|
|
|
*GetTypeName = *Geo::OGRc::FieldDefn_GetTypeName; |
554
|
|
|
|
|
|
|
*GetFieldTypeName = *Geo::OGRc::FieldDefn_GetFieldTypeName; |
555
|
|
|
|
|
|
|
*IsIgnored = *Geo::OGRc::FieldDefn_IsIgnored; |
556
|
|
|
|
|
|
|
*SetIgnored = *Geo::OGRc::FieldDefn_SetIgnored; |
557
|
|
|
|
|
|
|
*IsNullable = *Geo::OGRc::FieldDefn_IsNullable; |
558
|
|
|
|
|
|
|
*SetNullable = *Geo::OGRc::FieldDefn_SetNullable; |
559
|
|
|
|
|
|
|
*GetDefault = *Geo::OGRc::FieldDefn_GetDefault; |
560
|
|
|
|
|
|
|
*SetDefault = *Geo::OGRc::FieldDefn_SetDefault; |
561
|
|
|
|
|
|
|
*IsDefaultDriverSpecific = *Geo::OGRc::FieldDefn_IsDefaultDriverSpecific; |
562
|
|
|
|
|
|
|
sub DISOWN { |
563
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
564
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
565
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
566
|
|
|
|
|
|
|
} |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub ACQUIRE { |
569
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
570
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
571
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
############# Class : Geo::OGR::GeomFieldDefn ############## |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
package Geo::OGR::GeomFieldDefn; |
578
|
6
|
|
|
6
|
|
38
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1002
|
|
579
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
580
|
|
|
|
|
|
|
%OWNER = (); |
581
|
|
|
|
|
|
|
%ITERATORS = (); |
582
|
|
|
|
|
|
|
sub DESTROY { |
583
|
50
|
100
|
|
50
|
|
260
|
return unless $_[0]->isa('HASH'); |
584
|
25
|
|
|
|
|
30
|
my $self = tied(%{$_[0]}); |
|
25
|
|
|
|
|
62
|
|
585
|
25
|
50
|
|
|
|
61
|
return unless defined $self; |
586
|
25
|
|
|
|
|
49
|
delete $ITERATORS{$self}; |
587
|
25
|
100
|
|
|
|
108
|
if (exists $OWNER{$self}) { |
588
|
2
|
|
|
|
|
14
|
Geo::OGRc::delete_GeomFieldDefn($self); |
589
|
2
|
|
|
|
|
10
|
delete $OWNER{$self}; |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
|
593
|
6
|
|
|
6
|
|
28
|
use Carp; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
3287
|
|
594
|
|
|
|
|
|
|
sub new { |
595
|
2
|
|
|
2
|
|
5
|
my $pkg = shift; |
596
|
2
|
|
|
|
|
9
|
my ($name, $type) = ('geom', 'Unknown'); |
597
|
2
|
|
|
|
|
5
|
my %args; |
598
|
2
|
50
|
66
|
|
|
24
|
if (@_ == 0) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
599
|
|
|
|
|
|
|
} elsif (@_ == 1) { |
600
|
0
|
|
|
|
|
0
|
$name = shift; |
601
|
|
|
|
|
|
|
} elsif (@_ == 2 and not $Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$_[0]}) { |
602
|
0
|
|
|
|
|
0
|
$name = shift; |
603
|
0
|
|
|
|
|
0
|
$type = shift; |
604
|
|
|
|
|
|
|
} else { |
605
|
2
|
|
|
|
|
6
|
my %named = @_; |
606
|
2
|
|
|
|
|
10
|
for my $key (keys %named) { |
607
|
3
|
50
|
|
|
|
12
|
if ($Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$key}) { |
608
|
3
|
|
|
|
|
22
|
$args{$key} = $named{$key}; |
609
|
|
|
|
|
|
|
} else { |
610
|
0
|
|
|
|
|
0
|
carp "Unrecognized argument: '$key'."; |
611
|
|
|
|
|
|
|
} |
612
|
|
|
|
|
|
|
} |
613
|
2
|
100
|
|
|
|
11
|
$name = $args{Name} if exists $args{Name}; |
614
|
2
|
|
|
|
|
5
|
delete $args{Name}; |
615
|
2
|
50
|
|
|
|
9
|
$type = $args{Type} if $args{Type}; |
616
|
2
|
|
|
|
|
4
|
delete $args{Type}; |
617
|
2
|
50
|
|
|
|
7
|
$type = $args{GeometryType} if $args{GeometryType}; |
618
|
2
|
|
|
|
|
6
|
delete $args{GeometryType}; |
619
|
|
|
|
|
|
|
} |
620
|
2
|
50
|
|
|
|
9
|
confess "Unknown geometry type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
621
|
2
|
|
|
|
|
6
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
622
|
2
|
|
|
|
|
20
|
my $self = Geo::OGRc::new_GeomFieldDefn($name, $type); |
623
|
2
|
50
|
|
|
|
15
|
if (defined($self)) { |
624
|
2
|
|
|
|
|
5
|
bless $self, $pkg; |
625
|
2
|
|
|
|
|
10
|
$self->Schema(%args); |
626
|
|
|
|
|
|
|
} |
627
|
2
|
|
|
|
|
7
|
return $self; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
*GetName = *Geo::OGRc::GeomFieldDefn_GetName; |
631
|
|
|
|
|
|
|
*GetNameRef = *Geo::OGRc::GeomFieldDefn_GetNameRef; |
632
|
|
|
|
|
|
|
*SetName = *Geo::OGRc::GeomFieldDefn_SetName; |
633
|
|
|
|
|
|
|
*GetType = *Geo::OGRc::GeomFieldDefn_GetType; |
634
|
|
|
|
|
|
|
*SetType = *Geo::OGRc::GeomFieldDefn_SetType; |
635
|
|
|
|
|
|
|
*GetSpatialRef = *Geo::OGRc::GeomFieldDefn_GetSpatialRef; |
636
|
|
|
|
|
|
|
*SetSpatialRef = *Geo::OGRc::GeomFieldDefn_SetSpatialRef; |
637
|
|
|
|
|
|
|
*IsIgnored = *Geo::OGRc::GeomFieldDefn_IsIgnored; |
638
|
|
|
|
|
|
|
*SetIgnored = *Geo::OGRc::GeomFieldDefn_SetIgnored; |
639
|
|
|
|
|
|
|
*IsNullable = *Geo::OGRc::GeomFieldDefn_IsNullable; |
640
|
|
|
|
|
|
|
*SetNullable = *Geo::OGRc::GeomFieldDefn_SetNullable; |
641
|
|
|
|
|
|
|
sub DISOWN { |
642
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
643
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
644
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
645
|
|
|
|
|
|
|
} |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
sub ACQUIRE { |
648
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
649
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
650
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
############# Class : Geo::OGR::Geometry ############## |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
package Geo::OGR::Geometry; |
657
|
6
|
|
|
6
|
|
35
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
1166
|
|
658
|
|
|
|
|
|
|
@ISA = qw( Geo::OGR ); |
659
|
|
|
|
|
|
|
%OWNER = (); |
660
|
|
|
|
|
|
|
sub DESTROY { |
661
|
120
|
|
|
120
|
|
11729
|
my $self; |
662
|
120
|
100
|
|
|
|
434
|
if ($_[0]->isa('SCALAR')) { |
663
|
60
|
|
|
|
|
87
|
$self = $_[0]; |
664
|
|
|
|
|
|
|
} else { |
665
|
60
|
50
|
|
|
|
243
|
return unless $_[0]->isa('HASH'); |
666
|
60
|
|
|
|
|
63
|
$self = tied(%{$_[0]}); |
|
60
|
|
|
|
|
121
|
|
667
|
60
|
50
|
|
|
|
126
|
return unless defined $self; |
668
|
|
|
|
|
|
|
} |
669
|
120
|
|
|
|
|
197
|
delete $ITERATORS{$self}; |
670
|
120
|
100
|
|
|
|
300
|
if (exists $OWNER{$self}) { |
671
|
27
|
|
|
|
|
155
|
Geo::OGRc::delete_Geometry($self); |
672
|
27
|
|
|
|
|
57
|
delete $OWNER{$self}; |
673
|
|
|
|
|
|
|
} |
674
|
120
|
|
|
|
|
238
|
$self->RELEASE_PARENTS(); |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
6
|
|
|
6
|
|
30
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
13431
|
|
678
|
|
|
|
|
|
|
sub new { |
679
|
40
|
|
|
40
|
|
2053
|
my $pkg = shift; |
680
|
40
|
|
|
|
|
48
|
my ($type, $wkt, $wkb, $gml, $json, $srs, $points, $arc); |
681
|
0
|
|
|
|
|
0
|
my %param; |
682
|
40
|
100
|
100
|
|
|
237
|
if (@_ == 1 and ref($_[0]) eq 'HASH') { |
|
|
100
|
|
|
|
|
|
683
|
4
|
|
|
|
|
5
|
%param = %{$_[0]}; |
|
4
|
|
|
|
|
18
|
|
684
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0) { |
685
|
16
|
|
|
|
|
51
|
%param = @_; |
686
|
|
|
|
|
|
|
} else { |
687
|
20
|
|
|
|
|
60
|
($param{GeometryType}) = @_; |
688
|
|
|
|
|
|
|
} |
689
|
40
|
|
33
|
|
|
186
|
$type = ($param{type} or $param{Type} or $param{GeometryType}); |
690
|
40
|
|
33
|
|
|
108
|
$srs = ($param{srs} or $param{SRS}); |
691
|
40
|
|
66
|
|
|
108
|
$wkt = ($param{wkt} or $param{WKT}); |
692
|
40
|
|
33
|
|
|
105
|
$wkb = ($param{wkb} or $param{WKB}); |
693
|
40
|
|
33
|
|
|
105
|
my $hex = ($param{hexewkb} or $param{HEXEWKB}); # PostGIS HEX EWKB |
694
|
40
|
|
|
|
|
52
|
my $srid; |
695
|
40
|
50
|
|
|
|
68
|
if ($hex) { |
696
|
|
|
|
|
|
|
# get and remove SRID |
697
|
0
|
|
|
|
|
0
|
$srid = substr($hex, 10, 8); |
698
|
0
|
|
|
|
|
0
|
substr($hex, 10, 8) = ''; |
699
|
|
|
|
|
|
|
} else { |
700
|
40
|
|
66
|
|
|
116
|
$hex = ($param{hexwkb} or $param{HEXWKB}); |
701
|
|
|
|
|
|
|
} |
702
|
40
|
100
|
|
|
|
81
|
if ($hex) { |
703
|
1
|
|
|
|
|
4
|
$wkb = ''; |
704
|
1
|
|
|
|
|
10
|
for (my $i = 0; $i < length($hex); $i+=2) { |
705
|
89
|
|
|
|
|
196
|
$wkb .= chr(hex(substr($hex,$i,2))); |
706
|
|
|
|
|
|
|
} |
707
|
|
|
|
|
|
|
} |
708
|
40
|
|
66
|
|
|
98
|
$gml = ($param{gml} or $param{GML}); |
709
|
40
|
|
33
|
|
|
103
|
$json = ($param{geojson} or $param{GeoJSON}); |
710
|
40
|
|
|
|
|
49
|
$points = $param{Points}; |
711
|
40
|
|
33
|
|
|
103
|
$arc = ($param{arc} or $param{Arc}); |
712
|
40
|
|
|
|
|
46
|
my $self; |
713
|
40
|
100
|
|
|
|
145
|
if (defined $wkt) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
714
|
13
|
|
|
|
|
235
|
$self = Geo::OGRc::CreateGeometryFromWkt($wkt, $srs); |
715
|
|
|
|
|
|
|
} elsif (defined $wkb) { |
716
|
1
|
|
|
|
|
14
|
$self = Geo::OGRc::CreateGeometryFromWkb($wkb, $srs); |
717
|
|
|
|
|
|
|
} elsif (defined $gml) { |
718
|
1
|
|
|
|
|
47
|
$self = Geo::OGRc::CreateGeometryFromGML($gml); |
719
|
|
|
|
|
|
|
} elsif (defined $json) { |
720
|
1
|
|
|
|
|
47
|
$self = Geo::OGRc::CreateGeometryFromJson($json); |
721
|
|
|
|
|
|
|
} elsif (defined $type) { |
722
|
24
|
50
|
|
|
|
58
|
confess "Unknown geometry type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
723
|
24
|
|
|
|
|
45
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
724
|
24
|
|
|
|
|
217
|
$self = Geo::OGRc::new_Geometry($type); # flattens the type |
725
|
24
|
50
|
|
|
|
97
|
SetCoordinateDimension($self, 3) if Geo::OGR::GT_HasZ($type); |
726
|
|
|
|
|
|
|
} elsif (defined $arc) { |
727
|
0
|
|
|
|
|
0
|
$self = Geo::OGRc::ApproximateArcAngles(@$arc); |
728
|
|
|
|
|
|
|
} else { |
729
|
0
|
|
|
|
|
0
|
confess "Missing a parameter when creating a Geo::OGR::Geometry object."; |
730
|
|
|
|
|
|
|
} |
731
|
39
|
50
|
|
|
|
110
|
bless $self, $pkg if defined $self; |
732
|
39
|
100
|
|
|
|
79
|
$self->Points($points) if $points; |
733
|
39
|
|
|
|
|
123
|
return $self; |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
*ExportToWkt = *Geo::OGRc::Geometry_ExportToWkt; |
737
|
|
|
|
|
|
|
*ExportToIsoWkt = *Geo::OGRc::Geometry_ExportToIsoWkt; |
738
|
|
|
|
|
|
|
*_ExportToWkb = *Geo::OGRc::Geometry__ExportToWkb; |
739
|
|
|
|
|
|
|
*ExportToIsoWkb = *Geo::OGRc::Geometry_ExportToIsoWkb; |
740
|
|
|
|
|
|
|
*ExportToGML = *Geo::OGRc::Geometry_ExportToGML; |
741
|
|
|
|
|
|
|
*ExportToKML = *Geo::OGRc::Geometry_ExportToKML; |
742
|
|
|
|
|
|
|
*ExportToJson = *Geo::OGRc::Geometry_ExportToJson; |
743
|
|
|
|
|
|
|
*AddPoint_3D = *Geo::OGRc::Geometry_AddPoint_3D; |
744
|
|
|
|
|
|
|
*AddPoint_2D = *Geo::OGRc::Geometry_AddPoint_2D; |
745
|
|
|
|
|
|
|
*AddGeometryDirectly = *Geo::OGRc::Geometry_AddGeometryDirectly; |
746
|
|
|
|
|
|
|
*AddGeometry = *Geo::OGRc::Geometry_AddGeometry; |
747
|
|
|
|
|
|
|
*Clone = *Geo::OGRc::Geometry_Clone; |
748
|
|
|
|
|
|
|
*GetGeometryType = *Geo::OGRc::Geometry_GetGeometryType; |
749
|
|
|
|
|
|
|
*GetGeometryName = *Geo::OGRc::Geometry_GetGeometryName; |
750
|
|
|
|
|
|
|
*Length = *Geo::OGRc::Geometry_Length; |
751
|
|
|
|
|
|
|
*Area = *Geo::OGRc::Geometry_Area; |
752
|
|
|
|
|
|
|
*GetArea = *Geo::OGRc::Geometry_GetArea; |
753
|
|
|
|
|
|
|
*GetPointCount = *Geo::OGRc::Geometry_GetPointCount; |
754
|
|
|
|
|
|
|
*GetX = *Geo::OGRc::Geometry_GetX; |
755
|
|
|
|
|
|
|
*GetY = *Geo::OGRc::Geometry_GetY; |
756
|
|
|
|
|
|
|
*GetZ = *Geo::OGRc::Geometry_GetZ; |
757
|
|
|
|
|
|
|
*GetPoint_3D = *Geo::OGRc::Geometry_GetPoint_3D; |
758
|
|
|
|
|
|
|
*GetPoint_2D = *Geo::OGRc::Geometry_GetPoint_2D; |
759
|
|
|
|
|
|
|
*GetGeometryCount = *Geo::OGRc::Geometry_GetGeometryCount; |
760
|
|
|
|
|
|
|
*SetPoint_3D = *Geo::OGRc::Geometry_SetPoint_3D; |
761
|
|
|
|
|
|
|
*SetPoint_2D = *Geo::OGRc::Geometry_SetPoint_2D; |
762
|
|
|
|
|
|
|
*GetGeometryRef = *Geo::OGRc::Geometry_GetGeometryRef; |
763
|
|
|
|
|
|
|
*Simplify = *Geo::OGRc::Geometry_Simplify; |
764
|
|
|
|
|
|
|
*SimplifyPreserveTopology = *Geo::OGRc::Geometry_SimplifyPreserveTopology; |
765
|
|
|
|
|
|
|
*Boundary = *Geo::OGRc::Geometry_Boundary; |
766
|
|
|
|
|
|
|
*GetBoundary = *Geo::OGRc::Geometry_GetBoundary; |
767
|
|
|
|
|
|
|
*ConvexHull = *Geo::OGRc::Geometry_ConvexHull; |
768
|
|
|
|
|
|
|
*Buffer = *Geo::OGRc::Geometry_Buffer; |
769
|
|
|
|
|
|
|
*Intersection = *Geo::OGRc::Geometry_Intersection; |
770
|
|
|
|
|
|
|
*Union = *Geo::OGRc::Geometry_Union; |
771
|
|
|
|
|
|
|
*UnionCascaded = *Geo::OGRc::Geometry_UnionCascaded; |
772
|
|
|
|
|
|
|
*Difference = *Geo::OGRc::Geometry_Difference; |
773
|
|
|
|
|
|
|
*SymDifference = *Geo::OGRc::Geometry_SymDifference; |
774
|
|
|
|
|
|
|
*SymmetricDifference = *Geo::OGRc::Geometry_SymmetricDifference; |
775
|
|
|
|
|
|
|
*Distance = *Geo::OGRc::Geometry_Distance; |
776
|
|
|
|
|
|
|
*Empty = *Geo::OGRc::Geometry_Empty; |
777
|
|
|
|
|
|
|
*IsEmpty = *Geo::OGRc::Geometry_IsEmpty; |
778
|
|
|
|
|
|
|
*IsValid = *Geo::OGRc::Geometry_IsValid; |
779
|
|
|
|
|
|
|
*IsSimple = *Geo::OGRc::Geometry_IsSimple; |
780
|
|
|
|
|
|
|
*IsRing = *Geo::OGRc::Geometry_IsRing; |
781
|
|
|
|
|
|
|
*Intersects = *Geo::OGRc::Geometry_Intersects; |
782
|
|
|
|
|
|
|
*Intersect = *Geo::OGRc::Geometry_Intersect; |
783
|
|
|
|
|
|
|
*Equals = *Geo::OGRc::Geometry_Equals; |
784
|
|
|
|
|
|
|
*Equal = *Geo::OGRc::Geometry_Equal; |
785
|
|
|
|
|
|
|
*Disjoint = *Geo::OGRc::Geometry_Disjoint; |
786
|
|
|
|
|
|
|
*Touches = *Geo::OGRc::Geometry_Touches; |
787
|
|
|
|
|
|
|
*Crosses = *Geo::OGRc::Geometry_Crosses; |
788
|
|
|
|
|
|
|
*Within = *Geo::OGRc::Geometry_Within; |
789
|
|
|
|
|
|
|
*Contains = *Geo::OGRc::Geometry_Contains; |
790
|
|
|
|
|
|
|
*Overlaps = *Geo::OGRc::Geometry_Overlaps; |
791
|
|
|
|
|
|
|
*TransformTo = *Geo::OGRc::Geometry_TransformTo; |
792
|
|
|
|
|
|
|
*Transform = *Geo::OGRc::Geometry_Transform; |
793
|
|
|
|
|
|
|
*GetSpatialReference = *Geo::OGRc::Geometry_GetSpatialReference; |
794
|
|
|
|
|
|
|
*AssignSpatialReference = *Geo::OGRc::Geometry_AssignSpatialReference; |
795
|
|
|
|
|
|
|
*CloseRings = *Geo::OGRc::Geometry_CloseRings; |
796
|
|
|
|
|
|
|
*FlattenTo2D = *Geo::OGRc::Geometry_FlattenTo2D; |
797
|
|
|
|
|
|
|
*Segmentize = *Geo::OGRc::Geometry_Segmentize; |
798
|
|
|
|
|
|
|
*GetEnvelope = *Geo::OGRc::Geometry_GetEnvelope; |
799
|
|
|
|
|
|
|
*GetEnvelope3D = *Geo::OGRc::Geometry_GetEnvelope3D; |
800
|
|
|
|
|
|
|
*Centroid = *Geo::OGRc::Geometry_Centroid; |
801
|
|
|
|
|
|
|
*PointOnSurface = *Geo::OGRc::Geometry_PointOnSurface; |
802
|
|
|
|
|
|
|
*WkbSize = *Geo::OGRc::Geometry_WkbSize; |
803
|
|
|
|
|
|
|
*GetCoordinateDimension = *Geo::OGRc::Geometry_GetCoordinateDimension; |
804
|
|
|
|
|
|
|
*SetCoordinateDimension = *Geo::OGRc::Geometry_SetCoordinateDimension; |
805
|
|
|
|
|
|
|
*GetDimension = *Geo::OGRc::Geometry_GetDimension; |
806
|
|
|
|
|
|
|
*HasCurveGeometry = *Geo::OGRc::Geometry_HasCurveGeometry; |
807
|
|
|
|
|
|
|
*GetLinearGeometry = *Geo::OGRc::Geometry_GetLinearGeometry; |
808
|
|
|
|
|
|
|
*GetCurveGeometry = *Geo::OGRc::Geometry_GetCurveGeometry; |
809
|
|
|
|
|
|
|
*Value = *Geo::OGRc::Geometry_Value; |
810
|
|
|
|
|
|
|
*Move = *Geo::OGRc::Geometry_Move; |
811
|
|
|
|
|
|
|
sub DISOWN { |
812
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
813
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
814
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
815
|
|
|
|
|
|
|
} |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
sub ACQUIRE { |
818
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
819
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
820
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
821
|
|
|
|
|
|
|
} |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
# ------- VARIABLE STUBS -------- |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
package Geo::OGR; |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
*wkb25DBit = *Geo::OGRc::wkb25DBit; |
829
|
|
|
|
|
|
|
*wkb25Bit = *Geo::OGRc::wkb25Bit; |
830
|
|
|
|
|
|
|
*wkbUnknown = *Geo::OGRc::wkbUnknown; |
831
|
|
|
|
|
|
|
*wkbPoint = *Geo::OGRc::wkbPoint; |
832
|
|
|
|
|
|
|
*wkbLineString = *Geo::OGRc::wkbLineString; |
833
|
|
|
|
|
|
|
*wkbPolygon = *Geo::OGRc::wkbPolygon; |
834
|
|
|
|
|
|
|
*wkbMultiPoint = *Geo::OGRc::wkbMultiPoint; |
835
|
|
|
|
|
|
|
*wkbMultiLineString = *Geo::OGRc::wkbMultiLineString; |
836
|
|
|
|
|
|
|
*wkbMultiPolygon = *Geo::OGRc::wkbMultiPolygon; |
837
|
|
|
|
|
|
|
*wkbGeometryCollection = *Geo::OGRc::wkbGeometryCollection; |
838
|
|
|
|
|
|
|
*wkbCircularString = *Geo::OGRc::wkbCircularString; |
839
|
|
|
|
|
|
|
*wkbCompoundCurve = *Geo::OGRc::wkbCompoundCurve; |
840
|
|
|
|
|
|
|
*wkbCurvePolygon = *Geo::OGRc::wkbCurvePolygon; |
841
|
|
|
|
|
|
|
*wkbMultiCurve = *Geo::OGRc::wkbMultiCurve; |
842
|
|
|
|
|
|
|
*wkbMultiSurface = *Geo::OGRc::wkbMultiSurface; |
843
|
|
|
|
|
|
|
*wkbNone = *Geo::OGRc::wkbNone; |
844
|
|
|
|
|
|
|
*wkbLinearRing = *Geo::OGRc::wkbLinearRing; |
845
|
|
|
|
|
|
|
*wkbCircularStringZ = *Geo::OGRc::wkbCircularStringZ; |
846
|
|
|
|
|
|
|
*wkbCompoundCurveZ = *Geo::OGRc::wkbCompoundCurveZ; |
847
|
|
|
|
|
|
|
*wkbCurvePolygonZ = *Geo::OGRc::wkbCurvePolygonZ; |
848
|
|
|
|
|
|
|
*wkbMultiCurveZ = *Geo::OGRc::wkbMultiCurveZ; |
849
|
|
|
|
|
|
|
*wkbMultiSurfaceZ = *Geo::OGRc::wkbMultiSurfaceZ; |
850
|
|
|
|
|
|
|
*wkbPoint25D = *Geo::OGRc::wkbPoint25D; |
851
|
|
|
|
|
|
|
*wkbLineString25D = *Geo::OGRc::wkbLineString25D; |
852
|
|
|
|
|
|
|
*wkbPolygon25D = *Geo::OGRc::wkbPolygon25D; |
853
|
|
|
|
|
|
|
*wkbMultiPoint25D = *Geo::OGRc::wkbMultiPoint25D; |
854
|
|
|
|
|
|
|
*wkbMultiLineString25D = *Geo::OGRc::wkbMultiLineString25D; |
855
|
|
|
|
|
|
|
*wkbMultiPolygon25D = *Geo::OGRc::wkbMultiPolygon25D; |
856
|
|
|
|
|
|
|
*wkbGeometryCollection25D = *Geo::OGRc::wkbGeometryCollection25D; |
857
|
|
|
|
|
|
|
*OFTInteger = *Geo::OGRc::OFTInteger; |
858
|
|
|
|
|
|
|
*OFTIntegerList = *Geo::OGRc::OFTIntegerList; |
859
|
|
|
|
|
|
|
*OFTReal = *Geo::OGRc::OFTReal; |
860
|
|
|
|
|
|
|
*OFTRealList = *Geo::OGRc::OFTRealList; |
861
|
|
|
|
|
|
|
*OFTString = *Geo::OGRc::OFTString; |
862
|
|
|
|
|
|
|
*OFTStringList = *Geo::OGRc::OFTStringList; |
863
|
|
|
|
|
|
|
*OFTWideString = *Geo::OGRc::OFTWideString; |
864
|
|
|
|
|
|
|
*OFTWideStringList = *Geo::OGRc::OFTWideStringList; |
865
|
|
|
|
|
|
|
*OFTBinary = *Geo::OGRc::OFTBinary; |
866
|
|
|
|
|
|
|
*OFTDate = *Geo::OGRc::OFTDate; |
867
|
|
|
|
|
|
|
*OFTTime = *Geo::OGRc::OFTTime; |
868
|
|
|
|
|
|
|
*OFTDateTime = *Geo::OGRc::OFTDateTime; |
869
|
|
|
|
|
|
|
*OFTInteger64 = *Geo::OGRc::OFTInteger64; |
870
|
|
|
|
|
|
|
*OFTInteger64List = *Geo::OGRc::OFTInteger64List; |
871
|
|
|
|
|
|
|
*OFSTNone = *Geo::OGRc::OFSTNone; |
872
|
|
|
|
|
|
|
*OFSTBoolean = *Geo::OGRc::OFSTBoolean; |
873
|
|
|
|
|
|
|
*OFSTInt16 = *Geo::OGRc::OFSTInt16; |
874
|
|
|
|
|
|
|
*OFSTFloat32 = *Geo::OGRc::OFSTFloat32; |
875
|
|
|
|
|
|
|
*OJUndefined = *Geo::OGRc::OJUndefined; |
876
|
|
|
|
|
|
|
*OJLeft = *Geo::OGRc::OJLeft; |
877
|
|
|
|
|
|
|
*OJRight = *Geo::OGRc::OJRight; |
878
|
|
|
|
|
|
|
*wkbXDR = *Geo::OGRc::wkbXDR; |
879
|
|
|
|
|
|
|
*wkbNDR = *Geo::OGRc::wkbNDR; |
880
|
|
|
|
|
|
|
*NullFID = *Geo::OGRc::NullFID; |
881
|
|
|
|
|
|
|
*ALTER_NAME_FLAG = *Geo::OGRc::ALTER_NAME_FLAG; |
882
|
|
|
|
|
|
|
*ALTER_TYPE_FLAG = *Geo::OGRc::ALTER_TYPE_FLAG; |
883
|
|
|
|
|
|
|
*ALTER_WIDTH_PRECISION_FLAG = *Geo::OGRc::ALTER_WIDTH_PRECISION_FLAG; |
884
|
|
|
|
|
|
|
*ALTER_NULLABLE_FLAG = *Geo::OGRc::ALTER_NULLABLE_FLAG; |
885
|
|
|
|
|
|
|
*ALTER_DEFAULT_FLAG = *Geo::OGRc::ALTER_DEFAULT_FLAG; |
886
|
|
|
|
|
|
|
*ALTER_ALL_FLAG = *Geo::OGRc::ALTER_ALL_FLAG; |
887
|
|
|
|
|
|
|
*F_VAL_NULL = *Geo::OGRc::F_VAL_NULL; |
888
|
|
|
|
|
|
|
*F_VAL_GEOM_TYPE = *Geo::OGRc::F_VAL_GEOM_TYPE; |
889
|
|
|
|
|
|
|
*F_VAL_WIDTH = *Geo::OGRc::F_VAL_WIDTH; |
890
|
|
|
|
|
|
|
*F_VAL_ALLOW_NULL_WHEN_DEFAULT = *Geo::OGRc::F_VAL_ALLOW_NULL_WHEN_DEFAULT; |
891
|
|
|
|
|
|
|
*F_VAL_ALL = *Geo::OGRc::F_VAL_ALL; |
892
|
|
|
|
|
|
|
*OLCRandomRead = *Geo::OGRc::OLCRandomRead; |
893
|
|
|
|
|
|
|
*OLCSequentialWrite = *Geo::OGRc::OLCSequentialWrite; |
894
|
|
|
|
|
|
|
*OLCRandomWrite = *Geo::OGRc::OLCRandomWrite; |
895
|
|
|
|
|
|
|
*OLCFastSpatialFilter = *Geo::OGRc::OLCFastSpatialFilter; |
896
|
|
|
|
|
|
|
*OLCFastFeatureCount = *Geo::OGRc::OLCFastFeatureCount; |
897
|
|
|
|
|
|
|
*OLCFastGetExtent = *Geo::OGRc::OLCFastGetExtent; |
898
|
|
|
|
|
|
|
*OLCCreateField = *Geo::OGRc::OLCCreateField; |
899
|
|
|
|
|
|
|
*OLCDeleteField = *Geo::OGRc::OLCDeleteField; |
900
|
|
|
|
|
|
|
*OLCReorderFields = *Geo::OGRc::OLCReorderFields; |
901
|
|
|
|
|
|
|
*OLCAlterFieldDefn = *Geo::OGRc::OLCAlterFieldDefn; |
902
|
|
|
|
|
|
|
*OLCTransactions = *Geo::OGRc::OLCTransactions; |
903
|
|
|
|
|
|
|
*OLCDeleteFeature = *Geo::OGRc::OLCDeleteFeature; |
904
|
|
|
|
|
|
|
*OLCFastSetNextByIndex = *Geo::OGRc::OLCFastSetNextByIndex; |
905
|
|
|
|
|
|
|
*OLCStringsAsUTF8 = *Geo::OGRc::OLCStringsAsUTF8; |
906
|
|
|
|
|
|
|
*OLCIgnoreFields = *Geo::OGRc::OLCIgnoreFields; |
907
|
|
|
|
|
|
|
*OLCCreateGeomField = *Geo::OGRc::OLCCreateGeomField; |
908
|
|
|
|
|
|
|
*OLCCurveGeometries = *Geo::OGRc::OLCCurveGeometries; |
909
|
|
|
|
|
|
|
*ODsCCreateLayer = *Geo::OGRc::ODsCCreateLayer; |
910
|
|
|
|
|
|
|
*ODsCDeleteLayer = *Geo::OGRc::ODsCDeleteLayer; |
911
|
|
|
|
|
|
|
*ODsCCreateGeomFieldAfterCreateLayer = *Geo::OGRc::ODsCCreateGeomFieldAfterCreateLayer; |
912
|
|
|
|
|
|
|
*ODsCCurveGeometries = *Geo::OGRc::ODsCCurveGeometries; |
913
|
|
|
|
|
|
|
*ODsCTransactions = *Geo::OGRc::ODsCTransactions; |
914
|
|
|
|
|
|
|
*ODsCEmulatedTransactions = *Geo::OGRc::ODsCEmulatedTransactions; |
915
|
|
|
|
|
|
|
*ODrCCreateDataSource = *Geo::OGRc::ODrCCreateDataSource; |
916
|
|
|
|
|
|
|
*ODrCDeleteDataSource = *Geo::OGRc::ODrCDeleteDataSource; |
917
|
|
|
|
|
|
|
*OLMD_FID64 = *Geo::OGRc::OLMD_FID64; |
918
|
|
|
|
|
|
|
*TermProgress = *Geo::OGRc::TermProgress; |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
package Geo::OGR; |
922
|
|
|
|
|
|
|
our $VERSION = '2.00012'; # this needs to be the same as that in gdal_perl.i |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
package Geo::OGR::Driver; |
925
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
130
|
|
926
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
178
|
|
927
|
6
|
|
|
6
|
|
28
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
366
|
|
928
|
6
|
|
|
6
|
|
48
|
use vars qw /@CAPABILITIES %CAPABILITIES/; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
2013
|
|
929
|
|
|
|
|
|
|
for (keys %Geo::OGR::) { |
930
|
|
|
|
|
|
|
push(@CAPABILITIES, $1), next if /^ODrC(\w+)/; |
931
|
|
|
|
|
|
|
} |
932
|
|
|
|
|
|
|
for my $s (@CAPABILITIES) { |
933
|
|
|
|
|
|
|
my $cap = eval "\$Geo::OGR::ODrC$s"; |
934
|
|
|
|
|
|
|
$CAPABILITIES{$s} = $cap; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
sub Capabilities { |
938
|
1
|
50
|
|
1
|
|
11
|
return @CAPABILITIES if @_ == 0; |
939
|
1
|
|
|
|
|
3
|
my $self = shift; |
940
|
1
|
|
|
|
|
2
|
my @cap; |
941
|
1
|
|
|
|
|
3
|
for my $cap (@CAPABILITIES) { |
942
|
2
|
100
|
|
|
|
20
|
push @cap, $cap if _TestCapability($self, $CAPABILITIES{$cap}); |
943
|
|
|
|
|
|
|
} |
944
|
1
|
|
|
|
|
4
|
return @cap; |
945
|
|
|
|
|
|
|
} |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
sub TestCapability { |
948
|
3
|
|
|
3
|
|
57
|
my($self, $cap) = @_; |
949
|
3
|
50
|
|
|
|
21
|
confess "No such capability defined for class Driver: '$cap'." unless defined $CAPABILITIES{$cap}; |
950
|
3
|
|
|
|
|
29
|
return _TestCapability($self, $CAPABILITIES{$cap}); |
951
|
|
|
|
|
|
|
} |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
*Create = *CreateDataSource; |
954
|
|
|
|
|
|
|
*Copy = *CopyDataSource; |
955
|
|
|
|
|
|
|
*OpenDataSource = *Open; |
956
|
|
|
|
|
|
|
*Delete = *DeleteDataSource; |
957
|
|
|
|
|
|
|
*Name = *GetName; |
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
package Geo::OGR::DataSource; |
963
|
6
|
|
|
6
|
|
29
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
145
|
|
964
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
182
|
|
965
|
6
|
|
|
6
|
|
26
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
358
|
|
966
|
6
|
|
|
6
|
|
28
|
use vars qw /@CAPABILITIES %CAPABILITIES %LAYERS %RESULT_SET/; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
6914
|
|
967
|
|
|
|
|
|
|
for (keys %Geo::OGR::) { |
968
|
|
|
|
|
|
|
push(@CAPABILITIES, $1), next if /^ODsC(\w+)/; |
969
|
|
|
|
|
|
|
} |
970
|
|
|
|
|
|
|
for my $s (@CAPABILITIES) { |
971
|
|
|
|
|
|
|
my $cap = eval "\$Geo::OGR::ODsC$s"; |
972
|
|
|
|
|
|
|
$CAPABILITIES{$s} = $cap; |
973
|
|
|
|
|
|
|
} |
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
sub Capabilities { |
976
|
1
|
50
|
|
1
|
|
681
|
return @CAPABILITIES if @_ == 0; |
977
|
1
|
|
|
|
|
2
|
my $self = shift; |
978
|
1
|
|
|
|
|
3
|
my @cap; |
979
|
1
|
|
|
|
|
6
|
for my $cap (@CAPABILITIES) { |
980
|
6
|
100
|
|
|
|
40
|
push @cap, $cap if _TestCapability($self, $CAPABILITIES{$cap}); |
981
|
|
|
|
|
|
|
} |
982
|
1
|
|
|
|
|
5
|
return @cap; |
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
sub TestCapability { |
986
|
1
|
|
|
1
|
|
1046
|
my($self, $cap) = @_; |
987
|
1
|
50
|
|
|
|
6
|
confess "No such capability defined for class DataSource: '$cap'." unless defined $CAPABILITIES{$cap}; |
988
|
1
|
|
|
|
|
8
|
return _TestCapability($self, $CAPABILITIES{$cap}); |
989
|
|
|
|
|
|
|
} |
990
|
|
|
|
|
|
|
*GetDriver = *_GetDriver; |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
sub new { |
993
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
994
|
0
|
|
|
|
|
0
|
return Geo::OGR::Open(@_); |
995
|
|
|
|
|
|
|
} |
996
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
sub Open { |
998
|
0
|
|
|
0
|
|
0
|
return Geo::OGR::Open(@_); |
999
|
|
|
|
|
|
|
} |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
sub OpenShared { |
1002
|
0
|
|
|
0
|
|
0
|
return Geo::OGR::OpenShared(@_); |
1003
|
|
|
|
|
|
|
} |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
sub ExecuteSQL { |
1006
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1007
|
0
|
|
|
|
|
0
|
my $layer = $self->_ExecuteSQL(@_); |
1008
|
0
|
|
|
|
|
0
|
$LAYERS{tied(%$layer)} = $self; |
1009
|
0
|
|
|
|
|
0
|
$RESULT_SET{tied(%$layer)} = 1; |
1010
|
0
|
|
|
|
|
0
|
return $layer; |
1011
|
|
|
|
|
|
|
} |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
0
|
|
|
sub ReleaseResultSet { |
1014
|
|
|
|
|
|
|
# a no-op, _ReleaseResultSet is called from Layer::DESTROY |
1015
|
|
|
|
|
|
|
} |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
sub GetLayer { |
1018
|
0
|
|
|
0
|
|
0
|
my($self, $name) = @_; |
1019
|
0
|
0
|
|
|
|
0
|
my $layer = defined $name ? GetLayerByName($self, "$name") : GetLayerByIndex($self, 0); |
1020
|
0
|
0
|
|
|
|
0
|
$name = '' unless defined $name; |
1021
|
0
|
0
|
|
|
|
0
|
confess "No such layer: '$name'." unless $layer; |
1022
|
0
|
|
|
|
|
0
|
$LAYERS{tied(%$layer)} = $self; |
1023
|
0
|
|
|
|
|
0
|
return $layer; |
1024
|
|
|
|
|
|
|
} |
1025
|
|
|
|
|
|
|
*Layer = *GetLayer; |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
sub GetLayerNames { |
1028
|
2
|
|
|
2
|
|
8
|
my $self = shift; |
1029
|
2
|
|
|
|
|
3
|
my @names; |
1030
|
2
|
|
|
|
|
11
|
for my $i (0..$self->GetLayerCount-1) { |
1031
|
5
|
|
|
|
|
22
|
my $layer = GetLayerByIndex($self, $i); |
1032
|
5
|
|
|
|
|
31
|
push @names, $layer->GetName; |
1033
|
|
|
|
|
|
|
} |
1034
|
2
|
|
|
|
|
9
|
return @names; |
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
*Layers = *GetLayerNames; |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
sub CreateLayer { |
1039
|
19
|
|
|
19
|
|
7420
|
my $self = shift; |
1040
|
19
|
|
|
|
|
169
|
my %defaults = ( Name => 'unnamed', |
1041
|
|
|
|
|
|
|
SRS => undef, |
1042
|
|
|
|
|
|
|
Options => {}, |
1043
|
|
|
|
|
|
|
GeometryType => 'Unknown', |
1044
|
|
|
|
|
|
|
Schema => undef, |
1045
|
|
|
|
|
|
|
Fields => undef, |
1046
|
|
|
|
|
|
|
ApproxOK => 1); |
1047
|
19
|
|
|
|
|
43
|
my %params; |
1048
|
19
|
100
|
33
|
|
|
170
|
if (@_ == 0) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
1050
|
1
|
|
|
|
|
3
|
%params = %{$_[0]}; |
|
1
|
|
|
|
|
7
|
|
1051
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0 and (defined $_[0] and exists $defaults{$_[0]})) { |
1052
|
2
|
|
|
|
|
8
|
%params = @_; |
1053
|
|
|
|
|
|
|
} else { |
1054
|
15
|
|
|
|
|
86
|
($params{Name}, $params{SRS}, $params{GeometryType}, $params{Options}, $params{Schema}) = @_; |
1055
|
|
|
|
|
|
|
} |
1056
|
19
|
|
|
|
|
83
|
for (keys %params) { |
1057
|
81
|
50
|
|
|
|
199
|
carp "CreateLayer: unknown named parameter '$_'." unless exists $defaults{$_}; |
1058
|
|
|
|
|
|
|
} |
1059
|
19
|
100
|
|
|
|
66
|
if (exists $params{Schema}) { |
1060
|
15
|
|
|
|
|
30
|
my $s = $params{Schema}; |
1061
|
15
|
50
|
|
|
|
43
|
$params{GeometryType} = $s->{GeometryType} if exists $s->{GeometryType}; |
1062
|
15
|
50
|
|
|
|
38
|
$params{Fields} = $s->{Fields} if exists $s->{Fields}; |
1063
|
15
|
50
|
|
|
|
44
|
$params{Name} = $s->{Name} if exists $s->{Name}; |
1064
|
|
|
|
|
|
|
} |
1065
|
19
|
100
|
|
|
|
53
|
$defaults{GeometryType} = 'None' if $params{Fields}; |
1066
|
19
|
|
|
|
|
69
|
for (keys %defaults) { |
1067
|
133
|
100
|
|
|
|
359
|
$params{$_} = $defaults{$_} unless defined $params{$_}; |
1068
|
|
|
|
|
|
|
} |
1069
|
|
|
|
|
|
|
confess "Unknown geometry type: '$params{GeometryType}'." |
1070
|
19
|
50
|
|
|
|
82
|
unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$params{GeometryType}}; |
1071
|
19
|
|
|
|
|
47
|
my $gt = $Geo::OGR::Geometry::TYPE_STRING2INT{$params{GeometryType}}; |
1072
|
19
|
|
|
|
|
658
|
my $layer = _CreateLayer($self, $params{Name}, $params{SRS}, $gt, $params{Options}); |
1073
|
19
|
|
|
|
|
85
|
$LAYERS{tied(%$layer)} = $self; |
1074
|
19
|
|
|
|
|
36
|
my $f = $params{Fields}; |
1075
|
19
|
100
|
|
|
|
49
|
if ($f) { |
1076
|
1
|
50
|
|
|
|
4
|
confess "Named parameter 'Fields' must be a reference to an array." unless ref($f) eq 'ARRAY'; |
1077
|
1
|
|
|
|
|
3
|
for my $field (@$f) { |
1078
|
3
|
|
|
|
|
10
|
$layer->CreateField($field); |
1079
|
|
|
|
|
|
|
} |
1080
|
|
|
|
|
|
|
} |
1081
|
19
|
|
|
|
|
123
|
return $layer; |
1082
|
|
|
|
|
|
|
} |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
sub DeleteLayer { |
1085
|
1
|
|
|
1
|
|
5
|
my ($self, $name) = @_; |
1086
|
1
|
|
|
|
|
2
|
my $index; |
1087
|
1
|
|
|
|
|
9
|
for my $i (0..$self->GetLayerCount-1) { |
1088
|
2
|
|
|
|
|
35
|
my $layer = GetLayerByIndex($self, $i); |
1089
|
2
|
100
|
|
|
|
15
|
$index = $i, last if $layer->GetName eq $name; |
1090
|
|
|
|
|
|
|
} |
1091
|
1
|
50
|
|
|
|
5
|
confess "No such layer: '$name'." unless defined $index; |
1092
|
1
|
|
|
|
|
10
|
_DeleteLayer($self, $index); |
1093
|
|
|
|
|
|
|
} |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
package Geo::OGR::Layer; |
1099
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
161
|
|
1100
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
181
|
|
1101
|
6
|
|
|
6
|
|
32
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
330
|
|
1102
|
6
|
|
|
6
|
|
29
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
311
|
|
1103
|
6
|
|
|
6
|
|
25
|
use vars qw /@CAPABILITIES %CAPABILITIES %DEFNS/; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
14426
|
|
1104
|
|
|
|
|
|
|
for (keys %Geo::OGR::) { |
1105
|
|
|
|
|
|
|
push(@CAPABILITIES, $1), next if /^OLC(\w+)/; |
1106
|
|
|
|
|
|
|
} |
1107
|
|
|
|
|
|
|
for my $s (@CAPABILITIES) { |
1108
|
|
|
|
|
|
|
my $cap = eval "\$Geo::OGR::OLC$s"; |
1109
|
|
|
|
|
|
|
$CAPABILITIES{$s} = $cap; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
sub DESTROY { |
1113
|
44
|
|
|
44
|
|
2640
|
my $self; |
1114
|
44
|
100
|
|
|
|
181
|
if ($_[0]->isa('SCALAR')) { |
1115
|
22
|
|
|
|
|
30
|
$self = $_[0]; |
1116
|
|
|
|
|
|
|
} else { |
1117
|
22
|
50
|
|
|
|
80
|
return unless $_[0]->isa('HASH'); |
1118
|
22
|
|
|
|
|
24
|
$self = tied(%{$_[0]}); |
|
22
|
|
|
|
|
51
|
|
1119
|
22
|
50
|
|
|
|
47
|
return unless defined $self; |
1120
|
|
|
|
|
|
|
} |
1121
|
44
|
50
|
|
|
|
106
|
if ($Geo::OGR::DataSource::RESULT_SET{$self}) { |
1122
|
0
|
|
|
|
|
0
|
$Geo::OGR::DataSource::LAYERS{$self}->_ReleaseResultSet($self); |
1123
|
0
|
|
|
|
|
0
|
delete $Geo::OGR::DataSource::RESULT_SET{$self} |
1124
|
|
|
|
|
|
|
} |
1125
|
44
|
|
|
|
|
62
|
delete $ITERATORS{$self}; |
1126
|
44
|
50
|
|
|
|
102
|
if (exists $OWNER{$self}) { |
1127
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
1128
|
|
|
|
|
|
|
} |
1129
|
44
|
|
|
|
|
94
|
$self->RELEASE_PARENTS(); |
1130
|
|
|
|
|
|
|
} |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
sub RELEASE_PARENTS { |
1133
|
44
|
|
|
44
|
|
51
|
my $self = shift; |
1134
|
44
|
|
|
|
|
182
|
delete $Geo::OGR::DataSource::LAYERS{$self}; |
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
sub Capabilities { |
1138
|
1
|
50
|
|
1
|
|
8
|
return @CAPABILITIES if @_ == 0; |
1139
|
1
|
|
|
|
|
2
|
my $self = shift; |
1140
|
1
|
|
|
|
|
2
|
my @cap; |
1141
|
1
|
|
|
|
|
5
|
for my $cap (@CAPABILITIES) { |
1142
|
17
|
100
|
|
|
|
75
|
push @cap, $cap if _TestCapability($self, $CAPABILITIES{$cap}); |
1143
|
|
|
|
|
|
|
} |
1144
|
1
|
|
|
|
|
5
|
return @cap; |
1145
|
|
|
|
|
|
|
} |
1146
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
sub TestCapability { |
1148
|
0
|
|
|
0
|
|
0
|
my($self, $cap) = @_; |
1149
|
0
|
|
|
|
|
0
|
return _TestCapability($self, $CAPABILITIES{$cap}); |
1150
|
|
|
|
|
|
|
} |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
sub GetDataSource { |
1153
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1154
|
0
|
|
|
|
|
0
|
return $Geo::OGR::DataSource::LAYERS{$self}; |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
*DataSource = *GetDataSource; |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
sub GetDefn { |
1159
|
7
|
|
|
7
|
|
11
|
my $self = shift; |
1160
|
7
|
|
|
|
|
55
|
my $defn = $self->GetLayerDefn; |
1161
|
7
|
|
|
|
|
27
|
$DEFNS{$defn} = $self; |
1162
|
7
|
|
|
|
|
49
|
return $defn; |
1163
|
|
|
|
|
|
|
} |
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
sub CreateField { |
1166
|
91
|
|
|
91
|
|
452
|
my $self = shift; |
1167
|
91
|
|
|
|
|
263
|
my %defaults = ( ApproxOK => 1, |
1168
|
|
|
|
|
|
|
Type => '' ); |
1169
|
91
|
|
|
|
|
110
|
my %params; |
1170
|
91
|
50
|
|
|
|
362
|
if (@_ == 0) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
1172
|
3
|
|
|
|
|
4
|
%params = %{$_[0]}; |
|
3
|
|
|
|
|
16
|
|
1173
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0) { |
1174
|
4
|
|
|
|
|
27
|
%params = @_; |
1175
|
|
|
|
|
|
|
} else { |
1176
|
84
|
|
|
|
|
195
|
($params{Defn}) = @_; |
1177
|
|
|
|
|
|
|
} |
1178
|
91
|
|
|
|
|
264
|
for (keys %defaults) { |
1179
|
182
|
100
|
|
|
|
574
|
$params{$_} = $defaults{$_} unless defined $params{$_}; |
1180
|
|
|
|
|
|
|
} |
1181
|
91
|
100
|
66
|
|
|
739
|
if (blessed($params{Defn}) and $params{Defn}->isa('Geo::OGR::FieldDefn')) { |
|
|
50
|
33
|
|
|
|
|
1182
|
84
|
|
|
|
|
627
|
$self->_CreateField($params{Defn}, $params{ApproxOK}); |
1183
|
|
|
|
|
|
|
} elsif (blessed($_[0]) and $params{Defn}->isa('Geo::OGR::GeomFieldDefn')) { |
1184
|
0
|
|
|
|
|
0
|
$self->CreateGeomField($params{Defn}, $params{ApproxOK}); |
1185
|
|
|
|
|
|
|
} else { |
1186
|
7
|
|
|
|
|
16
|
my $a = $params{ApproxOK}; |
1187
|
7
|
|
|
|
|
13
|
delete $params{ApproxOK}; |
1188
|
7
|
100
|
|
|
|
22
|
if (exists $params{GeometryType}) { |
1189
|
1
|
|
|
|
|
4
|
$params{Type} = $params{GeometryType}; |
1190
|
1
|
|
|
|
|
3
|
delete $params{GeometryType}; |
1191
|
|
|
|
|
|
|
} |
1192
|
7
|
100
|
|
|
|
27
|
if (exists $Geo::OGR::FieldDefn::TYPE_STRING2INT{$params{Type}}) { |
1193
|
6
|
|
|
|
|
35
|
my $fd = Geo::OGR::FieldDefn->new(%params); |
1194
|
6
|
|
|
|
|
51
|
_CreateField($self, $fd, $a); |
1195
|
|
|
|
|
|
|
} else { |
1196
|
1
|
|
|
|
|
9
|
my $fd = Geo::OGR::GeomFieldDefn->new(%params); |
1197
|
1
|
|
|
|
|
12
|
CreateGeomField($self, $fd, $a); |
1198
|
|
|
|
|
|
|
} |
1199
|
|
|
|
|
|
|
} |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
sub AlterFieldDefn { |
1203
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1204
|
0
|
|
|
|
|
0
|
my $field = shift; |
1205
|
0
|
|
|
|
|
0
|
my $index; |
1206
|
0
|
|
|
|
|
0
|
eval { |
1207
|
0
|
|
|
|
|
0
|
$index = $self->GetFieldIndex($field); |
1208
|
|
|
|
|
|
|
}; |
1209
|
0
|
0
|
|
|
|
0
|
confess "Only non-spatial fields can be altered.\n$@" if $@; |
1210
|
0
|
0
|
0
|
|
|
0
|
if (blessed($_[0]) and $_[0]->isa('Geo::OGR::FieldDefn')) { |
|
|
0
|
|
|
|
|
|
1211
|
0
|
|
|
|
|
0
|
_AlterFieldDefn($self, $index, @_); |
1212
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0) { |
1213
|
0
|
|
|
|
|
0
|
my %params = @_; |
1214
|
0
|
|
|
|
|
0
|
my $definition = Geo::OGR::FieldDefn->new(%params); |
1215
|
0
|
|
|
|
|
0
|
my $flags = 0; |
1216
|
0
|
0
|
|
|
|
0
|
$flags |= 1 if exists $params{Name}; |
1217
|
0
|
0
|
|
|
|
0
|
$flags |= 2 if exists $params{Type}; |
1218
|
0
|
0
|
0
|
|
|
0
|
$flags |= 4 if exists $params{Width} or exists $params{Precision}; |
1219
|
0
|
0
|
|
|
|
0
|
$flags |= 8 if exists $params{Nullable}; |
1220
|
0
|
0
|
|
|
|
0
|
$flags |= 16 if exists $params{Default}; |
1221
|
0
|
|
|
|
|
0
|
_AlterFieldDefn($self, $index, $definition, $flags); |
1222
|
|
|
|
|
|
|
} else { |
1223
|
0
|
|
|
|
|
0
|
croak "Usage: AlterFieldDefn(\$Name, \%NamedParameters)"; |
1224
|
|
|
|
|
|
|
} |
1225
|
|
|
|
|
|
|
} |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
sub DeleteField { |
1228
|
1
|
|
|
1
|
|
5
|
my($self, $fn) = @_; |
1229
|
1
|
|
|
|
|
2
|
my $d = $self->GetDefn; |
1230
|
1
|
|
|
|
|
5
|
my $index = $d->GetFieldIndex($fn); |
1231
|
1
|
50
|
|
|
|
3
|
$index = $fn if $index < 0; |
1232
|
1
|
|
|
|
|
3
|
eval { |
1233
|
1
|
|
|
|
|
5
|
_DeleteField($self, $index); |
1234
|
|
|
|
|
|
|
}; |
1235
|
1
|
50
|
|
|
|
4
|
confess "Field not found: '$fn'. Only non-spatial fields can be deleted." if $@; |
1236
|
|
|
|
|
|
|
} |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
sub GetSchema { |
1239
|
2
|
|
|
2
|
|
10
|
my $self = shift; |
1240
|
2
|
50
|
|
|
|
9
|
carp "Schema of a layer should not be set directly." if @_; |
1241
|
2
|
50
|
33
|
|
|
6
|
if (@_ and @_ % 2 == 0) { |
1242
|
0
|
|
|
|
|
0
|
my %schema = @_; |
1243
|
0
|
0
|
|
|
|
0
|
if ($schema{Fields}) { |
1244
|
0
|
|
|
|
|
0
|
for my $field (@{$schema{Fields}}) { |
|
0
|
|
|
|
|
0
|
|
1245
|
0
|
|
|
|
|
0
|
$self->CreateField($field); |
1246
|
|
|
|
|
|
|
} |
1247
|
|
|
|
|
|
|
} |
1248
|
|
|
|
|
|
|
} |
1249
|
2
|
|
|
|
|
7
|
return $self->GetDefn->Schema; |
1250
|
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
*Schema = *GetSchema; |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
sub Row { |
1254
|
1
|
|
|
1
|
|
9
|
my $self = shift; |
1255
|
1
|
|
|
|
|
2
|
my $update = @_ > 0; |
1256
|
1
|
|
|
|
|
4
|
my %row = @_; |
1257
|
1
|
50
|
|
|
|
14
|
my $feature = defined $row{FID} ? $self->GetFeature($row{FID}) : $self->GetNextFeature; |
1258
|
1
|
50
|
|
|
|
3
|
return unless $feature; |
1259
|
1
|
|
|
|
|
2
|
my $ret; |
1260
|
1
|
50
|
|
|
|
3
|
if (defined wantarray) { |
1261
|
0
|
|
|
|
|
0
|
$ret = $feature->Row(@_); |
1262
|
|
|
|
|
|
|
} else { |
1263
|
1
|
|
|
|
|
3
|
$feature->Row(@_); |
1264
|
|
|
|
|
|
|
} |
1265
|
1
|
50
|
|
|
|
11
|
$self->SetFeature($feature) if $update; |
1266
|
1
|
50
|
|
|
|
6
|
return unless defined wantarray; |
1267
|
0
|
|
|
|
|
0
|
return $ret; |
1268
|
|
|
|
|
|
|
} |
1269
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
sub Tuple { |
1271
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
1272
|
1
|
|
|
|
|
2
|
my $FID = shift; |
1273
|
1
|
50
|
|
|
|
11
|
my $feature = defined $FID ? $self->GetFeature($FID) : $self->GetNextFeature; |
1274
|
1
|
50
|
|
|
|
4
|
return unless $feature; |
1275
|
1
|
|
|
|
|
3
|
my $set = @_ > 0; |
1276
|
1
|
50
|
|
|
|
3
|
unshift @_, $feature->GetFID if $set; |
1277
|
1
|
|
|
|
|
2
|
my @ret; |
1278
|
1
|
50
|
|
|
|
3
|
if (defined wantarray) { |
1279
|
1
|
|
|
|
|
4
|
@ret = $feature->Tuple(@_); |
1280
|
|
|
|
|
|
|
} else { |
1281
|
0
|
|
|
|
|
0
|
$feature->Tuple(@_); |
1282
|
|
|
|
|
|
|
} |
1283
|
1
|
50
|
|
|
|
29
|
$self->SetFeature($feature) if $set; |
1284
|
1
|
50
|
|
|
|
4
|
return unless defined wantarray; |
1285
|
1
|
|
|
|
|
5
|
return @ret; |
1286
|
|
|
|
|
|
|
} |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
sub SpatialFilter { |
1289
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1290
|
0
|
0
|
|
|
|
0
|
$self->SetSpatialFilter($_[0]) if @_ == 1; |
1291
|
0
|
0
|
|
|
|
0
|
$self->SetSpatialFilterRect(@_) if @_ == 4; |
1292
|
0
|
0
|
|
|
|
0
|
return unless defined wantarray; |
1293
|
0
|
|
|
|
|
0
|
$self->GetSpatialFilter; |
1294
|
|
|
|
|
|
|
} |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
sub InsertFeature { |
1297
|
4
|
|
|
4
|
|
43
|
my $self = shift; |
1298
|
4
|
|
|
|
|
7
|
my $feature = shift; |
1299
|
4
|
50
|
|
|
|
15
|
confess "Usage: \$feature->InsertFeature(reference to a hash or array)." unless ref($feature); |
1300
|
4
|
|
|
|
|
14
|
my $new = Geo::OGR::Feature->new($self->GetDefn); |
1301
|
4
|
100
|
0
|
|
|
15
|
if (ref($feature) eq 'HASH') { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1302
|
2
|
|
|
|
|
9
|
$new->Row(%$feature); |
1303
|
|
|
|
|
|
|
} elsif (ref($feature) eq 'ARRAY') { |
1304
|
2
|
|
|
|
|
16
|
$new->Tuple(@$feature); |
1305
|
|
|
|
|
|
|
} elsif (blessed($feature) and $feature->isa('Geo::OGR::Feature')) { |
1306
|
0
|
|
|
|
|
0
|
$new->Row($feature->Row); |
1307
|
|
|
|
|
|
|
} |
1308
|
3
|
|
|
|
|
41
|
$self->CreateFeature($new); |
1309
|
|
|
|
|
|
|
} |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
sub ForFeatures { |
1312
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1313
|
0
|
|
|
|
|
0
|
my $code = shift; |
1314
|
0
|
|
|
|
|
0
|
my $in_place = shift; |
1315
|
0
|
|
|
|
|
0
|
$self->ResetReading; |
1316
|
0
|
|
|
|
|
0
|
while (my $f = $self->GetNextFeature) { |
1317
|
0
|
|
|
|
|
0
|
$code->($f); |
1318
|
0
|
0
|
|
|
|
0
|
$self->SetFeature($f) if $in_place; |
1319
|
|
|
|
|
|
|
}; |
1320
|
|
|
|
|
|
|
} |
1321
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
sub ForGeometries { |
1323
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1324
|
0
|
|
|
|
|
0
|
my $code = shift; |
1325
|
0
|
|
|
|
|
0
|
my $in_place = shift; |
1326
|
0
|
|
|
|
|
0
|
$self->ResetReading; |
1327
|
0
|
|
|
|
|
0
|
while (my $f = $self->GetNextFeature) { |
1328
|
0
|
|
|
|
|
0
|
my $g = $f->Geometry(); |
1329
|
0
|
|
|
|
|
0
|
$code->($g); |
1330
|
0
|
0
|
|
|
|
0
|
if ($in_place) { |
1331
|
0
|
|
|
|
|
0
|
$f->Geometry($g); |
1332
|
0
|
|
|
|
|
0
|
$self->SetFeature($f); |
1333
|
|
|
|
|
|
|
} |
1334
|
|
|
|
|
|
|
} |
1335
|
|
|
|
|
|
|
} |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
sub GetFieldNames { |
1338
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1339
|
0
|
|
|
|
|
0
|
my $d = $self->GetDefn; |
1340
|
0
|
|
|
|
|
0
|
my @ret; |
1341
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < $d->GetFieldCount; $i++) { |
1342
|
0
|
|
|
|
|
0
|
push @ret, $d->GetFieldDefn($i)->Name(); |
1343
|
|
|
|
|
|
|
} |
1344
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < $d->GetGeomFieldCount; $i++) { |
1345
|
0
|
|
|
|
|
0
|
push @ret, $d->GetGeomFieldDefn($i)->Name(); |
1346
|
|
|
|
|
|
|
} |
1347
|
0
|
|
|
|
|
0
|
return @ret; |
1348
|
|
|
|
|
|
|
} |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
sub GetFieldDefn { |
1351
|
0
|
|
|
0
|
|
0
|
my ($self, $name) = @_; |
1352
|
0
|
|
|
|
|
0
|
my $d = $self->GetDefn; |
1353
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < $d->GetFieldCount; $i++) { |
1354
|
0
|
|
|
|
|
0
|
my $fd = $d->GetFieldDefn($i); |
1355
|
0
|
0
|
|
|
|
0
|
return $fd if $fd->Name eq $name; |
1356
|
|
|
|
|
|
|
} |
1357
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < $d->GetGeomFieldCount; $i++) { |
1358
|
0
|
|
|
|
|
0
|
my $fd = $d->GetGeomFieldDefn($i); |
1359
|
0
|
0
|
|
|
|
0
|
return $fd if $fd->Name eq $name; |
1360
|
|
|
|
|
|
|
} |
1361
|
0
|
|
|
|
|
0
|
confess "No such field: '$name'."; |
1362
|
|
|
|
|
|
|
} |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
sub GeometryType { |
1365
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1366
|
0
|
|
|
|
|
0
|
my $d = $self->GetDefn; |
1367
|
0
|
|
|
|
|
0
|
my $fd = $d->GetGeomFieldDefn(0); |
1368
|
0
|
0
|
|
|
|
0
|
return $fd->Type if $fd; |
1369
|
|
|
|
|
|
|
} |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
sub SpatialReference { |
1372
|
0
|
|
|
0
|
|
0
|
my($self, $field, $sr) = @_; |
1373
|
0
|
|
|
|
|
0
|
my $d = $self->GetDefn; |
1374
|
0
|
|
|
|
|
0
|
my $i; |
1375
|
0
|
0
|
0
|
|
|
0
|
if (not defined $field or (blessed($field) and $field->isa('Geo::OSR::SpatialReference'))) { |
|
|
|
0
|
|
|
|
|
1376
|
0
|
|
|
|
|
0
|
$i = 0; |
1377
|
|
|
|
|
|
|
} else { |
1378
|
0
|
|
|
|
|
0
|
$i = $d->GetGeomFieldIndex($field); |
1379
|
|
|
|
|
|
|
} |
1380
|
0
|
|
|
|
|
0
|
my $d2 = $d->GetGeomFieldDefn($i); |
1381
|
0
|
0
|
|
|
|
0
|
$d2->SpatialReference($sr) if defined $sr; |
1382
|
0
|
0
|
|
|
|
0
|
return $d2->SpatialReference() if defined wantarray; |
1383
|
|
|
|
|
|
|
} |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
package Geo::OGR::FeatureDefn; |
1389
|
6
|
|
|
6
|
|
42
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
174
|
|
1390
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
176
|
|
1391
|
6
|
|
|
6
|
|
34
|
use Encode; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
610
|
|
1392
|
6
|
|
|
6
|
|
34
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
344
|
|
1393
|
6
|
|
|
6
|
|
33
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
7206
|
|
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
sub RELEASE_PARENTS { |
1396
|
104
|
|
|
104
|
|
126
|
my $self = shift; |
1397
|
104
|
|
|
|
|
175
|
delete $Geo::OGR::Feature::DEFNS{$self}; |
1398
|
104
|
|
|
|
|
411
|
delete $Geo::OGR::Layer::DEFNS{$self}; |
1399
|
|
|
|
|
|
|
} |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
*Name = *GetName; |
1402
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
sub GetSchema { |
1404
|
4
|
|
|
4
|
|
11
|
my $self = shift; |
1405
|
4
|
50
|
|
|
|
11
|
carp "Schema of a feature definition should not be set directly." if @_; |
1406
|
4
|
50
|
33
|
|
|
34
|
if (@_ and @_ % 2 == 0) { |
1407
|
0
|
|
|
|
|
0
|
my %schema = @_; |
1408
|
0
|
0
|
|
|
|
0
|
if ($schema{Fields}) { |
1409
|
0
|
|
|
|
|
0
|
for my $field (@{$schema{Fields}}) { |
|
0
|
|
|
|
|
0
|
|
1410
|
0
|
|
|
|
|
0
|
$self->AddField($field); |
1411
|
|
|
|
|
|
|
} |
1412
|
|
|
|
|
|
|
} |
1413
|
|
|
|
|
|
|
} |
1414
|
4
|
|
|
|
|
7
|
my %schema; |
1415
|
4
|
|
|
|
|
23
|
$schema{Name} = $self->Name(); |
1416
|
4
|
|
|
|
|
14
|
$schema{StyleIgnored} = $self->StyleIgnored(); |
1417
|
4
|
|
|
|
|
9
|
$schema{Fields} = []; |
1418
|
4
|
|
|
|
|
31
|
for my $i (0..$self->GetFieldCount-1) { |
1419
|
9
|
|
|
|
|
52
|
my $s = $self->GetFieldDefn($i)->Schema; |
1420
|
9
|
|
|
|
|
21
|
push @{$schema{Fields}}, $s; |
|
9
|
|
|
|
|
27
|
|
1421
|
|
|
|
|
|
|
} |
1422
|
4
|
|
|
|
|
23
|
for my $i (0..$self->GetGeomFieldCount-1) { |
1423
|
3
|
|
|
|
|
30
|
my $s = $self->GetGeomFieldDefn($i)->Schema; |
1424
|
3
|
|
|
|
|
11
|
push @{$schema{Fields}}, $s; |
|
3
|
|
|
|
|
12
|
|
1425
|
|
|
|
|
|
|
} |
1426
|
4
|
50
|
|
|
|
19
|
return wantarray ? %schema : \%schema; |
1427
|
|
|
|
|
|
|
} |
1428
|
|
|
|
|
|
|
*Schema = *GetSchema; |
1429
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
sub AddField { |
1431
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
1432
|
1
|
50
|
33
|
|
|
8
|
confess "Read-only definition." if $Geo::OGR::Feature::DEFNS{$self} or $Geo::OGR::Layer::DEFNS{$self}; |
1433
|
1
|
|
|
|
|
1
|
my %params; |
1434
|
1
|
50
|
|
|
|
8
|
if (@_ == 0) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
1436
|
0
|
|
|
|
|
0
|
%params = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
1437
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0) { |
1438
|
1
|
|
|
|
|
3
|
%params = @_; |
1439
|
|
|
|
|
|
|
} |
1440
|
1
|
50
|
|
|
|
4
|
$params{Type} = '' unless defined $params{Type}; |
1441
|
1
|
50
|
|
|
|
3
|
if (exists $Geo::OGR::FieldDefn::TYPE_STRING2INT{$params{Type}}) { |
1442
|
0
|
|
|
|
|
0
|
my $fd = Geo::OGR::FieldDefn->new(%params); |
1443
|
0
|
|
|
|
|
0
|
$self->AddFieldDefn($fd); |
1444
|
|
|
|
|
|
|
} else { |
1445
|
1
|
|
|
|
|
11
|
my $fd = Geo::OGR::GeomFieldDefn->new(%params); |
1446
|
1
|
|
|
|
|
9
|
$self->AddGeomFieldDefn($fd); |
1447
|
|
|
|
|
|
|
} |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
|
1450
|
|
|
|
|
|
|
sub DeleteField { |
1451
|
0
|
|
|
0
|
|
0
|
my ($self, $name) = @_; |
1452
|
0
|
0
|
0
|
|
|
0
|
confess "Read-only definition." if $Geo::OGR::Feature::DEFNS{$self} or $Geo::OGR::Layer::DEFNS{$self}; |
1453
|
0
|
|
|
|
|
0
|
for my $i (0..$self->GetFieldCount-1) { |
1454
|
0
|
0
|
|
|
|
0
|
confess "Non-geometry fields cannot be deleted." if $self->GetFieldDefn($i)->Name eq $name; |
1455
|
|
|
|
|
|
|
} |
1456
|
0
|
|
|
|
|
0
|
for my $i (0..$self->GetGeomFieldCount-1) { |
1457
|
0
|
0
|
|
|
|
0
|
$self->DeleteGeomFieldDefn($i) if $self->GetGeomFieldDefn($i)->Name eq $name; |
1458
|
|
|
|
|
|
|
} |
1459
|
0
|
|
|
|
|
0
|
confess "No such field: '$name'."; |
1460
|
|
|
|
|
|
|
} |
1461
|
|
|
|
|
|
|
|
1462
|
|
|
|
|
|
|
sub GetFieldNames { |
1463
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1464
|
0
|
|
|
|
|
0
|
my @names = (); |
1465
|
0
|
|
|
|
|
0
|
for my $i (0..$self->GetFieldCount-1) { |
1466
|
0
|
|
|
|
|
0
|
push @names, $self->GetFieldDefn($i)->Name; |
1467
|
|
|
|
|
|
|
} |
1468
|
0
|
|
|
|
|
0
|
for my $i (0..$self->GetGeomFieldCount-1) { |
1469
|
0
|
|
|
|
|
0
|
push @names, $self->GetGeomFieldDefn($i)->Name; |
1470
|
|
|
|
|
|
|
} |
1471
|
0
|
|
|
|
|
0
|
return @names; |
1472
|
|
|
|
|
|
|
} |
1473
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
sub GetFieldDefn { |
1475
|
|
|
|
|
|
|
my ($self, $name) = @_; |
1476
|
|
|
|
|
|
|
for my $i (0..$self->GetFieldCount-1) { |
1477
|
|
|
|
|
|
|
my $fd = $self->GetFieldDefn($i); |
1478
|
|
|
|
|
|
|
return $fd if $fd->Name eq $name; |
1479
|
|
|
|
|
|
|
} |
1480
|
|
|
|
|
|
|
for my $i (0..$self->GetGeomFieldCount-1) { |
1481
|
|
|
|
|
|
|
my $fd = $self->GetGeomFieldDefn($i); |
1482
|
|
|
|
|
|
|
return $fd if $fd->Name eq $name; |
1483
|
|
|
|
|
|
|
} |
1484
|
|
|
|
|
|
|
confess "No such field: '$name'."; |
1485
|
|
|
|
|
|
|
} |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
sub GeomType { |
1488
|
12
|
|
|
12
|
|
55
|
my ($self, $type) = @_; |
1489
|
12
|
50
|
33
|
|
|
78
|
confess "Read-only definition." if $Geo::OGR::Feature::DEFNS{$self} or $Geo::OGR::Layer::DEFNS{$self}; |
1490
|
12
|
50
|
|
|
|
26
|
if (defined $type) { |
1491
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry data type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
1492
|
0
|
|
|
|
|
0
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
1493
|
0
|
|
|
|
|
0
|
SetGeomType($self, $type); |
1494
|
|
|
|
|
|
|
} |
1495
|
12
|
50
|
|
|
|
96
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GetGeomType($self)} if defined wantarray; |
1496
|
|
|
|
|
|
|
} |
1497
|
|
|
|
|
|
|
*GeometryType = *GeomType; |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
sub GeometryIgnored { |
1500
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1501
|
0
|
0
|
|
|
|
0
|
SetGeometryIgnored($self, $_[0]) if @_; |
1502
|
0
|
0
|
|
|
|
0
|
IsGeometryIgnored($self) if defined wantarray; |
1503
|
|
|
|
|
|
|
} |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
sub StyleIgnored { |
1506
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
1507
|
4
|
50
|
|
|
|
13
|
SetStyleIgnored($self, $_[0]) if @_; |
1508
|
4
|
50
|
|
|
|
38
|
IsStyleIgnored($self) if defined wantarray; |
1509
|
|
|
|
|
|
|
} |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
package Geo::OGR::Feature; |
1515
|
6
|
|
|
6
|
|
40
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
157
|
|
1516
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
227
|
|
1517
|
6
|
|
|
6
|
|
30
|
use vars qw /%GEOMETRIES %DEFNS/; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
290
|
|
1518
|
6
|
|
|
6
|
|
32
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
303
|
|
1519
|
6
|
|
|
6
|
|
33
|
use Encode; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
512
|
|
1520
|
6
|
|
|
6
|
|
31
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
18655
|
|
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
sub FETCH { |
1523
|
0
|
|
|
0
|
|
0
|
my($self, $index) = @_; |
1524
|
0
|
|
|
|
|
0
|
my $i; |
1525
|
0
|
|
|
|
|
0
|
eval {$i = $self->_GetFieldIndex($index)}; |
|
0
|
|
|
|
|
0
|
|
1526
|
0
|
0
|
|
|
|
0
|
$self->GetField($i) unless $@; |
1527
|
0
|
|
|
|
|
0
|
$i = $self->_GetGeomFieldIndex($index); |
1528
|
0
|
|
|
|
|
0
|
$self->GetGeometry($i); |
1529
|
|
|
|
|
|
|
} |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
sub STORE { |
1532
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1533
|
0
|
|
|
|
|
0
|
my $index = shift; |
1534
|
0
|
|
|
|
|
0
|
my $i; |
1535
|
0
|
|
|
|
|
0
|
eval {$i = $self->_GetFieldIndex($index)}; |
|
0
|
|
|
|
|
0
|
|
1536
|
0
|
0
|
|
|
|
0
|
$self->SetField($i, @_) unless $@; |
1537
|
0
|
|
|
|
|
0
|
$i = $self->_GetGeomFieldIndex($index); |
1538
|
0
|
|
|
|
|
0
|
$self->SetGeometry($i, @_); |
1539
|
|
|
|
|
|
|
} |
1540
|
|
|
|
|
|
|
|
1541
|
|
|
|
|
|
|
sub FID { |
1542
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1543
|
0
|
0
|
|
|
|
0
|
$self->SetFID($_[0]) if @_; |
1544
|
0
|
0
|
|
|
|
0
|
return unless defined wantarray; |
1545
|
0
|
|
|
|
|
0
|
$self->GetFID; |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
sub StyleString { |
1549
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1550
|
0
|
0
|
|
|
|
0
|
$self->SetStyleString($_[0]) if @_; |
1551
|
0
|
0
|
|
|
|
0
|
return unless defined wantarray; |
1552
|
0
|
|
|
|
|
0
|
$self->GetStyleString; |
1553
|
|
|
|
|
|
|
} |
1554
|
|
|
|
|
|
|
|
1555
|
|
|
|
|
|
|
sub Validate { |
1556
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1557
|
0
|
|
|
|
|
0
|
my $flags = 0; |
1558
|
0
|
|
|
|
|
0
|
for my $flag (@_) { |
1559
|
0
|
|
|
|
|
0
|
my $f = eval '$Geo::OGR::'.uc($flag); |
1560
|
0
|
|
|
|
|
0
|
$flags |= $f; |
1561
|
|
|
|
|
|
|
} |
1562
|
0
|
|
|
|
|
0
|
_Validate($self, $flags); |
1563
|
|
|
|
|
|
|
} |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
sub GetSchema { |
1566
|
1
|
|
|
1
|
|
7
|
my $self = shift; |
1567
|
1
|
50
|
|
|
|
5
|
confess "Schema of a feature cannot be set directly." if @_; |
1568
|
1
|
|
|
|
|
8
|
return $self->GetDefnRef->Schema; |
1569
|
|
|
|
|
|
|
} |
1570
|
|
|
|
|
|
|
*Schema = *GetSchema; |
1571
|
|
|
|
|
|
|
|
1572
|
|
|
|
|
|
|
sub Row { |
1573
|
7
|
|
|
7
|
|
24
|
my $self = shift; |
1574
|
7
|
|
|
|
|
24
|
my $nf = $self->GetFieldCount; |
1575
|
7
|
|
|
|
|
19
|
my $ngf = $self->GetGeomFieldCount; |
1576
|
7
|
100
|
|
|
|
17
|
if (@_) { # update |
1577
|
4
|
|
|
|
|
6
|
my %row; |
1578
|
4
|
50
|
33
|
|
|
35
|
if (@_ == 1 and ref($_[0]) eq 'HASH') { |
|
|
50
|
33
|
|
|
|
|
1579
|
0
|
|
|
|
|
0
|
%row = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
1580
|
|
|
|
|
|
|
} elsif (@_ and @_ % 2 == 0) { |
1581
|
4
|
|
|
|
|
23
|
%row = @_; |
1582
|
|
|
|
|
|
|
} else { |
1583
|
0
|
|
|
|
|
0
|
confess 'Usage: $feature->Row(%FeatureData).'; |
1584
|
|
|
|
|
|
|
} |
1585
|
4
|
100
|
|
|
|
14
|
$self->SetFID($row{FID}) if defined $row{FID}; |
1586
|
|
|
|
|
|
|
#$self->Geometry($schema, $row{Geometry}) if $row{Geometry}; |
1587
|
4
|
|
|
|
|
12
|
for my $name (keys %row) { |
1588
|
13
|
100
|
|
|
|
30
|
next if $name eq 'FID'; |
1589
|
12
|
100
|
|
|
|
24
|
if ($name eq 'Geometry') { |
1590
|
3
|
|
|
|
|
8
|
$self->SetGeometry(0, $row{$name}); |
1591
|
3
|
|
|
|
|
8
|
next; |
1592
|
|
|
|
|
|
|
} |
1593
|
9
|
|
|
|
|
21
|
my $f = 0; |
1594
|
9
|
|
|
|
|
20
|
for my $i (0..$nf-1) { |
1595
|
27
|
100
|
|
|
|
141
|
if ($self->GetFieldDefnRef($i)->Name eq $name) { |
1596
|
9
|
|
|
|
|
24
|
$self->SetField($i, $row{$name}); |
1597
|
9
|
|
|
|
|
15
|
$f = 1; |
1598
|
9
|
|
|
|
|
15
|
last; |
1599
|
|
|
|
|
|
|
} |
1600
|
|
|
|
|
|
|
} |
1601
|
9
|
50
|
|
|
|
19
|
next if $f; |
1602
|
0
|
|
|
|
|
0
|
for my $i (0..$ngf-1) { |
1603
|
0
|
0
|
|
|
|
0
|
if ($self->GetGeomFieldDefnRef($i)->Name eq $name) { |
1604
|
0
|
|
|
|
|
0
|
$self->SetGeometry($i, $row{$name}); |
1605
|
0
|
|
|
|
|
0
|
$f = 1; |
1606
|
0
|
|
|
|
|
0
|
last; |
1607
|
|
|
|
|
|
|
} |
1608
|
|
|
|
|
|
|
} |
1609
|
0
|
0
|
|
|
|
0
|
next if $f; |
1610
|
0
|
|
|
|
|
0
|
carp "Feature->Row: Unknown field: '$name'."; |
1611
|
|
|
|
|
|
|
} |
1612
|
|
|
|
|
|
|
} |
1613
|
7
|
100
|
|
|
|
21
|
return unless defined wantarray; |
1614
|
3
|
|
|
|
|
12
|
my %row = (); |
1615
|
3
|
|
|
|
|
9
|
for my $i (0..$nf-1) { |
1616
|
7
|
|
|
|
|
40
|
my $name = $self->GetFieldDefnRef($i)->Name; |
1617
|
7
|
|
|
|
|
16
|
$row{$name} = $self->GetField($i); |
1618
|
|
|
|
|
|
|
} |
1619
|
3
|
|
|
|
|
8
|
for my $i (0..$ngf-1) { |
1620
|
3
|
|
|
|
|
20
|
my $name = $self->GetGeomFieldDefnRef($i)->Name; |
1621
|
3
|
100
|
|
|
|
8
|
$name = 'Geometry' if $name eq ''; |
1622
|
3
|
|
|
|
|
8
|
$row{$name} = $self->GetGeometry($i); |
1623
|
|
|
|
|
|
|
} |
1624
|
3
|
|
|
|
|
14
|
$row{FID} = $self->GetFID; |
1625
|
|
|
|
|
|
|
#$row{Geometry} = $self->Geometry; |
1626
|
3
|
|
|
|
|
9
|
return \%row; |
1627
|
|
|
|
|
|
|
} |
1628
|
|
|
|
|
|
|
|
1629
|
|
|
|
|
|
|
sub Tuple { |
1630
|
6
|
|
|
6
|
|
966
|
my $self = shift; |
1631
|
6
|
|
|
|
|
34
|
my $nf = $self->GetFieldCount; |
1632
|
6
|
|
|
|
|
22
|
my $ngf = $self->GetGeomFieldCount; |
1633
|
6
|
100
|
|
|
|
20
|
if (@_) { |
1634
|
2
|
|
|
|
|
14
|
my $FID; |
1635
|
2
|
100
|
|
|
|
12
|
$FID = shift if @_ == $nf + $ngf + 1; |
1636
|
2
|
100
|
|
|
|
76
|
$self->SetFID($FID) if defined $FID; |
1637
|
2
|
|
|
|
|
6
|
my $values = \@_; |
1638
|
2
|
100
|
|
|
|
9
|
if (@$values != $nf + $ngf) { |
1639
|
1
|
|
|
|
|
3
|
my $n = $nf + $ngf; |
1640
|
1
|
|
|
|
|
503
|
confess "Too many or too few attribute values for a feature (need $n)."; |
1641
|
|
|
|
|
|
|
} |
1642
|
1
|
|
|
|
|
2
|
my $index = 0; # index to non-geometry and geometry fields |
1643
|
1
|
|
|
|
|
10
|
for my $i (0..$nf-1) { |
1644
|
1
|
|
|
|
|
9
|
$self->SetField($i, $values->[$i]); |
1645
|
|
|
|
|
|
|
} |
1646
|
1
|
|
|
|
|
10
|
for my $i (0..$ngf-1) { |
1647
|
1
|
|
|
|
|
8
|
$self->SetGeometry($i, $values->[$nf+$i]); |
1648
|
|
|
|
|
|
|
} |
1649
|
|
|
|
|
|
|
} |
1650
|
5
|
100
|
|
|
|
13
|
return unless defined wantarray; |
1651
|
4
|
|
|
|
|
16
|
my @ret = ($self->GetFID); |
1652
|
4
|
|
|
|
|
11
|
for my $i (0..$nf-1) { |
1653
|
10
|
|
|
|
|
17
|
my $v = $self->GetField($i); |
1654
|
10
|
|
|
|
|
28
|
push @ret, $v; |
1655
|
|
|
|
|
|
|
} |
1656
|
4
|
|
|
|
|
11
|
for my $i (0..$ngf-1) { |
1657
|
4
|
|
|
|
|
10
|
my $v = $self->GetGeometry($i); |
1658
|
4
|
|
|
|
|
10
|
push @ret, $v; |
1659
|
|
|
|
|
|
|
} |
1660
|
4
|
|
|
|
|
14
|
return @ret; |
1661
|
|
|
|
|
|
|
} |
1662
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
sub GetDefn { |
1664
|
17
|
|
|
17
|
|
22
|
my $self = shift; |
1665
|
17
|
|
|
|
|
88
|
my $defn = $self->GetDefnRef; |
1666
|
17
|
|
|
|
|
60
|
$DEFNS{$defn} = $self; |
1667
|
17
|
|
|
|
|
118
|
return $defn; |
1668
|
|
|
|
|
|
|
} |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
*GetFieldNames = *Geo::OGR::Layer::GetFieldNames; |
1671
|
|
|
|
|
|
|
*GetFieldDefn = *Geo::OGR::Layer::GetFieldDefn; |
1672
|
|
|
|
|
|
|
|
1673
|
|
|
|
|
|
|
sub _GetFieldIndex { |
1674
|
120
|
|
|
120
|
|
181
|
my($self, $field) = @_; |
1675
|
120
|
100
|
|
|
|
440
|
if ($field =~ /^\d+$/) { |
1676
|
114
|
50
|
33
|
|
|
844
|
return $field if $field >= 0 and $field < $self->GetFieldCount; |
1677
|
|
|
|
|
|
|
} else { |
1678
|
6
|
|
|
|
|
35
|
for my $i (0..$self->GetFieldCount-1) { |
1679
|
21
|
100
|
|
|
|
110
|
return $i if $self->GetFieldDefnRef($i)->Name eq $field; |
1680
|
|
|
|
|
|
|
} |
1681
|
|
|
|
|
|
|
} |
1682
|
0
|
|
|
|
|
0
|
confess "No such field: '$field'."; |
1683
|
|
|
|
|
|
|
} |
1684
|
|
|
|
|
|
|
|
1685
|
|
|
|
|
|
|
sub GetField { |
1686
|
26
|
|
|
26
|
|
6772
|
my($self, $field) = @_; |
1687
|
26
|
|
|
|
|
51
|
$field = $self->_GetFieldIndex($field); |
1688
|
26
|
100
|
|
|
|
111
|
return unless IsFieldSet($self, $field); |
1689
|
17
|
|
|
|
|
46
|
my $type = GetFieldType($self, $field); |
1690
|
17
|
100
|
|
|
|
40
|
if ($type == $Geo::OGR::OFTInteger) { |
1691
|
8
|
|
|
|
|
42
|
return GetFieldAsInteger($self, $field); |
1692
|
|
|
|
|
|
|
} |
1693
|
9
|
50
|
|
|
|
20
|
if ($type == $Geo::OGR::OFTInteger64) { |
1694
|
0
|
|
|
|
|
0
|
return GetFieldAsInteger64($self, $field); |
1695
|
|
|
|
|
|
|
} |
1696
|
9
|
100
|
|
|
|
19
|
if ($type == $Geo::OGR::OFTReal) { |
1697
|
1
|
|
|
|
|
5
|
return GetFieldAsDouble($self, $field); |
1698
|
|
|
|
|
|
|
} |
1699
|
8
|
100
|
|
|
|
19
|
if ($type == $Geo::OGR::OFTString) { |
1700
|
2
|
|
|
|
|
11
|
return GetFieldAsString($self, $field); |
1701
|
|
|
|
|
|
|
} |
1702
|
6
|
100
|
|
|
|
13
|
if ($type == $Geo::OGR::OFTIntegerList) { |
1703
|
1
|
|
|
|
|
10
|
my $ret = GetFieldAsIntegerList($self, $field); |
1704
|
1
|
50
|
|
|
|
7
|
return wantarray ? @$ret : $ret; |
1705
|
|
|
|
|
|
|
} |
1706
|
5
|
50
|
|
|
|
10
|
if ($type == $Geo::OGR::OFTInteger64List) { |
1707
|
0
|
|
|
|
|
0
|
my $ret = GetFieldAsInteger64List($self, $field); |
1708
|
0
|
0
|
|
|
|
0
|
return wantarray ? @$ret : $ret; |
1709
|
|
|
|
|
|
|
} |
1710
|
5
|
100
|
|
|
|
11
|
if ($type == $Geo::OGR::OFTRealList) { |
1711
|
1
|
|
|
|
|
5
|
my $ret = GetFieldAsDoubleList($self, $field); |
1712
|
1
|
50
|
|
|
|
7
|
return wantarray ? @$ret : $ret; |
1713
|
|
|
|
|
|
|
} |
1714
|
4
|
100
|
|
|
|
10
|
if ($type == $Geo::OGR::OFTStringList) { |
1715
|
1
|
|
|
|
|
6
|
my $ret = GetFieldAsStringList($self, $field); |
1716
|
1
|
50
|
|
|
|
8
|
return wantarray ? @$ret : $ret; |
1717
|
|
|
|
|
|
|
} |
1718
|
3
|
50
|
|
|
|
9
|
if ($type == $Geo::OGR::OFTBinary) { |
1719
|
0
|
|
|
|
|
0
|
return GetFieldAsString($self, $field); |
1720
|
|
|
|
|
|
|
} |
1721
|
3
|
100
|
|
|
|
7
|
if ($type == $Geo::OGR::OFTDate) { |
1722
|
1
|
|
|
|
|
14
|
my @ret = GetFieldAsDateTime($self, $field); |
1723
|
|
|
|
|
|
|
# year, month, day, hour, minute, second, timezone |
1724
|
1
|
50
|
|
|
|
7
|
return wantarray ? @ret[0..2] : [@ret[0..2]]; |
1725
|
|
|
|
|
|
|
} |
1726
|
2
|
100
|
|
|
|
6
|
if ($type == $Geo::OGR::OFTTime) { |
1727
|
1
|
|
|
|
|
11
|
my @ret = GetFieldAsDateTime($self, $field); |
1728
|
1
|
50
|
|
|
|
7
|
return wantarray ? @ret[3..6] : [@ret[3..6]]; |
1729
|
|
|
|
|
|
|
} |
1730
|
1
|
50
|
|
|
|
5
|
if ($type == $Geo::OGR::OFTDateTime) { |
1731
|
1
|
|
|
|
|
7
|
return GetFieldAsDateTime($self, $field); |
1732
|
|
|
|
|
|
|
} |
1733
|
0
|
|
|
|
|
0
|
confess "Perl bindings do not support field type '$Geo::OGR::FieldDefn::TYPE_INT2STRING{$type}'."; |
1734
|
|
|
|
|
|
|
} |
1735
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
sub UnsetField { |
1737
|
0
|
|
|
0
|
|
0
|
my($self, $field) = @_; |
1738
|
0
|
|
|
|
|
0
|
$field = $self->_GetFieldIndex($field); |
1739
|
0
|
|
|
|
|
0
|
_UnsetField($self, $field); |
1740
|
|
|
|
|
|
|
} |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
sub SetField { |
1743
|
94
|
|
|
94
|
|
519
|
my $self = shift; |
1744
|
94
|
|
|
|
|
122
|
my $field = shift; |
1745
|
94
|
|
|
|
|
171
|
$field = $self->_GetFieldIndex($field); |
1746
|
94
|
50
|
33
|
|
|
448
|
if (@_ == 0 or !defined($_[0])) { |
1747
|
0
|
|
|
|
|
0
|
_UnsetField($self, $field); |
1748
|
0
|
|
|
|
|
0
|
return; |
1749
|
|
|
|
|
|
|
} |
1750
|
94
|
100
|
|
|
|
239
|
my $list = ref($_[0]) ? $_[0] : [@_]; |
1751
|
94
|
|
|
|
|
291
|
my $type = GetFieldType($self, $field); |
1752
|
94
|
100
|
66
|
|
|
928
|
if ($type == $Geo::OGR::OFTInteger or |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1753
|
|
|
|
|
|
|
$type == $Geo::OGR::OFTInteger64 or |
1754
|
|
|
|
|
|
|
$type == $Geo::OGR::OFTReal or |
1755
|
|
|
|
|
|
|
$type == $Geo::OGR::OFTString or |
1756
|
|
|
|
|
|
|
$type == $Geo::OGR::OFTBinary) |
1757
|
|
|
|
|
|
|
{ |
1758
|
52
|
|
|
|
|
400
|
_SetField($self, $field, $_[0]); |
1759
|
|
|
|
|
|
|
} |
1760
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTIntegerList) { |
1761
|
13
|
|
|
|
|
82
|
SetFieldIntegerList($self, $field, $list); |
1762
|
|
|
|
|
|
|
} |
1763
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTInteger64List) { |
1764
|
0
|
|
|
|
|
0
|
SetFieldInteger64List($self, $field, $list); |
1765
|
|
|
|
|
|
|
} |
1766
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTRealList) { |
1767
|
13
|
|
|
|
|
86
|
SetFieldDoubleList($self, $field, $list); |
1768
|
|
|
|
|
|
|
} |
1769
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTStringList) { |
1770
|
13
|
|
|
|
|
96
|
SetFieldStringList($self, $field, $list); |
1771
|
|
|
|
|
|
|
} |
1772
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTDate) { |
1773
|
|
|
|
|
|
|
# year, month, day, hour, minute, second, timezone |
1774
|
1
|
|
|
|
|
5
|
for my $i (0..6) { |
1775
|
7
|
100
|
|
|
|
19
|
$list->[$i] = 0 unless defined $list->[$i]; |
1776
|
|
|
|
|
|
|
} |
1777
|
1
|
|
|
|
|
6
|
_SetField($self, $field, @$list[0..6]); |
1778
|
|
|
|
|
|
|
} |
1779
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTTime) { |
1780
|
1
|
50
|
|
|
|
5
|
$list->[3] = 0 unless defined $list->[3]; |
1781
|
1
|
|
|
|
|
9
|
_SetField($self, $field, 0, 0, 0, @$list[0..3]); |
1782
|
|
|
|
|
|
|
} |
1783
|
|
|
|
|
|
|
elsif ($type == $Geo::OGR::OFTDateTime) { |
1784
|
1
|
50
|
|
|
|
5
|
$list->[6] = 0 unless defined $list->[6]; |
1785
|
1
|
|
|
|
|
14
|
_SetField($self, $field, @$list[0..6]); |
1786
|
|
|
|
|
|
|
} |
1787
|
|
|
|
|
|
|
else { |
1788
|
0
|
|
|
|
|
0
|
confess "Perl bindings do not support field type '$Geo::OGR::FieldDefn::TYPE_INT2STRING{$type}'."; |
1789
|
|
|
|
|
|
|
} |
1790
|
|
|
|
|
|
|
} |
1791
|
|
|
|
|
|
|
|
1792
|
|
|
|
|
|
|
sub Field { |
1793
|
1
|
|
|
1
|
|
1088
|
my $self = shift; |
1794
|
1
|
|
|
|
|
2
|
my $field = shift; |
1795
|
1
|
50
|
|
|
|
5
|
$self->SetField($field, @_) if @_; |
1796
|
1
|
|
|
|
|
3
|
$self->GetField($field); |
1797
|
|
|
|
|
|
|
} |
1798
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
sub _GetGeomFieldIndex { |
1800
|
25
|
|
|
25
|
|
35
|
my($self, $field) = @_; |
1801
|
25
|
100
|
|
|
|
56
|
if (not defined $field) { |
1802
|
14
|
50
|
|
|
|
94
|
return 0 if $self->GetGeomFieldCount > 0; |
1803
|
11
|
50
|
|
|
|
40
|
} if ($field =~ /^\d+$/) { |
1804
|
11
|
50
|
33
|
|
|
87
|
return $field if $field >= 0 and $field < $self->GetGeomFieldCount; |
1805
|
|
|
|
|
|
|
} else { |
1806
|
0
|
|
|
|
|
0
|
for my $i (0..$self->GetGeomFieldCount-1) { |
1807
|
0
|
0
|
|
|
|
0
|
return $i if $self->GetGeomFieldDefn($i)->Name eq $field; |
1808
|
|
|
|
|
|
|
} |
1809
|
0
|
0
|
0
|
|
|
0
|
return 0 if $self->GetGeomFieldCount > 0 and $field eq 'Geometry'; |
1810
|
|
|
|
|
|
|
} |
1811
|
0
|
|
|
|
|
0
|
confess "No such field: '$field'."; |
1812
|
|
|
|
|
|
|
} |
1813
|
|
|
|
|
|
|
|
1814
|
|
|
|
|
|
|
sub Geometry { |
1815
|
25
|
|
|
25
|
|
3918
|
my $self = shift; |
1816
|
25
|
100
|
66
|
|
|
117
|
my $field = (ref($_[0]) eq '' or (@_ > 2 and @_ % 2 == 1)) ? shift : undef; |
1817
|
25
|
|
|
|
|
57
|
$field = $self->_GetGeomFieldIndex($field); |
1818
|
25
|
100
|
|
|
|
69
|
if (@_) { |
1819
|
17
|
|
|
|
|
52
|
my $type = $self->GetDefn->GetGeomFieldDefn($field)->Type; |
1820
|
17
|
|
|
|
|
52
|
my $geometry; |
1821
|
17
|
50
|
0
|
|
|
45
|
if (@_ == 1) { |
|
|
0
|
|
|
|
|
|
1822
|
17
|
|
|
|
|
25
|
$geometry = $_[0]; |
1823
|
|
|
|
|
|
|
} elsif (@_ and @_ % 2 == 0) { |
1824
|
0
|
|
|
|
|
0
|
%$geometry = @_; |
1825
|
|
|
|
|
|
|
} |
1826
|
17
|
100
|
66
|
|
|
118
|
if (blessed($geometry) and $geometry->isa('Geo::OGR::Geometry')) { |
|
|
50
|
|
|
|
|
|
1827
|
13
|
50
|
66
|
|
|
54
|
confess "The type of the inserted geometry ('".$geometry->GeometryType."') is not the field type ('$type')." |
1828
|
|
|
|
|
|
|
if $type ne 'Unknown' and $type ne $geometry->GeometryType; |
1829
|
13
|
|
|
|
|
24
|
eval { |
1830
|
13
|
|
|
|
|
87
|
$self->SetGeomFieldDirectly($field, $geometry); |
1831
|
|
|
|
|
|
|
}; |
1832
|
13
|
50
|
|
|
|
31
|
confess "$@" if $@; |
1833
|
13
|
|
|
|
|
17
|
$GEOMETRIES{tied(%{$geometry})} = $self; |
|
13
|
|
|
|
|
43
|
|
1834
|
|
|
|
|
|
|
} elsif (ref($geometry) eq 'HASH') { |
1835
|
4
|
50
|
|
|
|
15
|
$geometry->{GeometryType} = $type unless exists $geometry->{GeometryType}; |
1836
|
4
|
|
|
|
|
4
|
eval { |
1837
|
4
|
|
|
|
|
18
|
$geometry = Geo::OGR::Geometry->new($geometry); |
1838
|
|
|
|
|
|
|
}; |
1839
|
4
|
50
|
33
|
|
|
23
|
confess "The type of the inserted geometry ('".$geometry->GeometryType."') is not the field type ('$type')." |
1840
|
|
|
|
|
|
|
if $type ne 'Unknown' and $type ne $geometry->GeometryType; |
1841
|
4
|
|
|
|
|
7
|
eval { |
1842
|
4
|
|
|
|
|
32
|
$self->SetGeomFieldDirectly($field, $geometry); |
1843
|
|
|
|
|
|
|
}; |
1844
|
4
|
50
|
|
|
|
18
|
confess "$@" if $@; |
1845
|
|
|
|
|
|
|
} else { |
1846
|
0
|
|
|
|
|
0
|
confess "'@_' does not define a geometry."; |
1847
|
|
|
|
|
|
|
} |
1848
|
|
|
|
|
|
|
} |
1849
|
25
|
100
|
|
|
|
78
|
return unless defined wantarray; |
1850
|
8
|
|
|
|
|
43
|
my $geometry = $self->GetGeomFieldRef($field); |
1851
|
8
|
50
|
|
|
|
19
|
return unless $geometry; |
1852
|
8
|
|
|
|
|
10
|
$GEOMETRIES{tied(%{$geometry})} = $self; |
|
8
|
|
|
|
|
24
|
|
1853
|
8
|
|
|
|
|
24
|
return $geometry; |
1854
|
|
|
|
|
|
|
} |
1855
|
|
|
|
|
|
|
*GetGeometry = *Geometry; |
1856
|
|
|
|
|
|
|
*SetGeometry = *Geometry; |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
sub SetFrom { |
1859
|
0
|
|
|
0
|
|
0
|
my($self, $other) = @_; |
1860
|
0
|
0
|
|
|
|
0
|
_SetFrom($self, $other), return if @_ <= 2; |
1861
|
0
|
|
|
|
|
0
|
my $forgiving = $_[2]; |
1862
|
0
|
0
|
|
|
|
0
|
_SetFrom($self, $other, $forgiving), return if @_ <= 3; |
1863
|
0
|
|
|
|
|
0
|
my $map = $_[3]; |
1864
|
0
|
|
|
|
|
0
|
my @list; |
1865
|
0
|
|
|
|
|
0
|
for my $i (1..GetFieldCount($self)) { |
1866
|
0
|
|
0
|
|
|
0
|
push @list, ($map->{$i} || -1); |
1867
|
|
|
|
|
|
|
} |
1868
|
0
|
|
|
|
|
0
|
SetFromWithMap($self, $other, 1, \@list); |
1869
|
|
|
|
|
|
|
} |
1870
|
|
|
|
|
|
|
|
1871
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
|
1873
|
|
|
|
|
|
|
|
1874
|
|
|
|
|
|
|
package Geo::OGR::FieldDefn; |
1875
|
6
|
|
|
6
|
|
39
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
137
|
|
1876
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
281
|
|
1877
|
6
|
|
|
|
|
708
|
use vars qw / |
1878
|
|
|
|
|
|
|
%SCHEMA_KEYS |
1879
|
|
|
|
|
|
|
@TYPES @SUB_TYPES @JUSTIFY_VALUES |
1880
|
|
|
|
|
|
|
%TYPE_STRING2INT %TYPE_INT2STRING |
1881
|
|
|
|
|
|
|
%SUB_TYPE_STRING2INT %SUB_TYPE_INT2STRING |
1882
|
|
|
|
|
|
|
%JUSTIFY_STRING2INT %JUSTIFY_INT2STRING |
1883
|
6
|
|
|
6
|
|
33
|
/; |
|
6
|
|
|
|
|
12
|
|
1884
|
6
|
|
|
6
|
|
32
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
304
|
|
1885
|
6
|
|
|
6
|
|
29
|
use Encode; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
7245
|
|
1886
|
|
|
|
|
|
|
%SCHEMA_KEYS = map {$_ => 1} qw/Name Type SubType Justify Width Precision Nullable Default Ignored/; |
1887
|
|
|
|
|
|
|
for (keys %Geo::OGR::) { |
1888
|
|
|
|
|
|
|
push(@TYPES, $1), next if /^OFT(\w+)/; |
1889
|
|
|
|
|
|
|
push(@SUB_TYPES, $1), next if /^OFST(\w+)/; |
1890
|
|
|
|
|
|
|
push(@JUSTIFY_VALUES, $1), next if /^OJ(\w+)/; |
1891
|
|
|
|
|
|
|
} |
1892
|
|
|
|
|
|
|
for my $string (@TYPES) { |
1893
|
|
|
|
|
|
|
my $int = eval "\$Geo::OGR::OFT$string"; |
1894
|
|
|
|
|
|
|
$TYPE_STRING2INT{$string} = $int; |
1895
|
|
|
|
|
|
|
$TYPE_INT2STRING{$int} = $string; |
1896
|
|
|
|
|
|
|
} |
1897
|
|
|
|
|
|
|
for my $string (@SUB_TYPES) { |
1898
|
|
|
|
|
|
|
my $int = eval "\$Geo::OGR::OFST$string"; |
1899
|
|
|
|
|
|
|
$SUB_TYPE_STRING2INT{$string} = $int; |
1900
|
|
|
|
|
|
|
$SUB_TYPE_INT2STRING{$int} = $string; |
1901
|
|
|
|
|
|
|
} |
1902
|
|
|
|
|
|
|
for my $string (@JUSTIFY_VALUES) { |
1903
|
|
|
|
|
|
|
my $int = eval "\$Geo::OGR::OJ$string"; |
1904
|
|
|
|
|
|
|
$JUSTIFY_STRING2INT{$string} = $int; |
1905
|
|
|
|
|
|
|
$JUSTIFY_INT2STRING{$int} = $string; |
1906
|
|
|
|
|
|
|
} |
1907
|
|
|
|
|
|
|
|
1908
|
|
|
|
|
|
|
sub Types { |
1909
|
0
|
|
|
0
|
|
0
|
return @TYPES; |
1910
|
|
|
|
|
|
|
} |
1911
|
|
|
|
|
|
|
|
1912
|
|
|
|
|
|
|
sub SubTypes { |
1913
|
0
|
|
|
0
|
|
0
|
return @SUB_TYPES; |
1914
|
|
|
|
|
|
|
} |
1915
|
|
|
|
|
|
|
|
1916
|
|
|
|
|
|
|
sub JustifyValues { |
1917
|
0
|
|
|
0
|
|
0
|
return @JUSTIFY_VALUES; |
1918
|
|
|
|
|
|
|
} |
1919
|
|
|
|
|
|
|
|
1920
|
|
|
|
|
|
|
sub Schema { |
1921
|
108
|
|
|
108
|
|
151
|
my $self = shift; |
1922
|
108
|
100
|
|
|
|
245
|
if (@_) { |
1923
|
1
|
|
|
|
|
3
|
my %args = @_; |
1924
|
1
|
|
|
|
|
5
|
for my $key (keys %SCHEMA_KEYS) { |
1925
|
9
|
|
|
|
|
477
|
eval '$self->'.$key.'($args{'.$key.'}) if exists $args{'.$key.'}'; |
1926
|
9
|
50
|
|
|
|
33
|
croak $@ if $@; |
1927
|
|
|
|
|
|
|
} |
1928
|
|
|
|
|
|
|
} |
1929
|
108
|
100
|
|
|
|
283
|
return unless defined wantarray; |
1930
|
10
|
|
|
|
|
15
|
my %schema = (); |
1931
|
10
|
|
|
|
|
51
|
for my $key (keys %SCHEMA_KEYS) { |
1932
|
90
|
|
|
|
|
3961
|
$schema{$key} = eval '$self->'.$key; |
1933
|
|
|
|
|
|
|
} |
1934
|
10
|
50
|
|
|
|
44
|
return wantarray ? %schema : \%schema; |
1935
|
|
|
|
|
|
|
} |
1936
|
|
|
|
|
|
|
*GetSchema = *Schema; |
1937
|
|
|
|
|
|
|
*SetSchema = *Schema; |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
sub Name { |
1940
|
65
|
|
|
65
|
|
99
|
my $self = shift; |
1941
|
65
|
50
|
|
|
|
141
|
SetName($self, $_[0]) if @_; |
1942
|
65
|
50
|
|
|
|
517
|
GetName($self) if defined wantarray; |
1943
|
|
|
|
|
|
|
} |
1944
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
sub Type { |
1946
|
94
|
|
|
94
|
|
25130
|
my($self, $type) = @_; |
1947
|
94
|
50
|
|
|
|
260
|
if (defined $type) { |
1948
|
0
|
0
|
|
|
|
0
|
confess "Unknown field type: '$type'." unless exists $TYPE_STRING2INT{$type}; |
1949
|
0
|
|
|
|
|
0
|
$type = $TYPE_STRING2INT{$type}; |
1950
|
0
|
|
|
|
|
0
|
SetType($self, $type); |
1951
|
|
|
|
|
|
|
} |
1952
|
94
|
50
|
|
|
|
689
|
return $TYPE_INT2STRING{GetType($self)} if defined wantarray; |
1953
|
|
|
|
|
|
|
} |
1954
|
|
|
|
|
|
|
|
1955
|
|
|
|
|
|
|
sub SubType { |
1956
|
10
|
|
|
10
|
|
45
|
my($self, $sub_type) = @_; |
1957
|
10
|
50
|
|
|
|
25
|
if (defined $sub_type) { |
1958
|
0
|
0
|
|
|
|
0
|
confess "Unknown field sub type: '$sub_type'." unless exists $SUB_TYPE_STRING2INT{$sub_type}; |
1959
|
0
|
|
|
|
|
0
|
$sub_type = $SUB_TYPE_STRING2INT{$sub_type}; |
1960
|
0
|
|
|
|
|
0
|
SetSubType($self, $sub_type); |
1961
|
|
|
|
|
|
|
} |
1962
|
10
|
50
|
|
|
|
125
|
return $SUB_TYPE_INT2STRING{GetSubType($self)} if defined wantarray; |
1963
|
|
|
|
|
|
|
} |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
sub Justify { |
1966
|
10
|
|
|
10
|
|
14
|
my($self, $justify) = @_; |
1967
|
10
|
50
|
|
|
|
26
|
if (defined $justify) { |
1968
|
0
|
0
|
|
|
|
0
|
confess "Unknown justify value: '$justify'." unless exists $JUSTIFY_STRING2INT{$justify}; |
1969
|
0
|
0
|
|
|
|
0
|
$justify = $JUSTIFY_STRING2INT{$justify} if exists $JUSTIFY_STRING2INT{$justify}; |
1970
|
0
|
|
|
|
|
0
|
SetJustify($self, $justify); |
1971
|
|
|
|
|
|
|
} |
1972
|
10
|
50
|
|
|
|
130
|
return $JUSTIFY_INT2STRING{GetJustify($self)} if defined wantarray; |
1973
|
|
|
|
|
|
|
} |
1974
|
|
|
|
|
|
|
|
1975
|
|
|
|
|
|
|
sub Width { |
1976
|
11
|
|
|
11
|
|
21
|
my $self = shift; |
1977
|
11
|
100
|
|
|
|
28
|
SetWidth($self, $_[0]) if @_; |
1978
|
11
|
100
|
|
|
|
141
|
GetWidth($self) if defined wantarray; |
1979
|
|
|
|
|
|
|
} |
1980
|
|
|
|
|
|
|
|
1981
|
|
|
|
|
|
|
sub Precision { |
1982
|
10
|
|
|
10
|
|
18
|
my $self = shift; |
1983
|
10
|
50
|
|
|
|
24
|
SetPrecision($self, $_[0]) if @_; |
1984
|
10
|
50
|
|
|
|
120
|
GetPrecision($self) if defined wantarray; |
1985
|
|
|
|
|
|
|
} |
1986
|
|
|
|
|
|
|
|
1987
|
|
|
|
|
|
|
sub Nullable { |
1988
|
10
|
|
|
10
|
|
15
|
my $self = shift; |
1989
|
10
|
50
|
|
|
|
27
|
SetNullable($self, $_[0]) if @_; |
1990
|
10
|
50
|
|
|
|
531
|
IsNullable($self) if defined wantarray; |
1991
|
|
|
|
|
|
|
} |
1992
|
|
|
|
|
|
|
|
1993
|
|
|
|
|
|
|
sub Default { |
1994
|
10
|
|
|
10
|
|
18
|
my $self = shift; |
1995
|
10
|
50
|
|
|
|
25
|
SetDefault($self, $_[0]) if @_; |
1996
|
10
|
50
|
|
|
|
124
|
GetDefault($self) if defined wantarray; |
1997
|
|
|
|
|
|
|
} |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
sub Ignored { |
2000
|
10
|
|
|
10
|
|
17
|
my $self = shift; |
2001
|
10
|
50
|
|
|
|
27
|
SetIgnored($self, $_[0]) if @_; |
2002
|
10
|
50
|
|
|
|
121
|
IsIgnored($self) if defined wantarray; |
2003
|
|
|
|
|
|
|
} |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
|
2006
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
|
2008
|
|
|
|
|
|
|
package Geo::OGR::GeomFieldDefn; |
2009
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
136
|
|
2010
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
190
|
|
2011
|
6
|
|
|
6
|
|
40
|
use vars qw / %SCHEMA_KEYS /; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
213
|
|
2012
|
6
|
|
|
6
|
|
30
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
354
|
|
2013
|
6
|
|
|
6
|
|
31
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
3616
|
|
2014
|
|
|
|
|
|
|
%SCHEMA_KEYS = map {$_ => 1} qw/Name Type SpatialReference Nullable Ignored/; |
2015
|
|
|
|
|
|
|
|
2016
|
|
|
|
|
|
|
sub Schema { |
2017
|
5
|
|
|
5
|
|
11
|
my $self = shift; |
2018
|
5
|
50
|
|
|
|
15
|
if (@_) { |
2019
|
0
|
|
|
|
|
0
|
my %args = @_; |
2020
|
0
|
|
|
|
|
0
|
for my $key (keys %SCHEMA_KEYS) { |
2021
|
0
|
|
|
|
|
0
|
eval '$self->'.$key.'($args{'.$key.'}) if exists $args{'.$key.'}'; |
2022
|
0
|
0
|
|
|
|
0
|
croak $@ if $@; |
2023
|
|
|
|
|
|
|
} |
2024
|
|
|
|
|
|
|
} |
2025
|
5
|
100
|
|
|
|
15
|
return unless defined wantarray; |
2026
|
3
|
|
|
|
|
9
|
my %schema = (); |
2027
|
3
|
|
|
|
|
15
|
for my $key (keys %SCHEMA_KEYS) { |
2028
|
15
|
|
|
|
|
717
|
$schema{$key} = eval '$self->'.$key; |
2029
|
|
|
|
|
|
|
} |
2030
|
3
|
50
|
|
|
|
13
|
return wantarray ? %schema : \%schema; |
2031
|
|
|
|
|
|
|
} |
2032
|
|
|
|
|
|
|
*GetSchema = *Schema; |
2033
|
|
|
|
|
|
|
*SetSchema = *Schema; |
2034
|
|
|
|
|
|
|
|
2035
|
|
|
|
|
|
|
sub Name { |
2036
|
6
|
|
|
6
|
|
12
|
my $self = shift; |
2037
|
6
|
50
|
|
|
|
18
|
SetName($self, $_[0]) if @_; |
2038
|
6
|
50
|
|
|
|
67
|
GetName($self) if defined wantarray; |
2039
|
|
|
|
|
|
|
} |
2040
|
|
|
|
|
|
|
|
2041
|
|
|
|
|
|
|
sub Type { |
2042
|
20
|
|
|
20
|
|
39
|
my($self, $type) = @_; |
2043
|
20
|
50
|
|
|
|
47
|
if (defined $type) { |
2044
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2045
|
0
|
|
|
|
|
0
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2046
|
0
|
|
|
|
|
0
|
SetType($self, $type); |
2047
|
|
|
|
|
|
|
} |
2048
|
20
|
50
|
|
|
|
181
|
$Geo::OGR::Geometry::TYPE_INT2STRING{GetType($self)} if defined wantarray; |
2049
|
|
|
|
|
|
|
} |
2050
|
|
|
|
|
|
|
|
2051
|
|
|
|
|
|
|
sub Types { |
2052
|
0
|
|
|
0
|
|
0
|
return @Geo::OGR::Geometry::GEOMETRY_TYPES; |
2053
|
|
|
|
|
|
|
} |
2054
|
|
|
|
|
|
|
|
2055
|
|
|
|
|
|
|
sub SpatialReference { |
2056
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
2057
|
3
|
50
|
|
|
|
11
|
SetSpatialRef($self, $_[0]) if @_; |
2058
|
3
|
50
|
|
|
|
43
|
GetSpatialRef($self) if defined wantarray; |
2059
|
|
|
|
|
|
|
} |
2060
|
|
|
|
|
|
|
|
2061
|
|
|
|
|
|
|
sub Nullable { |
2062
|
3
|
|
|
3
|
|
8
|
my $self = shift; |
2063
|
3
|
50
|
|
|
|
8
|
SetNullable($self, $_[0]) if @_; |
2064
|
3
|
50
|
|
|
|
52
|
IsNullable($self) if defined wantarray; |
2065
|
|
|
|
|
|
|
} |
2066
|
|
|
|
|
|
|
|
2067
|
|
|
|
|
|
|
sub Ignored { |
2068
|
3
|
|
|
3
|
|
8
|
my $self = shift; |
2069
|
3
|
50
|
|
|
|
11
|
SetIgnored($self, $_[0]) if @_; |
2070
|
3
|
50
|
|
|
|
44
|
IsIgnored($self) if defined wantarray; |
2071
|
|
|
|
|
|
|
} |
2072
|
|
|
|
|
|
|
|
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
|
2075
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
package Geo::OGR::Geometry; |
2077
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
143
|
|
2078
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
173
|
|
2079
|
6
|
|
|
6
|
|
30
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
347
|
|
2080
|
6
|
|
|
|
|
19070
|
use vars qw / |
2081
|
|
|
|
|
|
|
@BYTE_ORDER_TYPES @GEOMETRY_TYPES |
2082
|
|
|
|
|
|
|
%BYTE_ORDER_STRING2INT %BYTE_ORDER_INT2STRING |
2083
|
|
|
|
|
|
|
%TYPE_STRING2INT %TYPE_INT2STRING |
2084
|
6
|
|
|
6
|
|
30
|
/; |
|
6
|
|
|
|
|
16
|
|
2085
|
|
|
|
|
|
|
@BYTE_ORDER_TYPES = qw/XDR NDR/; |
2086
|
|
|
|
|
|
|
for my $string (@BYTE_ORDER_TYPES) { |
2087
|
|
|
|
|
|
|
my $int = eval "\$Geo::OGR::wkb$string"; |
2088
|
|
|
|
|
|
|
$BYTE_ORDER_STRING2INT{$string} = $int; |
2089
|
|
|
|
|
|
|
$BYTE_ORDER_INT2STRING{$int} = $string; |
2090
|
|
|
|
|
|
|
} |
2091
|
|
|
|
|
|
|
for (keys %Geo::OGR::) { |
2092
|
|
|
|
|
|
|
next if /^wkb25/; |
2093
|
|
|
|
|
|
|
next if /^wkb.DR/; |
2094
|
|
|
|
|
|
|
push(@GEOMETRY_TYPES, $1), next if /^wkb(\w+)/; |
2095
|
|
|
|
|
|
|
} |
2096
|
|
|
|
|
|
|
for my $string (@GEOMETRY_TYPES) { |
2097
|
|
|
|
|
|
|
my $int = eval "\$Geo::OGR::wkb$string"; |
2098
|
|
|
|
|
|
|
$TYPE_STRING2INT{$string} = $int; |
2099
|
|
|
|
|
|
|
$TYPE_INT2STRING{$int} = $string; |
2100
|
|
|
|
|
|
|
} |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
sub ByteOrders { |
2103
|
0
|
|
|
0
|
|
0
|
return @BYTE_ORDER_TYPES; |
2104
|
|
|
|
|
|
|
} |
2105
|
|
|
|
|
|
|
|
2106
|
|
|
|
|
|
|
sub GeometryTypes { |
2107
|
0
|
|
|
0
|
|
0
|
return @GEOMETRY_TYPES; |
2108
|
|
|
|
|
|
|
} |
2109
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
sub RELEASE_PARENTS { |
2111
|
120
|
|
|
120
|
|
139
|
my $self = shift; |
2112
|
120
|
|
|
|
|
597
|
delete $Geo::OGR::Feature::GEOMETRIES{$self}; |
2113
|
|
|
|
|
|
|
} |
2114
|
|
|
|
|
|
|
|
2115
|
|
|
|
|
|
|
sub ApproximateArcAngles { |
2116
|
0
|
|
|
0
|
|
0
|
my %p = @_; |
2117
|
0
|
|
|
|
|
0
|
my %default = ( Center => [0,0,0], |
2118
|
|
|
|
|
|
|
PrimaryRadius => 1, |
2119
|
|
|
|
|
|
|
SecondaryAxis => 1, |
2120
|
|
|
|
|
|
|
Rotation => 0, |
2121
|
|
|
|
|
|
|
StartAngle => 0, |
2122
|
|
|
|
|
|
|
EndAngle => 360, |
2123
|
|
|
|
|
|
|
MaxAngleStepSizeDegrees => 4 |
2124
|
|
|
|
|
|
|
); |
2125
|
0
|
|
|
|
|
0
|
for my $p (keys %p) { |
2126
|
0
|
0
|
|
|
|
0
|
if (exists $default{$p}) { |
2127
|
0
|
0
|
|
|
|
0
|
$p{$p} = $default{$p} unless defined $p{$p}; |
2128
|
|
|
|
|
|
|
} else { |
2129
|
0
|
|
|
|
|
0
|
carp "Unknown named parameter: '$p'."; |
2130
|
|
|
|
|
|
|
} |
2131
|
|
|
|
|
|
|
} |
2132
|
0
|
|
|
|
|
0
|
for my $p (keys %default) { |
2133
|
0
|
0
|
|
|
|
0
|
$p{$p} = $default{$p} unless exists $p{$p}; |
2134
|
|
|
|
|
|
|
} |
2135
|
0
|
0
|
|
|
|
0
|
confess "Usage: Center => [x,y,z]." unless ref($p{Center}) eq 'ARRAY'; |
2136
|
0
|
|
|
|
|
0
|
for my $i (0..2) { |
2137
|
0
|
0
|
|
|
|
0
|
$p{Center}->[$i] = 0 unless defined $p{Center}->[$i]; |
2138
|
|
|
|
|
|
|
} |
2139
|
0
|
|
|
|
|
0
|
return Geo::OGR::ApproximateArcAngles($p{Center}->[0], $p{Center}->[1], $p{Center}->[2], $p{PrimaryRadius}, $p{SecondaryAxis}, $p{Rotation}, $p{StartAngle}, $p{EndAngle}, $p{MaxAngleStepSizeDegrees}); |
2140
|
|
|
|
|
|
|
} |
2141
|
|
|
|
|
|
|
|
2142
|
|
|
|
|
|
|
sub As { |
2143
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2144
|
0
|
|
|
|
|
0
|
my %param; |
2145
|
0
|
0
|
0
|
|
|
0
|
if (@_ == 1 and ref($_[0]) eq 'HASH') { |
|
|
0
|
|
|
|
|
|
2146
|
0
|
|
|
|
|
0
|
%param = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
2147
|
|
|
|
|
|
|
} elsif (@_ % 2 == 0) { |
2148
|
0
|
|
|
|
|
0
|
%param = @_; |
2149
|
|
|
|
|
|
|
} else { |
2150
|
0
|
|
|
|
|
0
|
($param{Format}, $param{x}) = @_; |
2151
|
|
|
|
|
|
|
} |
2152
|
0
|
0
|
|
|
|
0
|
$param{ByteOrder} = 'XDR' unless $param{ByteOrder}; |
2153
|
0
|
|
|
|
|
0
|
my $f = $param{Format}; |
2154
|
0
|
|
|
|
|
0
|
my $x = $param{x}; |
2155
|
0
|
0
|
|
|
|
0
|
$x = $param{ByteOrder} unless defined $x; |
2156
|
0
|
0
|
|
|
|
0
|
if ($f =~ /text/i) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2157
|
0
|
|
|
|
|
0
|
return $self->AsText; |
2158
|
|
|
|
|
|
|
} elsif ($f =~ /wkt/i) { |
2159
|
0
|
0
|
|
|
|
0
|
if ($f =~ /iso/i) { |
2160
|
0
|
|
|
|
|
0
|
return $self->ExportToIsoWkt; |
2161
|
|
|
|
|
|
|
} else { |
2162
|
0
|
|
|
|
|
0
|
return $self->AsText; |
2163
|
|
|
|
|
|
|
} |
2164
|
|
|
|
|
|
|
} elsif ($f =~ /binary/i) { |
2165
|
0
|
|
|
|
|
0
|
return $self->AsBinary($x); |
2166
|
|
|
|
|
|
|
} elsif ($f =~ /wkb/i) { |
2167
|
0
|
0
|
|
|
|
0
|
if ($f =~ /iso/i) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2168
|
0
|
|
|
|
|
0
|
return $self->ExportToIsoWkb; |
2169
|
|
|
|
|
|
|
} elsif ($f =~ /hexe/i) { |
2170
|
0
|
0
|
|
|
|
0
|
$param{srid} = 'XDR' unless $param{srid}; |
2171
|
0
|
0
|
|
|
|
0
|
$x = $param{srid} unless defined $x; |
2172
|
0
|
|
|
|
|
0
|
return $self->AsHEXEWKB($x); |
2173
|
|
|
|
|
|
|
} elsif ($f =~ /hex/i) { |
2174
|
0
|
|
|
|
|
0
|
return $self->AsHEXWKB; |
2175
|
|
|
|
|
|
|
} else { |
2176
|
0
|
|
|
|
|
0
|
return $self->AsBinary($x); |
2177
|
|
|
|
|
|
|
} |
2178
|
|
|
|
|
|
|
} elsif ($f =~ /gml/i) { |
2179
|
0
|
|
|
|
|
0
|
return $self->AsGML; |
2180
|
|
|
|
|
|
|
} elsif ($f =~ /kml/i) { |
2181
|
0
|
|
|
|
|
0
|
return $self->AsKML; |
2182
|
|
|
|
|
|
|
} elsif ($f =~ /json/i) { |
2183
|
0
|
|
|
|
|
0
|
return $self->AsJSON; |
2184
|
|
|
|
|
|
|
} else { |
2185
|
0
|
|
|
|
|
0
|
confess "Unsupported format: $f."; |
2186
|
|
|
|
|
|
|
} |
2187
|
|
|
|
|
|
|
} |
2188
|
|
|
|
|
|
|
|
2189
|
|
|
|
|
|
|
sub AsHEXWKB { |
2190
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
2191
|
0
|
|
|
|
|
0
|
my $wkb = _ExportToWkb($self, 1); |
2192
|
0
|
|
|
|
|
0
|
my $hex = ''; |
2193
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < length($wkb); $i++) { |
2194
|
0
|
|
|
|
|
0
|
my $x = sprintf("%x", ord(substr($wkb,$i,1))); |
2195
|
0
|
0
|
|
|
|
0
|
$x = '0' . $x if length($x) == 1; |
2196
|
0
|
|
|
|
|
0
|
$hex .= uc($x); |
2197
|
|
|
|
|
|
|
} |
2198
|
0
|
|
|
|
|
0
|
return $hex; |
2199
|
|
|
|
|
|
|
} |
2200
|
|
|
|
|
|
|
|
2201
|
|
|
|
|
|
|
sub AsHEXEWKB { |
2202
|
0
|
|
|
0
|
|
0
|
my ($self, $srid) = @_; |
2203
|
0
|
|
|
|
|
0
|
my $hex = AsHEXWKB($self); |
2204
|
0
|
0
|
|
|
|
0
|
if ($srid) { |
2205
|
0
|
|
|
|
|
0
|
my $s = sprintf("%x", $srid); |
2206
|
0
|
|
|
|
|
0
|
$srid = ''; |
2207
|
0
|
|
|
|
|
0
|
do { |
2208
|
0
|
0
|
|
|
|
0
|
if (length($s) > 2) { |
|
|
0
|
|
|
|
|
|
2209
|
0
|
|
|
|
|
0
|
$srid .= substr($s,-2,2); |
2210
|
0
|
|
|
|
|
0
|
substr($s,-2,2) = ''; |
2211
|
|
|
|
|
|
|
} elsif (length($s) > 1) { |
2212
|
0
|
|
|
|
|
0
|
$srid .= $s; |
2213
|
0
|
|
|
|
|
0
|
$s = ''; |
2214
|
|
|
|
|
|
|
} else { |
2215
|
0
|
|
|
|
|
0
|
$srid .= '0'.$s; |
2216
|
0
|
|
|
|
|
0
|
$s = ''; |
2217
|
|
|
|
|
|
|
} |
2218
|
|
|
|
|
|
|
} until $s eq ''; |
2219
|
|
|
|
|
|
|
} else { |
2220
|
0
|
|
|
|
|
0
|
$srid = '00000000'; |
2221
|
|
|
|
|
|
|
} |
2222
|
0
|
|
|
|
|
0
|
while (length($srid) < 8) { |
2223
|
0
|
|
|
|
|
0
|
$srid .= '00'; |
2224
|
|
|
|
|
|
|
} |
2225
|
0
|
|
|
|
|
0
|
substr($hex, 10, 0) = uc($srid); |
2226
|
0
|
|
|
|
|
0
|
return $hex; |
2227
|
|
|
|
|
|
|
} |
2228
|
|
|
|
|
|
|
|
2229
|
|
|
|
|
|
|
sub GeometryType { |
2230
|
21
|
|
|
21
|
|
969
|
my $self = shift; |
2231
|
21
|
|
|
|
|
167
|
return $TYPE_INT2STRING{$self->GetGeometryType}; |
2232
|
|
|
|
|
|
|
} |
2233
|
|
|
|
|
|
|
|
2234
|
|
|
|
|
|
|
sub CoordinateDimension { |
2235
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2236
|
0
|
0
|
|
|
|
0
|
SetCoordinateDimension($self, $_[0]) if @_; |
2237
|
0
|
0
|
|
|
|
0
|
GetCoordinateDimension($self) if defined wantarray; |
2238
|
|
|
|
|
|
|
} |
2239
|
|
|
|
|
|
|
|
2240
|
|
|
|
|
|
|
sub AddPoint { |
2241
|
21
|
100
|
|
21
|
|
254
|
@_ == 4 ? AddPoint_3D(@_) : AddPoint_2D(@_); |
2242
|
|
|
|
|
|
|
} |
2243
|
|
|
|
|
|
|
|
2244
|
|
|
|
|
|
|
sub SetPoint { |
2245
|
1
|
50
|
|
1
|
|
8
|
@_ == 5 ? SetPoint_3D(@_) : SetPoint_2D(@_); |
2246
|
|
|
|
|
|
|
} |
2247
|
|
|
|
|
|
|
|
2248
|
|
|
|
|
|
|
sub GetPoint { |
2249
|
16
|
|
|
16
|
|
77
|
my($self, $i) = @_; |
2250
|
16
|
100
|
|
|
|
36
|
$i = 0 unless defined $i; |
2251
|
16
|
50
|
|
|
|
95
|
my $point = ($self->GetGeometryType & 0x80000000) == 0 ? GetPoint_2D($self, $i) : GetPoint_3D($self, $i); |
2252
|
16
|
|
|
|
|
61
|
return @$point; |
2253
|
|
|
|
|
|
|
} |
2254
|
|
|
|
|
|
|
|
2255
|
|
|
|
|
|
|
sub Point { |
2256
|
2
|
|
|
2
|
|
12
|
my $self = shift; |
2257
|
2
|
|
|
|
|
4
|
my $i; |
2258
|
2
|
100
|
|
|
|
7
|
if (@_) { |
2259
|
1
|
|
|
|
|
5
|
my $t = $self->GetGeometryType; |
2260
|
1
|
50
|
|
|
|
4
|
if ($t == $Geo::OGR::wkbPoint) { |
|
|
0
|
|
|
|
|
|
2261
|
1
|
50
|
|
|
|
4
|
shift if @_ > 2; |
2262
|
1
|
|
|
|
|
2
|
$i = 0; |
2263
|
|
|
|
|
|
|
} elsif ($t == $Geo::OGR::wkbPoint25D) { |
2264
|
0
|
0
|
|
|
|
0
|
shift if @_ > 3; |
2265
|
0
|
|
|
|
|
0
|
$i = 0; |
2266
|
|
|
|
|
|
|
} else { |
2267
|
0
|
|
|
|
|
0
|
my $i = shift; |
2268
|
|
|
|
|
|
|
} |
2269
|
1
|
|
|
|
|
3
|
SetPoint($self, $i, @_); |
2270
|
|
|
|
|
|
|
} |
2271
|
2
|
100
|
|
|
|
8
|
return GetPoint($self, $i) if defined wantarray; |
2272
|
|
|
|
|
|
|
} |
2273
|
|
|
|
|
|
|
|
2274
|
|
|
|
|
|
|
sub Points { |
2275
|
9
|
|
|
9
|
|
803
|
my $self = shift; |
2276
|
9
|
|
|
|
|
32
|
my $t = $self->GetGeometryType; |
2277
|
9
|
|
|
|
|
25
|
my $flat = not Geo::OGR::GT_HasZ($t); |
2278
|
9
|
|
|
|
|
19
|
$t = Geo::OGR::GT_Flatten($t); |
2279
|
9
|
|
|
|
|
17
|
$t = $TYPE_INT2STRING{$t}; |
2280
|
9
|
|
|
|
|
12
|
my $points = shift; |
2281
|
9
|
100
|
|
|
|
22
|
if ($points) { |
2282
|
5
|
|
|
|
|
18
|
Empty($self); |
2283
|
5
|
50
|
33
|
|
|
49
|
if ($t eq 'Unknown' or $t eq 'None' or $t eq 'GeometryCollection') { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2284
|
0
|
|
|
|
|
0
|
confess "Can't set points of a geometry of type '$t'."; |
2285
|
|
|
|
|
|
|
} elsif ($t eq 'Point') { |
2286
|
|
|
|
|
|
|
# support both "Point" as a list of one point and one point |
2287
|
4
|
50
|
|
|
|
10
|
if (ref($points->[0])) { |
2288
|
|
|
|
|
|
|
$flat ? |
2289
|
0
|
|
|
|
|
0
|
AddPoint_2D($self, @{$points->[0]}[0..1]) : |
2290
|
0
|
0
|
|
|
|
0
|
AddPoint_3D($self, @{$points->[0]}[0..2]); |
|
0
|
|
|
|
|
0
|
|
2291
|
|
|
|
|
|
|
} else { |
2292
|
4
|
50
|
|
|
|
19
|
$flat ? |
2293
|
|
|
|
|
|
|
AddPoint_2D($self, @$points[0..1]) : |
2294
|
|
|
|
|
|
|
AddPoint_3D($self, @$points[0..2]); |
2295
|
|
|
|
|
|
|
} |
2296
|
|
|
|
|
|
|
} elsif ($t eq 'LineString' or $t eq 'LinearRing') { |
2297
|
1
|
50
|
|
|
|
3
|
if ($flat) { |
2298
|
1
|
|
|
|
|
5
|
for my $p (@$points) { |
2299
|
3
|
|
|
|
|
12
|
AddPoint_2D($self, @$p[0..1]); |
2300
|
|
|
|
|
|
|
} |
2301
|
|
|
|
|
|
|
} else{ |
2302
|
0
|
|
|
|
|
0
|
for my $p (@$points) { |
2303
|
0
|
|
|
|
|
0
|
AddPoint_3D($self, @$p[0..2]); |
2304
|
|
|
|
|
|
|
} |
2305
|
|
|
|
|
|
|
} |
2306
|
|
|
|
|
|
|
} elsif ($t eq 'Polygon') { |
2307
|
0
|
|
|
|
|
0
|
for my $r (@$points) { |
2308
|
0
|
|
|
|
|
0
|
my $ring = Geo::OGR::Geometry->new('LinearRing'); |
2309
|
0
|
0
|
|
|
|
0
|
$ring->SetCoordinateDimension(3) unless $flat; |
2310
|
0
|
|
|
|
|
0
|
$ring->Points($r); |
2311
|
0
|
|
|
|
|
0
|
$self->AddGeometryDirectly($ring); |
2312
|
|
|
|
|
|
|
} |
2313
|
|
|
|
|
|
|
} elsif ($t eq 'MultiPoint') { |
2314
|
0
|
|
|
|
|
0
|
for my $p (@$points) { |
2315
|
0
|
0
|
|
|
|
0
|
my $point = Geo::OGR::Geometry->new($flat ? 'Point' : 'Point25D'); |
2316
|
0
|
|
|
|
|
0
|
$point->Points($p); |
2317
|
0
|
|
|
|
|
0
|
$self->AddGeometryDirectly($point); |
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
} elsif ($t eq 'MultiLineString') { |
2320
|
0
|
|
|
|
|
0
|
for my $l (@$points) { |
2321
|
0
|
0
|
|
|
|
0
|
my $linestring = Geo::OGR::Geometry->new($flat ? 'LineString' : 'LineString25D'); |
2322
|
0
|
|
|
|
|
0
|
$linestring->Points($l); |
2323
|
0
|
|
|
|
|
0
|
$self->AddGeometryDirectly($linestring); |
2324
|
|
|
|
|
|
|
} |
2325
|
|
|
|
|
|
|
} elsif ($t eq 'MultiPolygon') { |
2326
|
0
|
|
|
|
|
0
|
for my $p (@$points) { |
2327
|
0
|
0
|
|
|
|
0
|
my $polygon = Geo::OGR::Geometry->new($flat ? 'Polygon' : 'Polygon25D'); |
2328
|
0
|
|
|
|
|
0
|
$polygon->Points($p); |
2329
|
0
|
|
|
|
|
0
|
$self->AddGeometryDirectly($polygon); |
2330
|
|
|
|
|
|
|
} |
2331
|
|
|
|
|
|
|
} |
2332
|
|
|
|
|
|
|
} |
2333
|
9
|
100
|
|
|
|
25
|
return unless defined wantarray; |
2334
|
4
|
|
|
|
|
14
|
$self->_GetPoints($flat); |
2335
|
|
|
|
|
|
|
} |
2336
|
|
|
|
|
|
|
|
2337
|
|
|
|
|
|
|
sub _GetPoints { |
2338
|
4
|
|
|
4
|
|
6
|
my($self, $flat) = @_; |
2339
|
4
|
|
|
|
|
6
|
my @points; |
2340
|
4
|
|
|
|
|
12
|
my $n = $self->GetGeometryCount; |
2341
|
4
|
50
|
|
|
|
8
|
if ($n) { |
2342
|
0
|
|
|
|
|
0
|
for my $i (0..$n-1) { |
2343
|
0
|
|
|
|
|
0
|
push @points, $self->GetGeometryRef($i)->_GetPoints($flat); |
2344
|
|
|
|
|
|
|
} |
2345
|
|
|
|
|
|
|
} else { |
2346
|
4
|
|
|
|
|
14
|
$n = $self->GetPointCount; |
2347
|
4
|
100
|
|
|
|
9
|
if ($n == 1) { |
2348
|
2
|
50
|
|
|
|
10
|
push @points, $flat ? GetPoint_2D($self) : GetPoint_3D($self); |
2349
|
|
|
|
|
|
|
} else { |
2350
|
2
|
|
|
|
|
3
|
my $i; |
2351
|
2
|
50
|
|
|
|
5
|
if ($flat) { |
2352
|
2
|
|
|
|
|
6
|
for my $i (0..$n-1) { |
2353
|
6
|
|
|
|
|
23
|
push @points, scalar GetPoint_2D($self, $i); |
2354
|
|
|
|
|
|
|
} |
2355
|
|
|
|
|
|
|
} else { |
2356
|
0
|
|
|
|
|
0
|
for my $i (0..$n-1) { |
2357
|
0
|
|
|
|
|
0
|
push @points, scalar GetPoint_3D($self, $i); |
2358
|
|
|
|
|
|
|
} |
2359
|
|
|
|
|
|
|
} |
2360
|
|
|
|
|
|
|
} |
2361
|
|
|
|
|
|
|
} |
2362
|
4
|
|
|
|
|
13
|
return \@points; |
2363
|
|
|
|
|
|
|
} |
2364
|
|
|
|
|
|
|
|
2365
|
|
|
|
|
|
|
sub ExportToWkb { |
2366
|
0
|
|
|
0
|
|
0
|
my($self, $bo) = @_; |
2367
|
0
|
0
|
|
|
|
0
|
if (defined $bo) { |
2368
|
0
|
0
|
|
|
|
0
|
confess "Unknown byte order: '$bo'." unless exists $BYTE_ORDER_STRING2INT{$bo}; |
2369
|
0
|
|
|
|
|
0
|
$bo = $BYTE_ORDER_STRING2INT{$bo}; |
2370
|
|
|
|
|
|
|
} |
2371
|
0
|
|
|
|
|
0
|
return _ExportToWkb($self, $bo); |
2372
|
|
|
|
|
|
|
} |
2373
|
|
|
|
|
|
|
|
2374
|
|
|
|
|
|
|
sub ForceTo { |
2375
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2376
|
0
|
|
|
|
|
0
|
my $type = shift; |
2377
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry type: '$type'." unless exists $TYPE_STRING2INT{$type}; |
2378
|
0
|
|
|
|
|
0
|
$type = $TYPE_STRING2INT{$type}; |
2379
|
0
|
|
|
|
|
0
|
eval { |
2380
|
0
|
|
|
|
|
0
|
$self = Geo::OGR::ForceTo($self, $type, @_); |
2381
|
|
|
|
|
|
|
}; |
2382
|
0
|
0
|
|
|
|
0
|
confess $@ if $@; |
2383
|
0
|
|
|
|
|
0
|
return $self; |
2384
|
|
|
|
|
|
|
} |
2385
|
|
|
|
|
|
|
|
2386
|
|
|
|
|
|
|
sub ForceToLineString { |
2387
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2388
|
0
|
|
|
|
|
0
|
$self = Geo::OGR::ForceToLineString($self); |
2389
|
0
|
|
|
|
|
0
|
return $self; |
2390
|
|
|
|
|
|
|
} |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
sub ForceToMultiPoint { |
2393
|
1
|
|
|
1
|
|
7
|
my $self = shift; |
2394
|
1
|
|
|
|
|
26
|
$self = Geo::OGR::ForceToMultiPoint($self); |
2395
|
1
|
|
|
|
|
9
|
for my $g (@_) { |
2396
|
1
|
|
|
|
|
8
|
$self->AddGeometry($g); |
2397
|
|
|
|
|
|
|
} |
2398
|
1
|
|
|
|
|
2
|
return $self; |
2399
|
|
|
|
|
|
|
} |
2400
|
|
|
|
|
|
|
|
2401
|
|
|
|
|
|
|
sub ForceToMultiLineString { |
2402
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
2403
|
1
|
|
|
|
|
23
|
$self = Geo::OGR::ForceToMultiLineString($self); |
2404
|
1
|
|
|
|
|
6
|
for my $g (@_) { |
2405
|
1
|
|
|
|
|
6
|
$self->AddGeometry($g); |
2406
|
|
|
|
|
|
|
} |
2407
|
1
|
|
|
|
|
3
|
return $self; |
2408
|
|
|
|
|
|
|
} |
2409
|
|
|
|
|
|
|
|
2410
|
|
|
|
|
|
|
sub ForceToMultiPolygon { |
2411
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
2412
|
1
|
|
|
|
|
17
|
$self = Geo::OGR::ForceToMultiPolygon($self); |
2413
|
1
|
|
|
|
|
5
|
for my $g (@_) { |
2414
|
1
|
|
|
|
|
7
|
$self->AddGeometry($g); |
2415
|
|
|
|
|
|
|
} |
2416
|
1
|
|
|
|
|
3
|
return $self; |
2417
|
|
|
|
|
|
|
} |
2418
|
|
|
|
|
|
|
|
2419
|
|
|
|
|
|
|
sub ForceToCollection { |
2420
|
1
|
|
|
1
|
|
4
|
my $self = Geo::OGR::Geometry->new(GeometryType => 'GeometryCollection'); |
2421
|
1
|
|
|
|
|
3
|
for my $g (@_) { |
2422
|
2
|
|
|
|
|
11
|
$self->AddGeometry($g); |
2423
|
|
|
|
|
|
|
} |
2424
|
1
|
|
|
|
|
3
|
return $self; |
2425
|
|
|
|
|
|
|
} |
2426
|
|
|
|
|
|
|
*Collect = *ForceToCollection; |
2427
|
|
|
|
|
|
|
|
2428
|
|
|
|
|
|
|
sub Dissolve { |
2429
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
2430
|
1
|
|
|
|
|
2
|
my @c; |
2431
|
1
|
|
|
|
|
9
|
my $n = $self->GetGeometryCount; |
2432
|
1
|
50
|
|
|
|
4
|
if ($n > 0) { |
2433
|
1
|
|
|
|
|
6
|
for my $i (0..$n-1) { |
2434
|
2
|
|
|
|
|
25
|
push @c, $self->GetGeometryRef($i)->Clone; |
2435
|
|
|
|
|
|
|
} |
2436
|
|
|
|
|
|
|
} else { |
2437
|
0
|
|
|
|
|
0
|
push @c, $self; |
2438
|
|
|
|
|
|
|
} |
2439
|
1
|
|
|
|
|
5
|
return @c; |
2440
|
|
|
|
|
|
|
} |
2441
|
|
|
|
|
|
|
*AsText = *ExportToWkt; |
2442
|
|
|
|
|
|
|
*AsBinary = *ExportToWkb; |
2443
|
|
|
|
|
|
|
*AsGML = *ExportToGML; |
2444
|
|
|
|
|
|
|
*AsKML = *ExportToKML; |
2445
|
|
|
|
|
|
|
*AsJSON = *ExportToJson; |
2446
|
|
|
|
|
|
|
*BuildPolygonFromEdges = *Geo::OGR::BuildPolygonFromEdges; |
2447
|
|
|
|
|
|
|
*ForceToPolygon = *Geo::OGR::ForceToPolygon; |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
package Geo::OGR; |
2451
|
6
|
|
|
6
|
|
38
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
136
|
|
2452
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
194
|
|
2453
|
6
|
|
|
6
|
|
42
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
7657
|
|
2454
|
|
|
|
|
|
|
|
2455
|
|
|
|
|
|
|
sub GeometryType { |
2456
|
55
|
|
|
55
|
0
|
10272
|
my($type_or_name) = @_; |
2457
|
55
|
100
|
|
|
|
104
|
if (defined $type_or_name) { |
2458
|
|
|
|
|
|
|
return $Geo::OGR::Geometry::TYPE_STRING2INT{$type_or_name} if |
2459
|
54
|
100
|
|
|
|
190
|
exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type_or_name}; |
2460
|
|
|
|
|
|
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{$type_or_name} if |
2461
|
27
|
50
|
|
|
|
102
|
exists $Geo::OGR::Geometry::TYPE_INT2STRING{$type_or_name}; |
2462
|
0
|
|
|
|
|
0
|
confess "Unknown geometry type: '$type_or_name'."; |
2463
|
|
|
|
|
|
|
} else { |
2464
|
1
|
|
|
|
|
13
|
return @Geo::OGR::Geometry::GEOMETRY_TYPES; |
2465
|
|
|
|
|
|
|
} |
2466
|
|
|
|
|
|
|
} |
2467
|
|
|
|
|
|
|
|
2468
|
|
|
|
|
|
|
sub GeometryTypeModify { |
2469
|
0
|
|
|
0
|
0
|
0
|
my($type, $modifier) = @_; |
2470
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2471
|
0
|
|
|
|
|
0
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2472
|
0
|
0
|
|
|
|
0
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_Flatten($type)} if $modifier =~ /flat/i; |
2473
|
0
|
0
|
|
|
|
0
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_SetZ($type)} if $modifier =~ /z/i; |
2474
|
0
|
0
|
|
|
|
0
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetCollection($type)} if $modifier =~ /collection/i; |
2475
|
0
|
0
|
|
|
|
0
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetCurve($type)} if $modifier =~ /curve/i; |
2476
|
0
|
0
|
|
|
|
0
|
return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetLinear($type)} if $modifier =~ /linear/i; |
2477
|
0
|
|
|
|
|
0
|
confess "Unknown geometry type modifier: '$modifier'."; |
2478
|
|
|
|
|
|
|
} |
2479
|
|
|
|
|
|
|
|
2480
|
|
|
|
|
|
|
sub GeometryTypeTest { |
2481
|
0
|
|
|
0
|
0
|
0
|
my($type, $test, $type2) = @_; |
2482
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry type: '$type'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2483
|
0
|
|
|
|
|
0
|
$type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type}; |
2484
|
0
|
0
|
|
|
|
0
|
if (defined $type2) { |
2485
|
0
|
0
|
|
|
|
0
|
confess "Unknown geometry type: '$type2'." unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type2}; |
2486
|
0
|
|
|
|
|
0
|
$type2 = $Geo::OGR::Geometry::TYPE_STRING2INT{$type2}; |
2487
|
|
|
|
|
|
|
} else { |
2488
|
0
|
0
|
|
|
|
0
|
confess "Usage: GeometryTypeTest(type1, 'is_subclass_of', type2)." if $test =~ /subclass/i; |
2489
|
|
|
|
|
|
|
} |
2490
|
0
|
0
|
|
|
|
0
|
return GT_HasZ($type) if $test =~ /z/i; |
2491
|
0
|
0
|
|
|
|
0
|
return GT_IsSubClassOf($type, $type2) if $test =~ /subclass/i; |
2492
|
0
|
0
|
|
|
|
0
|
return GT_IsCurve($type) if $test =~ /curve/i; |
2493
|
0
|
0
|
|
|
|
0
|
return GT_IsSurface($type) if $test =~ /surface/i; |
2494
|
0
|
0
|
|
|
|
0
|
return GT_IsNonLinear($type) if $test =~ /linear/i; |
2495
|
0
|
|
|
|
|
0
|
confess "Unknown geometry type test: '$test'."; |
2496
|
|
|
|
|
|
|
} |
2497
|
|
|
|
|
|
|
|
2498
|
|
|
|
678
|
0
|
|
sub RELEASE_PARENTS { |
2499
|
|
|
|
|
|
|
} |
2500
|
|
|
|
|
|
|
|
2501
|
|
|
|
|
|
|
*ByteOrders = *Geo::OGR::Geometry::ByteOrders; |
2502
|
|
|
|
|
|
|
*GeometryTypes = *Geo::OGR::Geometry::GeometryTypes; |
2503
|
|
|
|
|
|
|
|
2504
|
|
|
|
|
|
|
sub GetDriverNames { |
2505
|
0
|
|
|
0
|
0
|
0
|
my @names; |
2506
|
0
|
|
|
|
|
0
|
for my $i (0..GetDriverCount()-1) { |
2507
|
0
|
|
|
|
|
0
|
push @names, _GetDriver($i)->Name; |
2508
|
|
|
|
|
|
|
} |
2509
|
0
|
|
|
|
|
0
|
return @names; |
2510
|
|
|
|
|
|
|
} |
2511
|
|
|
|
|
|
|
|
2512
|
|
|
|
|
|
|
sub Drivers { |
2513
|
1
|
|
|
1
|
0
|
390
|
my @drivers; |
2514
|
1
|
|
|
|
|
103
|
for my $i (0..GetDriverCount()-1) { |
2515
|
44
|
|
|
|
|
2701
|
push @drivers, _GetDriver($i); |
2516
|
|
|
|
|
|
|
} |
2517
|
1
|
|
|
|
|
11
|
return @drivers; |
2518
|
|
|
|
|
|
|
} |
2519
|
|
|
|
|
|
|
|
2520
|
|
|
|
|
|
|
sub GetDriver { |
2521
|
4
|
|
|
4
|
0
|
12684
|
my($name) = @_; |
2522
|
4
|
50
|
|
|
|
40
|
$name = 0 unless defined $name; |
2523
|
4
|
|
|
|
|
15
|
my $driver; |
2524
|
4
|
50
|
|
|
|
31
|
$driver = _GetDriver($name) if $name =~ /^\d+$/; # is the name an index to driver list? |
2525
|
4
|
50
|
|
|
|
348
|
$driver = GetDriverByName("$name") unless $driver; |
2526
|
4
|
50
|
|
|
|
919
|
return $driver if $driver; |
2527
|
0
|
|
|
|
|
|
confess "Driver not found: '$name'. Maybe support for it was not built in?"; |
2528
|
|
|
|
|
|
|
} |
2529
|
|
|
|
|
|
|
*Driver = *GetDriver; |
2530
|
|
|
|
|
|
|
1; |