| 1 | package Geo::GDAL::FFI::Object; | ||||||||||||
| 2 | 13 | ▶ | use v5.10; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 13 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 13 | our $VERSION = '0.15'; | |||||||||||
| 8 | |||||||||||||
| 9 | sub GetDescription { | ||||||||||||
| 10 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
GetDescription: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 11 | 0 | return Geo::GDAL::FFI::GDALGetDescription($$self); | |||||||||||
| 12 | } | ||||||||||||
| 13 | |||||||||||||
| 14 | sub HasCapability { | ||||||||||||
| 15 | 0 | ▶ | my ($self, $cap) = @_; | ||||||||||
|
Subroutine
HasCapability: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 16 | 0 | my $tmp = $Geo::GDAL::FFI::capabilities{$cap}; | |||||||||||
| 17 | 0 | ▶ | confess "Unknown capability: $cap." unless defined $tmp; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | my $md = $self->GetMetadata(''); | |||||||||||
| 19 | 0 | return $md->{'DCAP_'.$cap}; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | sub GetMetadataDomainList { | ||||||||||||
| 23 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
GetMetadataDomainList: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 24 | 0 | my $csl = Geo::GDAL::FFI::GDALGetMetadataDomainList($$self); | |||||||||||
| 25 | 0 | my @list; | |||||||||||
| 26 | 0 | for my $i (0..Geo::GDAL::FFI::CSLCount($csl)-1) { | |||||||||||
| 27 | 0 | push @list, Geo::GDAL::FFI::CSLGetField($csl, $i); | |||||||||||
| 28 | } | ||||||||||||
| 29 | 0 | Geo::GDAL::FFI::CSLDestroy($csl); | |||||||||||
| 30 | 0 | ▶ | return wantarray ? @list : \@list; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | sub GetMetadata { | ||||||||||||
| 34 | 0 | ▶ | my ($self, $domain) = @_; | ||||||||||
|
Subroutine
GetMetadata: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 35 | 0 | my %md; | |||||||||||
| 36 | 0 | ▶ | unless (defined $domain) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | 0 | for $domain ($self->GetMetadataDomainList) { | |||||||||||
| 38 | 0 | $md{$domain} = $self->GetMetadata($domain); | |||||||||||
| 39 | } | ||||||||||||
| 40 | 0 | ▶ | return wantarray ? %md : \%md; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | } | ||||||||||||
| 42 | 0 | my $csl = Geo::GDAL::FFI::GDALGetMetadata($$self, $domain); | |||||||||||
| 43 | 0 | for my $i (0..Geo::GDAL::FFI::CSLCount($csl)-1) { | |||||||||||
| 44 | 0 | my ($name, $value) = split /=/, Geo::GDAL::FFI::CSLGetField($csl, $i); | |||||||||||
| 45 | 0 | $md{$name} = $value; | |||||||||||
| 46 | } | ||||||||||||
| 47 | 0 | ▶ | return wantarray ? %md : \%md; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | sub SetMetadata { | ||||||||||||
| 51 | 0 | ▶ | my ($self, $metadata, $domain) = @_; | ||||||||||
|
Subroutine
SetMetadata: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 52 | 0 | ▶ | unless (defined $domain) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | 0 | for $domain (keys %$metadata) { | |||||||||||
| 54 | 0 | $self->SetMetadata($metadata->{$domain}, $domain); | |||||||||||
| 55 | } | ||||||||||||
| 56 | } else { | ||||||||||||
| 57 | 0 | my $csl = 0; | |||||||||||
| 58 | 0 | for my $name (keys %$metadata) { | |||||||||||
| 59 | 0 | $csl = Geo::GDAL::FFI::CSLAddString($csl, "$name=$metadata->{$name}"); | |||||||||||
| 60 | } | ||||||||||||
| 61 | 0 | my $err = Geo::GDAL::FFI::GDALSetMetadata($$self, $csl, $domain); | |||||||||||
| 62 | 0 | Geo::GDAL::FFI::CSLDestroy($csl); | |||||||||||
| 63 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() if $err == $Geo::GDAL::FFI::Failure; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | 0 | ▶ | warn Geo::GDAL::FFI::error_msg() if $err == $Geo::GDAL::FFI::Warning; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | } | ||||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | sub GetMetadataItem { | ||||||||||||
| 69 | 0 | ▶ | my ($self, $name, $domain) = @_; | ||||||||||
|
Subroutine
GetMetadataItem: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 70 | 0 | ▶ | $domain //= ""; | ||||||||||
|
Condition0%0/2
$domain //= ""
MC/DC0%0/1
$domain //= ""
$domain
Truth table0%0/2
A
A= $domain
| |||||||||||||
| 71 | 0 | return Geo::GDAL::FFI::GDALGetMetadataItem($$self, $name, $domain); | |||||||||||
| 72 | } | ||||||||||||
| 73 | |||||||||||||
| 74 | sub SetMetadataItem { | ||||||||||||
| 75 | 0 | ▶ | my ($self, $name, $value, $domain) = @_; | ||||||||||
|
Subroutine
SetMetadataItem: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 76 | 0 | ▶ | $domain //= ""; | ||||||||||
|
Condition0%0/2
$domain //= ""
MC/DC0%0/1
$domain //= ""
$domain
Truth table0%0/2
A
A= $domain
| |||||||||||||
| 77 | 0 | my $err = Geo::GDAL::FFI::GDALSetMetadataItem($$self, $name, $value, $domain); | |||||||||||
| 78 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() if $err == $Geo::GDAL::FFI::Failure; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 79 | 0 | ▶ | warn Geo::GDAL::FFI::error_msg() if $err == $Geo::GDAL::FFI::Warning; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 13 | 1; | |||||||||||
| 83 | |||||||||||||
| 84 | =pod | ||||||||||||
| 85 | |||||||||||||
| 86 | =encoding UTF-8 | ||||||||||||
| 87 | |||||||||||||
| 88 | =head1 NAME | ||||||||||||
| 89 | |||||||||||||
| 90 | Geo::GDAL::FFI::Object - A GDAL major object | ||||||||||||
| 91 | |||||||||||||
| 92 | =head1 SYNOPSIS | ||||||||||||
| 93 | |||||||||||||
| 94 | =head1 DESCRIPTION | ||||||||||||
| 95 | |||||||||||||
| 96 | The base class for classes Driver, Dataset, Band, and Layer. | ||||||||||||
| 97 | |||||||||||||
| 98 | =head1 METHODS | ||||||||||||
| 99 | |||||||||||||
| 100 | =head2 GetDescription | ||||||||||||
| 101 | |||||||||||||
| 102 | my $desc = $object->GetDescription; | ||||||||||||
| 103 | |||||||||||||
| 104 | =head2 HasCapability | ||||||||||||
| 105 | |||||||||||||
| 106 | my $has_cap = $object->HasCapability($capability); | ||||||||||||
| 107 | |||||||||||||
| 108 | =head2 GetMetadataDomainList | ||||||||||||
| 109 | |||||||||||||
| 110 | my @domains = $object->GetMetadataDomainList; | ||||||||||||
| 111 | |||||||||||||
| 112 | =head2 GetMetadata | ||||||||||||
| 113 | |||||||||||||
| 114 | my %metadata = $object->GetMetadata($domain); | ||||||||||||
| 115 | |||||||||||||
| 116 | Returns the object metadata of a given domain. | ||||||||||||
| 117 | |||||||||||||
| 118 | my $metadata = $object->GetMetadata($domain); | ||||||||||||
| 119 | |||||||||||||
| 120 | Returns the object metadata of a given domain in an anonymous hash. | ||||||||||||
| 121 | |||||||||||||
| 122 | my %metadata = $object->GetMetadata; | ||||||||||||
| 123 | |||||||||||||
| 124 | Returns the object metadata. | ||||||||||||
| 125 | |||||||||||||
| 126 | my $metadata = $object->GetMetadata; | ||||||||||||
| 127 | |||||||||||||
| 128 | Returns the object metadata in an anonymous hash. | ||||||||||||
| 129 | |||||||||||||
| 130 | =head2 SetMetadata | ||||||||||||
| 131 | |||||||||||||
| 132 | $object->SetMetadata($metadata, $domain); | ||||||||||||
| 133 | |||||||||||||
| 134 | Sets the object metadata in a given domain. The metadata is in an | ||||||||||||
| 135 | anonymous hash. | ||||||||||||
| 136 | |||||||||||||
| 137 | $object->SetMetadata($metadata); | ||||||||||||
| 138 | |||||||||||||
| 139 | Sets the object metadata in the domains that are the keys of the hash | ||||||||||||
| 140 | $metadata references. The values of the hash are the metadata in | ||||||||||||
| 141 | anonymous hashes. | ||||||||||||
| 142 | |||||||||||||
| 143 | =head2 GetMetadataItem | ||||||||||||
| 144 | |||||||||||||
| 145 | my $value = $object->GetMetadataItem($item, $domain) | ||||||||||||
| 146 | |||||||||||||
| 147 | Gets the value of the metadata item in a domain (by default an empty | ||||||||||||
| 148 | string). | ||||||||||||
| 149 | |||||||||||||
| 150 | =head2 SetMetadataItem | ||||||||||||
| 151 | |||||||||||||
| 152 | $object->GetMetadataItem($item, $value, $domain) | ||||||||||||
| 153 | |||||||||||||
| 154 | Sets the value of the metadata item in a domain (by default an empty | ||||||||||||
| 155 | string). | ||||||||||||
| 156 | |||||||||||||
| 157 | =head1 LICENSE | ||||||||||||
| 158 | |||||||||||||
| 159 | This software is released under the Artistic License. See | ||||||||||||
| 160 | L<perlartistic>. | ||||||||||||
| 161 | |||||||||||||
| 162 | =head1 AUTHOR | ||||||||||||
| 163 | |||||||||||||
| 164 | Ari Jolma - Ari.Jolma at gmail.com | ||||||||||||
| 165 | |||||||||||||
| 166 | =head1 SEE ALSO | ||||||||||||
| 167 | |||||||||||||
| 168 | L<Geo::GDAL::FFI> | ||||||||||||
| 169 | |||||||||||||
| 170 | L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org> | ||||||||||||
| 171 | |||||||||||||
| 172 | =cut | ||||||||||||
| 173 | |||||||||||||
| 174 | __END__; | ||||||||||||