blib/lib/GIS/Distance/Formula.pm

filter: Statementstmt 90.2% 37 / 41 Branchbran 50.0% 4 / 8 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 4 totaltotal 73.2% 52 / 71 CC 8 SCAR 11.0
CC
8
Cov
80%
distance
5.8
BUILDARGS
3.5
new
2.0
CRAP 3.0
« blib/lib/GIS/Distance.pm ↑ Summary blib/lib/GIS/Distance/Vincenty.pm »
1 package GIS::Distance::Formula;
2 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 our $VERSION = '0.19';
5  
6 3 ▶use Class::Measure::Length qw( length );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $SELF;
12  
13 sub new {
14 9 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
15  
16 9 my $args = $class->BUILDARGS( @_ );
17  
18 9 my $self = bless { %$args }, $class;
19 9 $self->{code} = $class->can('_distance');
20 9 ▶ $self->BUILD() if $self->can('BUILD');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("BUILD") 0 9 9
21  
22 9 return $self;
23 }
24  
25 sub BUILDARGS {
26 9 ▶ my $class = shift;
Subroutine BUILDARGS: called CC=3 SCAR=12.5
Pod undocumented
27  
28 return shift
29 9 ▶ if @_==1 and ref($_[0]) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and ref $_[0] eq "HASH" 0 9 9
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
900
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
30  
31 9 return { @_ };
32 }
33  
34 sub distance {
35 33 ▶ my $self = shift;
Subroutine distance: called CC=5 SCAR=17.5
Pod undocumented
36  
37 33 my @coords;
38 33 foreach my $coord (@_) {
39 132 ▶ if ((blessed($coord)||'') eq 'Geo::Point') {
Branch: 1 branch
BranchTrueFalseTotal
if ((builtin::blessed($coord) || "") eq "Geo::Point") 0 132 132
Condition50%1/2
builtin::blessed($coord) || ''
l!l
0132
MC/DC0%0/1
builtin::blessed($coord) || ''
builtin::blessed($coord)
Truth table50%1/2
A
A= builtin::blessed($coord)
Aresult
11
00
40 0 push @coords, $coord->latlong();
41 0 next;
42 }
43  
44 132 push @coords, $coord;
45 }
46  
47 33 ▶ croak 'Invalid arguments passsed to distance()'
Branch: 1 branch
BranchTrueFalseTotal
if @coords != 4 0 33 33
48 if @coords!=4;
49  
50 33 local $SELF = $self;
51  
52 return length(
53 33 $self->{code}->( @coords ),
54 'km',
55 );
56 }
57  
58 sub distance_metal {
59 0 ▶ my $self = shift;
Subroutine distance_metal: not called CC=1 SCAR=6.9
Pod undocumented
60 0 return $self->{code}->( @_ );
61 }
62  
63 3 1;
64 __END__
« blib/lib/GIS/Distance.pm ↑ Summary blib/lib/GIS/Distance/Vincenty.pm »