Geo::GDAL  2.1
all.pm
Go to the documentation of this file.
1 #** @class Geo::GDAL
2 # @brief GDAL utility functions and a root class for raster classes.
3 #
4 # Geo::GDAL wraps many GDAL utility functions and is as a root class
5 # for all GDAL raster classes. A "raster" is an object, whose core is
6 # a rectagular grid of cells, called a "band" in GDAL. Each cell
7 # contains a numeric value of a specific data type.
8 #*
9 package Geo::GDAL;
10 
11 #** @method BuildVRT()
12 #*
13 sub BuildVRT {
14  for (keys %Geo::GDAL::Const::) {
15  next if /TypeCount/;
16  push(@DATA_TYPES, $1), next if /^GDT_(\w+)/;
17  push(@OPEN_FLAGS, $1), next if /^OF_(\w+)/;
18  push(@RESAMPLING_TYPES, $1), next if /^GRA_(\w+)/;
19  push(@RIO_RESAMPLING_TYPES, $1), next if /^GRIORA_(\w+)/;
20  push(@NODE_TYPES, $1), next if /^CXT_(\w+)/;
21  }
22  for my $string (@DATA_TYPES) {
23  my $int = eval "\$Geo::GDAL::Const::GDT_$string";
24  $TYPE_STRING2INT{$string} = $int;
25  $TYPE_INT2STRING{$int} = $string;
26  }
27  for my $string (@OPEN_FLAGS) {
28  my $int = eval "\$Geo::GDAL::Const::OF_$string";
29  $OF_STRING2INT{$string} = $int;
30  }
31  for my $string (@RESAMPLING_TYPES) {
32  my $int = eval "\$Geo::GDAL::Const::GRA_$string";
33  $RESAMPLING_STRING2INT{$string} = $int;
34  $RESAMPLING_INT2STRING{$int} = $string;
35  }
36  for my $string (@RIO_RESAMPLING_TYPES) {
37  my $int = eval "\$Geo::GDAL::Const::GRIORA_$string";
38  $RIO_RESAMPLING_STRING2INT{$string} = $int;
39  $RIO_RESAMPLING_INT2STRING{$int} = $string;
40  }
41  for my $string (@NODE_TYPES) {
42  my $int = eval "\$Geo::GDAL::Const::CXT_$string";
43  $NODE_TYPE_STRING2INT{$string} = $int;
44  $NODE_TYPE_INT2STRING{$int} = $string;
45 }
46 
47 #** @method CPLBinaryToHex()
48 #*
49 sub CPLBinaryToHex {
50 }
51 
52 #** @method CPLHexToBinary()
53 #*
54 sub CPLHexToBinary {
55 }
56 
57 #** @method CreatePansharpenedVRT()
58 #*
59 sub CreatePansharpenedVRT {
60 }
61 
62 #** @method scalar DataTypeIsComplex($DataType)
63 # Package subroutine.
64 # @param DataType A GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
65 # @return true if the data type is a complex number.
66 #*
67 sub DataTypeIsComplex {
68  return _DataTypeIsComplex(string2int(shift, \%TYPE_STRING2INT));
69 }
70 
71 #** @method list DataTypeValueRange($DataType)
72 # Package subroutine.
73 # @param DataType Data type (one of those listed by Geo::GDAL::DataTypes).
74 # @note Some returned values are inaccurate.
75 #
76 # @return the minimum, maximum range of the data type.
77 #*
78 sub DataTypeValueRange {
79  my $t = shift;
80  Geo::GDAL::error(1, $t, \%TYPE_STRING2INT) unless exists $TYPE_STRING2INT{$t};
81  # these values are from gdalrasterband.cpp
82  return (0,255) if $t =~ /Byte/;
83  return (0,65535) if $t =~/UInt16/;
84  return (-32768,32767) if $t =~/Int16/;
85  return (0,4294967295) if $t =~/UInt32/;
86  return (-2147483648,2147483647) if $t =~/Int32/;
87  return (-4294967295.0,4294967295.0) if $t =~/Float32/;
88  return (-4294967295.0,4294967295.0) if $t =~/Float64/;
89 }
90 
91 #** @method list DataTypes()
92 # Package subroutine.
93 # @return a list of GDAL raster cell data types. These are currently:
94 # Byte, CFloat32, CFloat64, CInt16, CInt32, Float32, Float64, Int16, Int32, UInt16, UInt32, and Unknown.
95 #*
96 sub DataTypes {
97  return @DATA_TYPES;
98 }
99 
100 #** @method scalar DecToDMS($angle, $axis, $precision=2)
101 # Package subroutine.
102 # Convert decimal degrees to degrees, minutes, and seconds string
103 # @param angle A number
104 # @param axis A string specifying latitude or longitude ('Long').
105 # @param precision
106 # @return a string nndnn'nn.nn'"L where n is a number and L is either
107 # N or E
108 #*
109 sub DecToDMS {
110 }
111 
112 #** @method scalar DecToPackedDMS($dec)
113 # Package subroutine.
114 # @param dec Decimal degrees
115 # @return packed DMS, i.e., a number DDDMMMSSS.SS
116 #*
117 sub DecToPackedDMS {
118 }
119 
120 #** @method DontUseExceptions()
121 # Package subroutine.
122 # Do not use the Perl exception mechanism for GDAL messages. Instead
123 # the messages are printed to standard error.
124 #*
125 sub DontUseExceptions {
126 }
127 
128 #** @method Geo::GDAL::Driver Driver($Name)
129 # Package subroutine.
130 # Access a format driver.
131 # @param Name The short name of the driver. One of
132 # Geo::GDAL::DriverNames or Geo::OGR::DriverNames.
133 # @note This subroutine is imported into the main namespace if Geo::GDAL
134 # is used with qw/:all/.
135 # @return a Geo::GDAL::Driver object.
136 #*
137 sub Driver {
138  return 'Geo::GDAL::Driver' unless @_;
139  return GetDriver(@_);
140 }
141 
142 #** @method list DriverNames()
143 # Package subroutine.
144 # Available raster format drivers.
145 # @note Use Geo::OGR::DriverNames for vector drivers.
146 # @return a list of the short names of all available GDAL raster drivers.
147 #*
148 sub DriverNames {
149 }
150 
151 #** @method list Drivers()
152 # Package subroutine.
153 # @note Use Geo::OGR::Drivers for vector drivers.
154 # @return a list of all available GDAL raster drivers.
155 #*
156 sub Drivers {
157  my @drivers;
158  for my $i (0..GetDriverCount()-1) {
159  my $driver = GetDriver($i);
160  push @drivers, $driver if $driver->TestCapability('RASTER');
161  }
162  return @drivers;
163 }
164 
165 #** @method EscapeString()
166 #*
167 sub EscapeString {
168 }
169 
170 #** @method scalar FindFile($basename)
171 # Package subroutine.
172 # Search for GDAL support files.
173 #
174 # An example:
175 # \code
176 # use Geo::GDAL;
177 # $a = Geo::GDAL::FindFile('pcs.csv');
178 # print STDERR "$a\n";
179 # \endcode
180 # Prints (for example):
181 # \code
182 # c:\msys\1.0\local\share\gdal\pcs.csv
183 # \endcode
184 #
185 # @param basename The name of the file to search for. For example
186 # 'pcs.csv'.
187 # @return the path to the searched file or undef.
188 #*
189 sub FindFile {
190  if (@_ == 1) {
191  _FindFile('', @_);
192  } else {
193  _FindFile(@_);
194  }
195 }
196 
197 #** @method FinderClean()
198 # Package subroutine.
199 # Clear the set of support file search paths.
200 #*
201 sub FinderClean {
202 }
203 
204 #** @method GOA2GetAccessToken()
205 #*
206 sub GOA2GetAccessToken {
207 }
208 
209 #** @method GOA2GetAuthorizationURL()
210 #*
211 sub GOA2GetAuthorizationURL {
212 }
213 
214 #** @method GOA2GetRefreshToken()
215 #*
216 sub GOA2GetRefreshToken {
217 }
218 
219 #** @method scalar GetCacheMax()
220 # Package subroutine.
221 # @return maximum amount of memory (as bytes) for caching within GDAL.
222 #*
223 sub GetCacheMax {
224 }
225 
226 #** @method scalar GetCacheUsed()
227 # Package subroutine.
228 # @return the amount of memory currently used for caching within GDAL.
229 #*
230 sub GetCacheUsed {
231 }
232 
233 #** @method scalar GetConfigOption($key)
234 # Package subroutine.
235 # @param key A GDAL config option. Consult <a
236 # href="https://trac.osgeo.org/gdal/wiki/ConfigOptions">the GDAL
237 # documentation</a> for available options and their use.
238 # @return the value of the GDAL config option.
239 #*
240 sub GetConfigOption {
241 }
242 
243 #** @method scalar GetDataTypeSize($DataType)
244 # Package subroutine.
245 # @param DataType A GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
246 # @return the size as the number of bits.
247 #*
248 sub GetDataTypeSize {
249  return _GetDataTypeSize(string2int(shift, \%TYPE_STRING2INT, \%TYPE_INT2STRING));
250 }
251 
252 #** @method GetJPEG2000StructureAsString()
253 #*
254 sub GetJPEG2000StructureAsString {
255 }
256 
257 #** @method Geo::GDAL::Driver IdentifyDriver($path, $siblings)
258 # Package subroutine.
259 # @param path a dataset path.
260 # @param siblings [optional] A list of names of files that belong to the data format.
261 # @return a Geo::GDAL::Driver.
262 #*
263 sub IdentifyDriver {
264 }
265 
266 #** @method Geo::GDAL::Dataset Open(%params)
267 # Package subroutine.
268 # Open a dataset.
269 # An example, which opens an existing raster dataset for editing:
270 # \code
271 # use Geo::GDAL qw/:all/;
272 # $ds = Open(Name => 'existing.tiff', Access => 'Update');
273 # \endcode
274 # @param params Named parameters:
275 # - \a Name Dataset string (typically a filename). Default is '.'.
276 # - \a Access Access type, either 'ReadOnly' or 'Update'. Default is 'ReadOnly'.
277 # - \a Type Dataset type, either 'Raster', 'Vector', or 'Any'. Default is 'Any'.
278 # - \a Options A hash of GDAL open options passed to candidate drivers. Default is {}.
279 # - \a Files A list of names of files that are auxiliary to the main file. Default is [].
280 #
281 # @note This subroutine is imported into the main namespace if Geo::GDAL
282 # is use'd with qw/:all/.
283 #
284 # @note Some datasets / dataset strings do not explicitly imply the
285 # dataset type (for example a PostGIS database). If the type is not
286 # specified in such a case the returned dataset may be of either type.
287 #
288 # @return a new Geo::GDAL::Dataset object if success.
289 #*
290 sub Open {
291  my $p = Geo::GDAL::named_parameters(\@_, Name => '.', Access => 'ReadOnly', Type => 'Any', Options => {}, Files => []);
292  my @flags;
293  my %o = (READONLY => 1, UPDATE => 1);
294  Geo::GDAL::error(1, $p->{access}, \%o) unless $o{uc($p->{access})};
295  push @flags, uc($p->{access});
296  %o = (RASTER => 1, VECTOR => 1, ANY => 1);
297  Geo::GDAL::error(1, $p->{type}, \%o) unless $o{uc($p->{type})};
298  push @flags, uc($p->{type}) unless uc($p->{type}) eq 'ANY';
299  my $dataset = OpenEx(Name => $p->{name}, Flags => \@flags, Options => $p->{options}, Files => $p->{files});
300  unless ($dataset) {
301  my $t = "Failed to open $p->{name}.";
302  $t .= " Is it a ".lc($p->{type})." dataset?" unless uc($p->{type}) eq 'ANY';
303  error($t);
304  }
305  return $dataset;
306 }
307 
308 #** @method Geo::GDAL::Dataset OpenEx(%params)
309 # Package subroutine.
310 # The generic dataset open method, used internally by all Open and OpenShared methods.
311 # @param params Named parameters:
312 # - \a Name The name of the data set or source to open. (Default is '.')
313 # - \a Flags A list of access mode flags. Available flags are listed by Geo::GDAL::OpenFlags(). (Default is [])
314 # - \a Drivers A list of short names of drivers that may be used. Empty list means all. (Default is [])
315 # - \a Options A hash of GDAL open options passed to candidate drivers. (Default is {})
316 # - \a Files A list of names of files that are auxiliary to the main file. (Default is [])
317 #
318 # An example
319 # \code
320 # $ds = Geo::GDAL::OpenEx(Name => 'existing.tiff', Flags => [qw/RASTER UPDATE/]);
321 # \endcode
322 # @return a new Geo::GDAL::Dataset object.
323 #*
324 sub OpenEx {
325  my $p = Geo::GDAL::named_parameters(\@_, Name => '.', Flags => [], Drivers => [], Options => {}, Files => []);
326  unless ($p) {
327  my $name = shift // '';
328  my @flags = @_;
329  $p = {name => $name, flags => \@flags, drivers => [], options => {}, files => []};
330  }
331  if ($p->{flags}) {
332  my $f = 0;
333  for my $flag (@{$p->{flags}}) {
334  Geo::GDAL::error(1, $flag, \%OF_STRING2INT) unless exists $OF_STRING2INT{$flag};
335  $f |= $Geo::GDAL::OF_STRING2INT{$flag};
336  }
337  $p->{flags} = $f;
338  }
339  return _OpenEx($p->{name}, $p->{flags}, $p->{drivers}, $p->{options}, $p->{files});
340 }
341 
342 #** @method list OpenFlags()
343 # Package subroutine.
344 # @return a list of GDAL data set open modes. These are currently:
345 # ALL, GNM, RASTER, READONLY, SHARED, UPDATE, VECTOR, and VERBOSE_ERROR.
346 #*
347 sub OpenFlags {
348  return @DATA_TYPES;
349 }
350 
351 #** @method Geo::GDAL::Dataset OpenShared($name, $access = 'ReadOnly')
352 # Package subroutine.
353 # Open a raster dataset in shared mode.
354 # @param name Raster dataset string (typically a filename).
355 # @param access Access type, either 'ReadOnly' (the default) or 'Update'.
356 # @return a new Geo::GDAL::Dataset object or undef.
357 #*
358 sub OpenShared {
359  my @p = @_; # name, update
360  my @flags = qw/RASTER SHARED/;
361  $p[1] //= 'ReadOnly';
362  Geo::GDAL::error(1, $p[1], {ReadOnly => 1, Update => 1}) unless ($p[1] eq 'ReadOnly' or $p[1] eq 'Update');
363  push @flags, qw/READONLY/ if $p[1] eq 'ReadOnly';
364  push @flags, qw/UPDATE/ if $p[1] eq 'Update';
365  my $dataset = OpenEx($p[0], \@flags);
366  error("Failed to open $p[0]. Is it a raster dataset?") unless $dataset;
367  return $dataset;
368 }
369 
370 #** @method scalar PackCharacter($DataType)
371 # Package subroutine.
372 # Get the character that is needed for Perl's pack and unpack when
373 # they are used with Geo::GDAL::Band::ReadRaster and
374 # Geo::GDAL::Band::WriteRaster. Note that Geo::GDAL::Band::ReadTile
375 # and Geo::GDAL::Band::WriteTile have simpler interfaces that do not
376 # require pack and unpack.
377 # @param DataType A GDAL raster cell data type, typically from $band->DataType.
378 # @return a character which can be used in Perl's pack and unpack.
379 #*
380 sub PackCharacter {
381  my $t = shift;
382  $t = $TYPE_INT2STRING{$t} if exists $TYPE_INT2STRING{$t};
383  Geo::GDAL::error(1, $t, \%TYPE_STRING2INT) unless exists $TYPE_STRING2INT{$t};
384  my $is_big_endian = unpack("h*", pack("s", 1)) =~ /01/; # from Programming Perl
385  return 'C' if $t =~ /^Byte$/;
386  return ($is_big_endian ? 'n': 'v') if $t =~ /^UInt16$/;
387  return 's' if $t =~ /^Int16$/;
388  return ($is_big_endian ? 'N' : 'V') if $t =~ /^UInt32$/;
389  return 'l' if $t =~ /^Int32$/;
390  return 'f' if $t =~ /^Float32$/;
391  return 'd' if $t =~ /^Float64$/;
392 }
393 
394 #** @method scalar PackedDMSToDec($packed)
395 # Package subroutine.
396 # @param packed DMS as a number DDDMMMSSS.SS
397 # @return decimal degrees
398 #*
399 sub PackedDMSToDec {
400 }
401 
402 #** @method PopFinderLocation()
403 # Package subroutine.
404 # Remove the latest addition from the set of support file search
405 # paths. Note that calling this subroutine may remove paths GDAL put
406 # into the finder.
407 #*
408 sub PopFinderLocation {
409 }
410 
411 #** @method PushFinderLocation($path)
412 # Package subroutine.
413 # Add a path to the set of paths from where GDAL support files are
414 # sought. Note that GDAL puts initially into the finder the current
415 # directory and value of GDAL_DATA environment variable (if it
416 # exists), installation directory (prepended with '/share/gdal' or
417 # '/Resources/gdal'), or '/usr/local/share/gdal'. It is usually only
418 # needed to add paths to the finder if using an alternate set of data
419 # files or a non-installed GDAL is used (as in testing).
420 #*
421 sub PushFinderLocation {
422 }
423 
424 #** @method list RIOResamplingTypes()
425 # Package subroutine.
426 # @return a list of GDAL raster IO resampling methods. These are currently:
427 # Average, Bilinear, Cubic, CubicSpline, Gauss, Lanczos, Mode, and NearestNeighbour.
428 #*
429 sub RIOResamplingTypes {
430  return @RIO_RESAMPLING_TYPES;
431 }
432 
433 #** @method list ResamplingTypes()
434 # Package subroutine.
435 # @return a list of GDAL resampling methods. These are currently:
436 # Average, Bilinear, Cubic, CubicSpline, Lanczos, Mode, and NearestNeighbour.
437 #*
438 sub ResamplingTypes {
439  return @RESAMPLING_TYPES;
440 }
441 
442 #** @method SetCacheMax($Bytes)
443 # Package subroutine.
444 # @param Bytes New maximum amount of memory for caching within GDAL.
445 #*
446 sub SetCacheMax {
447 }
448 
449 #** @method SetConfigOption($key, $value)
450 # Package subroutine.
451 # @param key A GDAL config option. Consult <a
452 # href="https://trac.osgeo.org/gdal/wiki/ConfigOptions">the GDAL
453 # documentation</a> for available options and their use.
454 # @param value A value for the option, typically 'YES', 'NO',
455 # undef, path, numeric value, or a filename.
456 #*
457 sub SetConfigOption {
458 }
459 
460 #** @method UseExceptions()
461 # Package subroutine.
462 # Use the Perl exception mechanism for GDAL messages (failures are
463 # confessed and warnings are warned) and collect the messages
464 # into \@Geo::GDAL::error. This is the default.
465 #*
466 sub UseExceptions {
467 }
468 
469 #** @method VSIFOpenExL()
470 #*
471 sub VSIFOpenExL {
472 }
473 
474 #** @method VSIGetLastErrorMsg()
475 #*
476 sub VSIGetLastErrorMsg {
477 }
478 
479 #** @method VSIGetLastErrorNo()
480 #*
481 sub VSIGetLastErrorNo {
482 }
483 
484 #** @method scalar VersionInfo($request = 'VERSION_NUM')
485 # Package subroutine.
486 # @param request A string specifying the request. Currently either
487 # "VERSION_NUM", "RELEASE_DATE", "RELEASE_NAME", or
488 # "--version". Default is "VERSION_NUM".
489 # @return Requested information.
490 #*
491 sub VersionInfo {
492 }
493 
494 #** @method scalar errstr()
495 # Package subroutine.
496 # Clear the error stack and return all generated GDAL error messages in one (possibly multiline) string.
497 # @return the chomped error stack joined with newlines.
498 #*
499 sub errstr {
500  my @stack = @error;
501  chomp(@stack);
502  @error = ();
503  return join("\n", @stack);
504 }
505 # usage: named_parameters(\@_, key value list of default parameters);
506 # returns parameters in a hash with low-case-without-_ keys
507 }
508 
509 #** @class Geo::GDAL::AsyncReader
510 # @brief Enable asynchronous requests.
511 # @todo Test and document.
512 #
513 # This class is not yet documented nor tested in the GDAL Perl wrappers
514 #*
515 package Geo::GDAL::AsyncReader;
516 
517 use base qw(Geo::GDAL)
518 
519 #** @method GetNextUpdatedRegion()
520 #*
521 sub GetNextUpdatedRegion {
522 }
523 
524 #** @method LockBuffer()
525 #*
526 sub LockBuffer {
527 }
528 
529 #** @method UnlockBuffer()
530 #*
531 sub UnlockBuffer {
532 }
533 
534 #** @class Geo::GDAL::Band
535 # @brief A raster band.
536 #*
537 package Geo::GDAL::Band;
538 
540 
541 #** @attr $XSize
542 # Object attribute.
543 # scalar (access as $band->{XSize})
544 #*
545 
546 #** @attr $YSize
547 # Object attribute.
548 # scalar (access as $band->{YSize})
549 #*
550 
551 #** @method Geo::GDAL::RasterAttributeTable AttributeTable($AttributeTable)
552 # Object method.
553 # @param AttributeTable [optional] A Geo::GDAL::RasterAttributeTable object.
554 # @return a new Geo::GDAL::RasterAttributeTable object, whose data is
555 # contained within the band.
556 #*
557 sub AttributeTable {
558  my $self = shift;
559  SetDefaultRAT($self, $_[0]) if @_ and defined $_[0];
560  return unless defined wantarray;
561  my $r = GetDefaultRAT($self);
562  $RATS{tied(%$r)} = $self if $r;
563  return $r;
564 }
565 
566 #** @method list CategoryNames(@names)
567 # Object method.
568 # @param names [optional]
569 # @return
570 #*
571 sub CategoryNames {
572  my $self = shift;
573  SetRasterCategoryNames($self, \@_) if @_;
574  return unless defined wantarray;
575  my $n = GetRasterCategoryNames($self);
576  return @$n;
577 }
578 
579 #** @method scalar Checksum($xoff = 0, $yoff = 0, $xsize = undef, $ysize = undef)
580 # Object method.
581 # Computes a checksum from the raster or a part of it.
582 # @param xoff
583 # @param yoff
584 # @param xsize
585 # @param ysize
586 # @return the checksum.
587 #*
588 sub Checksum {
589 }
590 
591 #** @method scalar ColorInterpretation($color_interpretation)
592 # Object method.
593 # @note a.k.a. GetRasterColorInterpretation and GetColorInterpretation
594 # (get only and returns an integer), SetRasterColorInterpretation and
595 # SetColorInterpretation (set only and requires an integer)
596 # @param color_interpretation [optional] new color interpretation, one
597 # of Geo::GDAL::Band::ColorInterpretations.
598 # @return The color interpretation of this band. One of Geo::GDAL::Band::ColorInterpretations.
599 #*
600 sub ColorInterpretation {
601  my($self, $ci) = @_;
602  if (defined $ci) {
603  $ci = Geo::GDAL::string2int($ci, \%COLOR_INTERPRETATION_STRING2INT);
604  SetRasterColorInterpretation($self, $ci);
605  }
606  return unless defined wantarray;
607  $COLOR_INTERPRETATION_INT2STRING{GetRasterColorInterpretation($self)};
608 }
609 
610 #** @method ColorInterpretations()
611 # Package subroutine.
612 # @return a list of types of color interpretation for raster
613 # bands. These are currently:
614 # AlphaBand, BlackBand, BlueBand, CyanBand, GrayIndex, GreenBand, HueBand, LightnessBand, MagentaBand, PaletteIndex, RedBand, SaturationBand, Undefined, YCbCr_CbBand, YCbCr_CrBand, YCbCr_YBand, and YellowBand.
615 #*
616 sub ColorInterpretations {
617  return @COLOR_INTERPRETATIONS;
618 }
619 
620 #** @method Geo::GDAL::ColorTable ColorTable($ColorTable)
621 # Object method.
622 # Get or set the color table of this band.
623 # @param ColorTable [optional] a Geo::GDAL::ColorTable object
624 # @return A new Geo::GDAL::ColorTable object which represents the
625 # internal color table associated with this band. Returns undef this
626 # band does not have an associated color table.
627 #*
628 sub ColorTable {
629  my $self = shift;
630  SetRasterColorTable($self, $_[0]) if @_ and defined $_[0];
631  return unless defined wantarray;
632  GetRasterColorTable($self);
633 }
634 
635 #** @method ComputeBandStats($samplestep = 1)
636 # Object method.
637 # @param samplestep the row increment in computing the statistics.
638 # @note Returns uncorrected sample standard deviation.
639 #
640 # See also Geo::GDAL::Band::ComputeStatistics.
641 # @return a list (mean, stddev).
642 #*
643 sub ComputeBandStats {
644 }
645 
646 #** @method ComputeRasterMinMax($approx_ok = 0)
647 # Object method.
648 # @return arrayref MinMax = [min, max]
649 #*
650 sub ComputeRasterMinMax {
651 }
652 
653 #** @method list ComputeStatistics($approx_ok, $progress = undef, $progress_data = undef)
654 # Object method.
655 # @param approx_ok Whether it is allowed to compute the statistics
656 # based on overviews or similar.
657 # @note Returns uncorrected sample standard deviation.
658 #
659 # See also Geo::GDAL::Band::ComputeBandStats.
660 # @return a list ($min, $max, $mean, $stddev).
661 #*
662 sub ComputeStatistics {
663 }
664 
665 #** @method Geo::OGR::Layer Contours($DataSource, hashref LayerConstructor, $ContourInterval, $ContourBase, arrayref FixedLevels, $NoDataValue, $IDField, $ElevField, coderef Progress, $ProgressData)
666 # Object method.
667 # Generate contours for this raster band. This method can also be used with named parameters.
668 # @note This method is a wrapper for ContourGenerate.
669 #
670 # An example:
671 # \code
672 # use Geo::GDAL;
673 # $dem = Geo::GDAL::Open('dem.gtiff');
674 # $contours = $dem->Band->Contours(ContourInterval => 10, ElevField => 'z');
675 # $n = $contours->GetFeatureCount;
676 # \endcode
677 #
678 # @param DataSource a Geo::OGR::DataSource object, default is a Memory data source
679 # @param LayerConstructor data for Geo::OGR::DataSource::CreateLayer, default is {Name => 'contours'}
680 # @param ContourInterval default is 100
681 # @param ContourBase default is 0
682 # @param FixedLevels a reference to a list of fixed contour levels, default is []
683 # @param NoDataValue default is undef
684 # @param IDField default is '', i.e., no field (the field is created if this is given)
685 # @param ElevField default is '', i.e., no field (the field is created if this is given)
686 # @param progress [optional] a reference to a subroutine, which will
687 # be called with parameters (number progress, string msg, progress_data)
688 # @param progress_data [optional]
689 # @return
690 #*
691 sub Contours {
692  my $self = shift;
693  my $p = Geo::GDAL::named_parameters(\@_,
694  DataSource => undef,
695  LayerConstructor => {Name => 'contours'},
696  ContourInterval => 100,
697  ContourBase => 0,
698  FixedLevels => [],
699  NoDataValue => undef,
700  IDField => -1,
701  ElevField => -1,
702  Progress => undef,
703  ProgressData => undef);
704  $p->{datasource} //= Geo::OGR::GetDriver('Memory')->CreateDataSource('ds');
705  $p->{layerconstructor}->{Schema} //= {};
706  $p->{layerconstructor}->{Schema}{Fields} //= [];
707  my %fields;
708  unless ($p->{idfield} =~ /^[+-]?\d+$/ or $fields{$p->{idfield}}) {
709  push @{$p->{layerconstructor}->{Schema}{Fields}}, {Name => $p->{idfield}, Type => 'Integer'};
710  }
711  unless ($p->{elevfield} =~ /^[+-]?\d+$/ or $fields{$p->{elevfield}}) {
712  my $type = $self->DataType() =~ /Float/ ? 'Real' : 'Integer';
713  push @{$p->{layerconstructor}->{Schema}{Fields}}, {Name => $p->{elevfield}, Type => $type};
714  }
715  my $layer = $p->{datasource}->CreateLayer($p->{layerconstructor});
716  my $schema = $layer->GetLayerDefn;
717  for ('idfield', 'elevfield') {
718  $p->{$_} = $schema->GetFieldIndex($p->{$_}) unless $p->{$_} =~ /^[+-]?\d+$/;
719  }
720  $p->{progressdata} = 1 if $p->{progress} and not defined $p->{progressdata};
721  ContourGenerate($self, $p->{contourinterval}, $p->{contourbase}, $p->{fixedlevels},
722  $p->{nodatavalue}, $layer, $p->{idfield}, $p->{elevfield},
723  $p->{progress}, $p->{progressdata});
724  return $layer;
725 }
726 
727 #** @method CreateMaskBand(@flags)
728 # Object method.
729 # @note May invalidate any previous mask band obtained with Geo::GDAL::Band::GetMaskBand.
730 #
731 # @param flags one or more mask flags. The flags are Geo::GDAL::Band::MaskFlags.
732 #*
733 sub CreateMaskBand {
734  my $self = shift;
735  my $f = 0;
736  if (@_ and $_[0] =~ /^\d$/) {
737  $f = shift;
738  } else {
739  for my $flag (@_) {
740  carp "Unknown mask flag: '$flag'." unless $MASK_FLAGS{$flag};
741  $f |= $MASK_FLAGS{$flag};
742  }
743  }
744  $self->_CreateMaskBand($f);
745 }
746 
747 #** @method scalar DataType()
748 # Object method.
749 # @return The data type of this band. One of Geo::GDAL::DataTypes.
750 #*
751 sub DataType {
752  my $self = shift;
753  return $Geo::GDAL::TYPE_INT2STRING{$self->{DataType}};
754 }
755 
756 #** @method Geo::GDAL::Dataset Dataset()
757 # Object method.
758 # @return The dataset which this band belongs to.
759 #*
760 sub Dataset {
761  my $self = shift;
762  return $Geo::GDAL::Dataset::BANDS{tied(%{$self})};
763 }
764 
765 #** @method scalar DeleteNoDataValue()
766 # Object method.
767 #*
768 sub DeleteNoDataValue {
769 }
770 
771 #** @method Geo::GDAL::Band Distance(%params)
772 # Object method.
773 # Compute distances to specific cells of this raster.
774 # @param params Named parameters:
775 # - \a Distance A raster band, into which the distances are computed. If not given, a not given, a new in-memory raster band is created and returned. The data type of the raster can be given in the options.
776 # - \a Options Hash of options. Options are:
777 # - \a Values A list of cell values in this band to measure the distance from. If this option is not provided, the distance will be computed to non-zero pixel values. Currently pixel values are internally processed as integers.
778 # - \a DistUnits=PIXEL|GEO Indicates whether distances will be computed in cells or in georeferenced units. The default is pixel units. This also determines the interpretation of MaxDist.
779 # - \a MaxDist=n The maximum distance to search. Distances greater than this value will not be computed. Instead output cells will be set to a nodata value.
780 # - \a NoData=n The nodata value to use on the distance band for cells that are beyond MaxDist. If not provided, the distance band will be queried for a nodata value. If one is not found, 65535 will be used (255 if the type is Byte).
781 # - \a Use_Input_NoData=YES|NO If this option is set, the nodata value of this band will be respected. Leaving nodata cells in the input as nodata pixels in the distance raster.
782 # - \a Fixed_Buf_Val=n If this option is set, all cells within the MaxDist threshold are set to this value instead of the distance value.
783 # - \a DataType The data type for the result if it is not given.
784 # - \a Progress Progress function.
785 # - \a ProgressData Additional parameter for the progress function.
786 #
787 # @note This GDAL function behind this API is called GDALComputeProximity.
788 #
789 # @return The distance raster.
790 #*
791 sub Distance {
792  my $self = shift;
793  my $p = Geo::GDAL::named_parameters(\@_, Distance => undef, Options => undef, Progress => undef, ProgressData => undef);
794  for my $key (keys %{$p->{options}}) {
795  $p->{options}{uc($key)} = $p->{options}{$key};
796  }
797  $p->{options}{TYPE} //= $p->{options}{DATATYPE} //= 'Float32';
798  unless ($p->{distance}) {
799  my ($w, $h) = $self->Size;
800  $p->{distance} = Geo::GDAL::Driver('MEM')->Create(Name => 'distance', Width => $w, Height => $h, Type => $p->{options}{TYPE})->Band;
801  }
802  Geo::GDAL::ComputeProximity($self, $p->{distance}, $p->{options}, $p->{progress}, $p->{progressdata});
803  return $p->{distance};
804 }
805 
806 #** @method Domains()
807 #*
808 sub Domains {
809  return @DOMAINS;
810 }
811 
812 #** @method Fill($real_part, $imag_part = 0.0)
813 # Object method.
814 # Fill the band with a constant value.
815 # @param real_part Real component of fill value.
816 # @param imag_part Imaginary component of fill value.
817 #
818 #*
819 sub Fill {
820 }
821 
822 #** @method FillNoData($mask, $max_search_dist, $smoothing_iterations, $options, coderef progress, $progress_data)
823 # Object method.
824 # Interpolate values for cells in this raster. The cells to fill
825 # should be marked in the mask band with zero.
826 #
827 # @param mask [optional] a mask band indicating cells to be interpolated (zero valued) (default is to get it with Geo::GDAL::Band::GetMaskBand).
828 # @param max_search_dist [optional] the maximum number of cells to
829 # search in all directions to find values to interpolate from (default is 10).
830 # @param smoothing_iterations [optional] the number of 3x3 smoothing filter passes to run (0 or more) (default is 0).
831 # @param options [optional] A reference to a hash. No options have been defined so far for this algorithm (default is {}).
832 # @param progress [optional] a reference to a subroutine, which will
833 # be called with parameters (number progress, string msg, progress_data) (default is undef).
834 # @param progress_data [optional] (default is undef).
835 #
836 # <a href="http://www.gdal.org/gdal__alg_8h.html">Documentation for GDAL algorithms</a>
837 #*
838 sub FillNoData {
839 }
840 
841 #** @method FlushCache()
842 # Object method.
843 # Write cached data to disk. There is usually no need to call this
844 # method.
845 #*
846 sub FlushCache {
847 }
848 
849 #** @method scalar GetBandNumber()
850 # Object method.
851 # @return The index of this band in the parent dataset list of bands.
852 #*
853 sub GetBandNumber {
854 }
855 
856 #** @method list GetBlockSize()
857 # Object method.
858 # @return The size of a preferred i/o raster blocks as a list (width,
859 # height).
860 #*
861 sub GetBlockSize {
862 }
863 
864 #** @method list GetDefaultHistogram($force = 1, coderef progress = undef, $progress_data = undef)
865 # Object method.
866 # @param force true to force the computation
867 # @param progress [optional] a reference to a subroutine, which will
868 # be called with parameters (number progress, string msg, progress_data)
869 # @param progress_data [optional]
870 # @note See Note in Geo::GDAL::Band::GetHistogram.
871 # @return a list: ($min, $max, arrayref histogram).
872 #*
873 sub GetDefaultHistogram {
874 }
875 
876 #** @method list GetHistogram(%parameters)
877 # Object method.
878 # Compute histogram from the raster.
879 # @param parameters Named parameters:
880 # - \a Min the lower bound, default is -0.5
881 # - \a Max the upper bound, default is 255.5
882 # - \a Buckets the number of buckets in the histogram, default is 256
883 # - \a IncludeOutOfRange whether to use the first and last values in the returned list
884 # for out of range values, default is false;
885 # the bucket size is (Max-Min) / Buckets if this is false and
886 # (Max-Min) / (Buckets-2) if this is true
887 # - \a ApproxOK if histogram can be computed from overviews, default is false
888 # - \a Progress an optional progress function, the default is undef
889 # - \a ProgressData data for the progress function, the default is undef
890 # @note Histogram counts are treated as strings in the bindings to be
891 # able to use large integers (if GUIntBig is larger than Perl IV). In
892 # practice this is only important if you have a 32 bit machine and
893 # very large bucket counts. In those cases it may also be necessary to
894 # use Math::BigInt.
895 # @return a list which contains the count of values in each bucket
896 #*
897 sub GetHistogram {
898  my $self = shift;
899  my $p = Geo::GDAL::named_parameters(\@_,
900  Min => -0.5,
901  Max => 255.5,
902  Buckets => 256,
903  IncludeOutOfRange => 0,
904  ApproxOK => 0,
905  Progress => undef,
906  ProgressData => undef);
907  $p->{progressdata} = 1 if $p->{progress} and not defined $p->{progressdata};
908  _GetHistogram($self, $p->{min}, $p->{max}, $p->{buckets},
909  $p->{includeoutofrange}, $p->{approxok},
910  $p->{progress}, $p->{progressdata});
911 }
912 
913 #** @method Geo::GDAL::Band GetMaskBand()
914 # Object method.
915 # @return the mask band associated with this
916 # band.
917 #*
918 sub GetMaskBand {
919  my $self = shift;
920  my $band = _GetMaskBand($self);
921  $Geo::GDAL::Dataset::BANDS{tied(%{$band})} = $self;
922  return $band;
923 }
924 
925 #** @method list GetMaskFlags()
926 # Object method.
927 # @return the mask flags of the mask band associated with this
928 # band. The flags are one or more of Geo::GDAL::Band::MaskFlags.
929 #*
930 sub GetMaskFlags {
931  my $self = shift;
932  my $f = $self->_GetMaskFlags;
933  my @f;
934  for my $flag (keys %MASK_FLAGS) {
935  push @f, $flag if $f & $MASK_FLAGS{$flag};
936  }
937  return wantarray ? @f : $f;
938 }
939 
940 #** @method scalar GetMaximum()
941 # Object method.
942 # @note Call Geo::GDAL::Band::ComputeStatistics before calling
943 # GetMaximum to make sure the value is computed.
944 #
945 # @return statistical minimum of the band or undef if statistics are
946 # not kept or computed in scalar context. In list context returns the
947 # maximum value or a (kind of) maximum value supported by the data
948 # type and a boolean value, which indicates which is the case (true is
949 # first, false is second).
950 #*
951 sub GetMaximum {
952 }
953 
954 #** @method scalar GetMinimum()
955 # Object method.
956 # @note Call Geo::GDAL::Band::ComputeStatistics before calling
957 # GetMinimum to make sure the value is computed.
958 #
959 # @return statistical minimum of the band or undef if statistics are
960 # not kept or computed in scalar context. In list context returns the
961 # minimum value or a (kind of) minimum value supported by the data
962 # type and a boolean value, which indicates which is the case (true is
963 # first, false is second).
964 #*
965 sub GetMinimum {
966 }
967 
968 #** @method Geo::GDAL::Band GetOverview($index)
969 # Object method.
970 # @param index 0..GetOverviewCount-1
971 # @return a Geo::GDAL::Band object, which represents the internal
972 # overview band, or undef. if the index is out of bounds.
973 #*
974 sub GetOverview {
975  my ($self, $index) = @_;
976  my $band = _GetOverview($self, $index);
977  $Geo::GDAL::Dataset::BANDS{tied(%{$band})} = $self;
978  return $band;
979 }
980 
981 #** @method scalar GetOverviewCount()
982 # Object method.
983 # @return the number of overviews available of the band.
984 #*
985 sub GetOverviewCount {
986 }
987 
988 #** @method list GetStatistics($approx_ok, $force)
989 # Object method.
990 # @param approx_ok Whether it is allowed to compute the statistics
991 # based on overviews or similar.
992 # @param force Whether to force scanning of the whole raster.
993 # @note Uses Geo::GDAL::Band::ComputeStatistics internally.
994 #
995 # @return a list ($min, $max, $mean, $stddev).
996 #*
997 sub GetStatistics {
998 }
999 
1000 #** @method HasArbitraryOverviews()
1001 # Object method.
1002 # @return true or false.
1003 #*
1004 sub HasArbitraryOverviews {
1005 }
1006 
1007 #** @method list MaskFlags()
1008 # Package subroutine.
1009 # @return the list of mask flags. These are
1010 # - \a AllValid: There are no invalid cell, all mask values will be 255.
1011 # When used this will normally be the only flag set.
1012 # - \a PerDataset: The mask band is shared between all bands on the dataset.
1013 # - \a Alpha: The mask band is actually an alpha band and may have values
1014 # other than 0 and 255.
1015 # - \a NoData: Indicates the mask is actually being generated from nodata values.
1016 # (mutually exclusive of Alpha).
1017 #*
1018 sub MaskFlags {
1019  my @f = sort {$MASK_FLAGS{$a} <=> $MASK_FLAGS{$b}} keys %MASK_FLAGS;
1020  return @f;
1021 }
1022 
1023 #** @method scalar NoDataValue($NoDataValue)
1024 # Object method.
1025 # Remove no data value from this band.
1026 # @param NoDataValue [optional]
1027 # Get or set the "no data" value.
1028 # @note $band->NoDataValue(undef) sets the "no data" value to the
1029 # Posix floating point maximum. Use Geo::GDAL::Band::DeleteNoDataValue
1030 # to remove no data value from this band.
1031 # @return The "no data" value or undef in scalar context. An undef
1032 # value indicates that there is no no data value associated with this
1033 # band.
1034 #*
1035 sub NoDataValue {
1036  my $self = shift;
1037  if (@_ > 0) {
1038  if (defined $_[0]) {
1039  SetNoDataValue($self, $_[0]);
1040  } else {
1041  SetNoDataValue($self, POSIX::FLT_MAX); # hopefully an "out of range" value
1042  }
1043  }
1044  GetNoDataValue($self);
1045 }
1046 
1047 #** @method scalar PackCharacter()
1048 # Object method.
1049 # @return The character to use in Perl pack and unpack for the data of this band.
1050 #*
1051 sub PackCharacter {
1052  my $self = shift;
1053  return Geo::GDAL::PackCharacter($self->DataType);
1054 }
1055 
1056 #** @method Piddle()
1057 #*
1058 sub Piddle {
1059  my $self = shift; # should use named parameters for read raster and band
1060  # add Piddle sub to dataset too to make N x M x n piddles
1061  my ($w, $h) = $self->Size;
1062  my $data = $self->ReadRaster;
1063  my $pdl = PDL->new;
1064  my %map = (
1065  Byte => 0,
1066  UInt16 => 2,
1067  Int16 => 1,
1068  UInt32 => -1,
1069  Int32 => 3,
1070  Float32 => 5,
1071  Float64 => 6,
1072  CInt16 => -1,
1073  CInt32 => -1,
1074  CFloat32 => -1,
1075  CFloat64 => -1
1076  );
1077  my $datatype = $map{$self->DataType};
1078  croak "there is no direct mapping between the band datatype and PDL" if $datatype < 0;
1079  $pdl->set_datatype($datatype);
1080  $pdl->setdims([1,$w,$h]);
1081  my $dref = $pdl->get_dataref();
1082  $$dref = $data;
1083  $pdl->upd_data;
1084  return $pdl;
1085 }
1086 
1087 #** @method Geo::OGR::Layer Polygonize(%params)
1088 # Object method.
1089 # Polygonize this raster band.
1090 #
1091 # @param params Named parameters:
1092 # - \a Mask A raster band, which is used as a mask to select polygonized areas. Default is undef.
1093 # - \a OutLayer A vector layer into which the polygons are written. If not given, an in-memory layer 'polygonized' is created and returned.
1094 # - \a PixValField The name of the field in the output layer into which the cell value of the polygon area is stored. Default is 'val'.
1095 # - \a Options Hash or list of options. Connectedness can be set to 4 to use 4-connectedness, otherwise 8-connectedness is used. ForceIntPixel can be set to 1 to force using a 32 bit int buffer for cell values in the process. If this is not set and the data type of this raster does not fit into a 32 bit int buffer, a 32 bit float buffer is used.
1096 # - \a Progress Progress function.
1097 # - \a ProgressData Additional parameter for the progress function.
1098 #
1099 # @return Output vector layer.
1100 #*
1101 sub Polygonize {
1102  my $self = shift;
1103  my $p = Geo::GDAL::named_parameters(\@_, Mask => undef, OutLayer => undef, PixValField => 'val', Options => undef, Progress => undef, ProgressData => undef);
1104  my $dt = $self->DataType;
1105  my %leInt32 = (Byte => 1, Int16 => 1, Int32 => 1, UInt16 => 1);
1106  my $leInt32 = $leInt32{$dt};
1107  $dt = $dt =~ /Float/ ? 'Real' : 'Integer';
1108  $p->{outlayer} //= Geo::OGR::Driver('Memory')->Create()->
1109  CreateLayer(Name => 'polygonized',
1110  Fields => [{Name => 'val', Type => $dt},
1111  {Name => 'geom', Type => 'Polygon'}]);
1112  $p->{pixvalfield} = $p->{outlayer}->GetLayerDefn->GetFieldIndex($p->{pixvalfield});
1113  $p->{options}{'8CONNECTED'} = $p->{options}{Connectedness} if $p->{options}{Connectedness};
1114  if ($leInt32 || $p->{options}{ForceIntPixel}) {
1115  Geo::GDAL::_Polygonize($self, $p->{mask}, $p->{outlayer}, $p->{pixvalfield}, $p->{options}, $p->{progress}, $p->{progressdata});
1116  } else {
1117  Geo::GDAL::FPolygonize($self, $p->{mask}, $p->{outlayer}, $p->{pixvalfield}, $p->{options}, $p->{progress}, $p->{progressdata});
1118  }
1119  set the srs of the outlayer if it was created here
1120  return $p->{outlayer};
1121 }
1122 
1123 #** @method RasterAttributeTable()
1124 #*
1125 sub RasterAttributeTable {
1127 
1128 #** @method scalar ReadRaster(%params)
1129 # Object method.
1130 # Read data from the band.
1131 #
1132 # @param params Named parameters:
1133 # - \a XOff x offset (cell coordinates) (default is 0)
1134 # - \a YOff y offset (cell coordinates) (default is 0)
1135 # - \a XSize width of the area to read (default is the width of the band)
1136 # - \a YSize height of the area to read (default is the height of the band)
1137 # - \a BufXSize (default is undef, i.e., the same as XSize)
1138 # - \a BufYSize (default is undef, i.e., the same as YSize)
1139 # - \a BufType data type of the buffer (default is the data type of the band)
1140 # - \a BufPixelSpace (default is 0)
1141 # - \a BufLineSpace (default is 0)
1142 # - \a ResampleAlg one of Geo::GDAL::RIOResamplingTypes (default is 'NearestNeighbour'),
1143 # - \a Progress reference to a progress function (default is undef)
1144 # - \a ProgressData (default is undef)
1145 #
1146 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
1147 # @return a buffer, open the buffer with \a unpack function of Perl. See Geo::GDAL::Band::PackCharacter.
1148 #*
1149 sub ReadRaster {
1150  my $self = shift;
1151  my ($width, $height) = $self->Size;
1152  my ($type) = $self->DataType;
1153  my $p = Geo::GDAL::named_parameters(\@_,
1154  XOff => 0,
1155  YOff => 0,
1156  XSize => $width,
1157  YSize => $height,
1158  BufXSize => undef,
1159  BufYSize => undef,
1160  BufType => $type,
1161  BufPixelSpace => 0,
1162  BufLineSpace => 0,
1163  ResampleAlg => 'NearestNeighbour',
1164  Progress => undef,
1165  ProgressData => undef
1166  );
1167  $p->{resamplealg} = Geo::GDAL::string2int($p->{resamplealg}, \%Geo::GDAL::RIO_RESAMPLING_STRING2INT);
1168  $p->{buftype} = Geo::GDAL::string2int($p->{buftype}, \%Geo::GDAL::TYPE_STRING2INT, \%Geo::GDAL::TYPE_INT2STRING);
1169  $self->_ReadRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bufpixelspace},$p->{buflinespace},$p->{resamplealg},$p->{progress},$p->{progressdata});
1170 }
1171 
1172 #** @method array reference ReadTile($xoff = 0, $yoff = 0, $xsize = <width>, $ysize = <height>)
1173 # Object method.
1174 #
1175 # Usage example (print the data from a band):
1176 # \code
1177 # print "@$_\n" for ( @{ $band->ReadTile() } );
1178 # \endcode
1179 # Another usage example (process the data of a large dataset that has one band):
1180 # \code
1181 # my($W,$H) = $dataset->Band(1)->Size();
1182 # my($xoff,$yoff,$w,$h) = (0,0,200,200);
1183 # while (1) {
1184 # . if ($xoff >= $W) {
1185 # . $xoff = 0;
1186 # . $yoff += $h;
1187 # . last if $yoff >= $H;
1188 # . }
1189 # . my $data = $dataset->Band(1)->ReadTile($xoff,$yoff,min($W-$xoff,$w),min($H-$yoff,$h));
1190 # . # add your data processing code here
1191 # . $dataset->Band(1)->WriteTile($data,$xoff,$yoff);
1192 # . $xoff += $w;
1193 # }
1194 #
1195 # sub min {
1196 # . return $_[0] < $_[1] ? $_[0] : $_[1];
1197 # }
1198 # \endcode
1199 # @param xoff Number of cell to skip before starting to read from a row. Pixels are read from left to right.
1200 # @param yoff Number of cells to skip before starting to read from a column. Pixels are read from top to bottom.
1201 # @param xsize Number of cells to read from each row.
1202 # @param ysize Number of cells to read from each column.
1203 # @return a two-dimensional Perl array, organizes as data->[y][x], y =
1204 # 0..height-1, x = 0..width-1. I.e., y is row and x is column.
1205 #*
1206 sub ReadTile {
1207  my($self, $xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg) = @_;
1208  $xoff //= 0;
1209  $yoff //= 0;
1210  $xsize //= $self->{XSize} - $xoff;
1211  $ysize //= $self->{YSize} - $yoff;
1212  $w_tile //= $xsize;
1213  $h_tile //= $ysize;
1214  $alg //= 'NearestNeighbour';
1215  my $t = $self->{DataType};
1216  $alg = Geo::GDAL::string2int($alg, \%Geo::GDAL::RIO_RESAMPLING_STRING2INT);
1217  my $buf = $self->_ReadRaster($xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $t, 0, 0, $alg);
1218  my $pc = Geo::GDAL::PackCharacter($t);
1219  my $w = $w_tile * Geo::GDAL::GetDataTypeSize($t)/8;
1220  my $offset = 0;
1221  my @data;
1222  for my $y (0..$h_tile-1) {
1223  my @d = unpack($pc."[$w_tile]", substr($buf, $offset, $w));
1224  push @data, \@d;
1225  $offset += $w;
1226  }
1227  return \@data;
1228 }
1229 
1230 #** @method RegenerateOverview(Geo::GDAL::Band overview, $resampling, coderef progress, $progress_data)
1231 # Object method.
1232 # @param overview a Geo::GDAL::Band object for the overview.
1233 # @param resampling [optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
1234 # @param progress [optional] a reference to a subroutine, which will
1235 # be called with parameters (number progress, string msg, progress_data)
1236 # @param progress_data [optional]
1237 #*
1238 sub RegenerateOverview {
1239  my $self = shift;
1240  #Geo::GDAL::Band overview, scalar resampling, subref callback, scalar callback_data
1241  my @p = @_;
1242  Geo::GDAL::RegenerateOverview($self, @p);
1243 }
1244 
1245 #** @method RegenerateOverviews(arrayref overviews, $resampling, coderef progress, $progress_data)
1246 # Object method.
1247 # @todo This is not yet available
1248 #
1249 # @param overviews a list of Geo::GDAL::Band objects for the overviews.
1250 # @param resampling [optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
1251 # @param progress [optional] a reference to a subroutine, which will
1252 # be called with parameters (number progress, string msg, progress_data)
1253 # @param progress_data [optional]
1254 #*
1255 sub RegenerateOverviews {
1256  my $self = shift;
1257  #arrayref overviews, scalar resampling, subref callback, scalar callback_data
1258  my @p = @_;
1259  Geo::GDAL::RegenerateOverviews($self, @p);
1260 }
1261 
1262 #** @method ScaleAndOffset($scale, $offset)
1263 # Object method.
1264 # Scale and offset are used to transform raw cell values into the
1265 # units returned by GetUnits(). The conversion function is:
1266 # \code
1267 # Units value = (raw value * scale) + offset
1268 # \endcode
1269 # @return a list ($scale, $offset), the values are undefined if they
1270 # are not set.
1271 # @since version 1.9 of the bindings.
1272 #*
1273 sub ScaleAndOffset {
1274  my $self = shift;
1275  SetScale($self, $_[0]) if @_ > 0 and defined $_[0];
1276  SetOffset($self, $_[1]) if @_ > 1 and defined $_[1];
1277  return unless defined wantarray;
1278  my $scale = GetScale($self);
1279  my $offset = GetOffset($self);
1280  return ($scale, $offset);
1281 }
1282 
1283 #** @method list SetDefaultHistogram($min, $max, $histogram)
1284 # Object method.
1285 # @param min
1286 # @param max
1287 # @note See Note in Geo::GDAL::Band::GetHistogram.
1288 # @param histogram reference to an array containing the histogram
1289 #*
1290 sub SetDefaultHistogram {
1291 }
1292 
1293 #** @method SetStatistics($min, $max, $mean, $stddev)
1294 # Object method.
1295 # Save the statistics of the band if possible (the format can save
1296 # arbitrary metadata).
1297 # @param min
1298 # @param max
1299 # @param mean
1300 # @param stddev
1301 #*
1302 sub SetStatistics {
1303 }
1304 
1305 #** @method Geo::GDAL::Band Sieve(%params)
1306 # Object method.
1307 # Remove small areas by merging them into the largest neighbour area.
1308 # @param params Named parameters:
1309 # - \a Mask A raster band, which is used as a mask to select sieved areas. Default is undef.
1310 # - \a Dest A raster band into which the result is written. If not given, an new in-memory raster band is created and returned.
1311 # - \a Threshold The smallest area size (in number of cells) which are not sieved away.
1312 # - \a Options Hash or list of options. {Connectedness => 4} can be specified to use 4-connectedness, otherwise 8-connectedness is used.
1313 # - \a Progress Progress function.
1314 # - \a ProgressData Additional parameter for the progress function.
1315 #
1316 # @return The filtered raster band.
1317 #*
1318 sub Sieve {
1319  my $self = shift;
1320  my $p = Geo::GDAL::named_parameters(\@_, Mask => undef, Dest => undef, Threshold => 10, Options => undef, Progress => undef, ProgressData => undef);
1321  unless ($p->{dest}) {
1322  my ($w, $h) = $self->Size;
1323  $p->{dest} = Geo::GDAL::Driver('MEM')->Create(Name => 'sieved', Width => $w, Height => $h, Type => $self->DataType)->Band;
1324  }
1325  my $c = 8;
1326  if ($p->{options}{Connectedness}) {
1327  $c = $p->{options}{Connectedness};
1328  delete $p->{options}{Connectedness};
1329  }
1330  Geo::GDAL::SieveFilter($self, $p->{mask}, $p->{dest}, $p->{threshold}, $c, $p->{options}, $p->{progress}, $p->{progressdata});
1331  return $p->{dest};
1332 }
1333 
1334 #** @method list Size()
1335 # Object method.
1336 # @return The size of the band as a list (width, height).
1337 #*
1338 sub Size {
1339  my $self = shift;
1340  return ($self->{XSize}, $self->{YSize});
1341 }
1342 
1343 #** @method Unit($type)
1344 # Object method.
1345 # @param type [optional] the unit (a string).
1346 # @note $band->Unit(undef) sets the unit value to an empty string.
1347 # @return the unit (a string).
1348 # @since version 1.9 of the bindings.
1349 #*
1350 sub Unit {
1351  my $self = shift;
1352  if (@_ > 0) {
1353  my $unit = shift;
1354  $unit //= '';
1355  SetUnitType($self, $unit);
1356  }
1357  return unless defined wantarray;
1358  GetUnitType($self);
1359 }
1360 
1361 #** @method WriteRaster(%params)
1362 # Object method.
1363 # Write data into the band.
1364 #
1365 # @param params Named parameters:
1366 # - \a XOff x offset (cell coordinates) (default is 0)
1367 # - \a YOff y offset (cell coordinates) (default is 0)
1368 # - \a XSize width of the area to write (default is the width of the band)
1369 # - \a YSize height of the area to write (default is the height of the band)
1370 # - \a Buf a buffer (or a reference to a buffer) containing the data. Create the buffer with \a pack function of Perl. See Geo::GDAL::Band::PackCharacter.
1371 # - \a BufXSize (default is undef, i.e., the same as XSize)
1372 # - \a BufYSize (default is undef, i.e., the same as YSize)
1373 # - \a BufType data type of the buffer (default is the data type of the band)
1374 # - \a BufPixelSpace (default is 0)
1375 # - \a BufLineSpace (default is 0)
1376 #
1377 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
1378 #*
1379 sub WriteRaster {
1380  my $self = shift;
1381  my ($width, $height) = $self->Size;
1382  my ($type) = $self->DataType;
1383  my $p = Geo::GDAL::named_parameters(\@_,
1384  XOff => 0,
1385  YOff => 0,
1386  XSize => $width,
1387  YSize => $height,
1388  Buf => undef,
1389  BufXSize => undef,
1390  BufYSize => undef,
1391  BufType => $type,
1392  BufPixelSpace => 0,
1393  BufLineSpace => 0
1394  );
1395  confess "Usage: \$band->WriteRaster( Buf => \$data, ... )" unless defined $p->{buf};
1396  $p->{buftype} = Geo::GDAL::string2int($p->{buftype}, \%Geo::GDAL::TYPE_STRING2INT, \%Geo::GDAL::TYPE_INT2STRING);
1397  $self->_WriteRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{buf},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bufpixelspace},$p->{buflinespace});
1398 }
1399 
1400 #** @method WriteTile($data, $xoff = 0, $yoff = 0)
1401 # Object method.
1402 # @param data A two-dimensional Perl array, organizes as data->[y][x], y =
1403 # 0..height-1, x = 0..width-1.
1404 # @param xoff
1405 # @param yoff
1406 #
1407 #*
1408 sub WriteTile {
1409  my($self, $data, $xoff, $yoff) = @_;
1410  $xoff //= 0;
1411  $yoff //= 0;
1412  my $xsize = @{$data->[0]};
1413  if ($xsize > $self->{XSize} - $xoff) {
1414  warn "Buffer XSize too large ($xsize) for this raster band (width = $self->{XSize}, offset = $xoff).";
1415  $xsize = $self->{XSize} - $xoff;
1416  }
1417  my $ysize = @{$data};
1418  if ($ysize > $self->{YSize} - $yoff) {
1419  $ysize = $self->{YSize} - $yoff;
1420  warn "Buffer YSize too large ($ysize) for this raster band (height = $self->{YSize}, offset = $yoff).";
1421  }
1422  my $pc = Geo::GDAL::PackCharacter($self->{DataType});
1423  for my $i (0..$ysize-1) {
1424  my $scanline = pack($pc."[$xsize]", @{$data->[$i]});
1425  $self->WriteRaster( $xoff, $yoff+$i, $xsize, 1, $scanline );
1426  }
1427 }
1428 
1429 #** @class Geo::GDAL::ColorTable
1430 # @brief A color table from a raster band or a color table, which can be used for a band.
1431 #*
1432 package Geo::GDAL::ColorTable;
1433 
1434 use base qw(Geo::GDAL)
1435 
1436 #** @method Geo::GDAL::ColorTable Clone()
1437 # Object method.
1438 # Clone an existing color table.
1439 # @return a new Geo::GDAL::ColorTable object
1440 #*
1441 sub Clone {
1442 }
1443 
1444 #** @method list Color($index, @color)
1445 # Object method.
1446 # Get or set a color in this color table.
1447 # @param index The index of the color in the table. Note that the
1448 # color table may expand if the index is larger than the current max
1449 # index of this table and a color is given. An attempt to retrieve a
1450 # color out of the current size of the table causes an error.
1451 # @param color [optional] The color, either a list or a reference to a
1452 # list. If the list is too short or has undef values, the undef values
1453 # are taken as 0 except for alpha, which is taken as 255.
1454 # @note A color is an array of four integers having a value between 0
1455 # and 255: (gray, red, cyan or hue; green, magenta, or lightness;
1456 # blue, yellow, or saturation; alpha or blackband)
1457 # @return A color, in list context a list and in scalar context a reference to an anonymous array.
1458 #*
1459 sub Color {
1460 }
1461 
1462 #** @method list Colors(@colors)
1463 # Object method.
1464 # Get or set the colors in this color table.
1465 # @note The color table will expand to the size of the input list but
1466 # it will not shrink.
1467 # @param colors [optional] A list of all colors (a list of lists) for this color table.
1468 # @return A list of colors (a list of lists).
1469 #*
1470 sub Colors {
1471 }
1472 
1473 #** @method CreateColorRamp($start_index, arrayref start_color, $end_index, arrayref end_color)
1474 # Object method.
1475 # @param start_index
1476 # @param start_color
1477 # @param end_index
1478 # @param end_color
1479 #*
1480 sub CreateColorRamp {
1481 }
1482 
1483 #** @method scalar GetCount()
1484 # Object method.
1485 # @return The number of colors in this color table.
1486 #*
1487 sub GetCount {
1488 }
1489 
1490 #** @method scalar GetPaletteInterpretation()
1491 # Object method.
1492 # @return palette interpretation (string)
1493 #*
1494 sub GetPaletteInterpretation {
1495  my $self = shift;
1496  return $PALETTE_INTERPRETATION_INT2STRING{GetPaletteInterpretation($self)};
1497 }
1498 
1499 #** @method Geo::GDAL::ColorTable new($GDALPaletteInterp = 'RGB')
1500 # Class method.
1501 # Create a new empty color table.
1502 # @return a new Geo::GDAL::ColorTable object
1503 #*
1504 sub new {
1505  my($pkg, $pi) = @_;
1506  $pi //= 'RGB';
1507  $pi = Geo::GDAL::string2int($pi, \%PALETTE_INTERPRETATION_STRING2INT);
1508  my $self = Geo::GDALc::new_ColorTable($pi);
1509  bless $self, $pkg if defined($self);
1510 }
1511 
1512 #** @class Geo::GDAL::Dataset
1513 # @brief A set of associated raster bands or vector layer source.
1514 #*
1515 package Geo::GDAL::Dataset;
1516 
1517 use base qw(Geo::GDAL::MajorObject Geo::GDAL)
1518 
1519 #** @attr $RasterCount
1520 # scalar (access as $dataset->{RasterCount})
1521 #*
1522 
1523 #** @attr $RasterXSize
1524 # scalar (access as $dataset->{RasterXSize})
1525 #*
1526 
1527 #** @attr $RasterYSize
1528 # scalar (access as $dataset->{RasterYSize})
1529 #*
1530 
1531 #** @method AddBand($datatype = 'Byte', hashref options = {})
1532 # Object method.
1533 # Add a new band to the dataset. The driver must support the action.
1534 # @param datatype GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
1535 # @param options reference to a hash of format specific options.
1536 # @return The added band.
1537 #*
1538 sub AddBand {
1539  my ($self, $type, $options) = @_;
1540  $type //= 'Byte';
1541  $type = Geo::GDAL::string2int($type, \%Geo::GDAL::TYPE_STRING2INT);
1542  $self->_AddBand($type, $options);
1543  return unless defined wantarray;
1544  return $self->GetRasterBand($self->{RasterCount});
1545 }
1546 
1547 #** @method Geo::GDAL::Band Band($index)
1548 # Object method.
1549 # Create a band object for the band within the dataset.
1550 # @note a.k.a. GetRasterBand
1551 # @param index 1...RasterCount
1552 # @return a new Geo::GDAL::Band object
1553 #*
1554 sub Band {
1555 }
1556 
1557 #** @method list Bands()
1558 # Object method.
1559 # @return a list of new Geo::GDAL::Band objects
1560 #*
1561 sub Bands {
1562  my $self = shift;
1563  my @bands;
1564  for my $i (1..$self->{RasterCount}) {
1565  push @bands, GetRasterBand($self, $i);
1566  }
1567  return @bands;
1568 }
1569 
1570 #** @method BuildOverviews($resampling, arrayref overviews, coderef progress, $progress_data)
1571 # Object method.
1572 # @param resampling the resampling method, one of Geo::GDAL::RIOResamplingTypes.
1573 # @param overviews The list of overview decimation factors to
1574 # build. For example [2,4,8].
1575 # @param progress [optional] a reference to a subroutine, which will
1576 # be called with parameters (number progress, string msg, progress_data)
1577 # @param progress_data [optional]
1578 #*
1579 sub BuildOverviews {
1580  my $self = shift;
1581  my @p = @_;
1582  $p[0] = uc($p[0]) if $p[0];
1583  eval {
1584  $self->_BuildOverviews(@p);
1585  };
1586  confess(Geo::GDAL->last_error) if $@;
1587 }
1588 
1589 #** @method Geo::GDAL::Dataset BuildVRT($Dest, arrayref Sources, $Options, coderef progress, $progress_data)
1590 # Object method.
1591 # Build a virtual dataset from a set of datasets.
1592 # @param Dest Destination raster dataset definition string (typically
1593 # filename), or an object, which implements write and close.
1594 # @param Sources A list of filenames of input datasets or a list of
1595 # dataset objects.
1596 # @param Options A reference to a hash or list of options. For a hash
1597 # the keys are without the prefix '-' and the values must be
1598 # strings. For example give { r => 'cubic' } to select a resampling
1599 # algorithm. For a list the options are given as for the command line
1600 # utility. See <a
1601 # href="http://www.gdal.org/gdalbuildvrt.html">gdalbuildvrt</a> for a
1602 # complete list of options.
1603 # @return Dataset object
1604 #
1605 # @note This subroutine is imported into the main namespace if Geo::GDAL
1606 # is use'd with qw/:all/.
1607 #*
1608 sub BuildVRT {
1609  my ($dest, $sources, $options, $progress, $progress_data) = @_;
1610  $options = Geo::GDAL::GDALBuildVRTOptions->new(Geo::GDAL::make_processing_options($options));
1611  Geo::GDAL::error("Usage: Geo::GDAL::DataSet::BuildVRT(\$vrt_file_name, \\\@sources)")
1612  unless ref $sources eq 'ARRAY' && defined $sources->[0];
1613  unless (blessed($dest)) {
1614  if (blessed($sources->[0])) {
1615  return Geo::GDAL::wrapper_GDALBuildVRT_objects($dest, $sources, $options, $progress, $progress_data);
1616  } else {
1617  return Geo::GDAL::wrapper_GDALBuildVRT_names($dest, $sources, $options, $progress, $progress_data);
1618  }
1619  } else {
1620  if (blessed($sources->[0])) {
1621  return stdout_redirection_wrapper(
1622  $sources, $dest,
1623  \&Geo::GDAL::wrapper_GDALBuildVRT_objects,
1624  $options, $progress, $progress_data);
1625  } else {
1626  return stdout_redirection_wrapper(
1627  $sources, $dest,
1628  \&Geo::GDAL::wrapper_GDALBuildVRT_names,
1629  $options, $progress, $progress_data);
1630  }
1631  }
1632 }
1633 
1634 #** @method CommitTransaction()
1635 #*
1636 sub CommitTransaction {
1637 }
1638 
1639 #** @method Geo::GDAL::ColorTable ComputeColorTable(%params)
1640 # Object method.
1641 # Compute a color table from an RGB image
1642 # @param params Named parameters:
1643 # - \a Red The red band, the default is to use the red band of this dataset.
1644 # - \a Green The green band, the default is to use the green band of this dataset.
1645 # - \a Blue The blue band, the default is to use the blue band of this dataset.
1646 # - \a NumColors The number of colors in the computed color table. Default is 256.
1647 # - \a Progress reference to a progress function (default is undef)
1648 # - \a ProgressData (default is undef)
1649 # - \a Method The computation method. The default and currently only option is the median cut algorithm.
1650 #
1651 # @return a new color table object.
1652 #*
1653 sub ComputeColorTable {
1654  my $self = shift;
1655  my $p = Geo::GDAL::named_parameters(\@_,
1656  Red => undef,
1657  Green => undef,
1658  Blue => undef,
1659  NumColors => 256,
1660  Progress => undef,
1661  ProgressData => undef,
1662  Method => 'MedianCut');
1663  for my $b ($self->Bands) {
1664  for my $cion ($b->ColorInterpretation) {
1665  if ($cion eq 'RedBand') { $p->{red} //= $b; last; }
1666  if ($cion eq 'GreenBand') { $p->{green} //= $b; last; }
1667  if ($cion eq 'BlueBand') { $p->{blue} //= $b; last; }
1668  }
1669  }
1670  my $ct = Geo::GDAL::ColorTable->new;
1671  Geo::GDAL::ComputeMedianCutPCT($p->{red},
1672  $p->{green},
1673  $p->{blue},
1674  $p->{numcolors},
1675  $ct, $p->{progress},
1676  $p->{progressdata});
1677  return $ct;
1678 }
1679 
1680 #** @method Geo::OGR::Layer CopyLayer($layer, $name, hashref options = undef)
1681 # Object method.
1682 # @param layer A Geo::OGR::Layer object to be copied.
1683 # @param name A name for the new layer.
1684 # @param options A ref to a hash of format specific options.
1685 # @return a new Geo::OGR::Layer object.
1686 #*
1687 sub CopyLayer {
1688 }
1689 
1690 #** @method Geo::OGR::Layer CreateLayer(%params)
1691 # Object method.
1692 # @brief Create a new vector layer into this dataset.
1693 #
1694 # @param %params Named parameters:
1695 # - \a Name (scalar) name for the new layer.
1696 # - \a Fields (array reference) a list of (scalar and geometry) field definitions as in
1697 # Geo::OGR::Layer::CreateField.
1698 # - \a ApproxOK (boolean value, default is true) a flag, which is forwarded to Geo::OGR::Layer::CreateField.
1699 # - \a Options (hash reference) driver specific hash of layer creation options.
1700 # - \a Schema (hash reference, deprecated, use \a Fields and \a Name) may contain keys Name, Fields, GeomFields, GeometryType.
1701 # - \a SRS (scalar, deprecated) the spatial reference for the default geometry field.
1702 # - \a GeometryType (scalar) the type of the default geometry field
1703 # (if only one geometry field). Default is 'Unknown'.
1704 #
1705 # @note If Fields or Schema|Fields is not given, a default geometry
1706 # field (Name => '', GeometryType => 'Unknown') is created. If it is
1707 # given and it contains spatial fields, GeometryType is ignored. The
1708 # type can be also set with the named parameter.
1709 #
1710 # Example:
1711 # \code
1712 # my $roads = Geo::OGR::Driver('Memory')->Create('road')->
1713 # . CreateLayer(
1714 # . Fields => [ { Name => 'class',
1715 # . Type => 'Integer' },
1716 # . { Name => 'geom',
1717 # . Type => 'LineString25D' } ] );
1718 # \endcode
1719 #
1720 # @note Many formats allow only one spatial field, which currently
1721 # requires the use of GeometryType.
1722 #
1723 # @return a new Geo::OGR::Layer object.
1724 #*
1725 sub CreateLayer {
1726  my $self = shift;
1727  my $p = Geo::GDAL::named_parameters(\@_,
1728  Name => 'unnamed',
1729  SRS => undef,
1730  GeometryType => 'Unknown',
1731  Options => {},
1732  Schema => undef,
1733  Fields => undef,
1734  ApproxOK => 1);
1735  Geo::GDAL::error("The 'Fields' argument must be an array reference.") if $p->{fields} && ref($p->{fields}) ne 'ARRAY';
1736  if (defined $p->{schema}) {
1737  my $s = $p->{schema};
1738  $p->{geometrytype} = $s->{GeometryType} if exists $s->{GeometryType};
1739  $p->{fields} = $s->{Fields} if exists $s->{Fields};
1740  $p->{name} = $s->{Name} if exists $s->{Name};
1741  }
1742  $p->{fields} = [] unless ref($p->{fields}) eq 'ARRAY';
1743  # if fields contains spatial fields, then do not create default one
1744  for my $f (@{$p->{fields}}) {
1745  if ($f->{GeometryType} or exists $Geo::OGR::Geometry::TYPE_STRING2INT{$f->{Type}}) {
1746  $p->{geometrytype} = 'None';
1747  last;
1748  }
1749  }
1750  my $gt = Geo::GDAL::string2int($p->{geometrytype}, \%Geo::OGR::Geometry::TYPE_STRING2INT);
1751  my $layer = _CreateLayer($self, $p->{name}, $p->{srs}, $gt, $p->{options});
1752  $LAYERS{tied(%$layer)} = $self;
1753  for my $f (@{$p->{fields}}) {
1754  $layer->CreateField($f);
1755  }
1756  return $layer;
1757 }
1758 
1759 #** @method CreateMaskBand()
1760 # Object method.
1761 # Add a mask band to the dataset.
1762 #*
1763 sub CreateMaskBand {
1764  return _CreateMaskBand(@_);
1765 }
1766 
1767 #** @method Geo::GDAL::Dataset DEMProcessing($Dest, $Processing, $ColorFilename, $Options, coderef progress, $progress_data)
1768 # Object method.
1769 # Apply a DEM processing to this dataset.
1770 # @param Dest Destination raster dataset definition string (typically filename) or an object, which implements write and close.
1771 # @param Processing Processing to apply, one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", or "Roughness".
1772 # @param ColorFilename The color palette for color-relief.
1773 # @param Options A reference to a hash or list of options. For a hash
1774 # the keys are without the prefix '-'. For example give { of => 'PNG'
1775 # } to set the output format. For a list the options are given as for
1776 # the command line utility. See <a
1777 # href="http://www.gdal.org/gdaldem.html">gdaldem</a> for all options.
1778 # @param progress [optional] A reference to a subroutine, which will
1779 # be called with parameters (number progress, string msg, progress_data).
1780 # @param progress_data [optional]
1781 #
1782 #*
1783 sub DEMProcessing {
1784  my ($self, $dest, $Processing, $ColorFilename, $options, $progress, $progress_data) = @_;
1785  $options = Geo::GDAL::GDALDEMProcessingOptions->new(Geo::GDAL::make_processing_options($options));
1786  return $self->stdout_redirection_wrapper(
1787  $dest,
1788  \&Geo::GDAL::wrapper_GDALDEMProcessing,
1789  $Processing, $ColorFilename, $options, $progress, $progress_data
1790  );
1791 }
1792 
1793 #** @method Dataset()
1794 #*
1795 sub Dataset {
1796  my $self = shift;
1797  return $BANDS{tied(%$self)};
1798 }
1799 
1800 #** @method DeleteLayer($name)
1801 # Object method.
1802 # Deletes a layer from the data source. Note that if there is a layer
1803 # object for the deleted layer, it becomes unusable.
1804 # @param name name of the layer to delete.
1805 #*
1806 sub DeleteLayer {
1807  my ($self, $name) = @_;
1808  my $index;
1809  for my $i (0..$self->GetLayerCount-1) {
1810  my $layer = GetLayerByIndex($self, $i);
1811  $index = $i, last if $layer->GetName eq $name;
1812  }
1813  Geo::GDAL::error(2, $name, 'Layer') unless defined $index;
1814  _DeleteLayer($self, $index);
1815 }
1816 
1817 #** @method Geo::GDAL::Band Dither(%params)
1818 # Object method.
1819 # Compute one band with color table image from an RGB image
1820 # @params params Named parameters:
1821 # - \a Red The red band, the default is to use the red band of this dataset.
1822 # - \a Green The green band, the default is to use the green band of this dataset.
1823 # - \a Blue The blue band, the default is to use the blue band of this dataset.
1824 # - \a Dest The destination band. If this is not defined, a new in-memory band (and a dataset) will be created.
1825 # - \a ColorTable The color table for the result. If this is not defined, and the destination band does not contain one, it will be computed with the ComputeColorTable method.
1826 # - \a Progress Reference to a progress function (default is undef). Note that if ColorTable is computed using ComputeColorTable method, the progress will run twice from 0 to 1.
1827 # - \a ProgressData (default is undef)
1828 #
1829 # @return the destination band.
1830 #
1831 # Usage example. This code converts an RGB JPEG image into a one band PNG image with a color table.
1832 # \code
1833 # my $d = Geo::GDAL::Open('pic.jpg');
1834 # Geo::GDAL::Driver('PNG')->Copy(Name => 'test.png', Src => $d->Dither->Dataset);
1835 # \endcode
1836 #*
1837 sub Dither {
1838  my $self = shift;
1839  my $p = Geo::GDAL::named_parameters(\@_,
1840  Red => undef,
1841  Green => undef,
1842  Blue => undef,
1843  Dest => undef,
1844  ColorTable => undef,
1845  Progress => undef,
1846  ProgressData => undef);
1847  for my $b ($self->Bands) {
1848  for my $cion ($b->ColorInterpretation) {
1849  if ($cion eq 'RedBand') { $p->{red} //= $b; last; }
1850  if ($cion eq 'GreenBand') { $p->{green} //= $b; last; }
1851  if ($cion eq 'BlueBand') { $p->{blue} //= $b; last; }
1852  }
1853  }
1854  my ($w, $h) = $self->Size;
1855  $p->{dest} //= Geo::GDAL::Driver('MEM')->Create(Name => 'dithered',
1856  Width => $w,
1857  Height => $h,
1858  Type => 'Byte')->Band;
1859  $p->{colortable}
1860  //= $p->{dest}->ColorTable
1861  // $self->ComputeColorTable(Red => $p->{red},
1862  Green => $p->{green},
1863  Blue => $p->{blue},
1864  Progress => $p->{progress},
1865  ProgressData => $p->{progressdata});
1866  Geo::GDAL::DitherRGB2PCT($p->{red},
1867  $p->{green},
1868  $p->{blue},
1869  $p->{dest},
1870  $p->{colortable},
1871  $p->{progress},
1872  $p->{progressdata});
1873  $p->{dest}->ColorTable($p->{colortable});
1874  return $p->{dest};
1875 }
1876 
1877 #** @method Domains()
1878 #*
1879 sub Domains {
1880  return @DOMAINS;
1881 }
1882 
1883 #** @method Geo::OGR::Layer ExecuteSQL($statement, $geom = undef, $dialect = "")
1884 # Object method.
1885 # @param statement A SQL statement.
1886 # @param geom A Geo::OGR::Geometry object.
1887 # @param dialect
1888 # @return a new Geo::OGR::Layer object. The data source object will
1889 # exist as long as the layer object exists.
1890 #*
1891 sub ExecuteSQL {
1892  my $self = shift;
1893  my $layer = $self->_ExecuteSQL(@_);
1894  $LAYERS{tied(%$layer)} = $self;
1895  $RESULT_SET{tied(%$layer)} = 1;
1896  return $layer;
1897 }
1898 
1899 #** @method Extent()
1900 #*
1901 sub Extent {
1902  my $self = shift;
1903  return $self->GeoTransform->Extent($self->Size);
1904 }
1905 
1906 #** @method list GCPs(@GCPs, Geo::OSR::SpatialReference sr)
1907 # Object method.
1908 # Get or set the GCPs and their projection.
1909 # @param GCPs [optional] a list of Geo::GDAL::GCP objects
1910 # @param sr [optional] the projection of the GCPs.
1911 # @return a list of Geo::GDAL::GCP objects followed by a Geo::OSR::SpatialReference object.
1912 #*
1913 sub GCPs {
1914  my $self = shift;
1915  if (@_ > 0) {
1916  my $proj = pop @_;
1917  $proj = $proj->Export('WKT') if $proj and ref($proj);
1918  SetGCPs($self, \@_, $proj);
1919  }
1920  return unless defined wantarray;
1921  my $proj = Geo::OSR::SpatialReference->new(GetGCPProjection($self));
1922  my $GCPs = GetGCPs($self);
1923  return (@$GCPs, $proj);
1924 }
1925 
1926 #** @method Geo::GDAL::GeoTransform GeoTransform(Geo::GDAL::GeoTransform $geo_transform)
1927 # Object method.
1928 # Transformation from cell coordinates (column,row) to projection
1929 # coordinates (x,y)
1930 # \code
1931 # x = geo_transform[0] + column*geo_transform[1] + row*geo_transform[2]
1932 # y = geo_transform[3] + column*geo_transform[4] + row*geo_transform[5]
1933 # \endcode
1934 # @param geo_transform [optional]
1935 # @return the geo transform in a non-void context.
1936 #*
1937 sub GeoTransform {
1938  my $self = shift;
1939  eval {
1940  if (@_ == 1) {
1941  SetGeoTransform($self, $_[0]);
1942  } elsif (@_ > 1) {
1943  SetGeoTransform($self, \@_);
1944  }
1945  };
1946  confess(Geo::GDAL->last_error) if $@;
1947  return unless defined wantarray;
1948  my $t = GetGeoTransform($self);
1949  if (wantarray) {
1950  return @$t;
1951  } else {
1952  return Geo::GDAL::GeoTransform->new($t);
1953  }
1954 }
1955 
1956 #** @method Geo::GDAL::Driver GetDriver()
1957 # Object method.
1958 # @return a Geo::GDAL::Driver object that was used to open or create this dataset.
1959 #*
1960 sub GetDriver {
1961 }
1962 
1963 #** @method list GetFileList()
1964 # Object method.
1965 # @return list of files GDAL believes to be part of this dataset.
1966 #*
1967 sub GetFileList {
1968 }
1969 
1970 #** @method scalar GetGCPProjection()
1971 # Object method.
1972 # @return projection string.
1973 #*
1974 sub GetGCPProjection {
1975 }
1976 
1977 #** @method Geo::OGR::Layer GetLayer($name)
1978 # Object method.
1979 # @param name the name of the requested layer. If not given, then
1980 # returns the first layer in the data source.
1981 # @return a new Geo::OGR::Layer object that represents the layer
1982 # in the data source.
1983 #*
1984 sub GetLayer {
1985  my($self, $name) = @_;
1986  my $layer = defined $name ? GetLayerByName($self, "$name") : GetLayerByIndex($self, 0);
1987  $name //= '';
1988  Geo::GDAL::error(2, $name, 'Layer') unless $layer;
1989  $LAYERS{tied(%$layer)} = $self;
1990  return $layer;
1991 }
1992 
1993 #** @method list GetLayerNames()
1994 # Object method.
1995 # @note Delivers the functionality of undocumented method GetLayerCount.
1996 # @return a list of the names of the layers this data source provides.
1997 #*
1998 sub GetLayerNames {
1999  my $self = shift;
2000  my @names;
2001  for my $i (0..$self->GetLayerCount-1) {
2002  my $layer = GetLayerByIndex($self, $i);
2003  push @names, $layer->GetName;
2004  }
2005  return @names;
2006 }
2007 
2008 #** @method GetStyleTable()
2009 #*
2010 sub GetStyleTable {
2011 }
2012 
2013 #** @method Geo::GDAL::Dataset Grid($Dest, $Options)
2014 # Object method.
2015 # Creates a regular raster grid from this data source.
2016 # This is equivalent to the gdal_grid utility.
2017 # @param Dest Destination raster dataset definition string (typically filename) or an object, which implements write and close.
2018 # @param Options A reference to a hash or list of options. For a
2019 # hash the keys are without the prefix '-'. For example give { of =>
2020 # 'PNG' } to set the output format. You must specify at least layer
2021 # name (key = l) or SQL to create a layer (key = sql). For a list the
2022 # options are given as for the command line utility. See
2023 # <a href="http://www.gdal.org/gdal_grid.html">gdal_grid</a> for a
2024 # complete list of options.
2025 #
2026 #*
2027 sub Grid {
2028  my ($self, $dest, $options, $progress, $progress_data) = @_;
2029  $options = Geo::GDAL::GDALGridOptions->new(Geo::GDAL::make_processing_options($options));
2030  return $self->stdout_redirection_wrapper(
2031  $dest,
2032  \&Geo::GDAL::wrapper_GDALGrid,
2033  $options, $progress, $progress_data
2034  );
2035 }
2036 
2037 #** @method scalar Info($Options)
2038 # Object method.
2039 # Information about this dataset.
2040 # @param Options A reference to a hash or list of options. For a hash
2041 # the keys are without the prefix '-'. For example give { JSON => 1 }
2042 # to set the output format to JSON. For a list the options are given
2043 # as for the command line utility. See <a
2044 # href="http://www.gdal.org/gdalinfo.html">gdalinfo</a> for all
2045 # options.
2046 #*
2047 sub Info {
2048  my ($self, $o) = @_;
2049  $o = Geo::GDAL::GDALInfoOptions->new(Geo::GDAL::make_processing_options($o));
2050  return Geo::GDAL::GDALInfo($self, $o);
2051 }
2052 
2053 #** @method Geo::GDAL::Dataset Nearblack($Dest, $Options, coderef progress, $progress_data)
2054 # Object method.
2055 # Convert nearly black/white pixels to black/white.
2056 # @param Dest Destination raster dataset definition string (typically
2057 # filename), destination dataset to which to add an alpha or mask
2058 # band, or an object, which implements write and close.
2059 # @param Options A reference to a hash or list of options. For a hash
2060 # the keys are without the prefix '-'. For example give { of => 'PNG'
2061 # } to set the output format. For a list the options are given as for
2062 # the command line utility. See <a
2063 # href="http://www.gdal.org/nearblack.html">nearblack</a> for all
2064 # options.
2065 # @return Dataset if destination dataset definition string was given,
2066 # otherwise a boolean for success/fail but the method croaks if there
2067 # was an error.
2068 #*
2069 sub Nearblack {
2070  my ($self, $dest, $options, $progress, $progress_data) = @_;
2071  $options = Geo::GDAL::GDALNearblackOptions->new(Geo::GDAL::make_processing_options($options));
2072  my $b = blessed($dest);
2073  if ($b && $b eq 'Geo::GDAL::Dataset') {
2074  Geo::GDAL::wrapper_GDALNearblackDestDS($dest, $self, $options, $progress, $progress_data);
2075  } else {
2076  return $self->stdout_redirection_wrapper(
2077  $dest,
2078  \&Geo::GDAL::wrapper_GDALNearblackDestName,
2079  $options, $progress, $progress_data
2080  );
2081  }
2082 }
2083 
2084 #** @method Geo::GDAL::Dataset Open()
2085 # Package subroutine.
2086 # The same as Geo::GDAL::Open
2087 #*
2088 sub Open {
2089 }
2090 
2091 #** @method Geo::GDAL::Dataset OpenShared()
2092 # Package subroutine.
2093 # The same as Geo::GDAL::OpenShared
2094 #*
2095 sub OpenShared {
2096 }
2097 
2098 #** @method Geo::GDAL::Dataset Rasterize($Dest, $Options, coderef progress, $progress_data)
2099 # Object method.
2100 # Render data from this data source into a raster.
2101 # @param Dest Destination raster dataset definition string (typically
2102 # filename), destination dataset, or an object, which implements write and close.
2103 # @param Options A reference to a hash or list of options. For a hash the keys
2104 # are without the prefix '-' and the values must be strings. For
2105 # example give { of => 'PNG' } to set the output format. You must
2106 # specify at least layer name (key = l) or SQL to create a layer (key
2107 # = sql). To create a new raster, you need to specify either target
2108 # resolution (tr => xres,yres) or target file size (ts =>
2109 # width,height). For a list the options are given as for the command
2110 # line utility.See <a href="http://www.gdal.org/gdal_rasterize.html">gdal_rasterize</a> for a
2111 # complete list of options.
2112 # @return Dataset if destination dataset definition string was given,
2113 # otherwise a boolean for success/fail but the method croaks if there
2114 # was an error.
2115 #
2116 #*
2117 sub Rasterize {
2118  my ($self, $dest, $options, $progress, $progress_data) = @_;
2119  $options = Geo::GDAL::GDALRasterizeOptions->new(Geo::GDAL::make_processing_options($options));
2120  my $b = blessed($dest);
2121  if ($b && $b eq 'Geo::GDAL::Dataset') {
2122  Geo::GDAL::wrapper_GDALRasterizeDestDS($dest, $self, $options, $progress, $progress_data);
2123  } else {
2124  return $self->stdout_redirection_wrapper(
2125  $dest,
2126  \&Geo::GDAL::wrapper_GDALRasterizeDestName,
2127  $options, $progress, $progress_data
2128  );
2129  }
2130 }
2131 
2132 #** @method scalar ReadRaster(%params)
2133 # Object method.
2134 # Read data from the dataset.
2135 #
2136 # @param params Named parameters:
2137 # - \a XOff x offset (cell coordinates) (default is 0)
2138 # - \a YOff y offset (cell coordinates) (default is 0)
2139 # - \a XSize width of the area to read (default is the width of the dataset)
2140 # - \a YSize height of the area to read (default is the height of the dataset)
2141 # - \a BufXSize (default is undef, i.e., the same as XSize)
2142 # - \a BufYSize (default is undef, i.e., the same as YSize)
2143 # - \a BufType data type of the buffer (default is the data type of the first band)
2144 # - \a BandList a reference to an array of band indices (default is [1])
2145 # - \a BufPixelSpace (default is 0)
2146 # - \a BufLineSpace (default is 0)
2147 # - \a BufBandSpace (default is 0)
2148 # - \a ResampleAlg one of Geo::GDAL::RIOResamplingTypes (default is 'NearestNeighbour'),
2149 # - \a Progress reference to a progress function (default is undef)
2150 # - \a ProgressData (default is undef)
2151 #
2152 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
2153 # @return a buffer, open the buffer with \a unpack function of Perl. See Geo::GDAL::Band::PackCharacter.
2154 #*
2155 sub ReadRaster {
2156  my $self = shift;
2157  my ($width, $height) = $self->Size;
2158  my ($type) = $self->Band->DataType;
2159  my $p = Geo::GDAL::named_parameters(\@_,
2160  XOff => 0,
2161  YOff => 0,
2162  XSize => $width,
2163  YSize => $height,
2164  BufXSize => undef,
2165  BufYSize => undef,
2166  BufType => $type,
2167  BandList => [1],
2168  BufPixelSpace => 0,
2169  BufLineSpace => 0,
2170  BufBandSpace => 0,
2171  ResampleAlg => 'NearestNeighbour',
2172  Progress => undef,
2173  ProgressData => undef
2174  );
2175  $p->{resamplealg} = Geo::GDAL::string2int($p->{resamplealg}, \%Geo::GDAL::RIO_RESAMPLING_STRING2INT);
2176  $p->{buftype} = Geo::GDAL::string2int($p->{buftype}, \%Geo::GDAL::TYPE_STRING2INT, \%Geo::GDAL::TYPE_INT2STRING);
2177  $self->_ReadRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bandlist},$p->{bufpixelspace},$p->{buflinespace},$p->{bufbandspace},$p->{resamplealg},$p->{progress},$p->{progressdata});
2178 }
2179 
2180 #** @method ReadTile()
2181 #*
2182 sub ReadTile {
2183  my ($self, $xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg) = @_;
2184  my @data;
2185  for my $i (0..$self->Bands-1) {
2186  $data[$i] = $self->Band($i+1)->ReadTile($xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg);
2187  }
2188  return \@data;
2189 }
2190 
2191 #** @method ReleaseResultSet($layer)
2192 # Object method.
2193 # @param layer A layer the has been created with ExecuteSQL.
2194 # @note There is no need to call this method. The result set layer is
2195 # released in the destructor of the layer that was created with SQL.
2196 #*
2197 sub ReleaseResultSet {
2198  # a no-op, _ReleaseResultSet is called from Layer::DESTROY
2199 }
2200 
2201 #** @method RollbackTransaction()
2202 #*
2203 sub RollbackTransaction {
2204 }
2205 
2206 #** @method SetStyleTable()
2207 #*
2208 sub SetStyleTable {
2209 }
2210 
2211 #** @method list Size()
2212 # Object method.
2213 # @return (width, height)
2214 #*
2215 sub Size {
2216  my $self = shift;
2217  return ($self->{RasterXSize}, $self->{RasterYSize});
2218 }
2219 
2220 #** @method Geo::OSR::SpatialReference SpatialReference(Geo::OSR::SpatialReference sr)
2221 # Object method.
2222 # Get or set the projection of this dataset.
2223 # @param sr [optional] a Geo::OSR::SpatialReference object,
2224 # which replaces the existing projection definition of this dataset.
2225 # @return a Geo::OSR::SpatialReference object, which represents the
2226 # projection of this dataset.
2227 # @note Methods GetProjection, SetProjection, and Projection return WKT strings.
2228 #*
2229 sub SpatialReference {
2230  my($self, $sr) = @_;
2231  SetProjection($self, $sr->As('WKT')) if defined $sr;
2232  if (defined wantarray) {
2233  my $p = GetProjection($self);
2234  return unless $p;
2235  return Geo::OSR::SpatialReference->new(WKT => $p);
2236  }
2237 }
2238 
2239 #** @method StartTransaction()
2240 #*
2241 sub StartTransaction {
2242 }
2243 
2244 #** @method TestCapability()
2245 #*
2246 sub TestCapability {
2247  return _TestCapability(@_);
2248 }
2249 
2250 #** @method Tile()
2251 #*
2252 sub Tile {
2253  my ($self, $e) = @_;
2254  my ($w, $h) = $self->Size;
2255  #print "sz $w $h\n";
2256  my $gt = $self->GeoTransform;
2257  #print "gt @$gt\n";
2258  confess "GeoTransform is not \"north up\"." unless $gt->NorthUp;
2259  my $x = $gt->Extent($w, $h);
2260  my $xoff = floor(($e->[0] - $gt->[0])/$gt->[1]);
2261  $xoff = 0 if $xoff < 0;
2262  my $yoff = floor(($gt->[3] - $e->[3])/(-$gt->[5]));
2263  $yoff = 0 if $yoff < 0;
2264  my $xsize = ceil(($e->[2] - $gt->[0])/$gt->[1]) - $xoff;
2265  $xsize = $w - $xoff if $xsize > $w - $xoff;
2266  my $ysize = ceil(($gt->[3] - $e->[1])/(-$gt->[5])) - $yoff;
2267  $ysize = $h - $yoff if $ysize > $h - $yoff;
2268  return ($xoff, $yoff, $xsize, $ysize);
2269 }
2270 
2271 #** @method Geo::GDAL::Dataset Translate($Dest, $Options, coderef progress, $progress_data)
2272 # Object method.
2273 # Convert this dataset into another format.
2274 # @param Dest Destination dataset definition string (typically
2275 # filename) or an object, which implements write and close.
2276 # @param Options A reference to a hash or list of options. For a hash
2277 # the keys are without the prefix '-'. For example give { of => 'PNG'
2278 # } to set the output format. For a list the options are given as for
2279 # the command line utility. See <a
2280 # href="http://www.gdal.org/gdal_translate.html">gdal_translate</a>
2281 # and <a href="http://www.gdal.org/ogr2ogr.html">ogr2ogr</a> for all
2282 # options.
2283 # @return New dataset object if destination dataset definition
2284 # string was given, otherwise a boolean for success/fail but the
2285 # method croaks if there was an error.
2286 #*
2287 sub Translate {
2288  my ($self, $dest, $options, $progress, $progress_data) = @_;
2289  return $self->stdout_redirection_wrapper(
2290  $dest,
2291 }
2292 
2293 #** @method Geo::GDAL::Dataset Warp($Dest, $Options, coderef progress, $progress_data)
2294 # Object method.
2295 # Reproject this dataset.
2296 # @param Dest Destination raster dataset definition string (typically
2297 # filename) or an object, which implements write and close.
2298 # @param Options A reference to a hash or list of options. For a hash
2299 # the keys are without the prefix '-'. For example give { of => 'PNG'
2300 # } to set the output format. For a list the options are given as for
2301 # the command line utility. See <a
2302 # href="http://www.gdal.org/gdalwarp.html">gdalwarp</a> for
2303 # all options.
2304 #*
2305 sub Warp {
2306  my ($self, $dest, $options, $progress, $progress_data) = @_;
2307  $options = Geo::GDAL::GDALWarpAppOptions->new(Geo::GDAL::make_processing_options($options));
2308  my $b = blessed($dest);
2309  if ($b && $b eq 'Geo::GDAL::Dataset') {
2310  Geo::GDAL::wrapper_GDALWarpDestDS($dest, $self, $options, $progress, $progress_data);
2311  } else {
2312  return $self->stdout_redirection_wrapper(
2313  $dest,
2314  \&Geo::GDAL::wrapper_GDALWarpDestName,
2315  $options, $progress, $progress_data
2316  );
2317  }
2318 }
2319 
2320 #** @method Geo::GDAL::Dataset Warped(%params)
2321 # Object method.
2322 # Create a virtual warped dataset from this dataset.
2323 #
2324 # @param params Named parameters:
2325 # - \a SrcSRS Override the spatial reference system of this dataset if there is one (default is undef).
2326 # - \a DstSRS The target spatial reference system of the result (default is undef).
2327 # - \a ResampleAlg The resampling algorithm (default is 'NearestNeighbour').
2328 # - \a MaxError Maximum error measured in input cellsize that is allowed in approximating the transformation (default is 0 for exact calculations).
2329 #
2330 # # <a href="http://www.gdal.org/gdalwarper_8h.html">Documentation for GDAL warper.</a>
2331 #
2332 # @return a new Geo::GDAL::Dataset object
2333 #*
2334 sub Warped {
2335  my $self = shift;
2336  my $p = Geo::GDAL::named_parameters(\@_, SrcSRS => undef, DstSRS => undef, ResampleAlg => 'NearestNeighbour', MaxError => 0);
2337  for my $srs (qw/srcsrs dstsrs/) {
2338  $p->{$srs} = $p->{$srs}->ExportToWkt if $p->{$srs} && blessed $p->{$srs};
2339  }
2340  $p->{resamplealg} = Geo::GDAL::string2int($p->{resamplealg}, \%Geo::GDAL::RESAMPLING_STRING2INT);
2341  my $warped = Geo::GDAL::_AutoCreateWarpedVRT($self, $p->{srcsrs}, $p->{dstsrs}, $p->{resamplealg}, $p->{maxerror});
2342  $BANDS{tied(%{$warped})} = $self if $warped; # self must live as long as warped
2343  return $warped;
2344 }
2345 
2346 #** @method WriteRaster(%params)
2347 # Object method.
2348 # Write data into the dataset.
2349 #
2350 # @param params Named parameters:
2351 # - \a XOff x offset (cell coordinates) (default is 0)
2352 # - \a YOff y offset (cell coordinates) (default is 0)
2353 # - \a XSize width of the area to write (default is the width of the dataset)
2354 # - \a YSize height of the area to write (default is the height of the dataset)
2355 # - \a Buf a buffer (or a reference to a buffer) containing the data. Create the buffer with \a pack function of Perl. See Geo::GDAL::Band::PackCharacter.
2356 # - \a BufXSize (default is undef, i.e., the same as XSize)
2357 # - \a BufYSize (default is undef, i.e., the same as YSize)
2358 # - \a BufType data type of the buffer (default is the data type of the first band)
2359 # - \a BandList a reference to an array of band indices (default is [1])
2360 # - \a BufPixelSpace (default is 0)
2361 # - \a BufLineSpace (default is 0)
2362 # - \a BufBandSpace (default is 0)
2363 #
2364 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
2365 #*
2366 sub WriteRaster {
2367  my $self = shift;
2368  my ($width, $height) = $self->Size;
2369  my ($type) = $self->Band->DataType;
2370  my $p = Geo::GDAL::named_parameters(\@_,
2371  XOff => 0,
2372  YOff => 0,
2373  XSize => $width,
2374  YSize => $height,
2375  Buf => undef,
2376  BufXSize => undef,
2377  BufYSize => undef,
2378  BufType => $type,
2379  BandList => [1],
2380  BufPixelSpace => 0,
2381  BufLineSpace => 0,
2382  BufBandSpace => 0
2383  );
2384  $p->{buftype} = Geo::GDAL::string2int($p->{buftype}, \%Geo::GDAL::TYPE_STRING2INT, \%Geo::GDAL::TYPE_INT2STRING);
2385  $self->_WriteRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{buf},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bandlist},$p->{bufpixelspace},$p->{buflinespace},$p->{bufbandspace});
2386 }
2387 
2388 #** @method WriteTile()
2389 #*
2390 sub WriteTile {
2391  my ($self, $data, $xoff, $yoff) = @_;
2392  $xoff //= 0;
2393  $yoff //= 0;
2394  for my $i (0..$self->Bands-1) {
2395  $self->Band($i+1)->WriteTile($data->[$i], $xoff, $yoff);
2396  }
2397 }
2398 
2399 #** @class Geo::GDAL::Driver
2400 # @brief A driver for a specific dataset format.
2401 #*
2402 package Geo::GDAL::Driver;
2403 
2404 use base qw(Geo::GDAL::MajorObject Geo::GDAL)
2405 
2406 #** @attr $HelpTopic
2407 # $driver->{HelpTopic}
2408 #*
2409 
2410 #** @attr $LongName
2411 # $driver->{LongName}
2412 #*
2413 
2414 #** @attr $ShortName
2415 # $driver->{ShortName}
2416 #*
2417 
2418 #** @method list Capabilities()
2419 # Object method.
2420 # @return A list of capabilities. When executed as a package subroutine
2421 # returns a list of all potential capabilities a driver may have. When
2422 # executed as an object method returns a list of all capabilities the
2423 # driver has.
2424 #
2425 # Currently capabilities are:
2426 # CREATE, CREATECOPY, DEFAULT_FIELDS, NOTNULL_FIELDS, NOTNULL_GEOMFIELDS, OPEN, RASTER, VECTOR, and VIRTUALIO.
2427 #
2428 # Examples.
2429 # \code
2430 # @all_capabilities = Geo::GDAL::Driver::Capabilities;
2431 # @capabilities_of_the_geotiff_driver = Geo::GDAL::Driver('GTiff')->Capabilities;
2432 # \endcode
2433 #*
2434 sub Capabilities {
2435  my $self = shift;
2436  return @CAPABILITIES unless $self;
2437  my $h = $self->GetMetadata;
2438  my @cap;
2439  for my $cap (@CAPABILITIES) {
2440  my $test = $h->{'DCAP_'.uc($cap)};
2441  push @cap, $cap if defined($test) and $test eq 'YES';
2442  }
2443  return @cap;
2444 }
2445 
2446 #** @method Geo::GDAL::Dataset Copy(%params)
2447 # Object method.
2448 # Create a new raster Geo::GDAL::Dataset as a copy of an existing dataset.
2449 # @note a.k.a. CreateCopy
2450 #
2451 # @param params Named parameters:
2452 # - \a Name name for the new raster dataset.
2453 # - \a Src the source Geo::GDAL::Dataset object.
2454 # - \a Strict 1 (default) if the copy must be strictly equivalent, or 0 if the copy may adapt.
2455 # - \a Options an anonymous hash of driver specific options.
2456 # - \a Progress [optional] a reference to a subroutine, which will
2457 # be called with parameters (number progress, string msg, progress_data).
2458 # - \a ProgressData [optional]
2459 # @return a new Geo::GDAL::Dataset object.
2460 #*
2461 sub Copy {
2462  my $self = shift;
2463  my $p = Geo::GDAL::named_parameters(\@_, Name => 'unnamed', Src => undef, Strict => 1, Options => {}, Progress => undef, ProgressData => undef);
2464  return $self->stdout_redirection_wrapper(
2465  $p->{name},
2466  $self->can('_CreateCopy'),
2467  $p->{src}, $p->{strict}, $p->{options}, $p->{progress}, $p->{progressdata});
2468 }
2469 
2470 #** @method CopyFiles($NewName, $OldName)
2471 # Object method.
2472 # Copy the files of a dataset.
2473 # @param NewName String.
2474 # @param OldName String.
2475 #*
2476 sub CopyFiles {
2477 }
2478 
2479 #** @method Geo::GDAL::Dataset Create(%params)
2480 # Object method.
2481 # Create a raster dataset using this driver.
2482 # @note a.k.a. CreateDataset
2483 #
2484 # @param params Named parameters:
2485 # - \a Name The name for the dataset (default is 'unnamed') or an object, which implements write and close.
2486 # - \a Width The width for the raster dataset (default is 256).
2487 # - \a Height The height for the raster dataset (default is 256).
2488 # - \a Bands The number of bands to create into the raster dataset (default is 1).
2489 # - \a Type The data type for the raster cells (default is 'Byte'). One of Geo::GDAL::Driver::CreationDataTypes.
2490 # - \a Options Driver creation options as a reference to a hash (default is {}).
2491 #
2492 # @return A new Geo::GDAL::Dataset object.
2493 #*
2494 sub Create {
2495  my $self = shift;
2496  my $p = Geo::GDAL::named_parameters(\@_, Name => 'unnamed', Width => 256, Height => 256, Bands => 1, Type => 'Byte', Options => {});
2497  my $type = Geo::GDAL::string2int($p->{type}, \%Geo::GDAL::TYPE_STRING2INT);
2498  return $self->stdout_redirection_wrapper(
2499  $p->{name},
2500  $self->can('_Create'),
2501  $p->{width}, $p->{height}, $p->{bands}, $type, $p->{options}
2502  );
2503 }
2504 
2505 #** @method list CreationDataTypes()
2506 # Object method.
2507 # @return a list of data types that can be used for new datasets of this format. A subset of Geo::GDAL::DataTypes
2508 #*
2509 sub CreationDataTypes {
2510  my $self = shift;
2511  my $h = $self->GetMetadata;
2512  return split /\s+/, $h->{DMD_CREATIONDATATYPES} if $h->{DMD_CREATIONDATATYPES};
2513 }
2514 
2515 #** @method list CreationOptionList()
2516 # Object method.
2517 # @return a list of options, each option is a hashref, the keys are
2518 # name, type and description or Value. Value is a listref.
2519 #*
2520 sub CreationOptionList {
2521  my $self = shift;
2522  my @options;
2523  my $h = $self->GetMetadata->{DMD_CREATIONOPTIONLIST};
2524  if ($h) {
2525  $h = Geo::GDAL::ParseXMLString($h);
2526  my($type, $value) = Geo::GDAL::NodeData($h);
2527  if ($value eq 'CreationOptionList') {
2528  for my $o (Geo::GDAL::Children($h)) {
2529  my %option;
2530  for my $a (Geo::GDAL::Children($o)) {
2531  my(undef, $key) = Geo::GDAL::NodeData($a);
2532  my(undef, $value) = Geo::GDAL::NodeData(Geo::GDAL::Child($a, 0));
2533  if ($key eq 'Value') {
2534  push @{$option{$key}}, $value;
2535  } else {
2536  $option{$key} = $value;
2537  }
2538  }
2539  push @options, \%option;
2540  }
2541  }
2542  }
2543  return @options;
2544 }
2545 
2546 #** @method Delete($name)
2547 # Object method.
2548 # @param name
2549 #*
2550 sub Delete {
2551 }
2552 
2553 #** @method Domains()
2554 #*
2555 sub Domains {
2556  return @DOMAINS;
2557 }
2558 
2559 #** @method scalar Extension()
2560 # Object method.
2561 # @return a suggested extension or extensions (e.g., ext1/ext2) for
2562 # datasets.
2563 #*
2564 sub Extension {
2565  my $self = shift;
2566  my $h = $self->GetMetadata;
2567  return $h->{DMD_EXTENSION};
2568 }
2569 
2570 #** @method scalar MIMEType()
2571 # Object method.
2572 # @return a suggested MIME type for datasets.
2573 #*
2574 sub MIMEType {
2575  my $self = shift;
2576  my $h = $self->GetMetadata;
2577  return $h->{DMD_MIMETYPE};
2578 }
2579 
2580 #** @method scalar Name()
2581 # Object method.
2582 # @return The short name of the driver.
2583 #*
2584 sub Name {
2585  my $self = shift;
2586  return $self->{ShortName};
2587 }
2588 
2589 #** @method Open()
2590 # Object method.
2591 # The same as Geo::GDAL::Open except that only this driver is allowed.
2592 #*
2593 sub Open {
2594  my $self = shift;
2595  my @p = @_; # name, update
2596  my @flags = qw/RASTER/;
2597  push @flags, qw/READONLY/ if $p[1] eq 'ReadOnly';
2598  push @flags, qw/UPDATE/ if $p[1] eq 'Update';
2599  my $dataset = Geo::GDAL::OpenEx($p[0], \@flags, [$self->Name()]);
2600  Geo::GDAL::error("Failed to open $p[0]. Is it a raster dataset?") unless $dataset;
2601  return $dataset;
2602 }
2603 
2604 #** @method Rename($NewName, $OldName)
2605 # Object method.
2606 # Rename (move) a GDAL dataset.
2607 # @param NewName String.
2608 # @param OldName String.
2609 #*
2610 sub Rename {
2611 }
2612 
2613 #** @method scalar TestCapability($cap)
2614 # Object method.
2615 # Test whether the driver has the specified capability.
2616 # @param cap A capability string (one of those returned by Capabilities).
2617 # @return a boolean value.
2618 #*
2619 sub TestCapability {
2620  my($self, $cap) = @_;
2621  my $h = $self->GetMetadata->{'DCAP_'.uc($cap)};
2622  return (defined($h) and $h eq 'YES') ? 1 : undef;
2623 }
2624 
2625 #** @method stdout_redirection_wrapper()
2626 #*
2627 sub stdout_redirection_wrapper {
2628  my ($self, $name, $sub, @params) = @_;
2629  my $object = 0;
2630  if ($name && blessed $name) {
2631  $object = $name;
2632  my $ref = $object->can('write');
2633  Geo::GDAL::VSIStdoutSetRedirection($ref);
2634  $name = '/vsistdout/';
2635  }
2636  my $ds;
2637  eval {
2638  $ds = $sub->($self, $name, @params);
2639  };
2640  if ($object) {
2641  if ($ds) {
2642  $Geo::GDAL::stdout_redirection{tied(%$ds)} = $object;
2643  } else {
2644  Geo::GDAL::VSIStdoutUnsetRedirection();
2645  $object->close;
2646  }
2647  }
2648  confess(Geo::GDAL->last_error) if $@;
2649  confess("Failed. Use Geo::OGR::Driver for vector drivers.") unless $ds;
2650  return $ds;
2651 }
2652 
2653 #** @class Geo::GDAL::Extent
2654 #*
2655 package Geo::GDAL::Extent;
2656 
2657 #** @method ExpandToInclude()
2658 #*
2659 sub ExpandToInclude {
2660  my ($self, $e) = @_;
2661  $self->[0] = $e->[0] if $e->[0] < $self->[0];
2662  $self->[1] = $e->[1] if $e->[1] < $self->[1];
2663  $self->[2] = $e->[2] if $e->[2] > $self->[2];
2664  $self->[3] = $e->[3] if $e->[3] > $self->[3];
2665 }
2666 
2667 #** @method Overlap()
2668 #*
2669 sub Overlap {
2670  my ($self, $e) = @_;
2671  return undef unless $self->Overlaps($e);
2672  my $ret = Geo::GDAL::Extent->new($self);
2673  $ret->[0] = $e->[0] if $self->[0] < $e->[0];
2674  $ret->[1] = $e->[1] if $self->[1] < $e->[1];
2675  $ret->[2] = $e->[2] if $self->[2] > $e->[2];
2676  $ret->[3] = $e->[3] if $self->[3] > $e->[3];
2677  return $ret;
2678 }
2679 
2680 #** @method Overlaps()
2681 #*
2682 sub Overlaps {
2683  my ($self, $e) = @_;
2684  return $self->[0] < $e->[2] && $self->[2] > $e->[0] && $self->[1] < $e->[3] && $self->[3] > $e->[1];
2685 }
2686 
2687 #** @method Size()
2688 #*
2689 sub Size {
2690  my $self = shift;
2691  return ($self->[2] - $self->[0], $self->[3] - $self->[1]);
2692 }
2693 
2694 #** @method new()
2695 #*
2696 sub new {
2697  my $class = shift;
2698  my $self;
2699  if (@_ == 0) {
2700  $self = [0,0,0,0];
2701  } elsif (ref $_[0]) {
2702  @$self = @{$_[0]};
2703  } else {
2704  @$self = @_;
2705  }
2706  bless $self, $class;
2707  return $self;
2708 }
2709 
2710 #** @class Geo::GDAL::GCP
2711 # @brief A ground control point for georeferencing rasters.
2712 #*
2713 package Geo::GDAL::GCP;
2714 
2715 use base qw(Geo::GDAL)
2716 
2717 #** @attr $Column
2718 # cell x coordinate (access as $gcp->{Column})
2719 #*
2720 
2721 #** @attr $Id
2722 # unique identifier (string) (access as $gcp->{Id})
2723 #*
2724 
2725 #** @attr $Info
2726 # informational message (access as $gcp->{Info})
2727 #*
2728 
2729 #** @attr $Row
2730 # cell y coordinate (access as $gcp->{Row})
2731 #*
2732 
2733 #** @attr $X
2734 # projection coordinate (access as $gcp->{X})
2735 #*
2736 
2737 #** @attr $Y
2738 # projection coordinate (access as $gcp->{Y})
2739 #*
2740 
2741 #** @attr $Z
2742 # projection coordinate (access as $gcp->{Z})
2743 #*
2744 
2745 #** @method scalar new($x = 0.0, $y = 0.0, $z = 0.0, $column = 0.0, $row = 0.0, $info = "", $id = "")
2746 # Class method.
2747 # @param x projection coordinate
2748 # @param y projection coordinate
2749 # @param z projection coordinate
2750 # @param column cell x coordinate
2751 # @param row cell y coordinate
2752 # @param info informational message
2753 # @param id unique identifier (string)
2754 # @return a new Geo::GDAL::GCP object
2755 #*
2756 sub new {
2757  my $pkg = shift;
2758  my $self = Geo::GDALc::new_GCP(@_);
2759  bless $self, $pkg if defined($self);
2760 }
2761 
2762 #** @class Geo::GDAL::GeoTransform
2763 # @brief An array of affine transformation coefficients.
2764 #
2765 # The geo transformation has the form
2766 # \code
2767 # x = a + column * b + row * c
2768 # y = d + column * e + row * f
2769 # \endcode
2770 # where<br/>
2771 # (column,row) is the location in cell coordinates<br/>
2772 # (x,y) is the location in projection coordinates<br/>
2773 # or vice versa.
2774 # A Geo::GDAL::GeoTransform object is a reference to an anonymous array [a,b,c,d,e,f].
2775 #*
2776 package Geo::GDAL::GeoTransform;
2777 
2778 #** @method Apply(array reference x, array reference y)
2779 # Object method.
2780 # @return a list (x, y), where x and y are references to arrays of
2781 # transformed coordinates.
2782 #*
2783 sub Apply {
2784  my ($self, $columns, $rows) = @_;
2785  my (@x, @y);
2786  for my $i (0..$#$columns) {
2787  ($x[$i], $y[$i]) =
2788  Geo::GDAL::ApplyGeoTransform($self, $columns->[$i], $rows->[$i]);
2789  }
2790  return (\@x, \@y);
2791 }
2792 
2793 #** @method Extent()
2794 #*
2795 sub Extent {
2796  my ($self, $w, $h) = @_;
2797  my $e = Geo::GDAL::Extent->new($self->[0], $self->[3], $self->[0], $self->[3]);
2798  for my $x ($self->[0] + $self->[1]*$w, $self->[0] + $self->[2]*$h, $self->[0] + $self->[1]*$w + $self->[2]*$h) {
2799  $e->[0] = $x if $x < $e->[0];
2800  $e->[2] = $x if $x > $e->[2];
2801  }
2802  for my $y ($self->[3] + $self->[4]*$w, $self->[3] + $self->[5]*$h, $self->[3] + $self->[4]*$w + $self->[5]*$h) {
2803  $e->[1] = $y if $y < $e->[1];
2804  $e->[3] = $y if $y > $e->[3];
2805  }
2806  return $e;
2807 }
2808 
2809 #** @method FromGCPs(@GCPs, $ApproxOK)
2810 # Object method.
2811 # Compute transformation coefficients from a list of Geo::GDAL::GCP
2812 # objects
2813 # @param GCPs A list of Geo::GDAL::GCP objects.
2814 # @param ApproxOK [optional] Minimize the error in the coefficient (integer, default is true).
2815 # @return a new Geo::GDAL::GeoTransform object.
2816 #*
2817 sub FromGCPs {
2818  my $gcps;
2819  my $p = shift;
2820  if (ref $p eq 'ARRAY') {
2821  $gcps = $p;
2822  } else {
2823  $gcps = [];
2824  while ($p && blessed $p) {
2825  push @$gcps, $p;
2826  $p = shift;
2827  }
2828  }
2829  my $approx_ok = shift // 1;
2830  Geo::GDAL::error('Usage: Geo::GDAL::GeoTransform::FromGCPs(\@gcps, $approx_ok)') unless @$gcps;
2831  my $self = Geo::GDAL::GCPsToGeoTransform($gcps, $approx_ok);
2832  bless $self, 'Geo::GDAL::GetTransform';
2833  return $self;
2834 }
2835 
2836 #** @method Inv()
2837 # Object method.
2838 # @return a new Geo::GDAL::GeoTransform object, which is the inverse
2839 # of this one (in void context changes this object).
2840 #*
2841 sub Inv {
2842  my $self = shift;
2843  my @inv = Geo::GDAL::InvGeoTransform($self);
2844  return new(@inv) if defined wantarray;
2845  @$self = @inv;
2846 }
2847 
2848 #** @method NorthUp()
2849 #*
2850 sub NorthUp {
2851  my $self = shift;
2852  return $self->[2] == 0 && $self->[4] == 0;
2853 }
2854 
2855 #** @method new(@coeffs)
2856 # Class method.
2857 # @return a new Geo::GDAL::GeoTransform object.
2858 #*
2859 sub new {
2860  my $class = shift;
2861  my $self;
2862  if (@_ == 0) {
2863  $self = [0,1,0,0,0,1];
2864  } elsif (@_ == 1) {
2865  $self = $_[0];
2866  } else {
2867  my @a = @_;
2868  $self = \@a;
2869  }
2870  bless $self, $class;
2871  return $self;
2872 }
2873 
2874 #** @class Geo::GDAL::MajorObject
2875 # @brief An object, which holds meta data.
2876 #*
2877 package Geo::GDAL::MajorObject;
2878 
2879 use base qw(Geo::GDAL)
2880 
2881 #** @method scalar Description($description)
2882 # Object method.
2883 # @param description [optional]
2884 # @return the description in a non-void context.
2885 #*
2886 sub Description {
2887  my($self, $desc) = @_;
2888  SetDescription($self, $desc) if defined $desc;
2889  GetDescription($self) if defined wantarray;
2890 }
2891 
2892 #** @method Domains()
2893 # Package subroutine.
2894 # @return the class specific DOMAINS list
2895 #*
2896 sub Domains {
2897  return @DOMAINS;
2898 }
2899 
2900 #** @method scalar GetDescription()
2901 # Object method.
2902 # @return
2903 #*
2904 sub GetDescription {
2905 }
2906 
2907 #** @method hash reference GetMetadata($domain = "")
2908 # Object method.
2909 # @note see Metadata
2910 # @param domain
2911 # @return
2912 #*
2913 sub GetMetadata {
2914 }
2915 
2916 #** @method GetMetadataDomainList()
2917 #*
2918 sub GetMetadataDomainList {
2920 
2921 #** @method hash reference Metadata(hashref metadata = undef, $domain = '')
2922 # Object method.
2923 # @param metadata
2924 # @param domain
2925 # @return the metadata in a non-void context.
2926 #*
2927 sub Metadata {
2928  my $self = shift,
2929  my $metadata = ref $_[0] ? shift : undef;
2930  my $domain = shift // '';
2931  SetMetadata($self, $metadata, $domain) if defined $metadata;
2932  GetMetadata($self, $domain) if defined wantarray;
2933 }
2934 
2935 #** @method SetDescription($NewDesc)
2936 # Object method.
2937 # @param NewDesc
2938 #
2939 #*
2940 sub SetDescription {
2941 }
2942 
2943 #** @method SetMetadata(hashref metadata, $domain = "")
2944 # Object method.
2945 # @note see Metadata
2946 # @param metadata
2947 # @param domain
2948 #
2949 #*
2950 sub SetMetadata {
2951 }
2952 
2953 #** @class Geo::GDAL::RasterAttributeTable
2954 # @brief An attribute table in a raster band.
2955 #*
2956 package Geo::GDAL::RasterAttributeTable;
2957 
2958 use base qw(Geo::GDAL)
2959 
2960 #** @method Band()
2961 #*
2962 sub Band {
2963  my $self = shift;
2964  return $Geo::GDAL::Band::RATS{tied(%$self)};
2965 }
2966 
2967 #** @method ChangesAreWrittenToFile()
2968 #*
2969 sub ChangesAreWrittenToFile {
2970 }
2971 
2972 #** @method Geo::GDAL::RasterAttributeTable Clone()
2973 # Object method.
2974 # @return a new Geo::GDAL::RasterAttributeTable object
2975 #*
2976 sub Clone {
2977 }
2978 
2979 #** @method hash Columns(%columns)
2980 # Object method.
2981 # A get/set method for the columns of the RAT
2982 # @param columns optional, a the keys are column names and the values are anonymous
2983 # hashes with keys Type and Usage
2984 # @return a hash similar to the optional input parameter
2985 #*
2986 sub Columns {
2987  my $self = shift;
2988  my %columns;
2989  if (@_) { # create columns
2990  %columns = @_;
2991  for my $name (keys %columns) {
2992  $self->CreateColumn($name, $columns{$name}{Type}, $columns{$name}{Usage});
2993  }
2994  }
2995  %columns = ();
2996  for my $c (0..$self->GetColumnCount-1) {
2997  my $name = $self->GetNameOfCol($c);
2998  $columns{$name}{Type} = $self->GetTypeOfCol($c);
2999  $columns{$name}{Usage} = $self->GetUsageOfCol($c);
3000  }
3001  return %columns;
3002 }
3003 
3004 #** @method CreateColumn($name, $type, $usage)
3005 # Object method.
3006 # @param name
3007 # @param type one of FieldTypes
3008 # @param usage one of FieldUsages
3009 #*
3010 sub CreateColumn {
3011  my($self, $name, $type, $usage) = @_;
3012  for my $color (qw/Red Green Blue Alpha/) {
3013  carp "RAT column type will be 'Integer' for usage '$color'." if $usage eq $color and $type ne 'Integer';
3014  }
3015  $type = Geo::GDAL::string2int($type, \%FIELD_TYPE_STRING2INT);
3016  $usage = Geo::GDAL::string2int($usage, \%FIELD_USAGE_STRING2INT);
3017  _CreateColumn($self, $name, $type, $usage);
3018 }
3019 
3020 #** @method DumpReadable()
3021 #*
3022 sub DumpReadable {
3023 }
3024 
3025 #** @method list FieldTypes()
3026 # Package subroutine.
3027 # @return
3028 #*
3029 sub FieldTypes {
3030  return @FIELD_TYPES;
3031 }
3032 
3033 #** @method list FieldUsages()
3034 # Package subroutine.
3035 # @return
3036 #*
3037 sub FieldUsages {
3038  return @FIELD_USAGES;
3039 }
3040 
3041 #** @method scalar GetColOfUsage($usage)
3042 # Object method.
3043 # @param usage
3044 # @return
3045 #*
3046 sub GetColOfUsage {
3047  my($self, $usage) = @_;
3048  _GetColOfUsage($self, $FIELD_USAGE_STRING2INT{$usage});
3049 }
3050 
3051 #** @method scalar GetColumnCount()
3052 # Object method.
3053 # @return
3054 #*
3055 sub GetColumnCount {
3056 }
3057 
3058 #** @method scalar GetNameOfCol($column)
3059 # Object method.
3060 # @param column
3061 # @return
3062 #*
3063 sub GetNameOfCol {
3064 }
3065 
3066 #** @method scalar GetRowCount()
3067 # Object method.
3068 #*
3069 sub GetRowCount {
3070 }
3071 
3072 #** @method scalar GetRowOfValue($value)
3073 # Object method.
3074 # @param value a cell value
3075 # @return row index or -1
3076 #*
3077 sub GetRowOfValue {
3078 }
3079 
3080 #** @method scalar GetTypeOfCol($column)
3081 # Object method.
3082 # @param column
3083 # @return
3084 #*
3085 sub GetTypeOfCol {
3086  my($self, $col) = @_;
3087  $FIELD_TYPE_INT2STRING{_GetTypeOfCol($self, $col)};
3088 }
3089 
3090 #** @method scalar GetUsageOfCol($column)
3091 # Object method.
3092 # @param column
3093 # @return
3094 #*
3095 sub GetUsageOfCol {
3096  my($self, $col) = @_;
3097  $FIELD_USAGE_INT2STRING{_GetUsageOfCol($self, $col)};
3098 }
3099 
3100 #** @method scalar GetValueAsDouble($row, $column)
3101 # Object method.
3102 # @param row
3103 # @param column
3104 # @return
3105 #*
3106 sub GetValueAsDouble {
3107 }
3108 
3109 #** @method scalar GetValueAsInt($row, $column)
3110 # Object method.
3111 # @param row
3112 # @param column
3113 # @return
3114 #*
3115 sub GetValueAsInt {
3116 }
3117 
3118 #** @method scalar GetValueAsString($row, $column)
3119 # Object method.
3120 # @param row
3121 # @param column
3122 # @return
3123 #*
3124 sub GetValueAsString {
3125 }
3126 
3127 #** @method LinearBinning($Row0MinIn, $BinSizeIn)
3128 # Object method.
3129 # @param Row0MinIn [optional] the lower bound (cell value) of the first category.
3130 # @param BinSizeIn [optional] the width of each category (in cell value units).
3131 # @return ($Row0MinIn, $BinSizeIn) or an empty list if LinearBinning is not set.
3132 #*
3133 sub LinearBinning {
3134  my $self = shift;
3135  SetLinearBinning($self, @_) if @_ > 0;
3136  return unless defined wantarray;
3137  my @a = GetLinearBinning($self);
3138  return $a[0] ? ($a[1], $a[2]) : ();
3139 }
3140 
3141 #** @method SetRowCount($count)
3142 # Object method.
3143 # @param count
3144 #
3145 #*
3146 sub SetRowCount {
3147 }
3148 
3149 #** @method SetValueAsDouble($row, $column, $value)
3150 # Object method.
3151 # @param row
3152 # @param column
3153 # @param value
3154 #
3155 #*
3156 sub SetValueAsDouble {
3157 }
3158 
3159 #** @method SetValueAsInt($row, $column, $value)
3160 # Object method.
3161 # @param row
3162 # @param column
3163 # @param value
3164 #
3165 #*
3166 sub SetValueAsInt {
3167 }
3168 
3169 #** @method SetValueAsString($row, $column, $value)
3170 # Object method.
3171 # @param row
3172 # @param column
3173 # @param value
3174 #
3175 #*
3176 sub SetValueAsString {
3177 }
3178 
3179 #** @method scalar Value($row, $column, $value)
3180 # Object method.
3181 # @param row
3182 # @param column
3183 # @param value [optional]
3184 # @return
3185 #*
3186 sub Value {
3187  my($self, $row, $column) = @_;
3188  SetValueAsString($self, $row, $column, $_[3]) if defined $_[3];
3189  return unless defined wantarray;
3190  GetValueAsString($self, $row, $column);
3191 }
3192 
3193 #** @method Geo::GDAL::RasterAttributeTable new()
3194 # Class method.
3195 # @return a new Geo::GDAL::RasterAttributeTable object
3196 #*
3197 sub new {
3198  my $pkg = shift;
3199  my $self = Geo::GDALc::new_RasterAttributeTable(@_);
3200  bless $self, $pkg if defined($self);
3201 }
3202 
3203 #** @class Geo::GDAL::Transformer
3204 # @brief
3205 #
3206 # This class is not yet documented for the GDAL Perl bindings.
3207 # @todo Test and document.
3208 #*
3209 package Geo::GDAL::Transformer;
3210 
3211 use base qw(Geo::GDAL)
3212 
3213 #** @method TransformGeolocations()
3214 #*
3215 sub TransformGeolocations {
3216 }
3217 
3218 #** @method TransformPoint()
3219 #*
3220 sub TransformPoint {
3221 }
3222 
3223 #** @method new()
3224 #*
3225 sub new {
3226  my $pkg = shift;
3227  my $self = Geo::GDALc::new_Transformer(@_);
3228  bless $self, $pkg if defined($self);
3229 }
3230 
3231 #** @class Geo::GDAL::VSIF
3232 # @brief A GDAL virtual file system.
3233 #*
3234 package Geo::GDAL::VSIF;
3235 
3236 use base qw(our Exporter)
3237 
3238 #** @method Close()
3239 # Object method.
3240 #*
3241 sub Close {
3242  my ($self, $data) = @_;
3243  Geo::GDAL::VSIFCloseL($self);
3244 }
3245 
3246 #** @method MkDir($path)
3247 # Package subroutine.
3248 # Make a directory.
3249 # @param path The directory to make.
3250 # @note The name of this method is VSIMkdir in GDAL.
3251 #*
3252 sub MkDir {
3253  my ($path) = @_;
3254  # mode unused in CPL
3255  Geo::GDAL::Mkdir($path, 0);
3256 }
3257 
3258 #** @method Geo::GDAL::VSIF Open($filename, $mode)
3259 # Package subroutine.
3260 # @param filename Name of the file to open. For example "/vsimem/x".
3261 # @param mode Access mode. 'r', 'r+', 'w', etc.
3262 # @return A file handle on success.
3263 #*
3264 sub Open {
3265  my ($path, $mode) = @_;
3266  my $self = Geo::GDAL::VSIFOpenL($path, $mode);
3267  bless $self, 'Geo::GDAL::VSIF';
3268 }
3269 
3270 #** @method scalar Read($count)
3271 # Object method.
3272 # @param count The number of bytes to read from the file.
3273 # @return A byte string.
3274 #*
3275 sub Read {
3276  my ($self, $count) = @_;
3277  Geo::GDAL::VSIFReadL($count, $self);
3278 }
3279 
3280 #** @method list ReadDir($dir)
3281 # Package subroutine.
3282 # @return Contents of a directory in an anonymous array or as a list.
3283 #*
3284 sub ReadDir {
3285  my ($path) = @_;
3286  Geo::GDAL::ReadDir($path);
3287 }
3288 
3289 #** @method scalar ReadDirRecursive($dir)
3290 # Package subroutine.
3291 # @note Give the directory in the form '/vsimem', i.e., without trailing '/'.
3292 # @return Contents of a directory tree in an anonymous array.
3293 #*
3294 sub ReadDirRecursive {
3295  my ($path) = @_;
3296  Geo::GDAL::ReadDirRecursive($path);
3297 }
3298 
3299 #** @method Rename($old, $new)
3300 # Package subroutine.
3301 # Rename a file.
3302 # @note The name of this method is VSIRename in GDAL.
3303 #*
3304 sub Rename {
3305  my ($old, $new) = @_;
3306  Geo::GDAL::Rename($old, $new);
3307 }
3308 
3309 #** @method RmDir($path)
3310 # Package subroutine.
3311 # Remove a directory.
3312 # @note The name of this method is VSIRmdir in GDAL.
3313 #*
3314 sub RmDir {
3315  my ($dirname, $recursive) = @_;
3316  eval {
3317  if (!$recursive) {
3318  Geo::GDAL::Rmdir($dirname);
3319  } else {
3320  for my $f (ReadDir($dirname)) {
3321  next if $f eq '..' or $f eq '.';
3322  my @s = Stat($dirname.'/'.$f);
3323  if ($s[0] eq 'f') {
3324  Unlink($dirname.'/'.$f);
3325  } elsif ($s[0] eq 'd') {
3326  Rmdir($dirname.'/'.$f, 1);
3327  Rmdir($dirname.'/'.$f);
3328  }
3329  }
3330  RmDir($dirname);
3331  }
3332  };
3333  if ($@) {
3334  my $r = $recursive ? ' recursively' : '';
3335  Geo::GDAL::error("Cannot remove directory \"$dirname\"$r.");
3336  }
3337 }
3338 
3339 #** @method Seek($offset, $whence)
3340 # Object method.
3341 #*
3342 sub Seek {
3343  my ($self, $offset, $whence) = @_;
3344  Geo::GDAL::VSIFSeekL($self, $offset, $whence);
3345 }
3346 
3347 #** @method list Stat($filename)
3348 # Package subroutine.
3349 # @return ($filemode, $filesize). filemode is f for a plain file, d
3350 # for a directory, l for a symbolic link, p for a named pipe (FIFO), S
3351 # for a socket, b for a block special file, and c for a character
3352 # special file.
3353 #*
3354 sub Stat {
3355  my ($path) = @_;
3356  Geo::GDAL::Stat($path);
3357 }
3358 
3359 #** @method scalar Tell()
3360 # Object method.
3361 #*
3362 sub Tell {
3363  my ($self) = @_;
3364  Geo::GDAL::VSIFTellL($self);
3365 }
3366 
3367 #** @method Truncate($new_size)
3368 # Object method.
3369 #*
3370 sub Truncate {
3371  my ($self, $new_size) = @_;
3372  Geo::GDAL::VSIFTruncateL($self, $new_size);
3373 }
3374 
3375 #** @method Unlink($filename)
3376 # Package subroutine.
3377 # @param filename The file to delete.
3378 # @return 0 on success and -1 on an error.
3379 #*
3380 sub Unlink {
3381  my ($filename) = @_;
3382  Geo::GDAL::Unlink($filename);
3383 }
3384 
3385 #** @method Write($scalar)
3386 # Object method.
3387 # @param scalar The byte string to write to the file.
3388 # @return Number of bytes written into the file.
3389 #*
3390 sub Write {
3391  my ($self, $data) = @_;
3392  Geo::GDAL::VSIFWriteL($data, $self);
3393 }
3394 
3395 #** @class Geo::GDAL::XML
3396 # @brief A simple XML parser
3397 #*
3398 package Geo::GDAL::XML;
3399 
3400 #** @method new($string)
3401 # Object method.
3402 # @param string String containing XML.
3403 # @return A new Geo::GDAL::XML object, which is a reference to an anonymous array.
3404 #*
3405 sub new {
3406  my $class = shift;
3407  my $xml = shift // '';
3408  my $self = Geo::GDAL::ParseXMLString($xml);
3409  bless $self, $class;
3410  $self->traverse(sub {my $node = shift; bless $node, $class});
3411  return $self;
3412 }
3413 
3414 #** @method serialize()
3415 # Object method.
3416 # @return The XML serialized into a string.
3417 #*
3418 sub serialize {
3419  my $self = shift;
3420  return Geo::GDAL::SerializeXMLTree($self);
3421 }
3422 1;
3423 # This file was automatically generated by SWIG (http://www.swig.org).
3424 # Version 2.0.4
3425 #
3426 # Do not make changes to this file unless you know what you are doing--modify
3427 # the SWIG interface file instead.
3428 }
3429 
3430 #** @method traverse(coderef subroutine)
3431 # Object method.
3432 # @param subroutine Code reference, which will be called for each node in the XML with parameters: node, node_type, node_value. Node type is either Attribute, Comment, Element, Literal, or Text.
3433 #*
3434 sub traverse {
3435  my ($self, $sub) = @_;
3436  my $type = $self->[0];
3437  my $data = $self->[1];
3438  $type = Geo::GDAL::NodeType($type);
3439  $sub->($self, $type, $data);
3440  for my $child (@{$self}[2..$#$self]) {
3441  traverse($child, $sub);
3442  }
3443 }
3444 
3445 #** @class Geo::GNM
3446 # @brief Base class for geographical networks in GDAL.
3447 #*
3448 package Geo::GNM;
3449 
3450 #** @method CastToGenericNetwork()
3451 #*
3452 sub CastToGenericNetwork {
3453 }
3454 
3455 #** @method CastToNetwork()
3456 #*
3457 sub CastToNetwork {
3458 }
3459 
3460 #** @method GATConnectedComponents()
3461 #*
3462 sub GATConnectedComponents {
3463 }
3464 
3465 #** @method GATDijkstraShortestPath()
3466 #*
3467 sub GATDijkstraShortestPath {
3468 }
3469 
3470 #** @method GATKShortestPath()
3471 #*
3472 sub GATKShortestPath {
3473 }
3474 
3475 #** @method GNM_EDGE_DIR_BOTH()
3476 #*
3477 sub GNM_EDGE_DIR_BOTH {
3478 }
3479 
3480 #** @method GNM_EDGE_DIR_SRCTOTGT()
3481 #*
3482 sub GNM_EDGE_DIR_SRCTOTGT {
3483 }
3484 
3485 #** @method GNM_EDGE_DIR_TGTTOSRC()
3486 #*
3487 sub GNM_EDGE_DIR_TGTTOSRC {
3488  1;
3489 }
3490 
3491 #** @class Geo::GNM::GenericNetwork
3492 #*
3493 package Geo::GNM::GenericNetwork;
3494 
3495 use base qw(Geo::GNM::Network Geo::GNM)
3496 
3497 #** @method ChangeAllBlockState()
3498 #*
3499 sub ChangeAllBlockState {
3500 }
3501 
3502 #** @method ChangeBlockState()
3503 #*
3504 sub ChangeBlockState {
3505 }
3506 
3507 #** @method ConnectFeatures()
3508 #*
3509 sub ConnectFeatures {
3510 }
3511 
3512 #** @method ConnectPointsByLines()
3513 #*
3514 sub ConnectPointsByLines {
3515 }
3516 
3517 #** @method CreateRule()
3518 #*
3519 sub CreateRule {
3520 }
3521 
3522 #** @method DeleteAllRules()
3523 #*
3524 sub DeleteAllRules {
3525 }
3526 
3527 #** @method DeleteRule()
3528 #*
3529 sub DeleteRule {
3530 }
3531 
3532 #** @method DisconnectFeatures()
3533 #*
3534 sub DisconnectFeatures {
3535 }
3536 
3537 #** @method DisconnectFeaturesWithId()
3538 #*
3539 sub DisconnectFeaturesWithId {
3540 }
3541 
3542 #** @method GetRules()
3543 #*
3544 sub GetRules {
3545 }
3546 
3547 #** @method ReconnectFeatures()
3548 #*
3549 sub ReconnectFeatures {
3550 }
3551 
3552 #** @class Geo::GNM::MajorObject
3553 #*
3554 package Geo::GNM::MajorObject;
3555 
3556 use base qw(Geo::GNM)
3557 
3558 #** @method GetDescription()
3559 #*
3560 sub GetDescription {
3561 }
3562 
3563 #** @method GetMetadataDomainList()
3564 #*
3565 sub GetMetadataDomainList {
3566 }
3567 
3568 #** @method GetMetadataItem()
3569 #*
3570 sub GetMetadataItem {
3571 }
3572 
3573 #** @method GetMetadata_Dict()
3574 #*
3575 sub GetMetadata_Dict {
3576 }
3577 
3578 #** @method GetMetadata_List()
3579 #*
3580 sub GetMetadata_List {
3581 }
3582 
3583 #** @method SetDescription()
3584 #*
3585 sub SetDescription {
3586 }
3587 
3588 #** @method SetMetadata()
3589 #*
3590 sub SetMetadata {
3591 }
3592 
3593 #** @method SetMetadataItem()
3594 #*
3595 sub SetMetadataItem {
3596 }
3597 
3598 #** @class Geo::GNM::Network
3599 #*
3600 package Geo::GNM::Network;
3601 
3602 use base qw(Geo::GNM::MajorObject Geo::GNM)
3603 
3604 #** @method CommitTransaction()
3605 #*
3606 sub CommitTransaction {
3607 }
3608 
3609 #** @method CopyLayer()
3610 #*
3611 sub CopyLayer {
3612 }
3613 
3614 #** @method CreateLayer()
3615 #*
3616 sub CreateLayer {
3617 }
3618 
3619 #** @method DeleteLayer()
3620 #*
3621 sub DeleteLayer {
3622 }
3623 
3624 #** @method DisconnectAll()
3625 #*
3626 sub DisconnectAll {
3627 }
3628 
3629 #** @method GetFeatureByGlobalFID()
3630 #*
3631 sub GetFeatureByGlobalFID {
3632 }
3633 
3634 #** @method GetFileList()
3635 #*
3636 sub GetFileList {
3637 }
3638 
3639 #** @method GetLayerByIndex()
3640 #*
3641 sub GetLayerByIndex {
3642 }
3643 
3644 #** @method GetLayerByName()
3645 #*
3646 sub GetLayerByName {
3647 }
3648 
3649 #** @method GetLayerCount()
3650 #*
3651 sub GetLayerCount {
3652 }
3653 
3654 #** @method GetName()
3655 #*
3656 sub GetName {
3657 }
3658 
3659 #** @method GetPath()
3660 #*
3661 sub GetPath {
3662 }
3663 
3664 #** @method GetProjection()
3665 #*
3666 sub GetProjection {
3667 }
3668 
3669 #** @method GetProjectionRef()
3670 #*
3671 sub GetProjectionRef {
3672 }
3673 
3674 #** @method GetVersion()
3675 #*
3676 sub GetVersion {
3677 }
3678 
3679 #** @method ReleaseResultSet()
3680 #*
3681 sub ReleaseResultSet {
3682 }
3683 
3684 #** @method RollbackTransaction()
3685 #*
3686 sub RollbackTransaction {
3687 }
3688 
3689 #** @method StartTransaction()
3690 #*
3691 sub StartTransaction {
3692 }
3693 
3694 #** @method TestCapability()
3695 #*
3696 sub TestCapability {
3697 }
3698 
3699 #** @class Geo::OGR
3700 # @brief OGR utility functions.
3701 #
3702 # A wrapper for many OGR utility functions and a root class for all
3703 # OGR classes.
3704 #*
3705 package Geo::OGR;
3706 
3707 #** @method list ByteOrders()
3708 # Package subroutine.
3709 # @return a list of byte order types, XDR and NDR. XDR denotes
3710 # big-endian and NDR denotes little-endian.
3711 #*
3712 sub ByteOrders {
3713 }
3714 
3715 #** @method Geo::GDAL::Driver Driver($name)
3716 # Package subroutine.
3717 # A.k.a GetDriver.
3718 # @param name the short name of the driver.
3719 # @note No check is made that the driver is actually a vector driver.
3720 # @return a Geo::GDAL::Driver object.
3721 #*
3722 sub Driver {
3723  return 'Geo::GDAL::Driver' unless @_;
3724  bless Geo::GDAL::Driver(@_), 'Geo::OGR::Driver';
3725 }
3726 
3727 #** @method list DriverNames()
3728 # Package subroutine.
3729 # A.k.a GetDriverNames
3730 # @note Use Geo::GDAL::DriverNames for raster drivers.
3731 # @return a list of the short names of all available GDAL vector drivers.
3732 #*
3733 sub DriverNames {
3734 }
3735 
3736 #** @method list Drivers()
3737 # Package subroutine.
3738 # @note Use Geo::GDAL::Drivers for raster drivers.
3739 # @return a list of all available GDAL vector drivers.
3740 #*
3741 sub Drivers {
3742  my @drivers;
3743  for my $i (0..GetDriverCount()-1) {
3744  my $driver = Geo::GDAL::GetDriver($i);
3745  push @drivers, $driver if $driver->TestCapability('VECTOR');
3746  }
3747  return @drivers;
3748 }
3749 
3750 #** @method scalar GeometryTypeModify($type, $modifier)
3751 # Object method.
3752 # @param type a geometry type (one of Geo::OGR::GeometryTypes).
3753 # @param modifier one of 'flatten', 'set_Z', 'make_collection', 'make_curve', or 'make_linear'.
3754 # @return modified geometry type.
3755 #*
3756 sub GeometryTypeModify {
3757  my($type, $modifier) = @_;
3758  Geo::GDAL::error(1, $type, \%Geo::OGR::Geometry::TYPE_STRING2INT) unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type};
3759  $type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type};
3760  return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_Flatten($type)} if $modifier =~ /flat/i;
3761  return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_SetZ($type)} if $modifier =~ /z/i;
3762  return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetCollection($type)} if $modifier =~ /collection/i;
3763  return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetCurve($type)} if $modifier =~ /curve/i;
3764  return $Geo::OGR::Geometry::TYPE_INT2STRING{GT_GetLinear($type)} if $modifier =~ /linear/i;
3765  Geo::GDAL::error(1, $modifier, {Flatten => 1, SetZ => 1, GetCollection => 1, GetCurve => 1, GetLinear => 1});
3766 }
3767 
3768 #** @method scalar GeometryTypeTest($type, $test, $type2)
3769 # Object method.
3770 # @param type a geometry type (one of Geo::OGR::GeometryTypes).
3771 # @param test one of 'has_z', 'is_subclass_of', 'is_curve', 'is_surface', or 'is_non_linear'.
3772 # @param type2 a geometry type (one of Geo::OGR::GeometryTypes). Required for 'is_subclass_of' test.
3773 # @return result of the test.
3774 #*
3775 sub GeometryTypeTest {
3776  my($type, $test, $type2) = @_;
3777  Geo::GDAL::error(1, $type, \%Geo::OGR::Geometry::TYPE_STRING2INT) unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type};
3778  $type = $Geo::OGR::Geometry::TYPE_STRING2INT{$type};
3779  if (defined $type2) {
3780  Geo::GDAL::error(1, $type2, \%Geo::OGR::Geometry::TYPE_STRING2INT) unless exists $Geo::OGR::Geometry::TYPE_STRING2INT{$type2};
3781  $type2 = $Geo::OGR::Geometry::TYPE_STRING2INT{$type2};
3782  } else {
3783  Geo::GDAL::error("Usage: GeometryTypeTest(type1, 'is_subclass_of', type2).") if $test =~ /subclass/i;
3784  }
3785  return GT_HasZ($type) if $test =~ /z/i;
3786  return GT_IsSubClassOf($type, $type2) if $test =~ /subclass/i;
3787  return GT_IsCurve($type) if $test =~ /curve/i;
3788  return GT_IsSurface($type) if $test =~ /surface/i;
3789  return GT_IsNonLinear($type) if $test =~ /linear/i;
3790  Geo::GDAL::error(1, $test, {HasZ => 1, IsSubClassOf => 1, IsCurve => 1, IsSurface => 1, IsNonLinear => 1});
3791 }
3792 
3793 #** @method list GeometryTypes()
3794 # Package subroutine.
3795 # @return a list of all geometry types, currently:
3796 # CircularString, CircularStringM, CircularStringZ, CircularStringZM, CompoundCurve, CompoundCurveM, CompoundCurveZ, CompoundCurveZM, Curve, CurveM, CurvePolygon, CurvePolygonM, CurvePolygonZ, CurvePolygonZM, CurveZ, CurveZM, GeometryCollection, GeometryCollection25D, GeometryCollectionM, GeometryCollectionZM, LineString, LineString25D, LineStringM, LineStringZM, LinearRing, MultiCurve, MultiCurveM, MultiCurveZ, MultiCurveZM, MultiLineString, MultiLineString25D, MultiLineStringM, MultiLineStringZM, MultiPoint, MultiPoint25D, MultiPointM, MultiPointZM, MultiPolygon, MultiPolygon25D, MultiPolygonM, MultiPolygonZM, MultiSurface, MultiSurfaceM, MultiSurfaceZ, MultiSurfaceZM, None, Point, Point25D, PointM, PointZM, Polygon, Polygon25D, PolygonM, PolygonZM, PolyhedralSurface, PolyhedralSurfaceM, PolyhedralSurfaceZ, PolyhedralSurfaceZM, Surface, SurfaceM, SurfaceZ, SurfaceZM, TIN, TINM, TINZ, TINZM, and Unknown.
3797 #*
3798 sub GeometryTypes {
3799  1;
3800  # This file was automatically generated by SWIG (http://www.swig.org).
3801  # Version 2.0.4
3802  #
3803  # Do not make changes to this file unless you know what you are doing--modify
3804  # the SWIG interface file instead.
3805 }
3806 
3807 #** @method GetNonLinearGeometriesEnabledFlag()
3808 #*
3809 sub GetNonLinearGeometriesEnabledFlag {
3810 }
3811 
3812 #** @method GetOpenDSCount()
3813 #*
3814 sub GetOpenDSCount {
3815 }
3816 
3817 #** @method Geo::GDAL::Dataset Open($name, $update = 0)
3818 # Object method.
3819 # Open a vector data source.
3820 # @param name The data source string (directory, filename, etc.).
3821 # @param update Whether to open the data source in update mode (default is not).
3822 # @return a new Geo::GDAL::Dataset object.
3823 #*
3824 sub Open {
3825  my @p = @_; # name, update
3826  my @flags = qw/VECTOR/;
3827  push @flags, qw/UPDATE/ if $p[1];
3828  my $dataset = Geo::GDAL::OpenEx($p[0], \@flags);
3829  Geo::GDAL::error("Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
3830  return $dataset;
3831 }
3832 
3833 #** @method Geo::GDAL::Dataset OpenShared($name, $update = 0)
3834 # Object method.
3835 # Open a vector data source in shared mode.
3836 # @param name The data source string (directory, filename, etc.).
3837 # @param update Whether to open the data source in update mode.
3838 # @return a new Geo::GDAL::Dataset object.
3839 #*
3840 sub OpenShared {
3841  my @p = @_; # name, update
3842  my @flags = qw/VECTOR SHARED/;
3843  push @flags, qw/UPDATE/ if $p[1];
3844  my $dataset = Geo::GDAL::OpenEx($p[0], \@flags);
3845  Geo::GDAL::error("Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
3846  return $dataset;
3847 }
3848 
3849 #** @method SetGenerate_DB2_V72_BYTE_ORDER($Generate_DB2_V72_BYTE_ORDER)
3850 # Object method.
3851 # Needed only on IBM DB2.
3852 #*
3853 sub SetGenerate_DB2_V72_BYTE_ORDER {
3854 }
3855 
3856 #** @method SetNonLinearGeometriesEnabledFlag()
3857 #*
3858 sub SetNonLinearGeometriesEnabledFlag {
3859 }
3860 
3861 #** @class Geo::OGR::DataSource
3862 # @brief A vector dataset. This is a legacy class which should not be
3863 # used in new code. Use Geo::GDAL::Dataset.
3864 #*
3865 package Geo::OGR::DataSource;
3866 
3867 #** @method Geo::GDAL::Dataset Open()
3868 # Package subroutine.
3869 # The same as Geo::OGR::Open
3870 #*
3871 sub Open {
3872 }
3873 
3874 #** @method Geo::GDAL::Dataset OpenShared()
3875 # Package subroutine.
3876 # The same as Geo::OGR::OpenShared
3877 #*
3878 sub OpenShared {
3879 }
3880 
3881 #** @class Geo::OGR::Driver
3882 # @brief A vector format driver. This is a legacy class which
3883 # should not be used in new code. Use Geo::GDAL::Driver.
3884 #*
3885 package Geo::OGR::Driver;
3886 
3887 use base qw(our /Geo::GDAL::Driver/)
3888 
3889 #** @method Geo::GDAL::Dataset Copy(Geo::GDAL::Dataset source, $name, arrayref options = undef)
3890 # Object method.
3891 # Copy a vector data source into a new data source with this driver.
3892 # @param source The Geo::GDAL::Dataset object to be copied.
3893 # @param name The name for the new data source.
3894 # @param options Driver specific options. In addition to options
3895 # specified in GDAL documentation the option STRICT can be set to 'NO'
3896 # for a more relaxed copy. Otherwise the STRICT is 'YES'.
3897 # @note The order of the first two parameters is different from that in Geo::GDAL::Driver::Copy.
3898 # @return a new Geo::GDAL::Dataset object.
3899 #*
3900 sub Copy {
3901  my ($self, @p) = @_; # src, name, options
3902  my $strict = 1; # the default in bindings
3903  $strict = 0 if $p[2] && $p[2]->{STRICT} eq 'NO';
3904  $self->SUPER::Copy($p[1], $p[0], $strict, @{$p[2..4]}); # path, src, strict, options, cb, cb_data
3905 }
3906 
3907 #** @method Geo::GDAL::Dataset Create($name, hashref options = undef )
3908 # Object method.
3909 # Create a new vector data source using this driver.
3910 # @param name The data source name.
3911 # @param options Driver specific dataset creation options.
3912 #*
3913 sub Create {
3914  my ($self, $name, $options) = @_; # name, options
3915  $options //= {};
3916  $self->SUPER::Create(Name => $name, Width => 0, Height => 0, Bands => 0, Type => 'Byte', Options => $options);
3917 }
3918 
3919 #** @method Open()
3920 # Object method.
3921 # The same as Geo::OGR::Open except that only this driver is allowed.
3922 #*
3923 sub Open {
3924  my $self = shift;
3925  my @p = @_; # name, update
3926  my @flags = qw/VECTOR/;
3927  push @flags, qw/UPDATE/ if $p[1];
3928  my $dataset = Geo::GDAL::OpenEx($p[0], \@flags, [$self->Name()]);
3929  Geo::GDAL::error("Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
3930  return $dataset;
3931 }
3932 
3933 #** @class Geo::OGR::Feature
3934 # @brief A collection of non-spatial and spatial attributes.
3935 #
3936 # A feature is a collection of non-spatial and spatial attributes and
3937 # an id, which is a special attribute, and data records according to
3938 # this data model. Attributes are called fields and some fields are
3939 # spatial, i.e., their value is a geometry. Fields have at least a
3940 # name and a type. Features may exist within a layer or
3941 # separetely. The data model of a feature is a definition object.
3942 #*
3943 package Geo::OGR::Feature;
3944 
3945 use base qw(Geo::OGR)
3946 
3947 #** @method Geo::OGR::Feature Clone()
3948 # Object method.
3949 # @return a new Geo::OGR::Feature object
3950 #*
3951 sub Clone {
3952 }
3953 
3954 #** @method DumpReadable()
3955 # Object method.
3956 # Write the contents of this feature to stdout.
3957 #*
3958 sub DumpReadable {
3959 }
3960 
3961 #** @method scalar Equal($feature)
3962 # Object method.
3963 # @param feature a Geo::OGR::Feature object for comparison
3964 # @return boolean
3965 #*
3966 sub Equal {
3967 }
3968 
3969 #** @method scalar FID($id)
3970 # Object method.
3971 # @brief Get or set the id of this feature.
3972 # @param id [optional] the id to set for this feature.
3973 # @return integer the id of this feature.
3974 #*
3975 sub FID {
3976  my $self = shift;
3977  $self->SetFID($_[0]) if @_;
3978  return unless defined wantarray;
3979  $self->GetFID;
3980 }
3981 
3982 #** @method Field($name, $value, ...)
3983 # Object method.
3984 # @brief Get, set, or unset the field value.
3985 # @param name the name (or the index) of the field.
3986 # @param value a scalar, a list of scalars or a reference to a
3987 # list. If undef, the field is unset. If a scalar or a list of
3988 # scalars, the field is set from them.
3989 # @note Non-scalar fields (for example Date) can be set either from a
3990 # scalar, which is then assumed to be a string and parsed, or from a
3991 # list of values (for example year, month, day for Date).
3992 # @return in non-void context the value of the field, which may be a
3993 # scalar or a list, depending on the field type. For unset fields the
3994 # undef value is returned.
3995 #*
3996 sub Field {
3997  my $self = shift;
3998  my $field = shift;
3999  $self->SetField($field, @_) if @_;
4000  $self->GetField($field) if defined wantarray;
4001 }
4002 
4003 #** @method FillUnsetWithDefault()
4004 #*
4005 sub FillUnsetWithDefault {
4006 }
4007 
4008 #** @method Geometry($name, $geometry)
4009 # Object method.
4010 # @brief Get or set the value of a geometry field.
4011 # @note This method delivers the functionality of undocumented methods
4012 # SetGeometry($geometry), SetGeometryDirectly, SetGeomField,
4013 # SetGeomFieldDirectly, GetGeometry, GetGeometryRef.
4014 #
4015 # Set or get the geometry in the feature. When setting, does a check
4016 # against the schema (GeometryType) of the feature. If the parameter
4017 # is a geometry object, it is cloned.
4018 # @param name [optional] the name of the spatial field,
4019 # whose geometry is to be set. If not given, sets or gets the geometry
4020 # of the first (or the single) spatial field.
4021 # @param geometry [optional] a Geo::OGR::Geometry object or a
4022 # reference to a hash from which such can be created (using
4023 # Geo::OGR::Geometry::new).
4024 # @return in a non-void context the indicated geometry in the feature
4025 # as a Geo::OGR::Geometry object. The returned object contains a
4026 # reference to the actual geometry data in the feature (the geometry
4027 # is not cloned) and to the feature object, thus keeping the feature
4028 # object from being destroyed while the geometry object exists.
4029 #*
4030 sub Geometry {
4031  my $self = shift;
4032  my $field = ((@_ > 0 and ref($_[0]) eq '') or (@_ > 2 and @_ % 2 == 1)) ? shift : 0;
4033  my $geometry;
4034  if (@_ and @_ % 2 == 0) {
4035  %$geometry = @_;
4036  } else {
4037  $geometry = shift;
4038  }
4039  if ($geometry) {
4040  my $type = $self->GetDefn->GetGeomFieldDefn($field)->Type;
4041  if (blessed($geometry) and $geometry->isa('Geo::OGR::Geometry')) {
4042  my $gtype = $geometry->GeometryType;
4043  Geo::GDAL::error("The type of the inserted geometry ('$gtype') is not the same as the type of the field ('$type').")
4044  if $type ne 'Unknown' and $type ne $gtype;
4045  eval {
4046  $self->SetGeomFieldDirectly($field, $geometry->Clone);
4047  };
4048  confess Geo::GDAL->last_error if $@;
4049  } elsif (ref($geometry) eq 'HASH') {
4050  $geometry->{GeometryType} //= $type;
4051  eval {
4052  $geometry = Geo::OGR::Geometry->new($geometry);
4053  };
4054  my $gtype = $geometry->GeometryType;
4055  Geo::GDAL::error("The type of the inserted geometry ('$gtype') is not the same as the type of the field ('$type').")
4056  if $type ne 'Unknown' and $type ne $gtype;
4057  eval {
4058  $self->SetGeomFieldDirectly($field, $geometry);
4059  };
4060  confess Geo::GDAL->last_error if $@;
4061  } else {
4062  Geo::GDAL::error("Usage: \$feature->Geometry([field],[geometry])");
4063  }
4064  }
4065  return unless defined wantarray;
4066  $geometry = $self->GetGeomFieldRef($field);
4067  return unless $geometry;
4068  $GEOMETRIES{tied(%$geometry)} = $self;
4069  return $geometry;
4070 }
4071 
4072 #** @method Geo::OGR::FeatureDefn GetDefn()
4073 # Object method.
4074 # @note A.k.a GetDefnRef.
4075 # @return a Geo::OGR::FeatureDefn object, which represents the definition of this feature.
4076 #*
4077 sub GetDefn {
4078  my $self = shift;
4079  my $defn = $self->GetDefnRef;
4080  $DEFNS{tied(%$defn)} = $self;
4081  return $defn;
4082 }
4083 
4084 #** @method scalar GetFID()
4085 # Object method.
4086 # @return the feature id (an integer).
4087 #*
4088 sub GetFID {
4089 }
4090 
4091 #** @method list GetField($name)
4092 # Object method.
4093 # See Field().
4094 #*
4095 sub GetField {
4096  my($self, $field) = @_;
4097  return unless IsFieldSet($self, $field);
4098  my $type = GetFieldType($self, $field);
4099  if ($type == $Geo::OGR::OFTInteger) {
4100  return GetFieldAsInteger($self, $field);
4101  }
4102  if ($type == $Geo::OGR::OFTInteger64) {
4103  return GetFieldAsInteger64($self, $field);
4104  }
4105  if ($type == $Geo::OGR::OFTReal) {
4106  return GetFieldAsDouble($self, $field);
4107  }
4108  if ($type == $Geo::OGR::OFTString) {
4109  return GetFieldAsString($self, $field);
4110  }
4111  if ($type == $Geo::OGR::OFTIntegerList) {
4112  my $ret = GetFieldAsIntegerList($self, $field);
4113  return wantarray ? @$ret : $ret;
4114  }
4115  if ($type == $Geo::OGR::OFTInteger64List) {
4116  my $ret = GetFieldAsInteger64List($self, $field);
4117  return wantarray ? @$ret : $ret;
4118  }
4119  if ($type == $Geo::OGR::OFTRealList) {
4120  my $ret = GetFieldAsDoubleList($self, $field);
4121  return wantarray ? @$ret : $ret;
4122  }
4123  if ($type == $Geo::OGR::OFTStringList) {
4124  my $ret = GetFieldAsStringList($self, $field);
4125  return wantarray ? @$ret : $ret;
4126  }
4127  if ($type == $Geo::OGR::OFTBinary) {
4128  return GetFieldAsBinary($self, $field);
4129  }
4130  if ($type == $Geo::OGR::OFTDate) {
4131  my @ret = GetFieldAsDateTime($self, $field);
4132  # year, month, day, hour, minute, second, timezone
4133  return wantarray ? @ret[0..2] : [@ret[0..2]];
4134  }
4135  if ($type == $Geo::OGR::OFTTime) {
4136  my @ret = GetFieldAsDateTime($self, $field);
4137  return wantarray ? @ret[3..6] : [@ret[3..6]];
4138  }
4139  if ($type == $Geo::OGR::OFTDateTime) {
4140  my @ret = GetFieldAsDateTime($self, $field);
4141  return wantarray ? @ret : [@ret];
4142  }
4143  Geo::GDAL::error("Perl bindings do not support field type '$Geo::OGR::FieldDefn::TYPE_INT2STRING{$type}'.");
4144 }
4145 
4146 #** @method Geo::OGR::FieldDefn GetFieldDefn($name)
4147 # Object method.
4148 # @note A.k.a GetFieldDefnRef
4149 # @param name the name of the field.
4150 # @return a new Geo::OGR::FieldDefn object that represents the field
4151 # in question.
4152 #*
4153 sub GetFieldDefn {
4154 }
4155 
4156 #** @method list GetFieldNames()
4157 # Object method.
4158 # Get the names of the fields in this feature.
4159 #*
4160 sub GetFieldNames {
4161 }
4162 
4163 #** @method GetGeomFieldDefn()
4164 #*
4165 sub GetGeomFieldDefn {
4166 }
4167 
4168 #** @method GetNativeData()
4169 #*
4170 sub GetNativeData {
4171 }
4172 
4173 #** @method GetNativeMediaType()
4174 #*
4175 sub GetNativeMediaType {
4176 }
4177 
4178 #** @method hash reference GetSchema()
4179 # Object method.
4180 # @brief Get the schema of this feature.
4181 #
4182 # @return the schema as a hash whose keywords are Name, StyleIgnored
4183 # and Fields. Fields is an anonymous array of first non-spatial and
4184 # then spatial field schemas as in Geo::OGR::FieldDefn::Schema() and
4185 # Geo::OGR::GeomFieldDefn::Schema().
4186 #*
4187 sub GetSchema {
4188  my $self = shift;
4189  Geo::GDAL::error("Schema of a feature cannot be set directly.") if @_;
4190  return $self->GetDefnRef->Schema;
4191 }
4192 
4193 #** @method scalar GetStyleString()
4194 # Object method.
4195 # @return a string
4196 #*
4197 sub GetStyleString {
4198 }
4199 
4200 #** @method Geo::OGR::Layer Layer()
4201 # Object method.
4202 # @return the layer to which this feature belongs to or undef.
4203 #*
4204 sub Layer {
4205  my $self = shift;
4206  return $Geo::OGR::Layer::FEATURES{tied(%$self)};
4207 }
4208 
4209 #** @method hash reference Row(%row)
4210 # Object method.
4211 # @note This method discards the data the destination feature (or
4212 # layer) does not support. Changes in data due to differences between
4213 # field types may also occur.
4214 #
4215 # Get and/or set the data of the feature. The key of the (key,value)
4216 # pairs of the row is the field name. Special field names FID and
4217 # Geometry are used for feature id and (single) geometry
4218 # respectively. The geometry/ies is/are set and get using the
4219 # Geo::OGR::Feature::Geometry method. Field values are set using the
4220 # Geo::OGR::Feature::Field method.
4221 # @param row [optional] feature data in a hash.
4222 # @return a reference to feature data in a hash. Spatial fields are
4223 # returned as Geo::OGR::Geometry objects.
4224 #*
4225 sub Row {
4226  my $self = shift;
4227  my $nf = $self->GetFieldCount;
4228  my $ngf = $self->GetGeomFieldCount;
4229  if (@_) { # update
4230  my %row;
4231  if (@_ == 1 and ref($_[0]) eq 'HASH') {
4232  %row = %{$_[0]};
4233  } elsif (@_ and @_ % 2 == 0) {
4234  %row = @_;
4235  } else {
4236  Geo::GDAL::error('Usage: $feature->Row(%FeatureData).');
4237  }
4238  $self->SetFID($row{FID}) if defined $row{FID};
4239  #$self->Geometry($schema, $row{Geometry}) if $row{Geometry};
4240  for my $name (keys %row) {
4241  next if $name eq 'FID';
4242  if ($name eq 'Geometry') {
4243  $self->Geometry(0, $row{$name});
4244  next;
4245  }
4246  my $f = 0;
4247  for my $i (0..$nf-1) {
4248  if ($self->GetFieldDefnRef($i)->Name eq $name) {
4249  $self->SetField($i, $row{$name});
4250  $f = 1;
4251  last;
4252  }
4253  }
4254  next if $f;
4255  for my $i (0..$ngf-1) {
4256  if ($self->GetGeomFieldDefnRef($i)->Name eq $name) {
4257  $self->Geometry($i, $row{$name});
4258  $f = 1;
4259  last;
4260  }
4261  }
4262  next if $f;
4263  carp "Unknown field: '$name'.";
4264  }
4265  }
4266  return unless defined wantarray;
4267  my %row = ();
4268  for my $i (0..$nf-1) {
4269  my $name = $self->GetFieldDefnRef($i)->Name;
4270  $row{$name} = $self->GetField($i);
4271  }
4272  for my $i (0..$ngf-1) {
4273  my $name = $self->GetGeomFieldDefnRef($i)->Name || 'Geometry';
4274  $row{$name} = $self->GetGeometry($i);
4275  }
4276  $row{FID} = $self->GetFID;
4277  return \%row;
4278 }
4279 
4280 #** @method SetFID($id)
4281 # Object method.
4282 # @param id the feature id.
4283 #*
4284 sub SetFID {
4285 }
4286 
4287 #** @method SetField($name, @Value)
4288 # Object method.
4289 # See Field().
4290 #*
4291 sub SetField {
4292  my $self = shift;
4293  my $field = shift;
4294  my $arg = $_[0];
4295  if (@_ == 0 or !defined($arg)) {
4296  _UnsetField($self, $field);
4297  return;
4298  }
4299  $arg = [@_] if @_ > 1;
4300  my $type = $self->GetFieldType($field);
4301  if (ref($arg)) {
4302  if ($type == $Geo::OGR::OFTIntegerList) {
4303  SetFieldIntegerList($self, $field, $arg);
4304  }
4305  elsif ($type == $Geo::OGR::OFTInteger64List) {
4306  SetFieldInteger64List($self, $field, $arg);
4307  }
4308  elsif ($type == $Geo::OGR::OFTRealList) {
4309  SetFieldDoubleList($self, $field, $arg);
4310  }
4311  elsif ($type == $Geo::OGR::OFTStringList) {
4312  SetFieldStringList($self, $field, $arg);
4313  }
4314  elsif ($type == $Geo::OGR::OFTDate) {
4315  _SetField($self, $field, @$arg[0..2], 0, 0, 0, 0);
4316  }
4317  elsif ($type == $Geo::OGR::OFTTime) {
4318  $arg->[3] //= 0;
4319  _SetField($self, $field, 0, 0, 0, @$arg[0..3]);
4320  }
4321  elsif ($type == $Geo::OGR::OFTDateTime) {
4322  $arg->[6] //= 0;
4323  _SetField($self, $field, @$arg[0..6]);
4324  }
4325  else {
4326  _SetField($self, $field, @$arg);
4327  }
4328  } else {
4329  if ($type == $Geo::OGR::OFTBinary) {
4330  #$arg = unpack('H*', $arg); # remove when SetFieldBinary is available
4331  $self->SetFieldBinary($field, $arg);
4332  } else {
4333  _SetField($self, $field, $arg);
4334  }
4335  }
4336 }
4337 
4338 #** @method SetFrom($other, $forgiving = 1, hashref map)
4339 # Object method.
4340 # @param other a Geo::OGR::Feature object
4341 # @param forgiving [optional] set to false if the operation should not
4342 # continue if output fields do not match some of the source fields
4343 # @param map [optional] a mapping from output field indexes to source
4344 # fields, include into the hash all field indexes of this feature
4345 # which should be set
4346 #*
4347 sub SetFrom {
4348  my($self, $other) = @_;
4349  _SetFrom($self, $other), return if @_ <= 2;
4350  my $forgiving = $_[2];
4351  _SetFrom($self, $other, $forgiving), return if @_ <= 3;
4352  my $map = $_[3];
4353  my @list;
4354  for my $i (1..GetFieldCount($self)) {
4355  push @list, ($map->{$i} || -1);
4356  }
4357  SetFromWithMap($self, $other, 1, \@list);
4358 }
4359 
4360 #** @method SetNativeData()
4361 #*
4362 sub SetNativeData {
4363 }
4364 
4365 #** @method SetNativeMediaType()
4366 #*
4367 sub SetNativeMediaType {
4368 }
4369 
4370 #** @method SetStyleString($string)
4371 # Object method.
4372 # @param string
4373 #*
4374 sub SetStyleString {
4375 }
4376 
4377 #** @method list Tuple(@tuple)
4378 # Object method.
4379 # @note This method discards the data the destination feature (or
4380 # layer) does not support. Changes in data due to differences between
4381 # field types may also occur.
4382 #
4383 # @note The schema of the tuple needs to be the same as that of the
4384 # feature.
4385 #
4386 # Get and/set the data of the feature. The expected data in the tuple
4387 # is ([feature_id,] non-spatial fields, spatial fields). The fields in
4388 # the tuple are in the order they are in the schema. Field values are
4389 # set using the Geo::OGR::Feature::Field method. Geometries are set
4390 # and get using the Geo::OGR::Feature::Geometry method.
4391 # @param tuple [optional] feature data in an array
4392 # @return feature data in an array
4393 #*
4394 sub Tuple {
4395  my $self = shift;
4396  my $nf = $self->GetFieldCount;
4397  my $ngf = $self->GetGeomFieldCount;
4398  if (@_) {
4399  my $FID;
4400  $FID = shift if @_ == $nf + $ngf + 1;
4401  $self->SetFID($FID) if defined $FID;
4402  my $values = \@_;
4403  if (@$values != $nf + $ngf) {
4404  my $n = $nf + $ngf;
4405  Geo::GDAL::error("Too many or too few attribute values for a feature (need $n).");
4406  }
4407  my $index = 0; # index to non-geometry and geometry fields
4408  for my $i (0..$nf-1) {
4409  $self->SetField($i, $values->[$i]);
4410  }
4411  for my $i (0..$ngf-1) {
4412  $self->Geometry($i, $values->[$nf+$i]);
4413  }
4414  }
4415  return unless defined wantarray;
4416  my @ret = ($self->GetFID);
4417  for my $i (0..$nf-1) {
4418  my $v = $self->GetField($i);
4419  push @ret, $v;
4420  }
4421  for my $i (0..$ngf-1) {
4422  my $v = $self->GetGeometry($i);
4423  push @ret, $v;
4424  }
4425  return @ret;
4426 }
4428 #** @method scalar Validate(list flags)
4429 # Object method.
4430 # @param flags one of more of null, geom_type, width,
4431 # allow_null_when_default, or all.
4432 # @exception croaks with an error message if the feature is not valid.
4433 # @return integer denoting the validity of the feature object.
4434 #*
4435 sub Validate {
4436  my $self = shift;
4437  my $flags = 0;
4438  for my $flag (@_) {
4439  my $f = eval '$Geo::OGR::'.uc($flag);
4440  $flags |= $f;
4441  }
4442  _Validate($self, $flags);
4443 }
4444 
4445 #** @method Geo::OGR::Feature new(%schema)
4446 # Class method.
4447 # @brief Create a new feature.
4448 # @param A Geo::OGR::FeatureDefn object or named parameters to create one:
4449 # - \a Name
4450 # - \a Fields a list of Geo::OGR::FieldDefn or Geo::OGR::GeomFieldDefn
4451 # objects or anonymous hashes from which such can be created.
4452 # - \a GeometryType the geometry type if the feature has only one spatial field.
4453 # - \a StyleIgnored whether the style can be omitted when fetching features. (default is false)
4454 #
4455 # @note Do not mix GeometryType and geometry fields in Fields list.
4456 #
4457 # @return a new Geo::OGR::Feature object.
4458 #*
4459 sub new {
4460  my $pkg = shift;
4461  my $arg = blessed($_[0]);
4462  my $defn;
4463  if ($arg && $arg eq 'Geo::OGR::FeatureDefn') {
4464  $defn = $_[0];
4465  } else {
4466  $defn = Geo::OGR::FeatureDefn->new(@_);
4467  }
4468  my $self = Geo::OGRc::new_Feature($defn);
4469  bless $self, $pkg if defined($self);
4470 }
4471 
4472 #** @class Geo::OGR::FeatureDefn
4473 # @brief The schema of a feature or a layer.
4474 #
4475 # A FeatureDefn object is a collection of field definition objects. A
4476 # read-only FeatureDefn object can be obtained from a layer
4477 # (Geo::OGR::Layer::GetDefn()) or a feature
4478 # (Geo::OGR::Feature::GetDefn()).
4479 #*
4480 package Geo::OGR::FeatureDefn;
4481 
4482 use base qw(Geo::OGR)
4483 
4484 #** @method AddField(%params)
4485 # Object method.
4486 # @param params Named parameters to create a new Geo::OGR::FieldDefn
4487 # or Geo::OGR::GeomFieldDefn object.
4488 #*
4489 sub AddField {
4490  my $self = shift;
4491  Geo::GDAL::error("Read-only definition.") if $Geo::OGR::Feature::DEFNS{tied(%$self)} || $Geo::OGR::Layer::DEFNS{tied(%$self)};
4492  my %params;
4493  if (@_ == 0) {
4494  } elsif (ref($_[0]) eq 'HASH') {
4495  %params = %{$_[0]};
4496  } elsif (@_ % 2 == 0) {
4497  %params = @_;
4498  }
4499  $params{Type} //= '';
4500  if (exists $Geo::OGR::FieldDefn::TYPE_STRING2INT{$params{Type}}) {
4501  my $fd = Geo::OGR::FieldDefn->new(%params);
4502  $self->AddFieldDefn($fd);
4503  } else {
4504  my $fd = Geo::OGR::GeomFieldDefn->new(%params);
4505  $self->AddGeomFieldDefn($fd);
4506  }
4507 }
4508 
4509 #** @method DeleteField($name)
4510 # Object method.
4511 # @note Currently only geometry fields can be deleted.
4512 # @param index the index of the geometry field to be deleted.
4513 #*
4514 sub DeleteField {
4515  my ($self, $name) = @_;
4516  Geo::GDAL::error("Read-only definition.") if $Geo::OGR::Feature::DEFNS{tied(%$self)} || $Geo::OGR::Layer::DEFNS{tied(%$self)};
4517  for my $i (0..$self->GetFieldCount-1) {
4518  Geo::GDAL::error("Non-geometry fields cannot be deleted.") if $self->GetFieldDefn($i)->Name eq $name;
4519  }
4520  for my $i (0..$self->GetGeomFieldCount-1) {
4521  $self->DeleteGeomFieldDefn($i) if $self->GetGeomFieldDefn($i)->Name eq $name;
4522  }
4523  Geo::GDAL::error(2, $name, 'Field');
4524 }
4525 
4526 #** @method Feature()
4527 #*
4528 sub Feature {
4529  my $self = shift;
4530  return $Geo::OGR::Feature::DEFNS{tied(%$self)};
4531 }
4532 
4533 #** @method object GetFieldDefn($name)
4534 # Object method.
4535 # @param name the name of the field.
4536 # @return either a Geo::OGR::FieldDefn or Geo::OGR::GeomFieldDefn
4537 # object that represents the field in question.
4538 #*
4539 sub GetFieldDefn {
4540  my ($self, $name) = @_;
4541  for my $i (0..$self->GetFieldCount-1) {
4542  my $fd = $self->GetFieldDefn($i);
4543  return $fd if $fd->Name eq $name;
4544  }
4545  for my $i (0..$self->GetGeomFieldCount-1) {
4546  my $fd = $self->GetGeomFieldDefn($i);
4547  return $fd if $fd->Name eq $name;
4548  }
4549  Geo::GDAL::error(2, $name, 'Field');
4550 }
4551 
4552 #** @method list GetFieldNames()
4553 # Object method.
4554 # The names of the fields in this layer or feature definition.
4555 # @return the list of field names.
4556 #*
4557 sub GetFieldNames {
4558  my $self = shift;
4559  my @names = ();
4560  for my $i (0..$self->GetFieldCount-1) {
4561  push @names, $self->GetFieldDefn($i)->Name;
4562  }
4563  for my $i (0..$self->GetGeomFieldCount-1) {
4564  push @names, $self->GetGeomFieldDefn($i)->Name;
4565  }
4566  return @names;
4567 }
4568 
4569 #** @method scalar GetName()
4570 # Object method.
4571 # @return the name of this layer or feature definition.
4572 #*
4573 sub GetName {
4574 }
4575 
4576 #** @method hash reference GetSchema()
4577 # Object method.
4578 # @brief Get the schema of this feature or layer definition.
4579 #
4580 # @return the schema as a hash whose keywords are Name, StyleIgnored
4581 # and Fields. Fields is an anonymous array of first non-spatial and
4582 # then spatial field schemas as in Geo::OGR::FieldDefn::Schema() and
4583 # Geo::OGR::GeomFieldDefn::Schema().
4584 #*
4585 sub GetSchema {
4586  my $self = shift;
4587  carp "Schema of a feature definition should not be set directly." if @_;
4588  if (@_ and @_ % 2 == 0) {
4589  my %schema = @_;
4590  if ($schema{Fields}) {
4591  for my $field (@{$schema{Fields}}) {
4592  $self->AddField($field);
4593  }
4594  }
4595  }
4596  my %schema;
4597  $schema{Name} = $self->Name();
4598  $schema{StyleIgnored} = $self->StyleIgnored();
4599  $schema{Fields} = [];
4600  for my $i (0..$self->GetFieldCount-1) {
4601  my $s = $self->GetFieldDefn($i)->Schema;
4602  push @{$schema{Fields}}, $s;
4603  }
4604  for my $i (0..$self->GetGeomFieldCount-1) {
4605  my $s = $self->GetGeomFieldDefn($i)->Schema;
4606  push @{$schema{Fields}}, $s;
4607  }
4608  return wantarray ? %schema : \%schema;
4609 }
4610 
4611 #** @method IsSame(Geo::OGR::FeatureDefn defn)
4612 # Object method.
4613 # @return true if this definition is similar to the other definition,
4614 # false otherwise.
4615 #*
4616 sub IsSame {
4617 }
4618 
4619 #** @method scalar IsStyleIgnored()
4620 # Object method.
4621 # Get the ignore status of style information when fetching features.
4622 # @return the ignore status of style information
4623 # @since 1.9.0
4624 #*
4625 sub IsStyleIgnored {
4626 }
4627 
4628 #** @method SetStyleIgnored($IgnoreState)
4629 # Object method.
4630 # Set the ignore status of style information when fetching features.
4631 # @since 1.9.0
4632 #*
4633 sub SetStyleIgnored {
4634 }
4635 
4636 #** @method Geo::OGR::FeatureDefn new(%schema)
4637 # Class method.
4638 # Creates a new layer or feature definition. The new definition is
4639 # either initialized to the given schema or it will contain no
4640 # non-spatial fields and one spatial field, whose Name is '' and
4641 # GeometryType is 'Unknown' or the value of the named parameter
4642 # GeometryType.
4643 # @param schema [optional] The schema for the new feature definition,
4644 # as in Geo::OGR::FeatureDefn::Schema().
4645 # @return a Geo::OGR::FeatureDefn object
4646 #
4647 # Example usage:
4648 # \code
4649 # $fd = Geo::OGR::FeatureDefn->new(
4650 # Name => "name",
4651 # Fields => [{ Name => 'field1', Type => 'String' },
4652 # { Name => 'geom', GeometryType => 'Point' }] );
4653 # \endcode
4654 #*
4655 sub new {
4656  my $pkg = shift;
4657  my %schema;
4658  if (@_ == 1 and ref($_[0]) eq 'HASH') {
4659  %schema = %{$_[0]};
4660  } elsif (@_ and @_ % 2 == 0) {
4661  %schema = @_;
4662  }
4663  my $fields = $schema{Fields};
4664  Geo::GDAL::error("The 'Fields' argument must be an array reference.") if $fields and ref($fields) ne 'ARRAY';
4665  $schema{Name} //= '';
4666  my $self = Geo::OGRc::new_FeatureDefn($schema{Name});
4667  bless $self, $pkg;
4668  my $gt = $schema{GeometryType};
4669  if ($gt) {
4670  $self->GeometryType($gt);
4671  } elsif ($fields) {
4672  $self->DeleteGeomFieldDefn(0);
4673  }
4674  $self->StyleIgnored($schema{StyleIgnored}) if exists $schema{StyleIgnored};
4675  for my $fd (@{$fields}) {
4676  my $d = $fd;
4677  if (ref($fd) eq 'HASH') {
4678  if ($fd->{GeometryType} or exists $Geo::OGR::Geometry::TYPE_STRING2INT{$fd->{Type}}) {
4679  $d = Geo::OGR::GeomFieldDefn->new(%$fd);
4680  } else {
4681  $d = Geo::OGR::FieldDefn->new(%$fd);
4682  }
4683  }
4684  if (blessed($d) and $d->isa('Geo::OGR::FieldDefn')) {
4685  AddFieldDefn($self, $d);
4686  } elsif (blessed($d) and $d->isa('Geo::OGR::GeomFieldDefn')) {
4687  Geo::GDAL::error("Do not mix GeometryType and geometry fields in Fields.") if $gt;
4688  AddGeomFieldDefn($self, $d);
4689  } else {
4690  Geo::GDAL::error("Item in field list does not define a field.");
4691  }
4692  }
4693  return $self;
4694 }
4695 
4696 #** @class Geo::OGR::FieldDefn
4697 # @brief A definition of a non-spatial attribute.
4698 #*
4699 package Geo::OGR::FieldDefn;
4700 
4701 use base qw(Geo::OGR)
4702 
4703 #** @method scalar Default($value)
4704 # Object method.
4705 # Get or set the default value for this field.
4706 # @note a.k.a. GetDefault and SetDefault
4707 # @param value [optional]
4708 # @return the default value of this field in non-void context.
4709 #*
4710 sub Default {
4711  my $self = shift;
4712  SetDefault($self, $_[0]) if @_;
4713  GetDefault($self) if defined wantarray;
4714 }
4715 
4716 #** @method GetSchema()
4717 #*
4718 sub GetSchema {
4719 }
4720 
4721 #** @method scalar Ignored($ignore)
4722 # Object method.
4723 # Get and/or set the ignore status (whether this field should be
4724 # omitted when fetching features) of this field.
4725 # @note a.k.a. IsIgnored, SetIgnored
4726 # @param ignore [optional]
4727 # @return the ignore status of this field in non-void context.
4728 # @since 1.9.0
4729 #*
4730 sub Ignored {
4731  my $self = shift;
4732  SetIgnored($self, $_[0]) if @_;
4733  IsIgnored($self) if defined wantarray;
4734 }
4735 
4736 #** @method IsDefaultDriverSpecific()
4737 #*
4738 sub IsDefaultDriverSpecific {
4739 }
4740 
4741 #** @method scalar Justify($justify)
4742 # Object method.
4743 # Get and/or set the justification of this field.
4744 # @note a.k.a. GetJustify, SetJustify
4745 # @param justify [optional] One of field justify types (Geo::OGR::FieldDefn::JustifyValues).
4746 # @return the justify value of this field in non-void context.
4747 #*
4748 sub Justify {
4749  my($self, $justify) = @_;
4750  if (defined $justify) {
4751  Geo::GDAL::error(1, $justify, \%JUSTIFY_STRING2INT) unless exists $JUSTIFY_STRING2INT{$justify};
4752  $justify = $JUSTIFY_STRING2INT{$justify} if exists $JUSTIFY_STRING2INT{$justify};
4753  SetJustify($self, $justify);
4754  }
4755  return $JUSTIFY_INT2STRING{GetJustify($self)} if defined wantarray;
4756 }
4757 
4758 #** @method list JustifyValues()
4759 # Package subroutine.
4760 # Justify values supported by GDAL. Current list is
4761 # Left, Right, and Undefined.
4762 #*
4763 sub JustifyValues {
4764  return @JUSTIFY_VALUES;
4765 }
4766 
4767 #** @method scalar Name($name)
4768 # Object method.
4769 # Get and/or set the name of the field.
4770 # @note a.k.a. GetName, GetNameRef, SetName
4771 # @param name [optional]
4772 # @return the name in non-void context
4773 #*
4774 sub Name {
4775  my $self = shift;
4776  SetName($self, $_[0]) if @_;
4777  GetName($self) if defined wantarray;
4778 }
4779 
4780 #** @method scalar Nullable($nullable)
4781 # Object method.
4782 # Get or set the nullable constraint for this field.
4783 # @note a.k.a. IsNullable and SetNullable
4784 # @param nullable [optional]
4785 # @return the nullable value of this field in non-void context.
4786 #*
4787 sub Nullable {
4788  my $self = shift;
4789  SetNullable($self, $_[0]) if @_;
4790  IsNullable($self) if defined wantarray;
4791 }
4792 
4793 #** @method scalar Precision($precision)
4794 # Object method.
4795 # Get and/or set the precision of this field.
4796 # @note a.k.a. GetPrecision, SetPrecision
4797 # @param precision [optional]
4798 # @return the precision of this field in non-void context.
4799 #*
4800 sub Precision {
4801  my $self = shift;
4802  SetPrecision($self, $_[0]) if @_;
4803  GetPrecision($self) if defined wantarray;
4804 }
4805 
4806 #** @method hash reference Schema(%params)
4807 # Object method.
4808 # Get the schema or set parts of the schema
4809 # @param params [optional] as those in Geo::OGR::FieldDefn::new.
4810 # @return a reference to a hash whose keys are as those in Geo::OGR::FieldDefn::new.
4811 #*
4812 sub Schema {
4813  my $self = shift;
4814  if (@_) {
4815  my $params = @_ % 2 == 0 ? {@_} : shift;
4816  for my $key (keys %SCHEMA_KEYS) {
4817  next unless exists $params->{$key};
4818  eval "\$self->$key(\$params->{$key})";
4819  confess(Geo::GDAL->last_error()) if $@;
4820  }
4821  }
4822  return unless defined wantarray;
4823  my %schema = ();
4824  for my $key (keys %SCHEMA_KEYS) {
4825  $schema{$key} = eval '$self->'.$key;
4826  }
4827  return wantarray ? %schema : \%schema;
4828 }
4829 
4830 #** @method SetSchema()
4831 #*
4832 sub SetSchema {
4833 }
4834 
4835 #** @method scalar SubType($SubType)
4836 # Object method.
4837 # @note a.k.a. GetSubType, SetSubType
4838 # @param SubType [optional] One of field sub types (Geo::OGR::FieldDefn::SubTypes).
4839 # @return the sub type of this field in non-void context.
4840 #*
4841 sub SubType {
4842  my($self, $sub_type) = @_;
4843  if (defined $sub_type) {
4844  Geo::GDAL::error(1, $sub_type, \%SUB_TYPE_STRING2INT) unless exists $SUB_TYPE_STRING2INT{$sub_type};
4845  $sub_type = $SUB_TYPE_STRING2INT{$sub_type};
4846  SetSubType($self, $sub_type);
4847  }
4848  return $SUB_TYPE_INT2STRING{GetSubType($self)} if defined wantarray;
4849 }
4850 
4851 #** @method SubTypes()
4852 #*
4853 sub SubTypes {
4854  return @SUB_TYPES;
4855 }
4856 
4857 #** @method scalar Type($type)
4858 # Object method.
4859 # Get and/or set the type of the field.
4860 # @note a.k.a. GetFieldTypeName, GetTypeName, GetType, SetType
4861 # @param type [optional] One of field types (Geo::OGR::FieldDefn::Types).
4862 # @return one of field types in non-void context.
4863 #*
4864 sub Type {
4865  my($self, $type) = @_;
4866  if (defined $type) {
4867  Geo::GDAL::error(1, $type, \%TYPE_STRING2INT) unless exists $TYPE_STRING2INT{$type};
4868  $type = $TYPE_STRING2INT{$type};
4869  SetType($self, $type);
4870  }
4871  return $TYPE_INT2STRING{GetType($self)} if defined wantarray;
4872 }
4874 #** @method list Types()
4875 # Package subroutine.
4876 # Field types supported by GDAL. Current list is
4877 # Binary, Date, DateTime, Integer, Integer64, Integer64List, IntegerList, Real, RealList, String, StringList, Time, WideString, and WideStringList.
4878 # (However, WideString is not supported.)
4879 #*
4880 sub Types {
4881  return @TYPES;
4882 }
4883 
4884 #** @method scalar Width($width)
4885 # Object method.
4886 # Get and/or set the field width.
4887 # @note a.k.a. GetWidth, SetWidth
4888 # @param width [optional]
4889 # @return the width of this field in non-void context.
4890 #*
4891 sub Width {
4892  my $self = shift;
4893  SetWidth($self, $_[0]) if @_;
4894  GetWidth($self) if defined wantarray;
4895 }
4896 
4897 #** @method Geo::OGR::FieldDefn new(%params)
4898 # Class method.
4899 # @brief Create a new field definition.
4900 #
4901 # @param Named parameters:
4902 # - \a Name Field name (default is 'unnamed').
4903 # - \a Type Field type, one of Geo::OGR::FieldDefn::Types (default is 'String').
4904 # - \a SubType Field sub type, one of Geo::OGR::FieldDefn::SubTypes.
4905 # - \a Justify Justify value, one of Geo::OGR::FieldDefn::JustifyValues
4906 # - \a Width
4907 # - \a Precision
4908 # - \a Nullable (default is true)
4909 # - \a Default
4910 # - \a Ignored (default is false)
4911 # @return a new Geo::OGR::FieldDefn object
4912 #*
4913 sub new {
4914  my $pkg = shift;
4915  my $params = {Name => 'unnamed', Type => 'String'};
4916  if (@_ == 0) {
4917  } elsif (@_ == 1 and not ref $_[0]) {
4918  $params->{Name} = shift;
4919  } elsif (@_ == 2 and not $Geo::OGR::FieldDefn::SCHEMA_KEYS{$_[0]}) {
4920  $params->{Name} = shift;
4921  $params->{Type} = shift;
4922  } else {
4923  my $tmp = @_ % 2 == 0 ? {@_} : shift;
4924  for my $key (keys %$tmp) {
4925  if ($Geo::OGR::FieldDefn::SCHEMA_KEYS{$key}) {
4926  $params->{$key} = $tmp->{$key};
4927  } else {
4928  carp "Unknown parameter: '$key'." if $key ne 'Index';
4929  }
4930  }
4931  }
4932  $params->{Type} = Geo::GDAL::string2int($params->{Type}, \%Geo::OGR::FieldDefn::TYPE_STRING2INT);
4933  my $self = Geo::OGRc::new_FieldDefn($params->{Name}, $params->{Type});
4934  bless $self, $pkg;
4935  delete $params->{Name};
4936  delete $params->{Type};
4937  $self->Schema($params);
4938  return $self;
4939 }
4940 
4941 #** @class Geo::OGR::GeomFieldDefn
4942 # @brief A definition of a spatial attribute.
4943 #*
4944 package Geo::OGR::GeomFieldDefn;
4945 
4946 use base qw(Geo::OGR)
4947 
4948 #** @method scalar GeometryType($type)
4949 # Object method.
4950 # @note a.k.a. GetType, SetType
4951 # @return the geometry type of the field.
4952 #*
4953 sub GeometryType {
4954 }
4955 
4956 #** @method GetSchema()
4957 #*
4958 sub GetSchema {
4959 }
4960 
4961 #** @method scalar Ignored($ignore)
4962 # Object method.
4963 # @note a.k.a. IsIgnored, SetIgnored
4964 # @return the ignore status of the field.
4965 #*
4966 sub Ignored {
4967  my $self = shift;
4968  SetIgnored($self, $_[0]) if @_;
4969  IsIgnored($self) if defined wantarray;
4970 }
4971 
4972 #** @method scalar Name($name)
4973 # Object method.
4974 # @note a.k.a. GetName, GetNameRef, SetName
4975 # @return the name of the field.
4976 #*
4977 sub Name {
4978  my $self = shift;
4979  SetName($self, $_[0]) if @_;
4980  GetName($self) if defined wantarray;
4981 }
4982 
4983 #** @method scalar Nullable($nullable)
4984 # Object method.
4985 # @note a.k.a. IsNullable, SetNullable
4986 # @return the nullable status of the field.
4987 #*
4988 sub Nullable {
4989  my $self = shift;
4990  SetNullable($self, $_[0]) if @_;
4991  IsNullable($self) if defined wantarray;
4992 }
4993 
4994 #** @method hash reference Schema(%params)
4995 # Object method.
4996 # Get the schema or set parts of the schema.
4997 # @param params [optional] as those in Geo::OGR::GeomFieldDefn::new.
4998 # @return a reference to a hash whose keys are as those in Geo::OGR::GeomFieldDefn::new.
4999 #*
5000 sub Schema {
5001  my $self = shift;
5002  if (@_) {
5003  my $params = @_ % 2 == 0 ? {@_} : shift;
5004  for my $key (keys %SCHEMA_KEYS) {
5005  next unless exists $params->{$key};
5006  eval "\$self->$key(\$params->{$key})";
5007  confess Geo::GDAL->last_error() if $@;
5008  }
5009  }
5010  return unless defined wantarray;
5011  my %schema = ();
5012  for my $key (keys %SCHEMA_KEYS) {
5013  $schema{$key} = eval '$self->'.$key;
5014  }
5015  return wantarray ? %schema : \%schema;
5016 }
5017 
5018 #** @method SetSchema()
5019 #*
5020 sub SetSchema {
5021 }
5022 
5023 #** @method scalar SpatialReference($sr)
5024 # Object method.
5025 # @note a.k.a. GetSpatialRef, SetSpatialRef
5026 # @return the spatial reference of the field as a Geo::OSR::SpatialReference object.
5027 #*
5028 sub SpatialReference {
5029  my $self = shift;
5030  SetSpatialRef($self, $_[0]) if @_;
5031  GetSpatialRef($self) if defined wantarray;
5032 }
5033 
5034 #** @method Type()
5035 # Object method.
5036 # @return the type of this geometry field. One of Geo::OGR::GeomFieldDefn::Types
5037 #*
5038 sub Type {
5039  my($self, $type) = @_;
5040  if (defined $type) {
5041  $type = Geo::GDAL::string2int($type, \%Geo::OGR::Geometry::TYPE_STRING2INT);
5042  SetType($self, $type);
5043  }
5044  $Geo::OGR::Geometry::TYPE_INT2STRING{GetType($self)} if defined wantarray;
5045 }
5046 
5047 #** @method Types()
5048 # Package subroutine.
5049 # @return a list of all geometry types, currently:
5050 # CircularString, CircularStringM, CircularStringZ, CircularStringZM, CompoundCurve, CompoundCurveM, CompoundCurveZ, CompoundCurveZM, Curve, CurveM, CurvePolygon, CurvePolygonM, CurvePolygonZ, CurvePolygonZM, CurveZ, CurveZM, GeometryCollection, GeometryCollection25D, GeometryCollectionM, GeometryCollectionZM, LineString, LineString25D, LineStringM, LineStringZM, LinearRing, MultiCurve, MultiCurveM, MultiCurveZ, MultiCurveZM, MultiLineString, MultiLineString25D, MultiLineStringM, MultiLineStringZM, MultiPoint, MultiPoint25D, MultiPointM, MultiPointZM, MultiPolygon, MultiPolygon25D, MultiPolygonM, MultiPolygonZM, MultiSurface, MultiSurfaceM, MultiSurfaceZ, MultiSurfaceZM, None, Point, Point25D, PointM, PointZM, Polygon, Polygon25D, PolygonM, PolygonZM, PolyhedralSurface, PolyhedralSurfaceM, PolyhedralSurfaceZ, PolyhedralSurfaceZM, Surface, SurfaceM, SurfaceZ, SurfaceZM, TIN, TINM, TINZ, TINZM, and Unknown.
5051 #*
5052 sub Types {
5053  return @Geo::OGR::Geometry::GEOMETRY_TYPES;
5054 }
5055 
5056 #** @method Geo::OGR::GeomFieldDefn new(%params)
5057 # Class method.
5058 # @brief Create a new spatial field definition.
5059 #
5060 # @param params one or more of:
5061 # - \a Name name for the field (default is 'geom').
5062 # - \a GeometryType type for the field type, one of Geo::OGR::GeomFieldDefn::Types (default is 'Unknown').
5063 # - \a SpatialReference a Geo::OSR::SpatialReference object.
5064 # - \a Nullable (default is true)
5065 # - \a Ignored (default is false)
5066 # @return a new Geo::OGR::GeomFieldDefn object
5067 #*
5068 sub new {
5069  my $pkg = shift;
5070  my $params = {Name => 'geom', Type => 'Unknown'};
5071  if (@_ == 0) {
5072  } elsif (@_ == 1) {
5073  $params->{Name} = shift;
5074  } elsif (@_ == 2 and not $Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$_[0]}) {
5075  $params->{Name} = shift;
5076  $params->{Type} = shift;
5077  } else {
5078  my $tmp = @_ % 2 == 0 ? {@_} : shift;
5079  for my $key (keys %$tmp) {
5080  if ($Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$key}) {
5081  $params->{$key} = $tmp->{$key};
5082  } else {
5083  carp "Unknown parameter: '$key'." if $key ne 'Index' && $key ne 'GeometryType';
5084  }
5085  }
5086  $params->{Type} //= $tmp->{GeometryType};
5087  }
5088  $params->{Type} = Geo::GDAL::string2int($params->{Type}, \%Geo::OGR::Geometry::TYPE_STRING2INT);
5089  my $self = Geo::OGRc::new_GeomFieldDefn($params->{Name}, $params->{Type});
5090  bless $self, $pkg;
5091  delete $params->{Name};
5092  delete $params->{Type};
5093  $self->Schema($params);
5094  return $self;
5095 }
5096 
5097 #** @class Geo::OGR::Geometry
5098 # @brief Spatial data.
5099 #
5100 # A geometry is spatial data (coordinate values, and a reference to a
5101 # spatial reference system) organized into one of the geometry
5102 # types. Geometries can be created from several type of data including
5103 # a Perl data structure. There are several methods, which modify,
5104 # compare, test, or compute values from geometries.
5105 # @note Most spatial analysis methods require <a
5106 # href="http://geos.osgeo.org/doxygen/">GEOS</a> to work rigorously.
5107 #*
5108 package Geo::OGR::Geometry;
5109 
5110 use base qw(Geo::OGR)
5111 
5112 #** @method AddGeometry($other)
5113 # Object method.
5114 # Add a copy of another geometry to a geometry collection
5115 # @param other a Geo::OGR::Geometry object
5116 #*
5117 sub AddGeometry {
5118 }
5119 
5120 #** @method AddGeometryDirectly($other)
5121 # Object method.
5122 # @param other a Geo::OGR::Geometry object
5123 #*
5124 sub AddGeometryDirectly {
5125 }
5126 
5127 #** @method AddPoint($x, $y, $z)
5128 # Object method.
5129 # Set the data of a point or add a point to a line string. Consider
5130 # using Geo::OGR::Geometry::Points. Note that the coordinate
5131 # dimension is automatically upgraded to 25D (3) if z is given.
5132 # @param x
5133 # @param y
5134 # @param z [optional]
5135 # Calls internally the 2D or 3D version depending on the number of parameters.
5136 #*
5137 sub AddPoint {
5138  my $self = shift;
5139  my $t = $self->GetGeometryType;
5140  my $has_z = Geo::OGR::GT_HasZ($t);
5141  my $has_m = Geo::OGR::GT_HasM($t);
5142  if (!$has_z && !$has_m) {
5143  $self->AddPoint_2D(@_[0..1]);
5144  } elsif ($has_z && !$has_m) {
5145  $self->AddPoint_3D(@_[0..2]);
5146  } elsif (!$has_z && $has_m) {
5147  $self->AddPointM(@_[0..2]);
5148  } else {
5149  $self->AddPointZM(@_[0..3]);
5150  }
5151 }
5152 
5153 #** @method AddPointM()
5154 #*
5155 sub AddPointM {
5156 }
5157 
5158 #** @method AddPointZM()
5159 #*
5160 sub AddPointZM {
5161 }
5162 
5163 #** @method AddPoint_2D($x, $y)
5164 # Object method.
5165 # Set the data of a point or add a point to a line string. Consider
5166 # using Geo::OGR::Geometry::Points.
5167 # @param x
5168 # @param y
5169 #*
5170 sub AddPoint_2D {
5171 }
5172 
5173 #** @method AddPoint_3D($x, $y, $z)
5174 # Object method.
5175 # Set the data of a point or add a point to a line string. Note that
5176 # the coordinate dimension is automatically upgraded to 25D (3). Consider
5177 # using Geo::OGR::Geometry::Points.
5178 # @param x
5179 # @param y
5180 # @param z
5181 #*
5182 sub AddPoint_3D {
5183 }
5184 
5185 #** @method Geo::OGR::Geometry ApproximateArcAngles(%params)
5186 # Package subroutine.
5187 # Create a line string, which approximates an arc.
5188 # @note All angles are in degrees.
5189 #
5190 # @param %params Named parameters:
5191 # - \a Center center point (default is [0, 0, 0])
5192 # - \a PrimaryRadius default is 1.
5193 # - \a SecondaryAxis default is 1.
5194 # - \a Rotation default is 0.
5195 # - \a StartAngle default is 0.
5196 # - \a EndAngle default is 360.
5197 # - \a MaxAngleStepSizeDegrees default is 4.
5198 # @return a new Geo::OGR::Geometry object.
5199 #*
5200 sub ApproximateArcAngles {
5201  my %p = @_;
5202  my %default = ( Center => [0,0,0],
5203  PrimaryRadius => 1,
5204  SecondaryAxis => 1,
5205  Rotation => 0,
5206  StartAngle => 0,
5207  EndAngle => 360,
5208  MaxAngleStepSizeDegrees => 4
5209  );
5210  for my $p (keys %p) {
5211  if (exists $default{$p}) {
5212  $p{$p} //= $default{$p};
5213  } else {
5214  carp "Unknown parameter: '$p'.";
5215  }
5216  }
5217  for my $p (keys %default) {
5218  $p{$p} //= $default{$p};
5219  }
5220  Geo::GDAL::error("Usage: Center => [x,y,z].") unless ref($p{Center}) eq 'ARRAY';
5221  for my $i (0..2) {
5222  $p{Center}->[$i] //= 0;
5223  }
5224  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});
5225 }
5226 
5227 #** @method scalar Area()
5228 # Object method.
5229 # @note a.k.a. GetArea
5230 # @return the area of the polygon or multipolygon
5231 #*
5232 sub Area {
5233 }
5234 
5235 #** @method scalar As(%params)
5236 # Object method.
5237 # Export the geometry into a known format.
5238 #
5239 # @param params Named parameters:
5240 # - \a Format One of
5241 # - \a WKT Well Known Text.
5242 # - <em>ISO WKT</em>
5243 # - \a Text Same as WKT.
5244 # - \a WKB Well Known Binary.
5245 # - <em>ISO WKB</em>
5246 # - \a Binary Same as WKB.
5247 # - \a HEXWKB
5248 # - \a HEXEWKB
5249 # - \a GML
5250 # - \a GeoJSON
5251 # - \a ByteOrder Byte order for binary formats. Default is 'XDR'.
5252 # - \a SRID Spatial reference id for HEXEWKB.
5253 # - \a Options GML generation options.
5254 # - \a AltitudeMode For KML.
5255 #
5256 # @return the geometry in a given format.
5257 #*
5258 sub As {
5259  my $self = shift;
5260  my $p = Geo::GDAL::named_parameters(\@_, Format => undef, ByteOrder => 'XDR', SRID => undef, Options => undef, AltitudeMode => undef);
5261  my $f = $p->{format};
5262  if ($f =~ /text/i) {
5263  return $self->AsText;
5264  } elsif ($f =~ /wkt/i) {
5265  if ($f =~ /iso/i) {
5266  return $self->ExportToIsoWkt;
5267  } else {
5268  return $self->AsText;
5269  }
5270  } elsif ($f =~ /binary/i) {
5271  return $self->ExportToWkb($p->{byteorder});
5272  } elsif ($f =~ /wkb/i) {
5273  if ($f =~ /iso/i) {
5274  $p->{byteorder} = Geo::GDAL::string2int($p->{byteorder}, \%Geo::OGR::Geometry::BYTE_ORDER_STRING2INT);
5275  return $self->ExportToIsoWkb($p->{byteorder});
5276  } elsif ($f =~ /ewkb/i) {
5277  return $self->AsHEXEWKB($p->{srid});
5278  } elsif ($f =~ /hex/i) {
5279  return $self->AsHEXWKB;
5280  } else {
5281  return $self->ExportToWkb($p->{byteorder});
5282  }
5283  } elsif ($f =~ /gml/i) {
5284  return $self->ExportToGML($p->{options});
5285  } elsif ($f =~ /kml/i) {
5286  return $self->ExportToKML($p->{altitudemode});
5287  } elsif ($f =~ /json/i) {
5288  return $self->AsJSON;
5289  } else {
5290  Geo::GDAL::error(1, $f, map {$_=>1} qw/Text WKT ISO_WKT ISO_WKB HEX_WKB HEX_EWKB Binary GML KML JSON/);
5291  }
5293 
5294 #** @method AssignSpatialReference($srs)
5295 # Object method.
5296 # @param srs a Geo::OSR::SpatialReference object
5297 #*
5298 sub AssignSpatialReference {
5299 }
5300 
5301 #** @method Geo::OGR::Geometry Boundary()
5302 # Object method.
5303 # @note a.k.a. GetBoundary
5304 # @return the boundary of this geometry as a geometry
5305 # @since 1.8.0
5306 #*
5307 sub Boundary {
5308 }
5309 
5310 #** @method Geo::OGR::Geometry Buffer($distance, $quadsecs = 30)
5311 # Object method.
5312 # @param distance
5313 # @param quadsecs
5314 # @return a new Geo::OGR::Geometry object
5315 #*
5316 sub Buffer {
5317 }
5318 
5319 #** @method Geo::OGR::Geometry BuildPolygonFromEdges($BestEffort = 0, $AutoClose = 0, $Tolerance = 0)
5320 # Object method.
5321 # Attempt to create a polygon from a collection of lines or from a multilinestring.
5322 # @param BestEffort For future
5323 # @param AutoClose Assure the first and last points of rings are same.
5324 # @param Tolerance Snap distance.
5325 # @exception Several possibilities, some are reported, some are general errors.
5326 # @return a new Geo::OGR::Geometry object (Polygon)
5327 #*
5328 sub BuildPolygonFromEdges {
5329 }
5330 
5331 #** @method list ByteOrders()
5332 # Package subroutine.
5333 # Same as Geo::OGR::ByteOrders
5334 #*
5335 sub ByteOrders {
5336  return @BYTE_ORDER_TYPES;
5337 }
5338 
5339 #** @method Geo::OGR::Geometry Centroid()
5340 # Object method.
5341 # @return a new Geo::OGR::Geometry object
5342 # @since 1.8.0
5343 #*
5344 sub Centroid {
5345 }
5346 
5347 #** @method Geo::OGR::Geometry Clone()
5348 # Object method.
5349 # @return a new Geo::OGR::Geometry object
5350 #*
5351 sub Clone {
5352 }
5353 
5354 #** @method CloseRings()
5355 # Object method.
5356 #*
5357 sub CloseRings {
5358 }
5359 
5360 #** @method Geo::OGR::Geometry Collect(@geometries)
5361 # Object method.
5362 # Create a geometrycollection from this and possibly other geometries.
5363 # @param geometries [optional] More geometries to add to the collection.
5364 # @return a new Geo::OGR::Geometry object of type geometrycollection.
5365 #*
5366 sub Collect {
5367 }
5368 
5369 #** @method scalar Contains($other)
5370 # Object method.
5371 # @param other a Geo::OGR::Geometry object
5372 # @return true if this geometry contains the other geometry, false otherwise
5373 #*
5374 sub Contains {
5375 }
5376 
5377 #** @method Geo::OGR::Geometry ConvexHull()
5378 # Object method.
5379 # @return a new Geo::OGR::Geometry object
5380 #*
5381 sub ConvexHull {
5382 }
5383 
5384 #** @method scalar CoordinateDimension($dimension)
5385 # Object method.
5386 # @param dimension [optional]
5387 # @return 2 or 3
5388 #*
5389 sub CoordinateDimension {
5390  my $self = shift;
5391  SetCoordinateDimension($self, $_[0]) if @_;
5392  GetCoordinateDimension($self) if defined wantarray;
5393 }
5394 
5395 #** @method scalar Crosses($other)
5396 # Object method.
5397 # @param other a Geo::OGR::Geometry object
5398 # @return true if this geometry crosses the other geometry, false otherwise
5399 #*
5400 sub Crosses {
5401 }
5402 
5403 #** @method DelaunayTriangulation()
5404 #*
5405 sub DelaunayTriangulation {
5406 }
5407 
5408 #** @method Geo::OGR::Geometry Difference($other)
5409 # Object method.
5410 # @param other a Geo::OGR::Geometry object
5411 # @return a new Geo::OGR::Geometry object
5412 #*
5413 sub Difference {
5414 }
5415 
5416 #** @method scalar Disjoint($other)
5417 # Object method.
5418 # @param other a Geo::OGR::Geometry object
5419 # @return true if this geometry is disjoint from the other geometry, false otherwise
5420 #*
5421 sub Disjoint {
5422 }
5423 
5424 #** @method list Dissolve()
5425 # Object method.
5426 # Dissolve a geometrycollection into separate geometries.
5427 # @return a list of new Geo::OGR::Geometry objects cloned from the collection.
5428 #*
5429 sub Dissolve {
5430  my $self = shift;
5431  my @c;
5432  my $n = $self->GetGeometryCount;
5433  if ($n > 0) {
5434  for my $i (0..$n-1) {
5435  push @c, $self->GetGeometryRef($i)->Clone;
5436  }
5437  } else {
5438  push @c, $self;
5439  }
5440  return @c;
5441 }
5442 
5443 #** @method scalar Distance($other)
5444 # Object method.
5445 # @param other a Geo::OGR::Geometry object
5446 # @return the distance to the other geometry
5447 #*
5448 sub Distance {
5449 }
5450 
5451 #** @method Empty()
5452 # Object method.
5453 # Clear geometry data, i.e., remove all points, or, for a point, set
5454 # the coordinate dimension as zero.
5455 #*
5456 sub Empty {
5457 }
5458 
5459 #** @method scalar Equals($other)
5460 # Object method.
5461 # @note a.k.a. Equal (deprecated)
5462 # @param other a Geo::OGR::Geometry object
5463 # @return true if this geometry is equivalent to the other geometry, false otherwise
5464 #*
5465 sub Equals {
5466 }
5467 
5468 #** @method Extent()
5469 #*
5470 sub Extent {
5471  my $self = shift;
5472  return Geo::GDAL::Extent->new($self->GetEnvelope);
5473 }
5474 
5475 #** @method Feature()
5476 #*
5477 sub Feature {
5478  my $self = shift;
5479  return $Geo::OGR::Feature::GEOMETRIES{tied(%$self)};
5480 }
5481 
5482 #** @method FlattenTo2D()
5483 # Object method.
5484 #*
5485 sub FlattenTo2D {
5486 }
5487 
5488 #** @method Geo::OGR::Geometry ForceTo($type, ref options)
5489 # Object method.
5490 # Attempt to make a geometry of type 'type' out of this geometry.
5491 # @param type target geometry type. One of Geo::OGR::GeometryTypes.
5492 # @param options not used currently.
5493 # @return a new Geo::OGR::Geometry object.
5494 #*
5495 sub ForceTo {
5496  my $self = shift;
5497  my $type = shift;
5498  $type = Geo::GDAL::string2int($type, \%TYPE_STRING2INT);
5499  eval {
5500  $self = Geo::OGR::ForceTo($self, $type, @_);
5501  };
5502  confess Geo::GDAL->last_error if $@;
5503  return $self;
5504 }
5505 
5506 #** @method Geo::OGR::Geometry ForceToCollection(@geometries)
5507 # Object method.
5508 # Create a geometrycollection from the geometry.
5509 # @param geometries [optional] More geometries to add to the collection.
5510 # @return a new Geo::OGR::Geometry object of type geometrycollection.
5511 #*
5512 sub ForceToCollection {
5513  my $self = Geo::OGR::Geometry->new(GeometryType => 'GeometryCollection');
5514  for my $g (@_) {
5515  $self->AddGeometry($g);
5516  }
5517  return $self;
5518 }
5519 
5520 #** @method Geo::OGR::Geometry ForceToLineString()
5521 # Object method.
5522 # Attempt to create a line string from this geometry.
5523 # @return a new Geo::OGR::Geometry object.
5524 #*
5525 sub ForceToLineString {
5526  my $self = shift;
5527  return Geo::OGR::ForceToLineString($self);
5528 }
5529 
5530 #** @method Geo::OGR::Geometry ForceToMultiLineString(@linestrings)
5531 # Object method.
5532 # Attempt to create a multilinestring from the geometry, which must be a linestring.
5533 # @param linestrings [optional] More linestrings to add to the collection.
5534 # @return a new Geo::OGR::Geometry object of type multilinestring.
5535 #*
5536 sub ForceToMultiLineString {
5537  my $self = shift;
5538  $self = Geo::OGR::ForceToMultiLineString($self);
5539  for my $g (@_) {
5540  $self->AddGeometry($g);
5541  }
5542  return $self;
5543 }
5544 
5545 #** @method Geo::OGR::Geometry ForceToMultiPoint(@points)
5546 # Object method.
5547 # Attempt to create a multipoint from the geometry, which must be a point.
5548 # @param points [optional] More points to add to the collection.
5549 # @return a new Geo::OGR::Geometry object of type multipoint.
5550 #*
5551 sub ForceToMultiPoint {
5552  my $self = shift;
5553  $self = Geo::OGR::ForceToMultiPoint($self);
5554  for my $g (@_) {
5555  $self->AddGeometry($g);
5556  }
5557  return $self;
5558 }
5559 
5560 #** @method Geo::OGR::Geometry ForceToMultiPolygon(@polygons)
5561 # Object method.
5562 # Attempt to create a multipolygon from the geometry, which must be a polygon.
5563 # @param polygons [optional] More polygons to add to the collection.
5564 # @return a new Geo::OGR::Geometry object of type multipolygon.
5565 #*
5566 sub ForceToMultiPolygon {
5567  my $self = shift;
5568  $self = Geo::OGR::ForceToMultiPolygon($self);
5569  for my $g (@_) {
5570  $self->AddGeometry($g);
5571  }
5572  return $self;
5573 }
5574 
5575 #** @method Geo::OGR::Geometry ForceToPolygon()
5576 # Object method.
5577 # Attempt to create a polygon from this geometry.
5578 # @exception None reported. If this method fails, just a copy is returned.
5579 # @return a new Geo::OGR::Geometry object.
5580 #*
5581 sub ForceToPolygon {
5582 }
5583 
5584 #** @method scalar GeometryType()
5585 # Object method.
5586 # @return the geometry type of this geometry (one of Geo::OGR::GeometryTypes).
5587 #*
5588 sub GeometryType {
5589  my $self = shift;
5590  return $TYPE_INT2STRING{$self->GetGeometryType};
5591 }
5592 
5593 #** @method list GeometryTypes()
5594 # Package subroutine.
5595 # Same as Geo::OGR::GeometryTypes
5596 #*
5597 sub GeometryTypes {
5598  return @GEOMETRY_TYPES;
5599 }
5600 
5601 #** @method scalar GetCoordinateDimension()
5602 # Object method.
5603 # @return an integer
5604 #*
5605 sub GetCoordinateDimension {
5606 }
5607 
5608 #** @method GetCurveGeometry()
5609 #*
5610 sub GetCurveGeometry {
5611 }
5612 
5613 #** @method scalar GetDimension()
5614 # Object method.
5615 # @return 0, 1, or 2
5616 #*
5617 sub GetDimension {
5618 }
5619 
5620 #** @method list GetEnvelope()
5621 # Object method.
5622 # @note In scalar context returns a reference to an anonymous array
5623 # containing the envelope.
5624 # @return the envelope ($minx, $maxx, $miny, $maxy)
5625 #*
5626 sub GetEnvelope {
5627 }
5628 
5629 #** @method list GetEnvelope3D()
5630 # Object method.
5631 # @note In scalar context returns a reference to an anonymous array
5632 # containing the envelope.
5633 # @return the 3-D envelope ($minx, $maxx, $miny, $maxy, $minz, $maxz)
5634 # @since 1.9.0
5635 #*
5636 sub GetEnvelope3D {
5637 }
5638 
5639 #** @method scalar GetGeometryCount()
5640 # Object method.
5641 # @return an integer
5642 #*
5643 sub GetGeometryCount {
5644 }
5645 
5646 #** @method scalar GetGeometryName()
5647 # Object method.
5648 # @deprecated use Geo::OGR::Geometry::GeometryType.
5649 #
5650 # @return a string
5651 #*
5652 sub GetGeometryName {
5653 }
5654 
5655 #** @method scalar GetGeometryRef($index)
5656 # Object method.
5657 # @param index index to the geometry, which is a part of this geometry
5658 # @return a new Geo::OGR::Geometry object whose data is a part of the
5659 # parent geometry
5660 #*
5661 sub GetGeometryRef {
5662 }
5663 
5664 #** @method scalar GetGeometryType()
5665 # Object method.
5666 # @deprecated use Geo::OGR::Geometry::GeometryType, which returns the
5667 # type as a string.
5668 #
5669 # @return type as an integer
5670 #*
5671 sub GetGeometryType {
5672 }
5673 
5674 #** @method GetLinearGeometry()
5675 #*
5676 sub GetLinearGeometry {
5677 }
5678 
5679 #** @method GetM()
5680 #*
5681 sub GetM {
5682 }
5683 
5684 #** @method list GetPoint($index = 0)
5685 # Object method.
5686 # @param index
5687 # @return (x,y) or a list with more coordinates
5688 #*
5689 sub GetPoint {
5690  my($self, $i) = @_;
5691  $i //= 0;
5692  my $t = $self->GetGeometryType;
5693  my $has_z = Geo::OGR::GT_HasZ($t);
5694  my $has_m = Geo::OGR::GT_HasM($t);
5695  my $point;
5696  if (!$has_z && !$has_m) {
5697  $point = $self->GetPoint_2D($i);
5698  } elsif ($has_z && !$has_m) {
5699  $point = $self->GetPoint_3D($i);
5700  } elsif (!$has_z && $has_m) {
5701  $point = $self->GetPointZM($i);
5702  @$point = ($point->[0], $point->[1], $point->[3]);
5703  } else {
5704  $point = $self->GetPointZM($i);
5705  }
5706  return wantarray ? @$point : $point;
5707 }
5708 
5709 #** @method scalar GetPointCount()
5710 # Object method.
5711 # @return an integer
5712 #*
5713 sub GetPointCount {
5714 }
5715 
5716 #** @method GetPointZM()
5717 #*
5718 sub GetPointZM {
5719 }
5720 
5721 #** @method scalar GetPoint_2D($index = 0)
5722 # Object method.
5723 # @param index
5724 # @return (x,y) or a list with more coordinates
5725 #*
5726 sub GetPoint_2D {
5727 }
5728 
5729 #** @method scalar GetPoint_3D($index = 0)
5730 # Object method.
5731 # @param index
5732 # @return (x,y) or a list with more coordinates
5733 #*
5734 sub GetPoint_3D {
5735 }
5736 
5737 #** @method Geo::OSR::SpatialReference GetSpatialReference()
5738 # Object method.
5739 # @return a new Geo::OSR::SpatialReference object
5740 #*
5741 sub GetSpatialReference {
5742 }
5743 
5744 #** @method scalar GetX($index = 0)
5745 # Object method.
5746 # @param index
5747 # @return a number
5748 #*
5749 sub GetX {
5750 }
5751 
5752 #** @method scalar GetY($index = 0)
5753 # Object method.
5754 # @param index
5755 # @return a number
5756 #*
5757 sub GetY {
5758 }
5759 
5760 #** @method scalar GetZ($index = 0)
5761 # Object method.
5762 # @param index
5763 # @return a number
5764 #*
5765 sub GetZ {
5766 }
5767 
5768 #** @method HasCurveGeometry()
5769 #*
5770 sub HasCurveGeometry {
5771 }
5772 
5773 #** @method Geo::OGR::Geometry Intersection($other)
5774 # Object method.
5775 # @param other a Geo::OGR::Geometry object
5776 # @return a new Geo::OGR::Geometry object
5777 #*
5778 sub Intersection {
5779 }
5780 
5781 #** @method scalar Intersects($other)
5782 # Object method.
5783 # @note a.k.a. Intersect (deprecated)
5784 # @param other a Geo::OGR::Geometry object
5785 # @return true if this geometry intersects with the other geometry, false otherwise
5786 #*
5787 sub Intersects {
5788 }
5789 
5790 #** @method Is3D()
5791 #*
5792 sub Is3D {
5793 }
5794 
5795 #** @method scalar IsEmpty()
5796 # Object method.
5797 # Test whether the geometry is empty (has no points, or, for a point,
5798 # has coordinate dimension of zero).
5799 # @return boolean
5800 #*
5801 sub IsEmpty {
5802 }
5803 
5804 #** @method IsMeasured()
5805 #*
5806 sub IsMeasured {
5807 }
5808 
5809 #** @method scalar IsRing()
5810 # Object method.
5811 # Test if the geometry is a ring. Requires GEOS in GDAL.
5812 # @return boolean
5813 #*
5814 sub IsRing {
5815 }
5816 
5817 #** @method scalar IsSimple()
5818 # Object method.
5819 # Test the simplicity of the geometry (OGC sense). Requires GEOS in GDAL.
5820 # @return boolean
5821 #*
5822 sub IsSimple {
5823 }
5824 
5825 #** @method scalar IsValid()
5826 # Object method.
5827 # Test the validity of the geometry (OGC sense). Requires GEOS in GDAL.
5828 # @return boolean
5829 #*
5830 sub IsValid {
5831 }
5832 
5833 #** @method scalar Length()
5834 # Object method.
5835 # @return the length of the linestring
5836 #*
5837 sub Length {
5838 }
5839 
5840 #** @method Move($dx, $dy, $dz)
5841 # Object method.
5842 # Move every point of the object as defined by the parameters.
5843 # @param dx
5844 # @param dy
5845 # @param dz [optional]
5846 #*
5847 sub Move {
5848 }
5849 
5850 #** @method scalar Overlaps($other)
5851 # Object method.
5852 # @param other a Geo::OGR::Geometry object
5853 # @return true if this geometry overlaps the other geometry, false otherwise
5854 #*
5855 sub Overlaps {
5856 }
5857 
5858 #** @method list Point($index, $x, $y, $z)
5859 # Object method.
5860 # Get or set the point
5861 # @param index The index of the point. Optional (ignored if given) for
5862 # Point and Point25D geometries.
5863 # @param x [optional]
5864 # @param y [optional]
5865 # @param z [optional]
5866 # @return
5867 #*
5868 sub Point {
5869  my $self = shift;
5870  my $i;
5871  if (@_) {
5872  my $t = $self->GetGeometryType;
5873  my $i;
5874  if (Geo::OGR::GT_Flatten($t) == $Geo::OGR::wkbPoint) {
5875  my $has_z = Geo::OGR::GT_HasZ($t);
5876  my $has_m = Geo::OGR::GT_HasM($t);
5877  if (!$has_z && !$has_m) {
5878  shift if @_ > 2;
5879  $i = 0;
5880  } elsif ($has_z || $has_m) {
5881  shift if @_ > 3;
5882  $i = 0;
5883  } else {
5884  shift if @_ > 4;
5885  $i = 0;
5886  }
5887  }
5888  $i = shift unless defined $i;
5889  $self->SetPoint($i, @_);
5890  }
5891  return unless defined wantarray;
5892  my $point = $self->GetPoint;
5893  return wantarray ? @$point : $point;
5894 }
5895 
5896 #** @method PointOnSurface()
5897 #*
5898 sub PointOnSurface {
5899 }
5900 
5901 #** @method array reference Points(arrayref points)
5902 # Object method.
5903 # Get or set the points of the geometry. The points (vertices) are
5904 # stored in obvious lists of lists. When setting, the geometry is
5905 # first emptied. The method uses internally either AddPoint_2D or
5906 # AddPoint_3D depending on the coordinate dimension of the input data.
5907 #
5908 # @note The same structure may represent different geometries
5909 # depending on the actual geometry type of the object.
5910 #
5911 # @param points [optional] A reference to an array. A point is a reference to an
5912 # array of numbers, a linestring or a ring is a reference to an array of points,
5913 # a polygon is a reference to an array of rings, etc.
5914 #
5915 # @return A reference to an array.
5916 #*
5917 sub Points {
5918  my $self = shift;
5919  my $t = $self->GetGeometryType;
5920  my $has_z = Geo::OGR::GT_HasZ($t);
5921  my $has_m = Geo::OGR::GT_HasM($t);
5922  my $postfix = '';
5923  $postfix .= 'Z' if Geo::OGR::GT_HasZ($t);
5924  $postfix .= 'M' if Geo::OGR::GT_HasM($t);
5925  $t = $TYPE_INT2STRING{Geo::OGR::GT_Flatten($t)};
5926  my $points = shift;
5927  if ($points) {
5928  Empty($self);
5929  if ($t eq 'Unknown' or $t eq 'None' or $t eq 'GeometryCollection') {
5930  Geo::GDAL::error("Can't set points of a geometry of type '$t'.");
5931  } elsif ($t eq 'Point') {
5932  # support both "Point" as a list of one point and one point
5933  if (ref($points->[0])) {
5934  $self->AddPoint(@{$points->[0]});
5935  } else {
5936  $self->AddPoint(@$points);
5937  }
5938  } elsif ($t eq 'LineString' or $t eq 'LinearRing' or $t eq 'CircularString') {
5939  for my $p (@$points) {
5940  $self->AddPoint(@$p);
5941  }
5942  } elsif ($t eq 'Polygon') {
5943  for my $r (@$points) {
5944  my $ring = Geo::OGR::Geometry->new('LinearRing');
5945  $ring->Set3D(1) if $has_z;
5946  $ring->SetMeasured(1) if $has_m;
5947  $ring->Points($r);
5948  $self->AddGeometryDirectly($ring);
5949  }
5950  } elsif ($t eq 'MultiPoint') {
5951  for my $p (@$points) {
5952  my $point = Geo::OGR::Geometry->new('Point'.$postfix);
5953  $point->Points($p);
5954  $self->AddGeometryDirectly($point);
5955  }
5956  } elsif ($t eq 'MultiLineString') {
5957  for my $l (@$points) {
5958  my $linestring = Geo::OGR::Geometry->new('Point'.$postfix);
5959  $linestring->Points($l);
5960  $self->AddGeometryDirectly($linestring);
5961  }
5962  } elsif ($t eq 'MultiPolygon') {
5963  for my $p (@$points) {
5964  my $polygon = Geo::OGR::Geometry->new('Point'.$postfix);
5965  $polygon->Points($p);
5966  $self->AddGeometryDirectly($polygon);
5967  }
5968  }
5969  }
5970  return unless defined wantarray;
5971  $self->_GetPoints();
5972 }
5973 
5974 #** @method Segmentize($MaxLength)
5975 # Object method.
5976 # Modify the geometry such it has no segment longer than the given length.
5977 # @param MaxLength the given length
5978 #*
5979 sub Segmentize {
5980 }
5981 
5982 #** @method Set3D()
5983 #*
5984 sub Set3D {
5985 }
5986 
5987 #** @method SetCoordinateDimension($dimension)
5988 # Object method.
5989 # @param dimension
5990 #*
5991 sub SetCoordinateDimension {
5992 }
5993 
5994 #** @method SetMeasured()
5995 #*
5996 sub SetMeasured {
5997 }
5998 
5999 #** @method SetPoint($index, $x, $y, $z)
6000 # Object method.
6001 # Set the data of a point or a line string. Note that the coordinate
6002 # dimension is automatically upgraded to 25D (3) if z is given.
6003 # @param index
6004 # @param x
6005 # @param y
6006 # @param z [optional]
6007 #*
6008 sub SetPoint {
6009  my $self = shift;
6010  my $t = $self->GetGeometryType;
6011  my $has_z = Geo::OGR::GT_HasZ($t);
6012  my $has_m = Geo::OGR::GT_HasM($t);
6013  if (!$has_z && !$has_m) {
6014  $self->SetPoint_2D(@_[0..2]);
6015  } elsif ($has_z && !$has_m) {
6016  $self->SetPoint_3D(@_[0..3]);
6017  } elsif (!$has_z && $has_m) {
6018  $self->SetPointM(@_[0..3]);
6019  } else {
6020  $self->SetPointZM(@_[0..4]);
6021  }
6022 }
6023 
6024 #** @method SetPointM()
6025 #*
6026 sub SetPointM {
6027 }
6028 
6029 #** @method SetPointZM()
6030 #*
6031 sub SetPointZM {
6032 }
6033 
6034 #** @method SetPoint_2D($index, $x, $y)
6035 # Object method.
6036 # @param index
6037 # @param x
6038 # @param y
6039 #*
6040 sub SetPoint_2D {
6041 }
6042 
6043 #** @method SetPoint_3D($index, $x, $y, $z)
6044 # Object method.
6045 # Set the data of a point or a line string. Note that the coordinate
6046 # dimension is automatically upgraded to 25D (3).
6047 # @param index
6048 # @param x
6049 # @param y
6050 # @param z
6051 #*
6052 sub SetPoint_3D {
6053 }
6054 
6055 #** @method Geo::OGR::Geometry Simplify($Tolerance)
6056 # Object method.
6057 # Simplify the geometry.
6058 # @param Tolerance the length tolerance for the simplification
6059 # @since 1.8.0
6060 # @return a new Geo::OSR::Geometry object
6061 #*
6062 sub Simplify {
6063 }
6064 
6065 #** @method SimplifyPreserveTopology()
6066 #*
6067 sub SimplifyPreserveTopology {
6068 }
6069 
6070 #** @method Geo::OGR::Geometry SymDifference($other)
6071 # Object method.
6072 # Compute symmetric difference.
6073 # @note a.k.a. SymmetricDifference
6074 # @param other a Geo::OGR::Geometry object
6075 # @return a new Geo::OGR::Geometry object
6076 # @since 1.8.0
6077 #*
6078 sub SymDifference {
6079 }
6080 
6081 #** @method scalar Touches($other)
6082 # Object method.
6083 # @param other a Geo::OGR::Geometry object
6084 # @return true if this geometry touches the other geometry, false otherwise
6085 #*
6086 sub Touches {
6087 }
6088 
6089 #** @method Transform($trans)
6090 # Object method.
6091 # @param trans a Geo::OSR::CoordinateTransformation object
6092 #*
6093 sub Transform {
6094 }
6095 
6096 #** @method TransformTo($srs)
6097 # Object method.
6098 # @param srs a Geo::OSR::SpatialReference object
6099 #*
6100 sub TransformTo {
6101 }
6102 
6103 #** @method Geo::OGR::Geometry Union($other)
6104 # Object method.
6105 # @param other a Geo::OGR::Geometry object
6106 # @return a new Geo::OGR::Geometry object
6107 #*
6108 sub Union {
6109 }
6110 
6111 #** @method Geo::OGR::Geometry UnionCascaded()
6112 # Object method.
6113 # @return a new Geo::OGR::Geometry object
6114 # @since 1.8.0
6115 #*
6116 sub UnionCascaded {
6117 }
6118 
6119 #** @method Value()
6120 #*
6121 sub Value {
6122 }
6123 
6124 #** @method scalar Within($other)
6125 # Object method.
6126 # @param other a Geo::OGR::Geometry object
6127 # @return true if this geometry is within the other geometry, false otherwise
6128 #*
6129 sub Within {
6130 }
6131 
6132 #** @method scalar WkbSize()
6133 # Object method.
6134 # @return an integer
6135 #*
6136 sub WkbSize {
6137 }
6138 
6139 #** @method Geo::OGR::Geometry new(%params)
6140 # Class method.
6141 # @param %params A named parameter, one of:
6142 # - \a GeometryType one the supported geometry types, see Geo::OGR::GeometryTypes.
6143 # - \a WKT a well known text string, which defines a geometry.
6144 # - \a WKB a well known binary string, which defines a geometry.
6145 # - \a HEXWKB WKB in hexadecimal.
6146 # - \a HEXEWKB PostGIS extended WKB.
6147 # - \a GML geometry written in Geographic Markup Language.
6148 # - \a GeoJSON geometry written in GeoJSON (JavaScript Object Notation for Geographic data).
6149 # - \a arc a reference to a list of values defining an arc: [CenterX,
6150 # CenterY, CenterZ, PrimaryRadius, SecondaryRadius, Rotation,
6151 # StartAngle, EndAngle, MaxAngleStepSizeDegrees] (see also Geo::OGR::Geometry::ApproximateArcAngles)
6152 # - \a Points An anonymous array as in method
6153 # Geo::OGR::Geometry::Points; Note: requires also GeometryType
6154 # parameter
6155 #
6156 # @return a new Geo::OGR::Geometry object.
6157 #*
6158 sub new {
6159  my $pkg = shift;
6160  my %param;
6161  if (@_ == 1 and ref($_[0]) eq 'HASH') {
6162  %param = %{$_[0]};
6163  } elsif (@_ % 2 == 0) {
6164  %param = @_;
6165  } else {
6166  ($param{GeometryType}) = @_;
6167  }
6168  my $type = $param{GeometryType} // $param{Type} // $param{type};
6169  my $srs = $param{SRS} // $param{srs};
6170  my $wkt = $param{WKT} // $param{wkt};
6171  my $wkb = $param{WKB} // $param{wkb};
6172  my $hex = $param{HEXEWKB} // $param{HEX_EWKB} // $param{hexewkb} // $param{hex_ewkb};
6173  my $srid;
6174  if ($hex) {
6175  # EWKB contains SRID
6176  $srid = substr($hex, 10, 8);
6177  substr($hex, 10, 8) = '';
6178  } else {
6179  $hex = $param{HEXWKB} // $param{HEX_WKB} // $param{hexwkb} // $param{hex_wkb};
6180  }
6181  if ($hex) {
6182  $wkb = '';
6183  for (my $i = 0; $i < length($hex); $i+=2) {
6184  $wkb .= chr(hex(substr($hex,$i,2)));
6185  }
6186  }
6187  my $gml = $param{GML} // $param{gml};
6188  my $json = $param{GeoJSON} // $param{geojson} // $param{JSON} // $param{json};
6189  my $points = $param{Points} // $param{points};
6190  my $arc = $param{Arc} // $param{arc};
6191  my $self;
6192  if (defined $wkt) {
6193  $self = Geo::OGRc::CreateGeometryFromWkt($wkt, $srs);
6194  } elsif (defined $wkb) {
6195  $self = Geo::OGRc::CreateGeometryFromWkb($wkb, $srs);
6196  } elsif (defined $gml) {
6197  $self = Geo::OGRc::CreateGeometryFromGML($gml);
6198  } elsif (defined $json) {
6199  $self = Geo::OGRc::CreateGeometryFromJson($json);
6200  } elsif (defined $type) {
6201  $type = Geo::GDAL::string2int($type, \%Geo::OGR::Geometry::TYPE_STRING2INT);
6202  $self = Geo::OGRc::new_Geometry($type); # flattens the type
6203  $self->Set3D(1) if Geo::OGR::GT_HasZ($type);
6204  $self->SetMeasured(1) if Geo::OGR::GT_HasM($type);
6205  } elsif (defined $arc) {
6206  $self = Geo::OGRc::ApproximateArcAngles(@$arc);
6207  } else {
6208  Geo::GDAL::error(1, undef, map {$_=>1} qw/GeometryType WKT WKB HEXEWKB HEXWKB GML GeoJSON Arc/);
6209  }
6210  bless $self, $pkg if defined $self;
6211  $self->Points($points) if $points;
6212  return $self;
6213 }
6214 
6215 #** @class Geo::OGR::Layer
6216 # @brief A collection of similar features.
6217 #
6218 # A layer object is typically obtained with a data source object. A
6219 # layer has a data model (a schema), which is maintained in a
6220 # definition object, and a set of features, which contain data
6221 # according to the data model. The schema is typically set when the
6222 # layer is created or opened, but it may be altered somewhat with
6223 # methods Geo::OGR::Layer::CreateField,
6224 # Geo::OGR::Layer::AlterFieldDefn, and
6225 # Geo::OGR::Layer::DeleteField. Features and/or their data can be
6226 # read, inserted and deleted. Reading can be filtered. Layers can be
6227 # compared to each other with methods Clip, Erase, Identity,
6228 # Intersection, SymDifference, Union, and Update.
6229 #
6230 # A layer may have metadata OLMD_FID64 => 'YES' if it holds features
6231 # with 64 bit FIDs. The metadata of a layer can be obtained with
6232 # GetMetadata method.
6233 #*
6234 package Geo::OGR::Layer;
6235 
6236 use base qw(Geo::GDAL::MajorObject Geo::OGR)
6237 
6238 #** @method AlterFieldDefn($name, %params)
6239 # Object method.
6240 # @param field the name of the field to be altered.
6241 # @param params as in Geo::OGR::FieldDefn::new. Width and
6242 # Precision should be both or neither.
6243 # @note Only non-spatial fields can be altered.
6244 # @note Also the deprecated form AlterFieldDefn($field,
6245 # Geo::OGR::FieldDefn $Defn, $Flags) works.
6246 #*
6247 sub AlterFieldDefn {
6248  my $self = shift;
6249  my $field = shift;
6250  my $index = $self->GetLayerDefn->GetFieldIndex($field);
6251  if (blessed($_[0]) and $_[0]->isa('Geo::OGR::FieldDefn')) {
6252  _AlterFieldDefn($self, $index, @_);
6253  } else {
6254  my $params = @_ % 2 == 0 ? {@_} : shift;
6255  my $definition = Geo::OGR::FieldDefn->new($params);
6256  my $flags = 0;
6257  $flags |= 1 if exists $params->{Name};
6258  $flags |= 2 if exists $params->{Type};
6259  $flags |= 4 if exists $params->{Width} or exists $params->{Precision};
6260  $flags |= 8 if exists $params->{Nullable};
6261  $flags |= 16 if exists $params->{Default};
6262  _AlterFieldDefn($self, $index, $definition, $flags);
6263  }
6264 }
6265 
6266 #** @method list Capabilities()
6267 # Object method.
6268 # Both a package subroutine and an object method.
6269 # @return a list of capabilities. The object method returns a list of
6270 # the capabilities the layer has. The package subroutine returns a list of
6271 # all potential capabilities a layer may have. These are currently:
6272 # AlterFieldDefn, CreateField, CreateGeomField, CurveGeometries, DeleteFeature, DeleteField, FastFeatureCount, FastGetExtent, FastSetNextByIndex, FastSpatialFilter, IgnoreFields, MeasuredGeometries, RandomRead, RandomWrite, ReorderFields, SequentialWrite, StringsAsUTF8, and Transactions.
6273 #
6274 # Examples:
6275 # \code
6276 # @cap = Geo::OGR::Layer::Capabilities(); # the package subroutine
6277 # @cap = $layer->Capabilities(); # the object method
6278 # \endcode
6279 #*
6280 sub Capabilities {
6281  return @CAPABILITIES if @_ == 0;
6282  my $self = shift;
6283  my @cap;
6284  for my $cap (@CAPABILITIES) {
6285  push @cap, $cap if _TestCapability($self, $CAPABILITIES{$cap});
6286  }
6287  return @cap;
6288 }
6289 
6290 #** @method Clip(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6291 # Object method.
6292 # Clip off areas that are not covered by the method layer. The schema
6293 # of the result layer can be set before calling this method, or is
6294 # initialized to to contain all fields from
6295 # this and method layer.
6296 # @param method method layer.
6297 # @param result result layer.
6298 # @param options a reference to an options hash.
6299 # @param callback [optional] a reference to a subroutine, which will
6300 # be called with parameters (number progress, string msg, callback_data)
6301 # @param callback_data [optional]
6302 #*
6303 sub Clip {
6304 }
6305 
6306 #** @method CommitTransaction()
6307 # Object method.
6308 #*
6309 sub CommitTransaction {
6310 }
6311 
6312 #** @method CreateFeature($feature)
6313 # Object method.
6314 # @deprecated use Geo::OGR::Layer::InsertFeature which accepts Perl
6315 # data and checks for geometry type and attribute data
6316 #
6317 # @note The feature should have the same schema as the layer.
6318 #
6319 # Inserts a feature into the layer. The given feature's id may change.
6320 # @param feature a Geo::OGR::Feature object
6321 #*
6322 sub CreateFeature {
6323 }
6324 
6325 #** @method CreateField(%params)
6326 # Object method.
6327 # Create a field.
6328 # @param params as in Geo::OGR::FieldDefn::new or
6329 # Geo::OGR::GeomFieldDefn::new, plus ApproxOK (whose default is true).
6330 #*
6331 sub CreateField {
6332  my $self = shift;
6333  my %defaults = ( ApproxOK => 1,
6334  Type => '' );
6335  my %params;
6336  if (@_ == 0) {
6337  } elsif (ref($_[0]) eq 'HASH') {
6338  %params = %{$_[0]};
6339  } elsif (@_ % 2 == 0) {
6340  %params = @_;
6341  } else {
6342  ($params{Defn}) = @_;
6343  }
6344  for my $k (keys %defaults) {
6345  $params{$k} //= $defaults{$k};
6346  }
6347  if (blessed($params{Defn}) and $params{Defn}->isa('Geo::OGR::FieldDefn')) {
6348  $self->_CreateField($params{Defn}, $params{ApproxOK});
6349  } elsif (blessed($_[0]) and $params{Defn}->isa('Geo::OGR::GeomFieldDefn')) {
6350  $self->CreateGeomField($params{Defn}, $params{ApproxOK});
6351  } else {
6352  my $a = $params{ApproxOK};
6353  delete $params{ApproxOK};
6354  if (exists $params{GeometryType}) {
6355  $params{Type} = $params{GeometryType};
6356  delete $params{GeometryType};
6357  }
6358  if (exists $Geo::OGR::FieldDefn::TYPE_STRING2INT{$params{Type}}) {
6359  my $fd = Geo::OGR::FieldDefn->new(%params);
6360  _CreateField($self, $fd, $a);
6361  } elsif (exists $Geo::OGR::Geometry::TYPE_STRING2INT{$params{Type}}) {
6362  my $fd = Geo::OGR::GeomFieldDefn->new(%params);
6363  CreateGeomField($self, $fd, $a);
6364  } else {
6365  Geo::GDAL::error("Invalid field type: $params{Type}.")
6366  }
6367  }
6368 }
6369 
6370 #** @method DataSource()
6371 #*
6372 sub DataSource {
6373 }
6374 
6375 #** @method Dataset()
6376 #*
6377 sub Dataset {
6378  my $self = shift;
6379  return $Geo::GDAL::Dataset::LAYERS{tied(%$self)};
6380 }
6381 
6382 #** @method DeleteFeature($fid)
6383 # Object method.
6384 # @param fid feature id
6385 #*
6386 sub DeleteFeature {
6387 }
6388 
6389 #** @method DeleteField($field)
6390 # Object method.
6391 # Delete an existing field from a layer.
6392 # @param field name (or index) of the field which is deleted
6393 # @note Only non-spatial fields can be deleted.
6394 #*
6395 sub DeleteField {
6396  my($self, $field) = @_;
6397  my $index = $self->GetLayerDefn->GetFieldIndex($field);
6398  _DeleteField($self, $index);
6399 }
6400 
6401 #** @method Erase(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6402 # Object method.
6403 # The result layer contains features whose geometries represent areas
6404 # that are in the input layer but not in the method layer. The
6405 # features in the result layer have attributes from the input
6406 # layer. The schema of the result layer can be set by the user or, if
6407 # it is empty, is initialized to contain all fields in the input
6408 # layer.
6409 # @param method method layer.
6410 # @param result result layer.
6411 # @param options a reference to an options hash.
6412 # @param callback [optional] a reference to a subroutine, which will
6413 # be called with parameters (number progress, string msg, callback_data)
6414 # @param callback_data [optional]
6415 #*
6416 sub Erase {
6417 }
6418 
6419 #** @method ForFeatures($code, $in_place)
6420 # Object method.
6421 # @note experimental, the syntax may change
6422 #
6423 # Call code for all features. This is a simple wrapper for
6424 # ResetReading and while(GetNextFeature).
6425 #
6426 # Example usage:
6427 # \code
6428 # $layer->ForFeatures(sub {my $f = shift; $self->DeleteFeature($f->FID)}); # empties the layer
6429 # \endcode
6430 #
6431 # @param code a reference to a subroutine, which is called with each
6432 # feature as an argument
6433 # @param in_place if set to true, the feature is stored back to the
6434 # layer
6435 #*
6436 sub ForFeatures {
6437  my $self = shift;
6438  my $code = shift;
6439  my $in_place = shift;
6440  $self->ResetReading;
6441  while (my $f = $self->GetNextFeature) {
6442  $FEATURES{tied(%$f)} = $self;
6443  $code->($f);
6444  $self->SetFeature($f) if $in_place;
6445  };
6446 }
6447 
6448 #** @method ForGeometries($code, $in_place)
6449 # Object method.
6450 # @note experimental, the syntax may change
6451 #
6452 # Call code for all geometries. This is a simple wrapper for
6453 # ResetReading and while(GetNextFeature).
6454 #
6455 # Example usage:
6456 # \code
6457 # my $area = 0;
6458 # $layer->ForGeometries(sub {my $g = shift; $area += $g->Area}); # computes the total area
6459 # \endcode
6460 #
6461 # @param code a reference to a subroutine, which is called with each
6462 # geometry as an argument
6463 # @param in_place if set to true, the geometry is stored back to the
6464 # layer
6465 #*
6466 sub ForGeometries {
6467  my $self = shift;
6468  my $code = shift;
6469  my $in_place = shift;
6470  $self->ResetReading;
6471  while (my $f = $self->GetNextFeature) {
6472  my $g = $f->Geometry();
6473  $code->($g);
6474  if ($in_place) {
6475  $f->Geometry($g);
6476  $self->SetFeature($f);
6477  }
6478  }
6479 }
6480 
6481 #** @method scalar GeometryType($field)
6482 # Object method.
6483 # @param field the name or index of the spatial field.
6484 # @return the geometry type of the spatial field.
6485 #*
6486 sub GeometryType {
6487  my $self = shift;
6488  my $field = shift;
6489  $field //= 0;
6490  my $fd = $self->GetDefn->GetGeomFieldDefn($field);
6491  return $fd->Type if $fd;
6492 }
6493 
6494 #** @method Geo::OGR::DataSource GetDataSource()
6495 # Object method.
6496 # @return the data source object to which this layer object belongs to.
6497 #*
6498 sub GetDataSource {
6499  my $self = shift;
6500  return $Geo::GDAL::Dataset::LAYERS{tied(%$self)};
6501 }
6502 
6503 #** @method Geo::OGR::FeatureDefn GetDefn()
6504 # Object method.
6505 # A.k.a GetLayerDefn.
6506 # @return a Geo::OGR::FeatureDefn object.
6507 #*
6508 sub GetDefn {
6509  my $self = shift;
6510  my $defn = $self->GetLayerDefn;
6511  $DEFNS{tied(%$defn)} = $self;
6512  return $defn;
6513 }
6514 
6515 #** @method list GetExtent($force = 1)
6516 # Object method.
6517 # @param force compute the extent even if it is expensive
6518 # @note In scalar context returns a reference to an anonymous array
6519 # containing the extent.
6520 # @return the extent ($minx, $maxx, $miny, $maxy)
6521 # @param force
6522 # @return the extent = ($minx, $maxx, $miny, $maxy) as a listref
6523 #*
6524 sub GetExtent {
6525 }
6526 
6527 #** @method scalar GetFIDColumn()
6528 # Object method.
6529 # @return the name of the underlying database column being used as the
6530 # FID column, or "" if not supported.
6531 #*
6532 sub GetFIDColumn {
6533 }
6534 
6535 #** @method Geo::OGR::Feature GetFeature($fid)
6536 # Object method.
6537 # @param fid feature id
6538 # @return a new Geo::OGR::Feature object that represents the feature in the layer.
6539 #*
6540 sub GetFeature {
6541  my ($self, $fid) = @_;
6542  $fid //= 0;
6543  my $f = $self->_GetFeature($fid);
6544  $FEATURES{tied(%$f)} = $self;
6545  return $f;
6546 }
6547 
6548 #** @method scalar GetFeatureCount($force = 1)
6549 # Object method.
6550 # @param force
6551 # @return integer
6552 #*
6553 sub GetFeatureCount {
6554 }
6555 
6556 #** @method scalar GetFeaturesRead()
6557 # Object method.
6558 # @return integer
6559 #*
6560 sub GetFeaturesRead {
6561 }
6563 #** @method hash GetFieldDefn($name)
6564 # Object method.
6565 # Get the definition of a field.
6566 # @param name the name of the field.
6567 # @return the field definition object, either Geo::OGR::FieldDefn or
6568 # Geo::OGR::GeomFieldDefn.
6569 #*
6570 sub GetFieldDefn {
6571  my ($self, $name) = @_;
6572  my $d = $self->GetDefn;
6573  for (my $i = 0; $i < $d->GetFieldCount; $i++) {
6574  my $fd = $d->GetFieldDefn($i);
6575  return $fd if $fd->Name eq $name;
6576  }
6577  for (my $i = 0; $i < $d->GetGeomFieldCount; $i++) {
6578  my $fd = $d->GetGeomFieldDefn($i);
6579  return $fd if $fd->Name eq $name;
6580  }
6581  Geo::GDAL::error(2, $name, 'Field');
6582 }
6583 
6584 #** @method list GetFieldNames()
6585 # Object method.
6586 # @return a list of the names of the fields in this layer. The
6587 # non-geometry field names are first in the list and then the geometry
6588 # fields.
6589 #*
6590 sub GetFieldNames {
6591  my $self = shift;
6592  my $d = $self->GetDefn;
6593  my @ret;
6594  for (my $i = 0; $i < $d->GetFieldCount; $i++) {
6595  push @ret, $d->GetFieldDefn($i)->Name();
6596  }
6597  for (my $i = 0; $i < $d->GetGeomFieldCount; $i++) {
6598  push @ret, $d->GetGeomFieldDefn($i)->Name();
6599  }
6600  return @ret;
6601 }
6602 
6603 #** @method scalar GetName()
6604 # Object method.
6605 # @return the name of the layer.
6606 #*
6607 sub GetName {
6608 }
6609 
6610 #** @method Geo::OGR::Feature GetNextFeature()
6611 # Object method.
6612 # @return iteratively Geo::OGR::Feature objects from the layer. The
6613 # iteration obeys the spatial and the attribute filter.
6614 #*
6615 sub GetNextFeature {
6616 }
6617 
6618 #** @method hash reference GetSchema()
6619 # Object method.
6620 # @brief Get the schema of this layer.
6621 # @note The schema of a layer cannot be set with this method. If you
6622 # have a Geo::OGR::FeatureDefn object before creating the layer, use
6623 # its schema in the Geo::OGR::CreateLayer method.
6624 # @return the schema of this layer, as in Geo::OGR::FeatureDefn::Schema.
6625 #*
6626 sub GetSchema {
6627  my $self = shift;
6628  carp "Schema of a layer should not be set directly." if @_;
6629  if (@_ and @_ % 2 == 0) {
6630  my %schema = @_;
6631  if ($schema{Fields}) {
6632  for my $field (@{$schema{Fields}}) {
6633  $self->CreateField($field);
6634  }
6635  }
6636  }
6637  return $self->GetDefn->Schema;
6638 }
6639 
6640 #** @method Geo::OGR::Geometry GetSpatialFilter()
6641 # Object method.
6642 # @return a new Geo::OGR::Geometry object
6643 #*
6644 sub GetSpatialFilter {
6645 }
6646 
6647 #** @method GetStyleTable()
6648 #*
6649 sub GetStyleTable {
6650 }
6651 
6652 #** @method Identity(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6653 # Object method.
6654 # The result layer contains features whose geometries represent areas
6655 # that are in the input layer. The features in the result layer have
6656 # attributes from both input and method layers. The schema of the
6657 # result layer can be set by the user or, if it is empty, is
6658 # initialized to contain all fields in input and method layers.
6659 # @param method method layer.
6660 # @param result result layer.
6661 # @param options a reference to an options hash.
6662 # @param callback [optional] a reference to a subroutine, which will
6663 # be called with parameters (number progress, string msg, callback_data)
6664 # @param callback_data [optional]
6665 #*
6666 sub Identity {
6667 }
6668 
6669 #** @method InsertFeature($feature)
6670 # Object method.
6671 # Creates a new feature which has the schema of the layer and
6672 # initializes it with data from the argument. Then inserts the feature
6673 # into the layer (using CreateFeature). Uses Geo::OGR::Feature::Row or
6674 # Geo::OGR::Feature::Tuple.
6675 # @param feature a Geo::OGR::Feature object or reference to feature
6676 # data in a hash (as in Geo::OGR::Feature::Row) or in an array (as in
6677 # Geo::OGR::Feature::Tuple)
6678 # @return the new feature.
6679 #*
6680 sub InsertFeature {
6681  my $self = shift;
6682  my $feature = shift;
6683  Geo::GDAL::error("Usage: \$feature->InsertFeature(reference to a hash or array).") unless ref($feature);
6684  my $new = Geo::OGR::Feature->new($self->GetDefn);
6685  if (ref($feature) eq 'HASH') {
6686  $new->Row(%$feature);
6687  } elsif (ref($feature) eq 'ARRAY') {
6688  $new->Tuple(@$feature);
6689  } elsif (blessed($feature) and $feature->isa('Geo::OGR::Feature')) {
6690  $new->Row($feature->Row);
6691  }
6692  $self->CreateFeature($new);
6693  return unless defined wantarray;
6694  $FEATURES{tied(%$new)} = $self;
6695  return $new;
6696 }
6697 
6698 #** @method Intersection(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6699 # Object method.
6700 # The result layer contains features whose geometries represent areas
6701 # that are common between features in the input layer and in the
6702 # method layer. The schema of the result layer can be set before
6703 # calling this method, or is initialized to contain all fields from
6704 # this and method layer.
6705 # @param method method layer.
6706 # @param result result layer.
6707 # @param options a reference to an options hash.
6708 # @param callback [optional] a reference to a subroutine, which will
6709 # be called with parameters (number progress, string msg, callback_data)
6710 # @param callback_data [optional]
6711 #*
6712 sub Intersection {
6713 }
6714 
6715 #** @method ReorderField()
6716 #*
6717 sub ReorderField {
6718 }
6719 
6720 #** @method ReorderFields()
6721 #*
6722 sub ReorderFields {
6723 }
6724 
6725 #** @method ResetReading()
6726 # Object method.
6727 # Initialize the layer object for iterative reading.
6728 #*
6729 sub ResetReading {
6730 }
6731 
6732 #** @method RollbackTransaction()
6733 # Object method.
6734 #*
6735 sub RollbackTransaction {
6736 }
6737 
6738 #** @method hash reference Row(%row)
6739 # Object method.
6740 # Get and/or set the data of a feature that has the supplied feature
6741 # id (the next feature obtained with GetNextFeature is used if feature
6742 # id is not given). Calls Geo::OGR::Feature::Row.
6743 # @param row [optional] feature data
6744 # @return a reference to feature data in a hash
6745 #*
6746 sub Row {
6747  my $self = shift;
6748  my $update = @_ > 0;
6749  my %row = @_;
6750  my $feature = defined $row{FID} ? $self->GetFeature($row{FID}) : $self->GetNextFeature;
6751  return unless $feature;
6752  my $ret;
6753  if (defined wantarray) {
6754  $ret = $feature->Row(@_);
6755  } else {
6756  $feature->Row(@_);
6757  }
6758  $self->SetFeature($feature) if $update;
6759  return unless defined wantarray;
6760  return $ret;
6761 }
6762 
6763 #** @method SetAttributeFilter($filter_string)
6764 # Object method.
6765 # Set or clear the attribute filter.
6766 # @param filter_string a SQL WHERE clause or undef to clear the
6767 # filter.
6768 #*
6769 sub SetAttributeFilter {
6770 }
6771 
6772 #** @method SetFeature($feature)
6773 # Object method.
6774 # @note The feature should have the same schema as the layer.
6775 #
6776 # Replaces a feature in the layer based on the given feature's
6777 # id. Requires RandomWrite capability.
6778 # @param feature a Geo::OGR::Feature object
6779 #*
6780 sub SetFeature {
6781 }
6782 
6783 #** @method SetIgnoredFields(@fields)
6784 # Object method.
6785 # @param fields a list of field names
6786 #*
6787 sub SetIgnoredFields {
6788 }
6789 
6790 #** @method SetNextByIndex($new_index)
6791 # Object method.
6792 # @param new_index the index to which set the read cursor in the
6793 # current iteration
6794 #*
6795 sub SetNextByIndex {
6796 }
6797 
6798 #** @method SetSpatialFilter($filter)
6799 # Object method.
6800 # @param filter [optional] a Geo::OGR::Geometry object. If not given,
6801 # removes the filter if there is one.
6802 #*
6803 sub SetSpatialFilter {
6804 }
6805 
6806 #** @method SetSpatialFilterRect($minx, $miny, $maxx, $maxy)
6807 # Object method.
6808 # @param minx
6809 # @param miny
6810 # @param maxx
6811 # @param maxy
6812 #*
6813 sub SetSpatialFilterRect {
6814 }
6815 
6816 #** @method SetStyleTable()
6817 #*
6818 sub SetStyleTable {
6819 }
6820 
6821 #** @method Geo::OGR::Geometry SpatialFilter(@filter)
6822 # Object method.
6823 # @param filter [optional] a Geo::OGR::Geometry object or a string. An
6824 # undefined value removes the filter if there is one.
6825 # @return a new Geo::OGR::Geometry object
6826 # @param filter [optional] a rectangle ($minx, $miny, $maxx, $maxy).
6827 # @return a new Geo::OGR::Geometry object
6828 #*
6829 sub SpatialFilter {
6830  my $self = shift;
6831  $self->SetSpatialFilter($_[0]) if @_ == 1;
6832  $self->SetSpatialFilterRect(@_) if @_ == 4;
6833  return unless defined wantarray;
6834  $self->GetSpatialFilter;
6835 }
6836 
6837 #** @method Geo::OSR::SpatialReference SpatialReference($name, Geo::OSR::SpatialReference sr)
6838 # Object method.
6839 # @note A.k.a GetSpatialRef.
6840 # Get or set the projection of a spatial field of this layer. Gets or
6841 # sets the projection of the first field if no field name is given.
6842 # @param name [optional] a name of a spatial field in this layer.
6843 # @param sr [optional] a Geo::OSR::SpatialReference object,
6844 # which replaces the existing projection.
6845 # @return a Geo::OSR::SpatialReference object, which represents the
6846 # projection in the given spatial field.
6847 #*
6848 sub SpatialReference {
6849  my($self, $field, $sr) = @_;
6850  my $d = $self->GetDefn;
6851  my $i;
6852  if (not defined $field or (blessed($field) and $field->isa('Geo::OSR::SpatialReference'))) {
6853  $i = 0;
6854  } else {
6855  $i = $d->GetGeomFieldIndex($field);
6856  }
6857  my $d2 = $d->GetGeomFieldDefn($i);
6858  $d2->SpatialReference($sr) if defined $sr;
6859  return $d2->SpatialReference() if defined wantarray;
6860 }
6861 
6862 #** @method StartTransaction()
6863 # Object method.
6864 #*
6865 sub StartTransaction {
6866 }
6867 
6868 #** @method SymDifference(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6869 # Object method.
6870 # The result layer contains features whose geometries represent areas
6871 # that are in either in the input layer or in the method layer but not
6872 # in both. The features in the result layer have attributes from both
6873 # input and method layers. For features which represent areas that are
6874 # only in the input or in the method layer the respective attributes
6875 # have undefined values. The schema of the result layer can be set by
6876 # the user or, if it is empty, is initialized to contain all fields in
6877 # the input and method layers.
6878 # @param method method layer.
6879 # @param result result layer.
6880 # @param options a reference to an options hash.
6881 # @param callback [optional] a reference to a subroutine, which will
6882 # be called with parameters (number progress, string msg, callback_data)
6883 # @param callback_data [optional]
6884 #*
6885 sub SymDifference {
6886 }
6887 
6888 #** @method SyncToDisk()
6889 # Object method.
6890 #*
6891 sub SyncToDisk {
6892 }
6893 
6894 #** @method scalar TestCapability($cap)
6895 # Object method.
6896 # @param cap A capability string.
6897 # @return a boolean value indicating whether the layer has the
6898 # specified capability.
6899 #*
6900 sub TestCapability {
6901  my($self, $cap) = @_;
6902  return _TestCapability($self, $CAPABILITIES{$cap});
6903 }
6904 
6905 #** @method list Tuple(@tuple)
6906 # Object method.
6907 # Get and/set the data of a feature that has the supplied feature id
6908 # (the next feature obtained with GetNextFeature is used if feature id
6909 # is not given). The expected data in the tuple is: ([feature id,]
6910 # non-spatial fields, spatial fields). Calls Geo::OGR::Feature::Tuple.
6911 # @param tuple [optional] feature data
6912 # @note The schema of the tuple needs to be the same as that of the
6913 # layer.
6914 # @return a reference to feature data in an array
6915 #*
6916 sub Tuple {
6917  my $self = shift;
6918  my $FID = shift;
6919  my $feature = defined $FID ? $self->GetFeature($FID) : $self->GetNextFeature;
6920  return unless $feature;
6921  my $set = @_ > 0;
6922  unshift @_, $feature->GetFID if $set;
6923  my @ret;
6924  if (defined wantarray) {
6925  @ret = $feature->Tuple(@_);
6926  } else {
6927  $feature->Tuple(@_);
6928  }
6929  $self->SetFeature($feature) if $set;
6930  return unless defined wantarray;
6931  return @ret;
6932 }
6933 
6934 #** @method Union(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6935 # Object method.
6936 # The result layer contains features whose geometries represent areas
6937 # that are in either in the input layer or in the method layer. The
6938 # schema of the result layer can be set before calling this method, or
6939 # is initialized to contain all fields from this and method layer.
6940 # @param method method layer.
6941 # @param result result layer.
6942 # @param options a reference to an options hash.
6943 # @param callback [optional] a reference to a subroutine, which will
6944 # be called with parameters (number progress, string msg, callback_data)
6945 # @param callback_data [optional]
6946 #*
6947 sub Union {
6948 }
6949 
6950 #** @method Update(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
6951 # Object method.
6952 # The result layer contains features whose geometries represent areas
6953 # that are either in the input layer or in the method layer. The
6954 # features in the result layer have areas of the features of the
6955 # method layer or those ares of the features of the input layer that
6956 # are not covered by the method layer. The features of the result
6957 # layer get their attributes from the input layer. The schema of the
6958 # result layer can be set by the user or, if it is empty, is
6959 # initialized to contain all fields in the input layer.
6960 # @param method method layer.
6961 # @param result result layer.
6962 # @param options a reference to an options hash.
6963 # @param callback [optional] a reference to a subroutine, which will
6964 # be called with parameters (number progress, string msg, callback_data)
6965 # @param callback_data [optional]
6966 #*
6967 sub Update {
6968 }
6969 
6970 #** @class Geo::OGR::StyleTable
6971 #*
6972 package Geo::OGR::StyleTable;
6973 
6974 use base qw(Geo::OGR)
6975 
6976 #** @method AddStyle()
6977 #*
6978 sub AddStyle {
6979 }
6980 
6981 #** @method Find()
6982 #*
6983 sub Find {
6984 }
6985 
6986 #** @method GetLastStyleName()
6987 #*
6988 sub GetLastStyleName {
6989 }
6990 
6991 #** @method GetNextStyle()
6992 #*
6993 sub GetNextStyle {
6994 }
6995 
6996 #** @method LoadStyleTable()
6997 #*
6998 sub LoadStyleTable {
6999 }
7000 
7001 #** @method ResetStyleStringReading()
7002 #*
7003 sub ResetStyleStringReading {
7004 }
7005 
7006 #** @method SaveStyleTable()
7007 #*
7008 sub SaveStyleTable {
7009 }
7010 
7011 #** @method new()
7012 #*
7013 sub new {
7014  my $pkg = shift;
7015  my $self = Geo::OGRc::new_StyleTable(@_);
7016  bless $self, $pkg if defined($self);
7017 }
7018 
7019 #** @class Geo::OSR
7020 # @brief Base class for projection related classes.
7021 #*
7022 package Geo::OSR;
7023 
7024 #** @method list AngularUnits()
7025 # Package subroutine.
7026 # @return list of known angular units.
7027 #*
7028 sub AngularUnits {
7029  return keys %ANGULAR_UNITS;
7030 }
7031 
7032 #** @method CreateCoordinateTransformation()
7033 #*
7034 sub CreateCoordinateTransformation {
7035 }
7036 
7037 #** @method list Datums()
7038 # Package subroutine.
7039 # @return list of known datums.
7040 #*
7041 sub Datums {
7042  return keys %DATUMS;
7043 }
7044 
7045 #** @method list GetProjectionMethodParamInfo($projection, $parameter)
7046 # Package subroutine.
7047 # @param projection one of Geo::OSR::Projections
7048 # @param parameter one of Geo::OSR::Parameters
7049 # @return a list ($user_friendly_name, $type, $default_value).
7050 #*
7051 sub GetProjectionMethodParamInfo {
7052 }
7053 
7054 #** @method list GetProjectionMethodParameterList($projection)
7055 # Package subroutine.
7056 # @param projection one of Geo::OSR::Projections
7057 # @return a list (arrayref parameters, $projection_name).
7058 #*
7059 sub GetProjectionMethodParameterList {
7060 }
7061 
7062 #** @method array reference GetProjectionMethods()
7063 # Package subroutine.
7064 # @deprecated Use Geo::OSR::Projections.
7065 #
7066 # @return reference to an array of possible projection methods.
7067 #*
7068 sub GetProjectionMethods {
7069 }
7070 
7071 #** @method scalar GetUserInputAsWKT($name)
7072 # Package subroutine.
7073 # @param name the user input
7074 # @return a WKT string.
7075 #*
7076 sub GetUserInputAsWKT {
7077 }
7078 
7079 #** @method scalar GetWellKnownGeogCSAsWKT($name)
7080 # Package subroutine.
7081 # @brief Get well known geographic coordinate system as WKT
7082 # @param name a well known name
7083 # @return a WKT string.
7084 #*
7085 sub GetWellKnownGeogCSAsWKT {
7086 }
7087 
7088 #** @method list LinearUnits()
7089 # Package subroutine.
7090 # @return list of known linear units.
7091 #*
7092 sub LinearUnits {
7093  return keys %LINEAR_UNITS;
7094 }
7095 
7096 #** @method OAO_Down()
7097 #*
7098 sub OAO_Down {
7099 }
7100 
7101 #** @method OAO_East()
7102 #*
7103 sub OAO_East {
7104 }
7105 
7106 #** @method OAO_North()
7107 #*
7108 sub OAO_North {
7109 }
7110 
7111 #** @method OAO_Other()
7112 #*
7113 sub OAO_Other {
7114 }
7115 
7116 #** @method OAO_South()
7117 #*
7118 sub OAO_South {
7119 }
7120 
7121 #** @method OAO_Up()
7122 #*
7123 sub OAO_Up {
7124 }
7125 
7126 #** @method OAO_West()
7127 #*
7128 sub OAO_West {
7129 }
7130 
7131 #** @method list Parameters()
7132 # Package subroutine.
7133 # @return list of known projection parameters.
7134 #*
7135 sub Parameters {
7136  return keys %PARAMETERS;
7137 }
7138 
7139 #** @method list Projections()
7140 # Package subroutine.
7141 # @return list of known projections.
7142 #*
7143 sub Projections {
7144  return keys %PROJECTIONS;
7145 }
7146 
7147 #** @method SRS_PM_GREENWICH()
7148 #*
7149 sub SRS_PM_GREENWICH {
7150 }
7151 
7152 #** @method SRS_WGS84_INVFLATTENING()
7153 #*
7154 sub SRS_WGS84_INVFLATTENING {
7155 }
7156 
7157 #** @method SRS_WGS84_SEMIMAJOR()
7158 #*
7159 sub SRS_WGS84_SEMIMAJOR {
7160 }
7161 
7162 #** @method SRS_WKT_WGS84()
7163 #*
7164 sub SRS_WKT_WGS84 {
7165 }
7166 
7167 #** @class Geo::OSR::CoordinateTransformation
7168 # @brief An object for transforming from one projection to another.
7169 #*
7170 package Geo::OSR::CoordinateTransformation;
7171 
7172 use base qw(Geo::OSR)
7173 
7174 #** @method array reference TransformPoint($x, $y, $z)
7175 # Object method.
7176 # @param x
7177 # @param y
7178 # @param z [optional]
7179 # @return arrayref = [$x, $y, $z]
7180 #*
7181 sub TransformPoint {
7182 }
7183 
7184 #** @method TransformPoints(arrayref points)
7185 # Object method.
7186 # @param points [in/out] a reference to a list of points (line string
7187 # or ring) that is modified in-place. A list of points is: ([x, y, z],
7188 # [x, y, z], ...), where z is optional. Supports also lists of line
7189 # strings and polygons.
7190 #*
7191 sub TransformPoints {
7192  my($self, $points) = @_;
7193  _TransformPoints($self, $points), return unless ref($points->[0]->[0]);
7194  for my $p (@$points) {
7195  TransformPoints($self, $p);
7196  }
7197 }
7198 1;
7199 # This file was automatically generated by SWIG (http://www.swig.org).
7200 # Version 2.0.4
7201 #
7202 # Do not make changes to this file unless you know what you are doing--modify
7203 # the SWIG interface file instead.
7204 }
7205 
7206 #** @method Geo::OSR::CoordinateTransformation new($src, $dst)
7207 # Class method.
7208 # @param src a Geo::OSR::SpatialReference object
7209 # @param dst a Geo::OSR::SpatialReference object
7210 # @return a new Geo::OSR::CoordinateTransformation object
7211 #*
7212 sub new {
7213  my $pkg = shift;
7214  my $self = Geo::OSRc::new_CoordinateTransformation(@_);
7215  bless $self, $pkg if defined($self);
7216 }
7217 
7218 #** @class Geo::OSR::SpatialReference
7219 # @brief A spatial reference system.
7220 #
7221 # <a href="http://www.gdal.org/classOGRSpatialReference.html">Documentation
7222 # of the underlying C++ class at www.gdal.org</a>
7223 #*
7224 package Geo::OSR::SpatialReference;
7225 
7226 use base qw(Geo::OSR)
7227 
7228 #** @method As()
7229 #*
7230 sub As {
7231 }
7232 
7233 #** @method AutoIdentifyEPSG()
7234 # Object method.
7235 # Set EPSG authority info if possible.
7236 #*
7237 sub AutoIdentifyEPSG {
7238 }
7239 
7240 #** @method Geo::OSR::SpatialReference Clone()
7241 # Object method.
7242 # Make a duplicate of this SpatialReference object.
7243 # @return a new Geo::OSR::SpatialReference object
7244 #*
7245 sub Clone {
7246 }
7247 
7248 #** @method Geo::OSR::SpatialReference CloneGeogCS()
7249 # Object method.
7250 # Make a duplicate of the GEOGCS node of this SpatialReference object.
7251 # @return a new Geo::OSR::SpatialReference object
7252 #*
7253 sub CloneGeogCS {
7254 }
7255 
7256 #** @method CopyGeogCSFrom($rhs)
7257 # Object method.
7258 # @param rhs Geo::OSR::SpatialReference
7259 #*
7260 sub CopyGeogCSFrom {
7261 }
7262 
7263 #** @method EPSGTreatsAsLatLong()
7264 # Object method.
7265 # Returns TRUE if EPSG feels this geographic coordinate system should be treated as having lat/long coordinate ordering.
7266 #*
7267 sub EPSGTreatsAsLatLong {
7268 }
7269 
7270 #** @method EPSGTreatsAsNorthingEasting()
7271 #*
7272 sub EPSGTreatsAsNorthingEasting {
7273 }
7274 
7275 #** @method Export($format)
7276 # Object method.
7277 # Export the spatial reference to a selected format.
7278 # @note a.k.a. As
7279 #
7280 # @param format One of the following. The return value is explained
7281 # after the format. Other arguments are explained in parenthesis.
7282 # - WKT (Text): Well Known Text string
7283 # - PrettyWKT: Well Known Text string nicely formatted (simplify)
7284 # - Proj4: PROJ.4 string
7285 # - PCI: a list: ($proj_string, $units, [$parms1, ...])
7286 # - USGS: a list: ($code, $zone, [$parms1, ...], $datum)
7287 # - GML (XML): GML based string (dialect)
7288 # - MapInfoCS (MICoordSys): MapInfo style co-ordinate system definition
7289 #
7290 # @note The named parameter syntax also works and is needed is those
7291 # cases when other arguments need or may be given. The format should
7292 # be given using key as, 'to' or 'format'.
7293 #
7294 # @note ExportTo* and AsText methods also exist but are not documented here.
7295 #
7296 # @return a scalar or a list depending on the export format
7297 #*
7298 sub Export {
7299  my $self = shift;
7300  my $format;
7301  $format = pop if @_ == 1;
7302  my %params = @_;
7303  $format //= $params{to} //= $params{format} //= $params{as} //= '';
7304  my $simplify = $params{simplify} // 0;
7305  my $dialect = $params{dialect} // '';
7306  my %converters = (
7307  WKT => sub { return ExportToWkt($self) },
7308  Text => sub { return ExportToWkt($self) },
7309  PrettyWKT => sub { return ExportToPrettyWkt($self, $simplify) },
7310  Proj4 => sub { return ExportToProj4($self) },
7311  PCI => sub { return ExportToPCI($self) },
7312  USGS => sub { return ExportToUSGS($self) },
7313  GML => sub { return ExportToXML($self, $dialect) },
7314  XML => sub { return ExportToXML($self, $dialect) },
7315  MICoordSys => sub { return ExportToMICoordSys() },
7316  MapInfoCS => sub { return ExportToMICoordSys() },
7317  );
7318  Geo::GDAL::error(1, $format, \%converters) unless $converters{$format};
7319  return $converters{$format}->();
7320 }
7321 
7322 #** @method Fixup()
7323 # Object method.
7324 #*
7325 sub Fixup {
7326 }
7327 
7328 #** @method FixupOrdering()
7329 # Object method.
7330 #*
7331 sub FixupOrdering {
7332 }
7333 
7334 #** @method scalar GetAngularUnits()
7335 # Object method.
7336 # @return a number
7337 #*
7338 sub GetAngularUnits {
7339 }
7340 
7341 #** @method GetAngularUnitsName()
7342 #*
7343 sub GetAngularUnitsName {
7344 }
7345 
7346 #** @method scalar GetAttrValue($name, $child = 0)
7347 # Object method.
7348 # @param name
7349 # @param child
7350 # @return string
7351 #*
7352 sub GetAttrValue {
7353 }
7354 
7355 #** @method scalar GetAuthorityCode($target_key)
7356 # Object method.
7357 # @param target_key
7358 # @return string
7359 #*
7360 sub GetAuthorityCode {
7361 }
7362 
7363 #** @method scalar GetAuthorityName($target_key)
7364 # Object method.
7365 # @param target_key
7366 # @return string
7367 #*
7368 sub GetAuthorityName {
7369 }
7370 
7371 #** @method GetAxisName()
7372 #*
7373 sub GetAxisName {
7374 }
7375 
7376 #** @method GetAxisOrientation()
7377 #*
7378 sub GetAxisOrientation {
7379 }
7380 
7381 #** @method GetInvFlattening()
7382 # Object method.
7383 #*
7384 sub GetInvFlattening {
7385 }
7386 
7387 #** @method scalar GetLinearUnits()
7388 # Object method.
7389 # @return a number
7390 #*
7391 sub GetLinearUnits {
7392 }
7393 
7394 #** @method scalar GetLinearUnitsName()
7395 # Object method.
7396 # @return string
7397 #*
7398 sub GetLinearUnitsName {
7399 }
7400 
7401 #** @method scalar GetNormProjParm($name, $default_val = 0.0)
7402 # Object method.
7403 # @param name
7404 # @param default_val
7405 # @return a number
7406 #*
7407 sub GetNormProjParm {
7408 }
7409 
7410 #** @method scalar GetProjParm($name, $default_val = 0.0)
7411 # Object method.
7412 # @param name
7413 # @param default_val
7414 # @return a number
7415 #*
7416 sub GetProjParm {
7417 }
7418 
7419 #** @method GetSemiMajor()
7420 # Object method.
7421 #*
7422 sub GetSemiMajor {
7423 }
7424 
7425 #** @method GetSemiMinor()
7426 # Object method.
7427 #*
7428 sub GetSemiMinor {
7429 }
7430 
7431 #** @method GetTOWGS84()
7432 # Object method.
7433 # @return array = ($p1, $p2, $p3, $p4, $p5, $p6, $p7)
7434 #*
7435 sub GetTOWGS84 {
7436 }
7437 
7438 #** @method GetUTMZone()
7439 # Object method.
7440 # Get UTM zone information.
7441 # @return The UTM zone (integer). In scalar context the returned value
7442 # is negative for southern hemisphere zones. In list context returns
7443 # two values ($zone, $north), where $zone is always non-negative and
7444 # $north is true or false.
7445 #*
7446 sub GetUTMZone {
7447  my $self = shift;
7448  my $zone = _GetUTMZone($self);
7449  if (wantarray) {
7450  my $north = 1;
7451  if ($zone < 0) {
7452  $zone *= -1;
7453  $north = 0;
7454  }
7455  return ($zone, $north);
7456  } else {
7457  return $zone;
7458  }
7459 }
7460 
7461 #** @method ImportFromOzi()
7462 #*
7463 sub ImportFromOzi {
7464 }
7465 
7466 #** @method scalar IsCompound()
7467 # Object method.
7468 # @return boolean
7469 #*
7470 sub IsCompound {
7471 }
7472 
7473 #** @method scalar IsGeocentric()
7474 # Object method.
7475 # @return boolean
7476 #*
7477 sub IsGeocentric {
7478 }
7479 
7480 #** @method scalar IsGeographic()
7481 # Object method.
7482 # @return boolean
7483 #*
7484 sub IsGeographic {
7485 }
7486 
7487 #** @method scalar IsLocal()
7488 # Object method.
7489 # @return boolean
7490 #*
7491 sub IsLocal {
7492 }
7493 
7494 #** @method scalar IsProjected()
7495 # Object method.
7496 # @return boolean
7497 #*
7498 sub IsProjected {
7499 }
7500 
7501 #** @method scalar IsSame($rs)
7502 # Object method.
7503 # @param rs a Geo::OSR::SpatialReference object
7504 # @return boolean
7505 #*
7506 sub IsSame {
7507 }
7508 
7509 #** @method scalar IsSameGeogCS($rs)
7510 # Object method.
7511 # @param rs a Geo::OSR::SpatialReference object
7512 # @return boolean
7513 #*
7514 sub IsSameGeogCS {
7515 }
7516 
7517 #** @method scalar IsSameVertCS($rs)
7518 # Object method.
7519 # @param rs a Geo::OSR::SpatialReference object
7520 # @return boolean
7521 #*
7522 sub IsSameVertCS {
7523 }
7524 
7525 #** @method scalar IsVertical()
7526 # Object method.
7527 # @return boolean
7528 #*
7529 sub IsVertical {
7530 }
7531 
7532 #** @method MorphFromESRI()
7533 # Object method.
7534 #*
7535 sub MorphFromESRI {
7536 }
7537 
7538 #** @method MorphToESRI()
7539 # Object method.
7540 #*
7541 sub MorphToESRI {
7542 }
7543 
7544 #** @method Set(%params)
7545 # Object method.
7546 # Set a parameter or parameters in the spatial reference object.
7547 # @param params Named parameters. Recognized keys and respective
7548 # values are the following.
7549 # - Authority: authority name (give also TargetKey, Node and Code)
7550 # - TargetKey:
7551 # - Node: partial or complete path to the target node (Node and Value together sets an attribute value)
7552 # - Code: code for value with an authority
7553 # - Value: value to be assigned to a node, a projection parameter or an object
7554 # - AngularUnits: angular units for the geographic coordinate system (give also Value) (one of Geo::OSR::LinearUnits)
7555 # - LinearUnits: linear units for the target node or the object (give also Value and optionally Node) (one of Geo::OSR::LinearUnits)
7556 # - Parameter: projection parameter to set (give also Value and Normalized) (one of Geo::OSR::Parameters)
7557 # - Normalized: set to true to indicate that the Value argument is in "normalized" form
7558 # - Name: a well known name of a geographic coordinate system (e.g. WGS84)
7559 # - GuessFrom: arbitrary text that specifies a projection ("user input")
7560 # - LOCAL_CS: name of a local coordinate system
7561 # - GeocentricCS: name of a geocentric coordinate system
7562 # - VerticalCS: name of a vertical coordinate system (give also Datum and optionally VertDatumType [default is 2005])
7563 # - Datum: a known (OGC or EPSG) name (or(?) one of Geo::OSR::Datums)
7564 # - CoordinateSystem: 'WGS', 'UTM', 'State Plane', or a user visible name (give optionally also Parameters, Zone, North, NAD83, UnitName, UnitConversionFactor, Datum, Spheroid, HorizontalCS, and/or VerticalCS
7565 # - Parameters: a reference to a list containing the coordinate system or projection parameters
7566 # - Zone: zone for setting up UTM or State Plane coordinate systems (State Plane zone in USGS numbering scheme)
7567 # - North: set false for southern hemisphere
7568 # - NAD83: set false if the NAD27 zone definition should be used instead of NAD83
7569 # - UnitName: to override the legal definition for a zone
7570 # - UnitConversionFactor: to override the legal definition for a zone
7571 # - Spheroid: user visible name
7572 # - HorizontalCS: Horizontal coordinate system name
7573 # - Projection: name of a projection, one of Geo::OSR::Projections (give also optionally Parameters and Variant)
7574 #
7575 # @note Numerous Set* methods also exist but are not documented here.
7576 #*
7577 sub Set {
7578  my($self, %params) = @_;
7579  if (exists $params{Authority} and exists $params{TargetKey} and exists $params{Node} and exists $params{Code}) {
7580  SetAuthority($self, $params{TargetKey}, $params{Authority}, $params{Code});
7581  } elsif (exists $params{Node} and exists $params{Value}) {
7582  SetAttrValue($self, $params{Node}, $params{Value});
7583  } elsif (exists $params{AngularUnits} and exists $params{Value}) {
7584  SetAngularUnits($self, $params{AngularUnits}, $params{Value});
7585  } elsif (exists $params{LinearUnits} and exists $params{Node} and exists $params{Value}) {
7586  SetTargetLinearUnits($self, $params{Node}, $params{LinearUnits}, $params{Value});
7587  } elsif (exists $params{LinearUnits} and exists $params{Value}) {
7588  SetLinearUnitsAndUpdateParameters($self, $params{LinearUnits}, $params{Value});
7589  } elsif ($params{Parameter} and exists $params{Value}) {
7590  Geo::GDAL::error(1, $params{Parameter}, \%Geo::OSR::PARAMETERS) unless exists $Geo::OSR::PARAMETERS{$params{Parameter}};
7591  $params{Normalized} ?
7592  SetNormProjParm($self, $params{Parameter}, $params{Value}) :
7593  SetProjParm($self, $params{Parameter}, $params{Value});
7594  } elsif (exists $params{Name}) {
7595  SetWellKnownGeogCS($self, $params{Name});
7596  } elsif (exists $params{GuessFrom}) {
7597  SetFromUserInput($self, $params{GuessFrom});
7598  } elsif (exists $params{LOCAL_CS}) {
7599  SetLocalCS($self, $params{LOCAL_CS});
7600  } elsif (exists $params{GeocentricCS}) {
7601  SetGeocCS($self, $params{GeocentricCS});
7602  } elsif (exists $params{VerticalCS} and $params{Datum}) {
7603  my $type = $params{VertDatumType} || 2005;
7604  SetVertCS($self, $params{VerticalCS}, $params{Datum}, $type);
7605  } elsif (exists $params{CoordinateSystem}) {
7606  my @parameters = ();
7607  @parameters = @{$params{Parameters}} if ref($params{Parameters});
7608  if ($params{CoordinateSystem} eq 'State Plane' and exists $params{Zone}) {
7609  my $NAD83 = exists $params{NAD83} ? $params{NAD83} : 1;
7610  my $name = exists $params{UnitName} ? $params{UnitName} : undef;
7611  my $c = exists $params{UnitConversionFactor} ? $params{UnitConversionFactor} : 0.0;
7612  SetStatePlane($self, $params{Zone}, $NAD83, $name, $c);
7613  } elsif ($params{CoordinateSystem} eq 'UTM' and exists $params{Zone} and exists $params{North}) {
7614  my $north = exists $params{North} ? $params{North} : 1;
7615  SetUTM($self, $params{Zone}, $north);
7616  } elsif ($params{CoordinateSystem} eq 'WGS') {
7617  SetTOWGS84($self, @parameters);
7618  } elsif ($params{CoordinateSystem} and $params{Datum} and $params{Spheroid}) {
7619  SetGeogCS($self, $params{CoordinateSystem}, $params{Datum}, $params{Spheroid}, @parameters);
7620  } elsif ($params{CoordinateSystem} and $params{HorizontalCS} and $params{VerticalCS}) {
7621  SetCompoundCS($self, $params{CoordinateSystem}, $params{HorizontalCS}, $params{VerticalCS});
7622  } else {
7623  SetProjCS($self, $params{CoordinateSystem});
7624  }
7625  } elsif (exists $params{Projection}) {
7626  Geo::GDAL::error(1, $params{Projection}, \%Geo::OSR::PROJECTIONS) unless exists $Geo::OSR::PROJECTIONS{$params{Projection}};
7627  my @parameters = ();
7628  @parameters = @{$params{Parameters}} if ref($params{Parameters});
7629  if ($params{Projection} eq 'Albers_Conic_Equal_Area') {
7630  SetACEA($self, @parameters);
7631  } elsif ($params{Projection} eq 'Azimuthal_Equidistant') {
7632  SetAE($self, @parameters);
7633  } elsif ($params{Projection} eq 'Bonne') {
7634  SetBonne($self, @parameters);
7635  } elsif ($params{Projection} eq 'Cylindrical_Equal_Area') {
7636  SetCEA($self, @parameters);
7637  } elsif ($params{Projection} eq 'Cassini_Soldner') {
7638  SetCS($self, @parameters);
7639  } elsif ($params{Projection} eq 'Equidistant_Conic') {
7640  SetEC($self, @parameters);
7641  # Eckert_I, Eckert_II, Eckert_III, Eckert_V ?
7642  } elsif ($params{Projection} eq 'Eckert_IV') {
7643  SetEckertIV($self, @parameters);
7644  } elsif ($params{Projection} eq 'Eckert_VI') {
7645  SetEckertVI($self, @parameters);
7646  } elsif ($params{Projection} eq 'Equirectangular') {
7647  @parameters == 4 ?
7648  SetEquirectangular($self, @parameters) :
7649  SetEquirectangular2($self, @parameters);
7650  } elsif ($params{Projection} eq 'Gauss_Schreiber_Transverse_Mercator') {
7651  SetGaussSchreiberTMercator($self, @parameters);
7652  } elsif ($params{Projection} eq 'Gall_Stereographic') {
7653  SetGS($self, @parameters);
7654  } elsif ($params{Projection} eq 'Goode_Homolosine') {
7655  SetGH($self, @parameters);
7656  } elsif ($params{Projection} eq 'Interrupted_Goode_Homolosine') {
7657  SetIGH($self);
7658  } elsif ($params{Projection} eq 'Geostationary_Satellite') {
7659  SetGEOS($self, @parameters);
7660  } elsif ($params{Projection} eq 'Gnomonic') {
7661  SetGnomonic($self, @parameters);
7662  } elsif ($params{Projection} eq 'Hotine_Oblique_Mercator') {
7663  # Hotine_Oblique_Mercator_Azimuth_Center ?
7664  SetHOM($self, @parameters);
7665  } elsif ($params{Projection} eq 'Hotine_Oblique_Mercator_Two_Point_Natural_Origin') {
7666  SetHOM2PNO($self, @parameters);
7667  } elsif ($params{Projection} eq 'Krovak') {
7668  SetKrovak($self, @parameters);
7669  } elsif ($params{Projection} eq 'Lambert_Azimuthal_Equal_Area') {
7670  SetLAEA($self, @parameters);
7671  } elsif ($params{Projection} eq 'Lambert_Conformal_Conic_2SP') {
7672  SetLCC($self, @parameters);
7673  } elsif ($params{Projection} eq 'Lambert_Conformal_Conic_1SP') {
7674  SetLCC1SP($self, @parameters);
7675  } elsif ($params{Projection} eq 'Lambert_Conformal_Conic_2SP_Belgium') {
7676  SetLCCB($self, @parameters);
7677  } elsif ($params{Projection} eq 'miller_cylindrical') {
7678  SetMC($self, @parameters);
7679  } elsif ($params{Projection} =~ /^Mercator/) {
7680  # Mercator_1SP, Mercator_2SP, Mercator_Auxiliary_Sphere ?
7681  # variant is in Variant (or Name)
7682  SetMercator($self, @parameters);
7683  } elsif ($params{Projection} eq 'Mollweide') {
7684  SetMollweide($self, @parameters);
7685  } elsif ($params{Projection} eq 'New_Zealand_Map_Grid') {
7686  SetNZMG($self, @parameters);
7687  } elsif ($params{Projection} eq 'Oblique_Stereographic') {
7688  SetOS($self, @parameters);
7689  } elsif ($params{Projection} eq 'Orthographic') {
7690  SetOrthographic($self, @parameters);
7691  } elsif ($params{Projection} eq 'Polyconic') {
7692  SetPolyconic($self, @parameters);
7693  } elsif ($params{Projection} eq 'Polar_Stereographic') {
7694  SetPS($self, @parameters);
7695  } elsif ($params{Projection} eq 'Robinson') {
7696  SetRobinson($self, @parameters);
7697  } elsif ($params{Projection} eq 'Sinusoidal') {
7698  SetSinusoidal($self, @parameters);
7699  } elsif ($params{Projection} eq 'Stereographic') {
7700  SetStereographic($self, @parameters);
7701  } elsif ($params{Projection} eq 'Swiss_Oblique_Cylindrical') {
7702  SetSOC($self, @parameters);
7703  } elsif ($params{Projection} eq 'Transverse_Mercator_South_Orientated') {
7704  SetTMSO($self, @parameters);
7705  } elsif ($params{Projection} =~ /^Transverse_Mercator/) {
7706  my($variant) = $params{Projection} =~ /^Transverse_Mercator_(\w+)/;
7707  $variant //= $params{Variant} //= $params{Name};
7708  $variant ?
7709  SetTMVariant($self, $variant, @parameters) :
7710  SetTM($self, @parameters);
7711  } elsif ($params{Projection} eq 'Tunisia_Mining_Grid') {
7712  SetTMG($self, @parameters);
7713  } elsif ($params{Projection} eq 'VanDerGrinten') {
7714  SetVDG($self, @parameters);
7715  } else {
7716  # Aitoff, Craster_Parabolic, International_Map_of_the_World_Polyconic, Laborde_Oblique_Mercator
7717  # Loximuthal, Miller_Cylindrical, Quadrilateralized_Spherical_Cube, Quartic_Authalic, Two_Point_Equidistant
7718  # Wagner_I, Wagner_II, Wagner_III, Wagner_IV, Wagner_V, Wagner_VI, Wagner_VII
7719  # Winkel_I, Winkel_II, Winkel_Tripel
7720  # ?
7721  SetProjection($self, $params{Projection});
7722  }
7723  } else {
7724  Geo::GDAL::error("Not enough information to create a spatial reference object.");
7725  }
7726 }
7727 
7728 #** @method StripCTParms()
7729 # Object method.
7730 #*
7731 sub StripCTParms {
7732 }
7733 
7734 #** @method Validate()
7735 # Object method.
7736 #*
7737 sub Validate {
7738 }
7739 
7740 #** @method Geo::OSR::SpatialReference new(%params)
7741 # Class method.
7742 # Create a new spatial reference object using a named parameter. This
7743 # constructor recognizes the following key words (alternative in
7744 # parenthesis): WKT (Text), Proj4, ESRI, EPSG, EPSGA, PCI, USGS, GML
7745 # (XML), URL, ERMapper (ERM), MapInfoCS (MICoordSys). The value
7746 # depends on the key.
7747 # - WKT: Well Known Text string
7748 # - Proj4: PROJ.4 string
7749 # - ESRI: reference to a list of strings (contents of ESRI .prj file)
7750 # - EPSG: EPSG code number
7751 # - EPSGA: EPSG code number (the resulting CS will have EPSG preferred axis ordering)
7752 # - PCI: listref: [PCI_projection_string, Grid_units_code, [17 cs parameters]]
7753 # - USGS: listref: [Projection_system_code, Zone, [15 cs parameters], Datum_code, Format_flag]
7754 # - GML: GML string
7755 # - URL: URL for downloading the spatial reference from
7756 # - ERMapper: listref: [Projection, Datum, Units]
7757 # - MapInfoCS: MapInfo style co-ordinate system definition
7758 #
7759 # For more information, consult the import methods in <a href="http://www.gdal.org/classOGRSpatialReference.html">OGR documentation</a>.
7760 #
7761 # @note ImportFrom* methods also exist but are not documented here.
7762 #
7763 # Usage:
7764 # \code
7765 # $sr = Geo::OSR::SpatialReference->new( key => value );
7766 # \endcode
7767 # @return a new Geo::OSR::SpatialReference object
7768 #*
7769 sub new {
7770  my $pkg = shift;
7771  my %param = @_;
7772  my $self = Geo::OSRc::new_SpatialReference();
7773  if (exists $param{WKT}) {
7774  ImportFromWkt($self, $param{WKT});
7775  } elsif (exists $param{Text}) {
7776  ImportFromWkt($self, $param{Text});
7777  } elsif (exists $param{Proj4}) {
7778  ImportFromProj4($self, $param{Proj4});
7779  } elsif (exists $param{ESRI}) {
7780  ImportFromESRI($self, @{$param{ESRI}});
7781  } elsif (exists $param{EPSG}) {
7782  ImportFromEPSG($self, $param{EPSG});
7783  } elsif (exists $param{EPSGA}) {
7784  ImportFromEPSGA($self, $param{EPSGA});
7785  } elsif (exists $param{PCI}) {
7786  ImportFromPCI($self, @{$param{PCI}});
7787  } elsif (exists $param{USGS}) {
7788  ImportFromUSGS($self, @{$param{USGS}});
7789  } elsif (exists $param{XML}) {
7790  ImportFromXML($self, $param{XML});
7791  } elsif (exists $param{GML}) {
7792  ImportFromGML($self, $param{GML});
7793  } elsif (exists $param{URL}) {
7794  ImportFromUrl($self, $param{URL});
7795  } elsif (exists $param{ERMapper}) {
7796  ImportFromERM($self, @{$param{ERMapper}});
7797  } elsif (exists $param{ERM}) {
7798  ImportFromERM($self, @{$param{ERM}});
7799  } elsif (exists $param{MICoordSys}) {
7800  ImportFromMICoordSys($self, $param{MICoordSys});
7801  } elsif (exists $param{MapInfoCS}) {
7802  ImportFromMICoordSys($self, $param{MapInfoCS});
7803  } elsif (exists $param{WGS}) {
7804  eval {
7805  SetWellKnownGeogCS($self, 'WGS'.$param{WGS});
7806  };
7807  confess Geo::GDAL->last_error if $@;
7808  } else {
7809  Geo::GDAL::error("Unrecognized/missing parameters: @_.");
7810  }
7811  bless $self, $pkg if defined $self;
7812 }
7813 
A definition of a non-spatial attribute.
Definition: all.pm:9185
The schema of a feature or a layer.
Definition: all.pm:8820
public method new(array coeffs)
public Geo::OGR::Geometry new(hash params)
public Geo::GDAL::Dataset OpenEx(hash params)
A set of associated raster bands or vector layer source.
Definition: all.pm:2910
public Geo::GDAL::Band Band(scalar index)
A driver for a specific dataset format.
Definition: all.pm:4410
public Geo::GDAL::Dataset Create(hash params)
public method AddGeometry(scalar other)
public Geo::OGR::FieldDefn new(hash params)
Create a new field definition.
public Geo::OSR::SpatialReference new(hash params)
public hash reference GetMetadata(scalar domain="")
public Geo::GDAL::Driver Driver(scalar Name)
public method new()
public scalar GeometryType()
public Geo::OGR::GeomFieldDefn new(hash params)
Create a new spatial field definition.
Spatial data.
Definition: all.pm:9964
A color table from a raster band or a color table, which can be used for a band.
Definition: all.pm:2733
GDAL utility functions and a root class for raster classes.
Definition: all.pm:14
public Geo::OGR::FeatureDefn new(hash schema)
OGR utility functions.
Definition: all.pm:7431
public array reference Points(arrayref points)
public method Set3D()
An object, which holds meta data.
Definition: all.pm:5292
public scalar GetDataTypeSize(scalar DataType)
Base class for projection related classes.
Definition: all.pm:13941
A spatial reference system.
Definition: all.pm:14469
public scalar PackCharacter(scalar DataType)
public scalar Name(scalar name)
An array of affine transformation coefficients.
Definition: all.pm:5108
public Geo::GDAL::ColorTable new(scalar GDALPaletteInterp= 'RGB')
Base class for geographical networks in GDAL.
Definition: all.pm:6562
A definition of a spatial attribute.
Definition: all.pm:9654