line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GIS::Distance; |
2
|
3
|
|
|
3
|
|
667426
|
use 5.008001; |
|
3
|
|
|
|
|
20
|
|
3
|
3
|
|
|
3
|
|
21
|
use strictures 2; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
127
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.18'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
9
|
|
|
9
|
0
|
17512
|
my ($class, $formula, @args) = @_; |
8
|
|
|
|
|
|
|
|
9
|
9
|
|
50
|
|
|
28
|
$formula ||= 'Haversine'; |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
|
|
18
|
my @modules; |
12
|
|
|
|
|
|
|
push @modules, "GIS::Distance::Fast::${formula}" |
13
|
9
|
50
|
33
|
|
|
74
|
unless $ENV{GIS_DISTANCE_PP} or $ENV{GEO_DISTANCE_PP}; |
14
|
9
|
|
|
|
|
26
|
push @modules, "GIS::Distance::$formula"; |
15
|
9
|
|
|
|
|
19
|
push @modules, $formula; |
16
|
|
|
|
|
|
|
|
17
|
9
|
|
|
|
|
24
|
foreach my $module (@modules) { |
18
|
27
|
100
|
|
|
|
67
|
next if !_try_load_module( $module ); |
19
|
9
|
50
|
|
|
|
88
|
next if !$module->isa('GIS::Distance::Formula'); |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
|
|
55
|
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
|
|
|
|
67
|
if defined $tried_modules{ $module }; |
34
|
|
|
|
|
|
|
|
35
|
27
|
|
|
|
|
75
|
$tried_modules{ $module } = 1; |
36
|
27
|
|
|
|
|
1650
|
my $ok = eval( "require $module; 1" ); |
37
|
27
|
100
|
|
|
|
199
|
return 1 if $ok; |
38
|
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
41
|
$tried_modules{ $module } = 0; |
40
|
18
|
50
|
|
|
|
88
|
die $@ if $@ !~ m{^Can't locate}; |
41
|
18
|
|
|
|
|
69
|
return 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |