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