line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GIS::Distance; |
2
|
3
|
|
|
3
|
|
704613
|
use 5.008001; |
|
3
|
|
|
|
|
22
|
|
3
|
3
|
|
|
3
|
|
18
|
use strictures 2; |
|
3
|
|
|
|
|
25
|
|
|
3
|
|
|
|
|
119
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
9
|
|
|
9
|
0
|
17877
|
my ($class, $formula, @args) = @_; |
8
|
|
|
|
|
|
|
|
9
|
9
|
|
50
|
|
|
32
|
$formula ||= 'Haversine'; |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
|
|
16
|
my @modules; |
12
|
|
|
|
|
|
|
push @modules, "GIS::Distance::Fast::${formula}" |
13
|
9
|
50
|
33
|
|
|
77
|
unless $ENV{GIS_DISTANCE_PP} or $ENV{GEO_DISTANCE_PP}; |
14
|
9
|
|
|
|
|
22
|
push @modules, "GIS::Distance::$formula"; |
15
|
9
|
|
|
|
|
16
|
push @modules, $formula; |
16
|
|
|
|
|
|
|
|
17
|
9
|
|
|
|
|
24
|
foreach my $module (@modules) { |
18
|
27
|
100
|
|
|
|
62
|
next if !_try_load_module( $module ); |
19
|
9
|
50
|
|
|
|
89
|
next if !$module->isa('GIS::Distance::Formula'); |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
|
|
49
|
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
|
|
56
|
my ($module) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $tried_modules{ $module } |
33
|
27
|
50
|
|
|
|
72
|
if defined $tried_modules{ $module }; |
34
|
|
|
|
|
|
|
|
35
|
27
|
|
|
|
|
64
|
$tried_modules{ $module } = 1; |
36
|
27
|
|
|
|
|
1681
|
my $ok = eval( "require $module; 1" ); |
37
|
27
|
100
|
|
|
|
198
|
return 1 if $ok; |
38
|
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
44
|
$tried_modules{ $module } = 0; |
40
|
18
|
50
|
|
|
|
93
|
die $@ if $@ !~ m{^Can't locate}; |
41
|
18
|
|
|
|
|
71
|
return 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |