Regions/CFITSIO.pm

filter: Statementstmt 98.3% 59 / 60 Branchbran 100% 2 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 95.6% 22 / 23 Podpod 100% 1 / 1 totaltotal 95.5% 85 / 89 CC 3 SCAR 1.8
CC
3
Cov
97%
mkregion
2.0
args
2.0
STRING
2.0
CRAP 1.2
« Regions/DS9.pm ↑ Summary Regions/DS9/Types.pm »
1 package CXC::Astro::Regions::CFITSIO;
2  
3 # ABSTRACT: CFITSIO Compatible Regions
4  
5 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use experimental 'signatures', 'postderef', 'lexical_subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.05';
10  
11 2 ▶use CXC::Astro::Regions::CFITSIO::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 Angle
13 ColumnName
14 Tuple
15 Length
16 NonEmptyStr
17 Vertex
18 ArrayRef
19 XPosition
20 YPosition
21 2 );
22  
23 2 ▶use CXC::Astro::Regions::CFITSIO::Variant;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 2 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 1 ▶my sub pkgpath ( @paths ) {
Subroutine pkgpath: called CC=1 SCAR=0.0
30 1 join q{::}, __PACKAGE__, map { ucfirst } @paths;
31 }
32  
33 66 ▶my sub args ( @args ) {
Subroutine args: called CC=2 SCAR=6.9
34 66 ▶ return @args == 1 ? ( name => $args[0] ) : @args;
Branch: 1 branch
BranchTrueFalseTotal
@args == 1 ? : 46 20 66
35 }
36  
37 8 ▶my sub ANGLE { { name => 'angle', isa => Angle, args( @_ ) } }
Subroutine ANGLE: called CC=1 SCAR=0.0
38 4 ▶my sub ANGLEPAIR { { name => 'angles', isa => Tuple [ Angle, Angle ], args( @_ ) } }
Subroutine ANGLEPAIR: called CC=1 SCAR=0.0
39 10 ▶my sub LENGTH { { name => 'length', isa => Length, args( @_ ) } }
Subroutine LENGTH: called CC=1 SCAR=0.0
40 8 ▶my sub LENGTHPAIR { { name => undef, isa => Tuple [ Length, Length ], args( @_ ) } }
Subroutine LENGTHPAIR: called CC=1 SCAR=0.0
41 0 ▶my sub STRING { { name => undef, isa => NonEmptyStr, args( @_ ) } }
Subroutine STRING: not called CC=1 SCAR=6.9
42 20 ▶my sub VERTEX { { name => undef, isa => Vertex, args( @_ ) } }
Subroutine VERTEX: called CC=1 SCAR=0.0
43 2 ▶my sub VERTICES { { name => 'vertices', isa => ArrayRef [Vertex], args( @_ ) } }
Subroutine VERTICES: called CC=1 SCAR=0.0
44 4 ▶my sub XPOS { { name => undef, isa => XPosition, args( @_ ) } }
Subroutine XPOS: called CC=1 SCAR=0.0
45 4 ▶my sub YPOS { { name => undef, isa => YPosition, args( @_ ) } }
Subroutine YPOS: called CC=1 SCAR=0.0
46 6 ▶my sub COLUMNPAIR {
Subroutine COLUMNPAIR: called CC=1 SCAR=0.0
47 6 { name => 'columns', isa => Tuple [ ColumnName, ColumnName ], required => 0, args( @_ ) };
48 }
49  
50 2 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 2 our @EXPORT_OK = ( 'mkregion' );
52  
53 # my sub REGION ( $name, $params ) { $Region{$name} = $params }
54 2 my $stash = Package::Stash->new( __PACKAGE__ );
55  
56 22 ▶my sub REGION ( $region, %spec ) {
Subroutine REGION: called CC=1 SCAR=0.0
57  
58 22 my $variant = Variant( $region, %spec );
59 22 Package::Stash->new( $variant )->add_symbol( q{@CARP_NOT}, [__PACKAGE__] );
60  
61 22 ▶ $stash->add_symbol( q{&} . $region, sub { $variant->new( @_ ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
62 22 push @EXPORT_OK, $region;
63 }
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75 # Annulus ( Xc, Yc, Rin, Rout )
76 2 REGION annulus => ( params => [ VERTEX( 'center' ), LENGTHPAIR( 'radii' ) ], );
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97 # Box ( Xc, Yc, Wdth, Hght, A )
98 # Box ( Xc, Yc, Wdth, Hght, A, Xcolumn, Ycolumn )
99 2 REGION box => ( params =>
100 [ VERTEX( 'center' ), LENGTH( 'width' ), LENGTH( 'height' ), ANGLE( default => 0 ), COLUMNPAIR, ],
101 );
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115 # Circle ( Xc, Yc, R )
116 # Circle ( Xc, Yc, R, Xcolumn, Ycolumn )
117 2 REGION circle => ( params => [ VERTEX( 'center' ), LENGTH( 'radius' ), COLUMNPAIR ], );
118  
119  
120  
121  
122  
123  
124  
125  
126 # Diamond ( Xc, Yc, Wdth, Hght, A )
127 2 REGION diamond =>
128 ( params => [ VERTEX( 'center' ), LENGTH( 'width' ), LENGTH( 'height' ), ANGLE( default => 0 ) ],
129 );
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150 # Ellipse ( Xc, Yc, Rx, Ry, A )
151 # Ellipse ( Xc, Yc, Rx, Ry, A, Xcolumn, Ycolumn )
152 2 REGION ellipse =>
153 ( params => [ VERTEX( 'center' ), LENGTHPAIR( 'radii' ), ANGLE( default => 0 ), COLUMNPAIR, ], );
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166 # Elliptannulus ( Xc, Yc, Rinx, Riny, Routx, Routy, Ain, Aout )
167 2 REGION elliptannulus =>
168 ( params => [ VERTEX( 'center' ), LENGTHPAIR( 'inner' ), LENGTHPAIR( 'outer' ), ANGLEPAIR ], );
169  
170  
171  
172  
173  
174  
175  
176  
177 # Line ( X1, Y1, X2, Y2 )
178 2 REGION line => ( params => [ VERTEX( 'v1' ), VERTEX( 'v2' ) ], );
179  
180  
181  
182  
183  
184  
185  
186  
187  
188 # Point ( X1, Y1 )
189 2 REGION point => ( params => [ VERTEX( 'center' ) ], );
190  
191  
192  
193  
194  
195  
196  
197  
198  
199 # Polygon ( X1, Y1, X2, Y2, ... )
200 2 REGION polygon => ( params => [VERTICES], );
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212 # Rectangle ( X1, Y1, X2, Y2, A )
213 2 REGION rectangle => (
214 params => [ XPOS( 'xmin' ), YPOS( 'ymin' ), XPOS( 'xmax' ), YPOS( 'ymax' ), ANGLE( default => 0 ) ],
215 );
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226 # Sector ( Xc, Yc, Amin, Amax )
227 2 REGION sector => ( params => [ VERTEX( 'center' ), ANGLEPAIR, ], );
228  
229 # No longer need this; clean it up.
230 2 undef $stash;
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241 1 ▶sub mkregion ( $shape, @args ) {
Subroutine mkregion: called CC=2 SCAR=7.1
Pod documented
242 1 my $class = pkgpath( $shape );
243 1 ▶ my $new = $class->can( 'new' ) // croak( "unknown region: $shape" );
Condition50%1/2
$class->can("new") // croak("unknown region: $shape")
l!l
10
MC/DC0%0/1
$class->can("new") // croak("unknown region: $shape")
$class->can("new")
Truth table50%1/2
A
A= $class->can("new")
Aresult
11
00
244 1 $class->$new( @args );
245 }
246  
247 2 1;
248  
249 #
250 # This file is part of CXC-Astro-Regions
251 #
252 # This software is Copyright (c) 2023 by Smithsonian Astrophysical Observatory.
253 #
254 # This is free software, licensed under:
255 #
256 # The GNU General Public License, Version 3, June 2007
257 #
258  
259 __END__
« Regions/DS9.pm ↑ Summary Regions/DS9/Types.pm »