line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GIS::Distance::Formula; |
2
|
3
|
|
|
3
|
|
1036
|
use 5.008001; |
|
3
|
|
|
|
|
10
|
|
3
|
3
|
|
|
3
|
|
13
|
use strictures 2; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
95
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1587
|
use Class::Measure::Length qw( length ); |
|
3
|
|
|
|
|
42460
|
|
|
3
|
|
|
|
|
12
|
|
7
|
3
|
|
|
3
|
|
632
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
8
|
3
|
|
|
3
|
|
13
|
use Scalar::Util qw( blessed ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
97
|
|
9
|
3
|
|
|
3
|
|
1285
|
use namespace::clean; |
|
3
|
|
|
|
|
38929
|
|
|
3
|
|
|
|
|
18
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $SELF; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
9
|
|
|
9
|
0
|
20
|
my $class = shift; |
15
|
|
|
|
|
|
|
|
16
|
9
|
|
|
|
|
35
|
my $args = $class->BUILDARGS( @_ ); |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
|
|
25
|
my $self = bless { %$args }, $class; |
19
|
9
|
|
|
|
|
69
|
$self->{code} = $class->can('_distance'); |
20
|
9
|
50
|
|
|
|
43
|
$self->BUILD() if $self->can('BUILD'); |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
35
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILDARGS { |
26
|
9
|
|
|
9
|
0
|
16
|
my $class = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return shift |
29
|
9
|
50
|
33
|
|
|
28
|
if @_==1 and ref($_[0]) eq 'HASH'; |
30
|
|
|
|
|
|
|
|
31
|
9
|
|
|
|
|
19
|
return { @_ }; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub distance { |
35
|
33
|
|
|
33
|
0
|
6931
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
33
|
|
|
|
|
37
|
my @coords; |
38
|
33
|
|
|
|
|
54
|
foreach my $coord (@_) { |
39
|
132
|
50
|
50
|
|
|
348
|
if ((blessed($coord)||'') eq 'Geo::Point') { |
40
|
0
|
|
|
|
|
0
|
push @coords, $coord->latlong(); |
41
|
0
|
|
|
|
|
0
|
next; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
132
|
|
|
|
|
170
|
push @coords, $coord; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
33
|
50
|
|
|
|
63
|
croak 'Invalid arguments passsed to distance()' |
48
|
|
|
|
|
|
|
if @coords!=4; |
49
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
48
|
local $SELF = $self; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return length( |
53
|
33
|
|
|
|
|
78
|
$self->{code}->( @coords ), |
54
|
|
|
|
|
|
|
'km', |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub distance_metal { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
return $self->{code}->( @_ ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |