FFI/SpatialReference.pm

filter: Statementstmt 27.0% 13 / 48 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 75.0% 3 / 4 totaltotal 26.6% 20 / 75 CC 8 SCAR 24.8
CC
8
Cov
21%
new
30.0
DESTROY
6.0
Export
6.0
CRAP 12.0
« FFI/Layer.pm ↑ Summary FFI/VSI.pm »
1 package Geo::GDAL::FFI::SpatialReference;
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, $arg, @arg) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
11 0 my $sr;
12 0 ▶ if (not defined $arg) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $arg) { } 0 0 0
elsif (not @arg) { } 0 0 0
13 0 $sr = Geo::GDAL::FFI::OSRNewSpatialReference();
14 } elsif (not @arg) {
15 0 $sr = Geo::GDAL::FFI::OSRNewSpatialReference($arg);
16 } else {
17 0 $sr = Geo::GDAL::FFI::OSRNewSpatialReference();
18 0 my $gdal = Geo::GDAL::FFI->get_instance;
19 0 $arg = $gdal->get_importer($arg);
20 0 ▶ if ($arg->($sr, @arg) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$arg($sr, @arg) != 0) 0 0 0
21 0 Geo::GDAL::FFI::OSRDestroySpatialReference($sr);
22 0 $sr = 0;
23 }
24 }
25 0 ▶ return bless \$sr, $class if $sr;
Branch: 1 branch
BranchTrueFalseTotal
if $sr 0 0 0
26 0 confess Geo::GDAL::FFI::error_msg();
27 }
28
29 sub DESTROY {
30 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=2 SCAR=17.9
31 # OSRGetReferenceCount method not yet implemented
32 0 my $refcount = (Geo::GDAL::FFI::OSRReference ($$self)-1);
33 0 Geo::GDAL::FFI::OSRDereference ($$self); # immediately decrement
34 0 ▶ if ($refcount == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($refcount == 0) 0 0 0
35 #warn "Calling DESTROY method for $$self\n";
36 0 Geo::GDAL::FFI::OSRDestroySpatialReference($$self);
37 }
38 }
39
40 sub Export {
41 0 ▶ my $self = shift;
Subroutine Export: not called CC=2 SCAR=17.9
Pod documented
42 0 my $format = shift;
43 0 my $gdal = Geo::GDAL::FFI->get_instance;
44 0 my $exporter = $gdal->get_exporter($format);
45 0 my $x;
46 0 ▶ if ($exporter->($$self, \$x, @_) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$exporter($$self, \$x, @_) != 0) 0 0 0
47 0 confess Geo::GDAL::FFI::error_msg();
48 }
49 0 return $x;
50 }
51
52 sub Set {
53 0 ▶ my $self = shift;
Subroutine Set: not called CC=2 SCAR=17.9
Pod documented
54 0 my $set = shift;
55 0 my $gdal = Geo::GDAL::FFI->get_instance;
56 0 my $setter = $gdal->get_setter($set);
57 0 ▶ if ($setter->($$self, @_) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$setter($$self, @_) != 0) 0 0 0
58 0 confess Geo::GDAL::FFI::error_msg();
59 }
60 }
61
62 sub Clone {
63 0 ▶ my $self = shift;
Subroutine Clone: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my $s = Geo::GDAL::FFI::OSRClone($$self);
65 0 return bless \$s, 'Geo::GDAL::FFI::SpatialReference';
66 }
67
68 13 1;
69
70 =pod
71
72 =encoding UTF-8
73
74 =head1 NAME
75
76 Geo::GDAL::FFI::SpatialReference - A spatial reference system in GDAL
77
78 =head1 SYNOPSIS
79
80 =head1 DESCRIPTION
81
82 =head1 METHODS
83
84 =head2 new
85
86 Create a new SpatialReference object.
87
88 my $sr = Geo::GDAL::FFI::SpatialReference->new('WKT here...');
89
90 If only one argument is given, it is taken as the well known text
91 (WKT) associated with the spatial reference system (SRS).
92
93 my $sr = Geo::GDAL::FFI::SpatialReference->new(EPSG => 3067);
94
95 If there are more than one argument, the first argument is taken as a
96 format and the rest of the arguments are taken as arguments to the
97 format. The list of formats known to GDAL (at the time of this
98 writing) is EPSG, EPSGA, Wkt, Proj4, ESRI, PCI, USGS, XML, Dict,
99 Panorama, Ozi, MICoordSys, ERM, Url.
100
101 =head2 Export
102
103 $sr->Export($format, @args);
104
105 Export a SpatialReference object to a format. The list of formats
106 known to GDAL (at the time of this writing) is Wkt, PrettyWkt, Proj4,
107 PCI, USGS, XML, Panorama, MICoordSys, ERM.
108
109 =head2 Set
110
111 $sr->Set($proj, @args);
112
113 Set projection parameters in a SpatialReference object. The list of
114 projection parameters known to GDAL (at the time of this writing) is
115 Axes, ACEA, AE, Bonne, CEA, CS, EC, Eckert, EckertIV, EckertVI,
116 Equirectangular, Equirectangular2, GS, GH, IGH, GEOS,
117 GaussSchreiberTMercator, Gnomonic, HOM, HOMAC, HOM2PNO, IWMPolyconic,
118 Krovak, LAEA, LCC, LCC1SP, LCCB, MC, Mercator, Mercator2SP, Mollweide,
119 NZMG, OS, Orthographic, Polyconic, PS, Robinson, Sinusoidal,
120 Stereographic, SOC, TM, TMVariant, TMG, TMSO, TPED, VDG, Wagner, QSC,
121 SCH.
122
123 =head1 LICENSE
124
125 This software is released under the Artistic License. See
126 L<perlartistic>.
127
128 =head1 AUTHOR
129
130 Ari Jolma - Ari.Jolma at gmail.com
131
132 =head1 SEE ALSO
133
134 L<Geo::GDAL::FFI>
135
136 L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org>
137
138 =cut
139
140 __END__;
« FFI/Layer.pm ↑ Summary FFI/VSI.pm »