blib/lib/Geo/GNUPlot.pm

filter: Statementstmt 2.8% 14 / 485 Branchbran 0.0% 0 / 194 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 29 Subroutinesub 19.0% 4 / 21 Podpod 100% 4 / 4 totaltotal 2.7% 22 / 796 CC 124 SCAR 52.4
CC
124
Cov
2%
_write_plot_config_file
506.0
plot_track
272.0
_read_grid
272.0
CRAP 189.3
↑ Summary
1 package Geo::GNUPlot;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use vars qw($VERSION $DEBUG);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 $VERSION = '0.01';
9 #$DEBUG = 0;
10  
11 #-------------------------------------------------------
12 #New method for Geo::GNUPlot
13 #Notice that it has a mandatory configuration file argument.
14 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
15 0 my $self=shift;
16 0 my $option_HR=shift;
17  
18 0 my ($grid_HR, $msg, $grid_file, $map_file, $gnuplot)=undef;
19  
20 0 $grid_file=$option_HR->{'grid_file'};
21 0 $map_file=$option_HR->{'map_file'};
22 0 $gnuplot=$option_HR->{'gnuplot'};
23
24 0 ▶ unless (defined $grid_file){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $grid_file) 0 0 0
25 0 $msg="new method called without the mandatory grid_file option key!";
26 0 carp $msg,"\n";
27 0 return (undef,$msg);
28 }#unless
29  
30 0 ▶ unless (defined $map_file){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $map_file) 0 0 0
31 0 $msg="new method called without the mandatory map_file option key!";
32 0 carp $msg,"\n";
33 0 return (undef,$msg);
34 }#unless
35
36 0 ▶ unless (defined $gnuplot){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $gnuplot) 0 0 0
37 0 $msg="new method called without the mandatory gnuplot option key!";
38 0 carp $msg,"\n";
39 0 return (undef,$msg);
40 }#unless
41  
42 0 $self={};
43 0 bless($self,'Geo::GNUPlot');
44  
45 0 ($grid_HR,$msg)=$self->_read_grid($grid_file);
46 0 ▶ return (undef,$msg) unless (defined $grid_HR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $grid_HR 0 0 0
47  
48 0 $self->{'grid_HR'}=$grid_HR;
49 0 $self->{'map_file'}=$map_file;
50 0 $self->{'gnuplot'}=$gnuplot;
51  
52 0 return ($self,undef);
53 }#new
54 #------------------------------------------------------
55 #If $track_AR has 2 elements in the first point in the track it is assumed
56 #the incomming position data is in x,y form.
57 #Otherwise it is assumed the incomming position data is in
58 #($long, $long_dir, $lat, $lat_dir) form.
59 0 ▶sub plot_track {
Subroutine plot_track: not called CC=16 SCAR=56.1
Pod documented
60 0 my $self=shift;
61 0 my $track_AR=shift;
62 0 my $output_file=shift;
63 0 my $option_HR=shift;
64  
65 0 my ($success, $error, $xy_data_AR, $radius, $temp_dir, $ppm_file)=undef;
66 0 my ($data_file, $config_file, $msg, $x_range_AR, $y_range_AR)=undef;
67 0 my ($x_pad, $y_pad, $x_scale, $y_scale, $term, $title)=undef;
68  
69 #Determine x_pad, y_pad, x_scale, y_scale, and term
70 0 ▶ if (defined $option_HR->{'x_pad'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'x_pad'}) { } 0 0 0
71 0 $x_pad=$option_HR->{'x_pad'};
72 }
73 else {
74 0 $x_pad=0;
75 }#if/else
76
77 0 ▶ if (defined $option_HR->{'y_pad'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'y_pad'}) { } 0 0 0
78 0 $y_pad=$option_HR->{'y_pad'};
79 }
80 else {
81 0 $y_pad=0;
82 }#if/else
83  
84 0 ▶ if (defined $option_HR->{'x_scale'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'x_scale'}) { } 0 0 0
85 0 $x_scale=$option_HR->{'x_scale'};
86 }
87 else {
88 0 $x_scale=1;
89 }#if/else
90  
91 0 ▶ if (defined $option_HR->{'y_scale'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'y_scale'}) { } 0 0 0
92 0 $y_scale=$option_HR->{'y_scale'};
93 }
94 else {
95 0 $y_scale=1;
96 }#if/else
97  
98 0 ▶ if (defined $option_HR->{'title'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'title'}) { } 0 0 0
99 0 $title=$option_HR->{'title'};
100 }
101 else {
102 0 $title='Storm Tracking Map';
103 }#if/else
104
105 0 ▶ if (defined $option_HR->{'term'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'term'}) { } 0 0 0
106 0 $term=$option_HR->{'term'};
107 }
108 else {
109 0 $term='gif';
110 }#if/else
111  
112 #Determine names for $data_file and $config_file.
113 0 ▶ if (defined $option_HR->{'temp_dir'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'temp_dir'}) { } 0 0 0
114 0 $temp_dir=$option_HR->{'temp_dir'};
115 }
116 else {
117 0 $temp_dir='/tmp/';
118 }
119  
120 0 $temp_dir =~ s!/*!/!;
121 0 $data_file=$temp_dir."datafile_$$";
122 0 $config_file=$temp_dir."configfile_$$";
123  
124 #Figure out what kind of track was passed.
125 #If necessary convert ($long, $long_dir, $lat, $lat_dir) form to xy form.
126 0 ▶ if (scalar(@{${$track_AR}[0]}) == 2){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{do { $track_AR }->[0];} == 2) { } 0 0 0
127 0 $xy_data_AR=$track_AR;
128 }
129 else {
130 #Get the track in x,y form as well as check the syntax of the position arrays.
131 0 ($xy_data_AR,$error)=$self->_generate_xy_data($track_AR);
132  
133 #Abort if _generage_xy_data had a problem.
134 0 ▶ return (0,$error) unless (defined $xy_data_AR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xy_data_AR 0 0 0
135 }#if/else
136  
137 #Write out the data file for gnuplot to plot.
138 0 ($success, $error)=$self->_write_plot_data_file($xy_data_AR,$data_file);
139 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
140  
141  
142 ($x_range_AR,$y_range_AR,$error)=$self->_get_range({
143 x_pad => $x_pad,
144 y_pad => $y_pad,
145 x_scale => $x_scale,
146 y_scale => $y_scale,
147 0 center_point => ${$xy_data_AR}[0],
148 });
149  
150 0 ▶ return (0, $error) unless ( (defined $x_range_AR) and (defined $y_range_AR) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x_range_AR and defined $y_range_AR 0 0 0
Condition0%0/3
defined $x_range_AR and defined $y_range_AR
!ll&&!rl&&r
000
MC/DC0%0/2
defined $x_range_AR and defined $y_range_AR
defined $x_range_AR defined $y_range_AR
Truth table0%0/3
A and B
A= defined $x_range_ARB= defined $y_range_AR
ABresult
0X0
100
111
151  
152 #Write out the config file for gnuplot.
153 0 ($success, $error)=$self->_write_plot_config_file({
154 'config_file'=>$config_file,
155 'data_file'=>$data_file,
156 'output'=>$output_file,
157 'xrange' => $x_range_AR,
158 'yrange' => $y_range_AR,
159 'term' => $term,
160 'title' => $title,
161 });
162 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
163  
164 #Call gnuplot on the config file.
165 0 ($success, $error)=$self->_call_gnuplot($config_file);
166 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
167  
168 #Erase temporary files
169 0 ($success, $error)=$self->_wack_files($data_file, $config_file);
170 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
171  
172 0 return (1,undef);
173  
174 }#plot_track
175 #-------------------------------------------------------
176 0 ▶sub plot_radius_function {
Subroutine plot_radius_function: not called CC=10 SCAR=47.0
Pod documented
177 0 my $self=shift;
178 0 my $output_file=shift;
179 0 my $output_file2=shift;
180 0 my $option_HR=shift;
181  
182 0 my ($term, $temp_dir)=undef;
183 0 my ($data_file, $data_file2, $config_file, $config_file2, $config_file3, $map_file)=undef;
184 0 my ($gnuplot_script, $gnuplot_script2, $gnuplot_script3)=undef;
185 0 my ($success, $error)=undef;
186  
187 0 ▶ if (defined $option_HR->{'term'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'term'}) { } 0 0 0
188 0 $term=$option_HR->{'term'};
189 }
190 else {
191 0 $term='gif';
192 }#if/else
193  
194 #Determine names for $data_file and $config_file.
195 0 ▶ if (defined $option_HR->{'temp_dir'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'temp_dir'}) { } 0 0 0
196 0 $temp_dir=$option_HR->{'temp_dir'};
197 }
198 else {
199 0 $temp_dir='/tmp/';
200 }
201  
202 0 $temp_dir =~ s!/*!/!;
203  
204 0 $data_file=$temp_dir."datafile_$$";
205 0 $data_file2=$temp_dir."datafile2_$$";
206  
207 0 $config_file=$temp_dir."configfile_$$";
208 0 $config_file2=$temp_dir."configfile2_$$";
209 0 $config_file3=$temp_dir."configfile3_$$";
210  
211 0 $map_file=$self->{'map_file'};
212  
213 #######
214 #Generate 3d radius data
215 0 ($success, $error)=$self->_generate_radius_data_file($data_file);
216  
217 ########
218 #Create a 2d contour file from the 3d data
219  
220 0 $gnuplot_script="set nosurface\nset contour\nset cntrparam levels 15\nset term table\nset output \'$data_file2\'\nsplot \'$data_file\'\n";
221  
222 0 ($success,$error)=$self->_make_file($config_file,$gnuplot_script);
223 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
224  
225 #Call gnuplot on the config file.
226 0 ($success, $error)=$self->_call_gnuplot($config_file);
227 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
228  
229  
230 ########
231 #Plot the contour ontop of the world map
232 0 $gnuplot_script2 = "set nokey\nset border\nset xtics\nset ytics\nset term $term\n";
233 0 $gnuplot_script2 .= "set output \'$output_file\'\nplot \'$data_file2\' with lines, \'$map_file\' with lines\n";
234  
235 0 ($success,$error)=$self->_make_file($config_file2,$gnuplot_script2);
236 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
237  
238 #Call gnuplot on the config file.
239 0 ($success, $error)=$self->_call_gnuplot($config_file2);
240 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
241  
242 #######
243 #Plot the 3d contour plot
244 0 $gnuplot_script3 = "set key\nset hidden\nset border\nset xtics\nset ytics\nset term $term\n";
245 0 $gnuplot_script3 .= "set contour base\nset cntrparam levels 15\nset autoscale\n";
246 0 $gnuplot_script3 .= "set output \'$output_file2\'\nsplot \'$data_file\' with lines\n";
247  
248 0 ($success,$error)=$self->_make_file($config_file3,$gnuplot_script3);
249 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
250  
251 #Call gnuplot on the config file.
252 0 ($success, $error)=$self->_call_gnuplot($config_file3);
253 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
254  
255  
256 ########
257 #Erase temporary files
258 0 ($success, $error)=$self->_wack_files($data_file, $data_file2, $config_file, $config_file2, $config_file3);
259 0 ▶ return (0,$error) unless ($success);
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
260  
261 #######
262 #All done
263 0 return (1,undef);
264  
265 }#plot_radius_function
266 #-------------------------------------------------------
267 0 ▶sub _make_file {
Subroutine _make_file: not called CC=2 SCAR=17.9
268 0 my $self=shift;
269 0 my $filename=shift;
270 0 my $string=shift;
271  
272 0 my ($io, $msg)=undef;
273  
274 0 $io=IO::File->new();
275 0 ▶ unless ($io->open(">$filename")){
Branch: 1 branch
BranchTrueFalseTotal
unless ($io->open(">$filename")) 0 0 0
276 0 $msg = "Had trouble writting to $filename!";
277 0 carp $msg,"\n";
278 0 return (0, $msg);
279 }#unless
280 0 $io->print($string);
281 0 $io->close();
282  
283 0 return (1,undef);
284  
285 }#_make_file
286 #-------------------------------------------------------
287 0 ▶sub _wack_files {
Subroutine _wack_files: not called CC=4 SCAR=30.0
288 0 my $self=shift;
289 0 my @files=@_;
290  
291 0 my ($msg, $file)=undef;
292  
293 0 ▶ unless ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Geo::GNUPlot::DEBUG) 0 0 0
294 0 foreach $file (@files){
295 0 ▶ unless(unlink $file){
Branch: 1 branch
BranchTrueFalseTotal
unless (unlink $file) 0 0 0
296 0 $msg="The $file file could not be erased!";
297 0 carp $msg,"\n";
298 0 return (0,$msg);
299 }#unless
300 }#foreach
301 }#unless
302  
303 0 return (1, undef);
304 }#_wack_files
305 #-------------------------------------------------------
306 0 ▶sub _generate_radius_data_file {
Subroutine _generate_radius_data_file: not called CC=6 SCAR=37.4
307 0 my $self=shift;
308 0 my $data_file=shift;
309  
310 0 my ($io, $x, $y, $radius, $error, $msg)=undef;
311  
312 0 ▶ $io=IO::File->new() or croak "Couldn't create new io object!";
Branch: 1 branch
BranchTrueFalseTotal
$io = "IO::File"->new or croak("Couldn't create new io object!") 0 0 0
313 0 ▶ unless ($io->open(">$data_file")){
Branch: 1 branch
BranchTrueFalseTotal
unless ($io->open(">$data_file")) 0 0 0
314 0 $msg="Couldn't open $data_file for writing!";
315 0 carp $msg, "\n";
316 0 return (0, $msg);
317 }#unless
318  
319 0 ▶ for ($x=-180; $x<=180; $x+=3){
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= 180) 0 0 0
320 0 ▶ for ($y=-90; $y<=90; $y+=3){
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= 90) 0 0 0
321 0 ($radius, $error)=$self->radius_function([$x, $y]);
322 0 ▶ return (0, $error) unless (defined $radius);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $radius 0 0 0
323 0 $io->print("$x\t$y\t$radius\n");
324 }#for
325 0 $io->print("\n");
326 }#for
327  
328 0 $io->close();
329  
330 0 return (1,undef);
331 }#_generate_radius_data_file
332 #-------------------------------------------------------
333 #($x_range_AR,$y_range_AR,$error)=$self->_get_range({
334 # x_pad => 1,
335 # y_pad => 1,
336 # x_scale => 2.5,
337 # y_scale => 2.5,
338 # center_pont => ${$xy_data_AR}[0]), # or [2,5]
339 # });
340 0 ▶sub _get_range {
Subroutine _get_range: not called CC=11 SCAR=48.8
341 0 my $self=shift;
342 0 my $option_HR=shift;
343  
344 0 my ($radius, $error, $x_pad, $y_pad, $x_scale, $y_scale, $center_point)=undef;
345 0 my ($x_low, $x_high, $y_low, $y_high, $x_center, $y_center, $msg)=undef;
346  
347 0 $x_pad=$option_HR->{'x_pad'};
348 0 $y_pad=$option_HR->{'y_pad'};
349 0 $x_scale=$option_HR->{'x_scale'};
350 0 $y_scale=$option_HR->{'y_scale'};
351 0 $center_point=$option_HR->{'center_point'};
352 0 $x_center=${$center_point}[0];
353 0 $y_center=${$center_point}[1];
354  
355 0 ▶ unless ((defined $x_pad) and (defined $y_pad) and
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $x_pad and defined $y_pad and defined $x_scale and defined $y_scale and defined $center_point) 0 0 0
Condition0%0/12
defined $x_pad and defined $y_pad and defined $x_scale and defined $y_scale and defined $center_point
!ll&&!rl&&r
000
defined $x_pad and defined $y_pad and defined $x_scale and defined $y_scale
!ll&&!rl&&r
000
defined $x_pad and defined $y_pad and defined $x_scale
!ll&&!rl&&r
000
defined $x_pad and defined $y_pad
!ll&&!rl&&r
000
MC/DC0%0/5
defined $x_pad and defined $y_pad and defined $x_scale and defined $y_scale and defined $center_point
defined $x_pad defined $y_pad defined $x_scale defined $y_scale defined $center_point
Truth table0%0/6
A and B and C and D and E
A= defined $x_padB= defined $y_padC= defined $x_scaleD= defined $y_scaleE= defined $center_point
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
356 (defined $x_scale) and (defined $y_scale) and
357 (defined $center_point)){
358 0 $msg="_get_range requires valid x_pad, y_pad, x_scale, y_scale, and ";
359 0 $msg .= "center_point keys in its mandatory hash reference argument. ";
360 0 $msg .= "At least one of these was ill defined!";
361 0 carp $msg, "\n";
362 0 return (undef, undef, $msg);
363 }#unless
364  
365 #Determine the plot radius.
366 0 ($radius, $error)=$self->radius_function($center_point);
367  
368 0 ▶ unless (defined $radius){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $radius) 0 0 0
369 0 return (undef, undef, $error);
370 }
371  
372 0 $y_low=$y_center-$radius*$y_scale-$y_pad;
373 0 ▶ if ($y_low < -90){
Branch: 1 branch
BranchTrueFalseTotal
if ($y_low < -90) 0 0 0
374 0 $y_low= -90;
375 }#if
376  
377 0 $y_high=$y_center+$radius*$y_scale+$y_pad;
378  
379 0 ▶ if ($y_high > 90){
Branch: 1 branch
BranchTrueFalseTotal
if ($y_high > 90) 0 0 0
380 0 $y_high=90;
381 }#if
382  
383 0 $x_low=$x_center-$radius*$x_scale-$x_pad;
384 0 ▶ if ($x_low < -180){
Branch: 1 branch
BranchTrueFalseTotal
if ($x_low < -180) 0 0 0
385 0 $x_low=180;
386 }#if
387  
388 0 $x_high=$x_center+$radius*$x_scale+$x_pad;
389 0 ▶ if ($x_high > 180){
Branch: 1 branch
BranchTrueFalseTotal
if ($x_high > 180) 0 0 0
390 0 $x_high=180;
391 }#if
392  
393  
394 0 return ([$x_low, $x_high],[$y_low, $y_high], undef);
395  
396 }#_get_range
397 #-------------------------------------------------------
398 0 ▶sub _call_gnuplot {
Subroutine _call_gnuplot: not called CC=3 SCAR=24.8
399 0 my $self=shift;
400 0 my $config_file=shift;
401  
402 0 my ($gnuplot, $msg, $exit_status, $error)=undef;
403  
404 0 $gnuplot=$self->{'gnuplot'};
405  
406 0 ▶ unless (-e $gnuplot){
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $gnuplot) 0 0 0
407 0 $msg="Gnuplot executable could not be found at $gnuplot!";
408 0 $msg.=" Examine new method of Geo::GNUPlot!";
409 0 carp $msg,"\n";
410 0 return (0,$msg);
411 }#unless
412  
413 0 $exit_status=system("$gnuplot $config_file");
414 0 $error=$!;
415 0 $exit_status=$exit_status/256;
416 0 ▶ unless ($exit_status == 0){
Branch: 1 branch
BranchTrueFalseTotal
unless ($exit_status == 0) 0 0 0
417 0 $msg="Execution of gnuplot failed. Exit status was $exit_status. Error was $error";
418 0 carp $msg,"\n";
419 0 return (0,$msg);
420 }#unless
421  
422 0 return (1,undef);
423 }#_call_gnuplot
424 #-------------------------------------------------------
425 0 ▶sub _write_plot_config_file {
Subroutine _write_plot_config_file: not called CC=22 SCAR=62.3
426 0 my $self=shift;
427 0 my $option_HR=shift;
428  
429 0 my ($io, $msg)=undef;
430  
431 0 $io=IO::File->new();
432 0 ▶ unless ($io->open($option_HR->{'config_file'},'w')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($io->open($option_HR->{"config_file"}, "w")) 0 0 0
433 0 $msg="Couldn't open ".$option_HR->{'configfile'}." for writting!";
434 0 carp $msg,"\n";
435 0 return (0,$msg);
436 }#unless
437  
438 #Key option
439 0 ▶ if (!defined $option_HR->{'key'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'key'}) { } 0 0 0
elsif ($option_HR->{'key'}) { } 0 0 0
440 0 $io->print("set nokey\n");
441 }
442 elsif ($option_HR->{'key'}){
443 0 $io->print("set key\n");
444 }
445 else {
446 0 $io->print("set nokey\n");
447 }#if/elsif/else
448  
449 #Border option
450 0 ▶ if (!defined $option_HR->{'border'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'border'}) { } 0 0 0
elsif ($option_HR->{'border'}) { } 0 0 0
451 0 $io->print("set border\n");
452 }
453 elsif ($option_HR->{'border'}){
454 0 $io->print("set border\n");
455 }
456 else {
457 0 $io->print("set noborder\n");
458 }#if/elsif/else
459  
460 #Yzeroaxis option
461 0 ▶ if (!defined $option_HR->{'yzeroaxis'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'yzeroaxis'}) { } 0 0 0
elsif ($option_HR->{'yzeroaxis'}) { } 0 0 0
462 0 $io->print("set yzeroaxis\n");
463 }
464 elsif ($option_HR->{'yzeroaxis'}){
465 0 $io->print("set yzeroaxis\n");
466 }
467 else {
468 0 $io->print("set noyzeroaxis\n");
469 }#if/elsif/else
470  
471 #Xzeroaxis option
472 0 ▶ if (!defined $option_HR->{'xzeroaxis'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'xzeroaxis'}) { } 0 0 0
elsif ($option_HR->{'xzeroaxis'}) { } 0 0 0
473 0 $io->print("set noxzeroaxis\n");
474 }
475 elsif ($option_HR->{'xzeroaxis'}){
476 0 $io->print("set xzeroaxis\n");
477 }
478 else {
479 0 $io->print("set noxzeroaxis\n");
480 }#if/elsif/else
481  
482 #X and Y range
483 0 ▶ if((defined $option_HR->{'xrange'}) and (defined $option_HR->{'yrange'})){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'xrange'} and defined $option_HR->{'yrange'}) { } 0 0 0
Condition0%0/3
defined $option_HR->{"xrange"} and defined $option_HR->{"yrange"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $option_HR->{"xrange"} and defined $option_HR->{"yrange"}
defined $option_HR->{"xrange"} defined $option_HR->{"yrange"}
Truth table0%0/3
A and B
A= defined $option_HR->{"xrange"}B= defined $option_HR->{"yrange"}
ABresult
0X0
100
111
484 0 $io->print("set xrange \[",${$option_HR->{'xrange'}}[0],":",${$option_HR->{'xrange'}}[1],"\]\n");
485 0 $io->print("set yrange \[",${$option_HR->{'yrange'}}[0],":",${$option_HR->{'yrange'}}[1],"\]\n");
486 }
487 else {
488 0 $io->print("set autoscale\n");
489 }#if/else
490  
491 #Xtics option
492 0 ▶ if (!defined $option_HR->{'xtics'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'xtics'}) { } 0 0 0
elsif ($option_HR->{'xtics'}) { } 0 0 0
493 0 $io->print("set xtics\n");
494 }
495 elsif ($option_HR->{'xtics'}){
496 0 $io->print("set xtics\n");
497 }
498 else {
499 0 $io->print("set noxtics\n");
500 }#if/elsif/else
501  
502 #Ytics option
503 0 ▶ if (!defined $option_HR->{'ytics'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'ytics'}) { } 0 0 0
elsif ($option_HR->{'ytics'}) { } 0 0 0
504 0 $io->print("set ytics\n");
505 }
506 elsif ($option_HR->{'ytics'}){
507 0 $io->print("set ytics\n");
508 }
509 else {
510 0 $io->print("set noytics\n");
511 }#if/elsif/else
512  
513 0 ▶ if ($option_HR->{'title'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($option_HR->{"title"}) 0 0 0
514 0 $io->print("set title \'".$option_HR->{'title'}."\'\n");
515 }#if
516  
517 0 ▶ if (!defined $option_HR->{'output'}){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $option_HR->{'output'}) { } 0 0 0
elsif ($option_HR->{'output'}) { } 0 0 0
518 0 $msg="output option to _write_plot_config_file must be set!";
519 0 carp $msg,"\n";
520 0 return (0,$msg);
521 }
522 elsif ($option_HR->{'output'}){
523 0 $io->print("set output \'".$option_HR->{'output'}."\'\n");
524 }#if/elsif
525  
526 #set term
527 0 ▶ if (defined $option_HR->{'term'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_HR->{'term'}) { } 0 0 0
528 0 $io->print("set term ",$option_HR->{'term'},"\n");
529 }
530 else {
531 0 $io->print("set term gif\n");
532 }#if/else
533  
534 #Check to make sure datafile exists.
535 0 ▶ unless ( (defined $option_HR->{'data_file'}) and (-e $option_HR->{'data_file'}) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $option_HR->{"data_file"} and -e $option_HR->{"data_file"}) 0 0 0
Condition0%0/3
defined $option_HR->{"data_file"} and -e $option_HR->{"data_file"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $option_HR->{"data_file"} and -e $option_HR->{"data_file"}
defined $option_HR->{"data_file"} -e $option_HR->{"data_file"}
Truth table0%0/3
A and B
A= defined $option_HR->{"data_file"}B= -e $option_HR->{"data_file"}
ABresult
0X0
100
111
536 0 $msg="data_file option to _write_plot_config_file is not set or the file doesn't exist!";
537 0 carp $msg,"\n";
538 0 return (0,$msg);
539 }#unless
540  
541 $io->print("plot \'",$self->{'map_file'},"\' with lines 1 2\, \'",
542 0 $option_HR->{'data_file'},"\' using 1:2 with lines 3 4\n");
543  
544 0 $io->close();
545  
546 0 return (1,undef);
547 }#_write_plot_config_file
548 #-------------------------------------------------------
549 0 ▶sub _generate_xy_data {
Subroutine _generate_xy_data: not called CC=3 SCAR=24.8
550 0 my $self=shift;
551 0 my $track_AR=shift;
552  
553 0 my ($position_AR, $xy_AR, $error)=undef;
554 0 my @xy_data=();
555
556 0 foreach $position_AR (@{$track_AR}){
557 0 ($xy_AR, $error)=$self->_position_to_xy($position_AR);
558 0 ▶ return (undef, $error) unless (defined $xy_AR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xy_AR 0 0 0
559 0 push (@xy_data,$xy_AR);
560 }#foreach
561  
562 0 return (\@xy_data,undef);
563 }#_generate_xy_data
564 #-------------------------------------------------------
565 0 ▶sub _write_plot_data_file {
Subroutine _write_plot_data_file: not called CC=3 SCAR=24.8
566 0 my $self=shift;
567 0 my $xy_data_AR=shift;
568 0 my $filename=shift;
569  
570 0 my ($io, $msg, $xy_AR)=undef;
571  
572 0 $io=IO::File->new();
573 0 ▶ unless ( $io->open(">$filename") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($io->open(">$filename")) 0 0 0
574 0 $msg="Couldn't open $filename for writting in _write_plot_data_file!";
575 0 carp $msg,"\n";
576 0 return (0,$msg);
577 }#unless
578 0 foreach $xy_AR (@{$xy_data_AR}){
579 0 $io->print(join("\t",@{$xy_AR}),"\n");
580 }#foreach
581 0 $io->close();
582  
583 0 return (1,undef);
584 }#_write_plot_data_file
585 #-------------------------------------------------------
586 0 ▶sub _read_grid {
Subroutine _read_grid: not called CC=16 SCAR=56.1
587 0 my $self=shift;
588 0 my $config_file=shift;
589  
590 0 my ($io, $msg, $anon_HR, $y_index, $in_line, $xtics, $ytics, $radius_grid)=undef;
591 0 my ($matches, $i)=undef;
592 0 my @xtics=();
593 0 my @ytics=();
594 0 my @x_array=();
595 0 my $grid_HR={};
596  
597 0 $io=IO::File->new();
598 0 ▶ unless($io->open("<$config_file")){
Branch: 1 branch
BranchTrueFalseTotal
unless ($io->open("<$config_file")) 0 0 0
599 0 $msg="Couldn't open $config_file!";
600 0 carp $msg,"\n";
601 0 return (undef, $msg);
602 }#unless;
603  
604 0 $y_index=-1;
605  
606 0 ▶ while (defined($in_line=$io->getline)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($in_line = $io->getline)) 0 0 0
607 0 chomp $in_line;
608  
609 #Watch for comment lines
610 0 ▶ next if (($in_line =~ m!^\s*#!) or ($in_line =~ m!^\s*$!));
Branch: 1 branch
BranchTrueFalseTotal
if $in_line =~ /^\s*#/ or $in_line =~ /^\s*$/ 0 0 0
Condition0%0/3
$in_line =~ /^\s*#/ or $in_line =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$in_line =~ /^\s*#/ or $in_line =~ /^\s*$/
$in_line =~ /^\s*#/ $in_line =~ /^\s*$/
Truth table0%0/3
A or B
A= $in_line =~ /^\s*#/B= $in_line =~ /^\s*$/
ABresult
1X1
011
000
611  
612 0 ▶ unless ($xtics){
Branch: 1 branch
BranchTrueFalseTotal
unless ($xtics) 0 0 0
613 0 $matches=($in_line=~ m!^xtics\:(.*)!i);
614 0 ▶ if ($matches){
Branch: 1 branch
BranchTrueFalseTotal
if ($matches) { } 0 0 0
615 0 @xtics=split(',',$1);
616 0 $xtics=scalar(@xtics);
617 #get rid of any spaces around the numbers.
618 0 map {s!([\d\.]*)!$1!} @xtics;
619 0 ▶ if ($self->_is_assending(@xtics)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_assending(@xtics)) { } 0 0 0
620 0 next;
621 }
622 else {
623 0 $msg="xtics are not in numerically assending order ";
624 0 $msg.="or has undefined values!";
625 0 carp $msg,"\n";
626 0 return (undef,$msg);
627 }#if/else
628 }
629 else {
630 0 next;
631 }#if/else
632 }#unless
633  
634 0 ▶ unless ($ytics){
Branch: 1 branch
BranchTrueFalseTotal
unless ($ytics) 0 0 0
635 0 $matches=($in_line=~ m!^ytics\:(.*)!i);
636 0 ▶ if ($matches){
Branch: 1 branch
BranchTrueFalseTotal
if ($matches) { } 0 0 0
637 0 @ytics=split(',',$1);
638 0 $ytics=scalar(@ytics);
639 #get rid of any spaces around the numbers.
640 0 map {s!([\d\.]*)!$1!} @ytics;
641 0 ▶ if ($self->_is_descending(@ytics)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_descending(@ytics)) { } 0 0 0
642 0 next;
643 }
644 else {
645 0 $msg="ytics are not in numerically descending order ";
646 0 $msg.="or has undefined values!";
647 0 carp $msg,"\n";
648 0 return (undef,$msg);
649 }#if/else
650 }
651 else {
652 0 next;
653 }#if/else
654 }#unless
655  
656 0 ▶ unless ($radius_grid){
Branch: 1 branch
BranchTrueFalseTotal
unless ($radius_grid) 0 0 0
657 0 $matches=($in_line=~ m!^radius_grid\:!i);
658 0 ▶ $radius_grid=1 if ($matches);
Branch: 1 branch
BranchTrueFalseTotal
if $matches 0 0 0
659 0 next;
660 }#unless
661  
662 0 @x_array=split("\t",$in_line);
663 0 ▶ unless (scalar(@x_array) == $xtics){
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @x_array == $xtics) 0 0 0
664 0 $msg="Badly formed radius_grid! Too many columns!";
665 0 carp $msg,"\n";
666 0 return (undef,$msg);
667 }#unless
668  
669 #get rid of any spaces around the numbers.
670 0 map {s!([\d\.]*)!$1!} @x_array;
671  
672  
673 #Increment y_index
674 0 $y_index++;
675  
676 #Make sure there are not too many rows.
677 0 ▶ if ($y_index >= $ytics){
Branch: 1 branch
BranchTrueFalseTotal
if ($y_index >= $ytics) 0 0 0
678 0 $msg="Badly formed radius_grid! Too many rows!";
679 0 carp $msg, "\n";
680 0 return (undef,$msg);
681 }#if
682  
683 0 $anon_HR={};
684 0 ▶ for ($i=0; $i<$xtics; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $xtics) 0 0 0
685 0 $anon_HR->{${xtics}[$i]}=$x_array[$i];
686 }#for
687  
688 0 $grid_HR->{${ytics}[$y_index]}=$anon_HR;
689  
690 }#while
691  
692 0 return ($grid_HR,undef);
693  
694 }#_read_grid
695 #-------------------------------------------------------
696 #Returns 1 only if all elements of the input array
697 #are numerically decreasing and defined.
698 #Returns 0 otherwise.
699 0 ▶sub _is_descending {
Subroutine _is_descending: not called CC=5 SCAR=34.0
700 0 my $self=shift;
701 0 my @array=@_;
702  
703 0 my ($last_elem, $elem)=undef;
704  
705 0 foreach $elem (@array){
706 0 ▶ return 0 if (!defined $elem);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $elem 0 0 0
707 0 ▶ if (defined $last_elem){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last_elem) { } 0 0 0
708 0 ▶ if ($elem < $last_elem){
Branch: 1 branch
BranchTrueFalseTotal
if ($elem < $last_elem) { } 0 0 0
709 0 $last_elem=$elem;
710 0 next;
711 }
712 else {
713 0 return 0;
714 }#if/else
715 }
716 else{
717 0 $last_elem=$elem;
718 }#if/else
719 }#foreach
720 0 return 1;
721 }#_is_descending
722 #-------------------------------------------------------
723 #Returns 1 only if all elements of the input array
724 #are numerically increasing and defined.
725 #Returns 0 otherwise.
726 0 ▶sub _is_assending {
Subroutine _is_assending: not called CC=5 SCAR=34.0
727 0 my $self=shift;
728 0 my @array=@_;
729  
730 0 my ($last_elem, $elem)=undef;
731  
732 0 foreach $elem (@array){
733 0 ▶ return 0 if (!defined $elem);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $elem 0 0 0
734 0 ▶ if (defined $last_elem){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last_elem) { } 0 0 0
735 0 ▶ if ($elem > $last_elem){
Branch: 1 branch
BranchTrueFalseTotal
if ($elem > $last_elem) { } 0 0 0
736 0 $last_elem=$elem;
737 0 next;
738 }
739 else {
740 0 return 0;
741 }#if/else
742 }
743 else{
744 0 $last_elem=$elem;
745 }#if/else
746 }#foreach
747 0 return 1;
748 }#_is_assending
749 #-------------------------------------------------------
750 #If $position_AR has 2 elements it is assumed the incomming position is in x,y form.
751 #Otherwise it is assumed the incomming position is in ($long, $long_dir, $lat, $lat_dir) form.
752 0 ▶sub radius_function {
Subroutine radius_function: not called CC=5 SCAR=34.0
Pod documented
753 0 my $self=shift;
754 0 my $position_AR=shift;
755
756 0 my ($xkey1, $xkey2, $ykey1, $ykey2, $xy_AR, $x, $y, $msg)=undef;
757 0 my ($grid_HR, $x_delta_from_xkey1, $delta_xkey, $y_delta_from_ykey1, $delta_ykey)=undef;
758 0 my ($f1, $f2, $f3, $f4, $t, $u, $f_interpolated)=undef;
759  
760 0 ▶ if (scalar(@{$position_AR}) == 2){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$position_AR;} == 2) { } 0 0 0
761 0 $xy_AR=$position_AR;
762 }
763 else {
764 #Get the postion in x,y form as well as check the syntax of the referenced position array.
765 0 ($xy_AR,$msg)=$self->_position_to_xy($position_AR);
766  
767 #Abort if _position_to_xy had a problem.
768 0 ▶ return (undef,$msg) unless (defined $xy_AR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xy_AR 0 0 0
769 }#if/else
770  
771 #Determine high and low key values for both the y and the x axis.
772 0 $x=${$xy_AR}[0];
773 0 $y=${$xy_AR}[1];
774
775 0 ($xkey1,$xkey2,$ykey1,$ykey2)=$self->_find_grid_square($x,$y);
776  
777 #Using equation 3.6.3, 3.6.4, and 3.6.5 on page 117 of
778 #Numerical Recipes in Fortran 77 (Second Edition)
779 #ISBN 0-521-43064-X
780  
781 0 $grid_HR=$self->{'grid_HR'};
782  
783 #Using f instead of y in eq. 3.6.3
784  
785 0 $f1=$grid_HR->{$ykey1}->{$xkey1};
786 0 $f2=$grid_HR->{$ykey1}->{$xkey2};
787 0 $f3=$grid_HR->{$ykey2}->{$xkey2};
788 0 $f4=$grid_HR->{$ykey2}->{$xkey1};
789  
790 0 ▶ if ($xkey1 > $x){
Branch: 1 branch
BranchTrueFalseTotal
if ($xkey1 > $x) { } 0 0 0
791 0 $x_delta_from_xkey1=(180-$xkey1)+$x;
792 0 $delta_xkey=(180-$xkey1)+$xkey2;
793 }
794 else {
795 0 $x_delta_from_xkey1=$x-$xkey1;
796 0 $delta_xkey=$xkey2-$xkey1;
797 }#if/else
798  
799 0 $t=$x_delta_from_xkey1/$delta_xkey;
800  
801 0 ▶ if ($ykey1 == $ykey2){
Branch: 1 branch
BranchTrueFalseTotal
if ($ykey1 == $ykey2) { } 0 0 0
802 #deal with infinity problem by just interpolating x values.
803 0 $f_interpolated=$x_delta_from_xkey1*($f1-$f2)/$delta_xkey + $f1;
804 0 return ($f_interpolated,undef);
805 }
806 else {
807 0 $y_delta_from_ykey1=$y-$ykey1;
808 0 $delta_ykey=$ykey2-$ykey1;
809 }#if/else
810  
811 0 $u=$y_delta_from_ykey1/$delta_ykey;
812  
813 0 $f_interpolated=(1-$t)*(1-$u)*$f1+$t*(1-$u)*$f2+$t*$u*$f3+(1-$t)*$u*$f4;
814  
815 0 return ($f_interpolated,undef);
816  
817 }#radius_function
818 #-------------------------------------------------------------------------------
819 0 ▶sub _position_to_xy {
Subroutine _position_to_xy: not called CC=11 SCAR=48.8
820 0 my $self=shift;
821 0 my $position_AR=shift;
822  
823 0 my ($lat, $lat_dir, $long, $long_dir, $msg, $x, $y)=undef;
824  
825 #Check the argument for problems.
826 0 ($lat,$lat_dir,$long,$long_dir)=@{$position_AR};
827 0 ▶ unless (
Branch: 1 branch
BranchTrueFalseTotal
unless ($lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/ and $long_dir =~ /^[WE]$/ and ($lat <= 90 and $lat >= 0) and ($long <= 180 and $long >= 0)) 0 0 0
Condition0%0/21
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/ and $long_dir =~ /^[WE]$/ and ($lat <= 90 and $lat >= 0) and ($long <= 180 and $long >= 0)
!ll&&!rl&&r
000
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/ and $long_dir =~ /^[WE]$/ and ($lat <= 90 and $lat >= 0)
!ll&&!rl&&r
000
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/ and $long_dir =~ /^[WE]$/
!ll&&!rl&&r
000
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/
!ll&&!rl&&r
000
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/
!ll&&!rl&&r
000
$lat <= 90 and $lat >= 0
!ll&&!rl&&r
000
$long <= 180 and $long >= 0
!ll&&!rl&&r
000
MC/DC0%0/8
$lat =~ /^\d+(\.\d*)?$/ and $long =~ /^\d+(\.\d*)?$/ and $lat_dir =~ /^[NS]$/ and $long_dir =~ /^[WE]$/ and ($lat <= 90 and $lat >= 0) and ($long <= 180 and $long >= 0)
$lat =~ /^\d+(\.\d*)?$/ $long =~ /^\d+(\.\d*)?$/ $lat_dir =~ /^[NS]$/ $long_dir =~ /^[WE]$/ $lat <= 90 $lat >= 0 $long <= 180 $long >= 0
Truth table0%0/9
A and B and C and D and E and F and G and H
A= $lat =~ /^\d+(\.\d*)?$/B= $long =~ /^\d+(\.\d*)?$/C= $lat_dir =~ /^[NS]$/D= $long_dir =~ /^[WE]$/E= $lat <= 90F= $lat >= 0G= $long <= 180H= $long >= 0
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
828 ($lat =~ m!^\d+(\.\d*)?$!) and
829 ($long =~ m!^\d+(\.\d*)?$!) and
830 ($lat_dir =~ m!^[NS]$!) and
831 ($long_dir =~ m!^[WE]$!) and
832 (($lat <= 90) and ($lat >= 0)) and
833 (($long <= 180) and ($long >= 0))
834 ){
835 0 $msg="Bad arguments passed to radius_function!";
836 0 carp $msg,"\n";
837 0 return (undef,$msg);
838 }#unless
839
840 #Translate longitude and latitude into x,y values.
841 0 ▶ if ($lat_dir eq 'N'){
Branch: 1 branch
BranchTrueFalseTotal
if ($lat_dir eq 'N') { } 0 0 0
842 0 $y=$lat;
843 }
844 else {
845 0 $y=-$lat;
846 }#if/else
847
848 0 ▶ if ($long_dir eq 'E'){
Branch: 1 branch
BranchTrueFalseTotal
if ($long_dir eq 'E') { } 0 0 0
849 0 $x=$long;
850 }
851 else {
852 0 $x=-$long;
853 }#if/else
854  
855 0 return ([$x,$y],undef);
856  
857 }#_position_to_xy
858 #-------------------------------------------------------------------------------
859 0 ▶sub _find_grid_square {
Subroutine _find_grid_square: not called CC=13 SCAR=52.0
860 0 my $self=shift;
861 0 my $x=shift;
862 0 my $y=shift;
863
864 0 my ($xval, $yval, $xkey1, $xkey2, $ykey1, $ykey2)=undef;
865 0 my ($xtics, $ytics, $i, $grid_HR)=undef;
866 0 my @ykeys=();
867 0 my @sorted_ykeys=();
868 0 my @xkeys=();
869 0 my @sorted_xkeys=();
870
871 0 $grid_HR=$self->{'grid_HR'};
872  
873 0 @ykeys=keys %{$grid_HR};
874 0 @sorted_ykeys = sort {$a<=>$b} @ykeys;
875  
876 0 $ytics=scalar(@sorted_ykeys);
877  
878 0 ▶ for ($i=0; $i <= $ytics; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ytics) 0 0 0
879 0 $yval=$sorted_ykeys[$i];
880 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($i == $ytics - 1 and $yval <= $y or $i == 0 and $yval > $y) { } 0 0 0
elsif ($yval <= $y) { } 0 0 0
Condition0%0/9
$i == $ytics - 1 and $yval <= $y or $i == 0 and $yval > $y
l!l&&r!l&&!r
000
$i == $ytics - 1 and $yval <= $y
!ll&&!rl&&r
000
$i == 0 and $yval > $y
!ll&&!rl&&r
000
MC/DC0%0/4
$i == $ytics - 1 and $yval <= $y or $i == 0 and $yval > $y
$i == $ytics - 1 $yval <= $y $i == 0 $yval > $y
Truth table0%0/7
A and B or C and D
A= $i == $ytics - 1B= $yval <= $yC= $i == 0D= $yval > $y
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
881 ( ($i == $ytics-1) and ($yval <= $y) ) or
882 ( ($i == 0) and ($yval > $y) )
883 ){
884 0 $ykey1=$sorted_ykeys[$i];
885 0 $ykey2=$sorted_ykeys[$i];
886 0 last;
887 }
888 elsif ($yval <= $y){
889 0 $ykey1=$yval;
890 0 next;
891 }
892 else {
893 0 $ykey2=$yval;
894 0 last;
895 }#if/elsif/else
896 }#for
897  
898 0 @xkeys=keys %{$grid_HR->{$ykey1}};
899 0 @sorted_xkeys = sort {$a<=>$b} @xkeys;
900  
901  
902 0 $xtics=scalar(@sorted_xkeys);
903  
904 0 ▶ for ($i=0; $i <= $xtics; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xtics) 0 0 0
905 0 $xval=$sorted_xkeys[$i];
906 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($i == $xtics - 1 and $xval <= $x or $i == 0 and $xval > $x) { } 0 0 0
elsif ($xval <= $x) { } 0 0 0
Condition0%0/9
$i == $xtics - 1 and $xval <= $x or $i == 0 and $xval > $x
l!l&&r!l&&!r
000
$i == $xtics - 1 and $xval <= $x
!ll&&!rl&&r
000
$i == 0 and $xval > $x
!ll&&!rl&&r
000
MC/DC0%0/4
$i == $xtics - 1 and $xval <= $x or $i == 0 and $xval > $x
$i == $xtics - 1 $xval <= $x $i == 0 $xval > $x
Truth table0%0/7
A and B or C and D
A= $i == $xtics - 1B= $xval <= $xC= $i == 0D= $xval > $x
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
907 ( ($i == $xtics-1) and ($xval <= $x) ) or
908 ( ($i == 0) and ($xval > $x) )
909 ){
910 0 $xkey1=$sorted_xkeys[$xtics-1];
911 0 $xkey2=$sorted_xkeys[0];
912 0 last;
913 }
914 elsif ($xval <= $x){
915 0 $xkey1=$xval;
916 0 next;
917 }
918 else {
919 0 $xkey2=$xval;
920 0 last;
921 }#if/elsif/else
922 }#for
923  
924 0 return ($xkey1,$xkey2,$ykey1,$ykey2);
925  
926 }#_find_grid_square
927 #-------------------------------------------------------
928 1 1;
929  
930 __END__
↑ Summary