| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 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
Condition50%1/2
builtin::blessed($coord) || ''
MC/DC0%0/1
builtin::blessed($coord) || ''
builtin::blessed($coord)
Truth table50%1/2
A
A= builtin::blessed($coord)
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||