| 1 | package Geo::GDAL::FFI::GeomFieldDefn; | ||||||||||||
| 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 new { | ||||||||||||
| 10 | 0 | ▶ | my ($class, $args) = @_; | ||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||
| 11 | 0 | ▶ | $args //= {}; | ||||||||||
|
Condition0%0/2
$args //= {}
MC/DC0%0/1
$args //= {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||
| 12 | 0 | ▶ | my $name = $args->{Name} // 'Unnamed'; | ||||||||||
|
Condition0%0/2
$args->{"Name"} // "Unnamed"
MC/DC0%0/1
$args->{"Name"} // "Unnamed"
$args->{"Name"}
Truth table0%0/2
A
A= $args->{"Name"}
| |||||||||||||
| 13 | 0 | ▶ | my $type = $args->{Type} // 'Point'; | ||||||||||
|
Condition0%0/2
$args->{"Type"} // "Point"
MC/DC0%0/1
$args->{"Type"} // "Point"
$args->{"Type"}
Truth table0%0/2
A
A= $args->{"Type"}
| |||||||||||||
| 14 | 0 | my $tmp = $Geo::GDAL::FFI::geometry_types{$type}; | |||||||||||
| 15 | 0 | ▶ | confess "Unknown geometry type: $type." unless defined $tmp; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | 0 | my $self = bless \Geo::GDAL::FFI::OGR_GFld_Create($name, $tmp), $class; | |||||||||||
| 17 | 0 | ▶ | $self->SetSpatialRef($args->{SpatialReference}) if $args->{SpatialReference}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | ▶ | $self->SetNullable(0) if $args->{NotNullable}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 19 | 0 | return $self; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | sub DESTROY { | ||||||||||||
| 23 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||
| 24 | 0 | ▶ | if ($Geo::GDAL::FFI::immutable{$$self}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 0 | $Geo::GDAL::FFI::immutable{$$self}--; | |||||||||||
| 26 | 0 | ▶ | delete $Geo::GDAL::FFI::immutable{$$self} if $Geo::GDAL::FFI::immutable{$$self} == 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | } else { | ||||||||||||
| 28 | 0 | Geo::GDAL::FFI::OGR_GFld_Destroy($$self); | |||||||||||
| 29 | } | ||||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | sub GetSchema { | ||||||||||||
| 33 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
GetSchema: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 34 | 0 | my $schema = { | |||||||||||
| 35 | Name => $self->GetName, | ||||||||||||
| 36 | Type => $self->GetType | ||||||||||||
| 37 | }; | ||||||||||||
| 38 | 0 | ▶ | if (my $sr = $self->GetSpatialRef) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | 0 | $schema->{SpatialReference} = $sr->Export('Wkt'); | |||||||||||
| 40 | } | ||||||||||||
| 41 | 0 | ▶ | $schema->{NotNullable} = 1 unless $self->IsNullable; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 0 | return $schema; | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | sub SetName { | ||||||||||||
| 46 | 0 | ▶ | my ($self, $name) = @_; | ||||||||||
|
Subroutine
SetName: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 47 | 0 | ▶ | confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 48 | 0 | ▶ | $name //= ''; | ||||||||||
|
Condition0%0/2
$name //= ""
MC/DC0%0/1
$name //= ""
$name
Truth table0%0/2
A
A= $name
| |||||||||||||
| 49 | 0 | Geo::GDAL::FFI::OGR_GFld_SetName($$self, $name); | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | sub GetName { | ||||||||||||
| 53 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
GetName: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 54 | 0 | return Geo::GDAL::FFI::OGR_GFld_GetNameRef($$self); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | sub SetType { | ||||||||||||
| 58 | 0 | ▶ | my ($self, $type) = @_; | ||||||||||
|
Subroutine
SetType: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 59 | 0 | ▶ | confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | 0 | ▶ | $type //= 'Point'; | ||||||||||
|
Condition0%0/2
$type //= "Point"
MC/DC0%0/1
$type //= "Point"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||
| 61 | 0 | my $tmp = $Geo::GDAL::FFI::geometry_types{$type}; | |||||||||||
| 62 | 0 | ▶ | confess "Unknown geometry type: $type." unless defined $tmp; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | 0 | $type = $tmp; | |||||||||||
| 64 | 0 | Geo::GDAL::FFI::OGR_GFld_SetType($$self, $type); | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | sub GetType { | ||||||||||||
| 68 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
GetType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 69 | 0 | return $Geo::GDAL::FFI::geometry_types_reverse{Geo::GDAL::FFI::OGR_GFld_GetType($$self)}; | |||||||||||
| 70 | } | ||||||||||||
| 71 | |||||||||||||
| 72 | sub SetSpatialRef { | ||||||||||||
| 73 | 0 | ▶ | my ($self, $sr) = @_; | ||||||||||
|
Subroutine
SetSpatialRef: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 74 | 0 | ▶ | confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | 0 | ▶ | $sr = Geo::GDAL::FFI::SpatialReference->new($sr) unless ref $sr; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 76 | 0 | Geo::GDAL::FFI::OGR_GFld_SetSpatialRef($$self, $$sr); | |||||||||||
| 77 | } | ||||||||||||
| 78 | |||||||||||||
| 79 | sub GetSpatialRef { | ||||||||||||
| 80 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
GetSpatialRef: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 81 | 0 | my $sr = Geo::GDAL::FFI::OGR_GFld_GetSpatialRef($$self); | |||||||||||
| 82 | 0 | ▶ | return bless \$sr, 'Geo::GDAL::FFI::SpatialReference' if $sr; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 83 | } | ||||||||||||
| 84 | |||||||||||||
| 85 | sub SetIgnored { | ||||||||||||
| 86 | 0 | ▶ | my ($self, $ignored) = @_; | ||||||||||
|
Subroutine
SetIgnored: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 87 | #confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; | ||||||||||||
| 88 | 0 | ▶ | $ignored //= 1; | ||||||||||
|
Condition0%0/2
$ignored //= 1
MC/DC0%0/1
$ignored //= 1
$ignored
Truth table0%0/2
A
A= $ignored
| |||||||||||||
| 89 | 0 | Geo::GDAL::FFI::OGR_GFld_SetIgnored($$self, $ignored); | |||||||||||
| 90 | } | ||||||||||||
| 91 | |||||||||||||
| 92 | sub IsIgnored { | ||||||||||||
| 93 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
IsIgnored: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 94 | 0 | return Geo::GDAL::FFI::OGR_GFld_IsIgnored($$self); | |||||||||||
| 95 | } | ||||||||||||
| 96 | |||||||||||||
| 97 | sub SetNullable { | ||||||||||||
| 98 | 0 | ▶ | my ($self, $nullable) = @_; | ||||||||||
|
Subroutine
SetNullable: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 99 | 0 | ▶ | confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 100 | 0 | ▶ | $nullable //= 0; | ||||||||||
|
Condition0%0/2
$nullable //= 0
MC/DC0%0/1
$nullable //= 0
$nullable
Truth table0%0/2
A
A= $nullable
| |||||||||||||
| 101 | 0 | Geo::GDAL::FFI::OGR_GFld_SetNullable($$self, $nullable); | |||||||||||
| 102 | } | ||||||||||||
| 103 | |||||||||||||
| 104 | sub IsNullable { | ||||||||||||
| 105 | 0 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
IsNullable: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 106 | 0 | return Geo::GDAL::FFI::OGR_GFld_IsNullable($$self); | |||||||||||
| 107 | } | ||||||||||||
| 108 | |||||||||||||
| 109 | 13 | 1; | |||||||||||
| 110 | |||||||||||||
| 111 | =pod | ||||||||||||
| 112 | |||||||||||||
| 113 | =encoding UTF-8 | ||||||||||||
| 114 | |||||||||||||
| 115 | =head1 NAME | ||||||||||||
| 116 | |||||||||||||
| 117 | Geo::GDAL::FFI::GeomFieldDefn - A spatial field in a GDAL feature schema | ||||||||||||
| 118 | |||||||||||||
| 119 | =head1 SYNOPSIS | ||||||||||||
| 120 | |||||||||||||
| 121 | =head1 DESCRIPTION | ||||||||||||
| 122 | |||||||||||||
| 123 | There should not usually be any reason to directly access this method | ||||||||||||
| 124 | except for the ignore methods. This object is created/read from/to the | ||||||||||||
| 125 | Perl data structure in the CreateLayer method of a dataset, or in the | ||||||||||||
| 126 | constructor or schema method of FeatureDefn. | ||||||||||||
| 127 | |||||||||||||
| 128 | The schema of a GeomFieldDefn is (Name, Type, SpatialReference, | ||||||||||||
| 129 | NotNullable). | ||||||||||||
| 130 | |||||||||||||
| 131 | =head1 METHODS | ||||||||||||
| 132 | |||||||||||||
| 133 | =head2 SetIgnored | ||||||||||||
| 134 | |||||||||||||
| 135 | $defn->SetIgnored($arg); | ||||||||||||
| 136 | |||||||||||||
| 137 | Ignore this field when reading features from a layer. To not ignore | ||||||||||||
| 138 | this field call this method with defined but false (0) argument. | ||||||||||||
| 139 | |||||||||||||
| 140 | =head2 IsIgnored | ||||||||||||
| 141 | |||||||||||||
| 142 | Is this field ignored when reading features from a layer. | ||||||||||||
| 143 | |||||||||||||
| 144 | =head1 LICENSE | ||||||||||||
| 145 | |||||||||||||
| 146 | This software is released under the Artistic License. See | ||||||||||||
| 147 | L<perlartistic>. | ||||||||||||
| 148 | |||||||||||||
| 149 | =head1 AUTHOR | ||||||||||||
| 150 | |||||||||||||
| 151 | Ari Jolma - Ari.Jolma at gmail.com | ||||||||||||
| 152 | |||||||||||||
| 153 | =head1 SEE ALSO | ||||||||||||
| 154 | |||||||||||||
| 155 | L<Geo::GDAL::FFI> | ||||||||||||
| 156 | |||||||||||||
| 157 | L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org> | ||||||||||||
| 158 | |||||||||||||
| 159 | =cut | ||||||||||||
| 160 | |||||||||||||
| 161 | __END__; | ||||||||||||