line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GIS::Distance; |
2
|
3
|
|
|
3
|
|
571026
|
use 5.008001; |
|
3
|
|
|
|
|
26
|
|
3
|
3
|
|
|
3
|
|
25
|
use strictures 2; |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
130
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
9
|
|
|
9
|
0
|
14624
|
my ($class, $formula, @args) = @_; |
8
|
|
|
|
|
|
|
|
9
|
9
|
|
50
|
|
|
24
|
$formula ||= 'Haversine'; |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
|
|
15
|
my @modules; |
12
|
|
|
|
|
|
|
push @modules, "GIS::Distance::Fast::${formula}" |
13
|
9
|
50
|
33
|
|
|
62
|
unless $ENV{GIS_DISTANCE_PP} or $ENV{GEO_DISTANCE_PP}; |
14
|
9
|
|
|
|
|
19
|
push @modules, "GIS::Distance::$formula"; |
15
|
9
|
|
|
|
|
13
|
push @modules, $formula; |
16
|
|
|
|
|
|
|
|
17
|
9
|
|
|
|
|
21
|
foreach my $module (@modules) { |
18
|
27
|
100
|
|
|
|
48
|
next if !_try_load_module( $module ); |
19
|
9
|
50
|
|
|
|
79
|
next if !$module->isa('GIS::Distance::Formula'); |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
|
|
41
|
return $module->new( @args ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
die "Cannot find a GIS::Distance::Formula class for $formula"; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %tried_modules; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _try_load_module { |
30
|
27
|
|
|
27
|
|
59
|
my ($module) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $tried_modules{ $module } |
33
|
27
|
50
|
|
|
|
62
|
if defined $tried_modules{ $module }; |
34
|
|
|
|
|
|
|
|
35
|
27
|
|
|
|
|
52
|
$tried_modules{ $module } = 1; |
36
|
27
|
|
|
|
|
1450
|
my $ok = eval( "require $module; 1" ); |
37
|
27
|
100
|
|
|
|
154
|
return 1 if $ok; |
38
|
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
38
|
$tried_modules{ $module } = 0; |
40
|
18
|
50
|
|
|
|
77
|
die $@ if $@ !~ m{^Can't locate}; |
41
|
18
|
|
|
|
|
57
|
return 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |