| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::App::Satpass2::Geocode; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1482
|
use 5.008; |
|
|
2
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
39
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
10
|
use parent qw{ Astro::App::Satpass2::Copier }; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
|
|
273
|
use Astro::App::Satpass2::Utils qw{ |
|
11
|
|
|
|
|
|
|
instance |
|
12
|
|
|
|
|
|
|
load_package |
|
13
|
|
|
|
|
|
|
@CARP_NOT |
|
14
|
2
|
|
|
2
|
|
123
|
}; |
|
|
2
|
|
|
|
|
6
|
|
|
15
|
2
|
|
|
2
|
|
15
|
use Astro::App::Satpass2::Warner; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
974
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.051_01'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
|
20
|
0
|
|
|
0
|
1
|
0
|
my ( $class, %args ) = @_; |
|
21
|
0
|
|
0
|
|
|
0
|
$class = ref $class || $class; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
my $self = {}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
bless $self, $class; |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
$self->warner( delete $args{warner} ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
0
|
__PACKAGE__ eq $class |
|
30
|
|
|
|
|
|
|
and $self->wail( |
|
31
|
|
|
|
|
|
|
"Class $class may not be instantiated directly", |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my $geocoder_class = $class->GEOCODER_CLASS(); |
|
35
|
0
|
0
|
|
|
|
0
|
load_package( $geocoder_class ) |
|
36
|
|
|
|
|
|
|
or $self->wail( |
|
37
|
|
|
|
|
|
|
"Unable to load $geocoder_class", |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
$self->geocoder( delete $args{geocoder} ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
$self->init( %args ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
return $self; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub attribute_names { |
|
48
|
2
|
|
|
2
|
1
|
5
|
my ( $self ) = @_; |
|
49
|
2
|
|
|
|
|
13
|
return ( qw{ geocoder }, $self->SUPER::attribute_names() ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub geocode { |
|
53
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
54
|
0
|
|
|
|
|
|
$self->wail( |
|
55
|
0
|
|
|
|
|
|
"The @{[ ref $self ]} class does not support geocoding. Use a subclass" |
|
56
|
|
|
|
|
|
|
); |
|
57
|
0
|
|
|
|
|
|
return; # wail() does not return, but Perl::Critic does not |
|
58
|
|
|
|
|
|
|
# know this. |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub geocoder { |
|
62
|
0
|
|
|
0
|
1
|
|
my ( $self, @args ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( @args ) { |
|
65
|
0
|
|
|
|
|
|
my $geocoder = shift @args; |
|
66
|
0
|
|
|
|
|
|
my $geocoder_class = $self->GEOCODER_CLASS(); |
|
67
|
0
|
0
|
|
|
|
|
defined $geocoder |
|
68
|
|
|
|
|
|
|
or $geocoder = $geocoder_class->new(); |
|
69
|
0
|
0
|
|
|
|
|
ref $geocoder |
|
70
|
|
|
|
|
|
|
or $geocoder = $geocoder->new(); |
|
71
|
0
|
0
|
|
|
|
|
instance( $geocoder, $geocoder_class ) |
|
72
|
|
|
|
|
|
|
or $self->wail( |
|
73
|
|
|
|
|
|
|
"Argument 'geocoder' must be an instance of $geocoder_class" |
|
74
|
|
|
|
|
|
|
); |
|
75
|
0
|
|
|
|
|
|
$self->{geocoder} = $geocoder; |
|
76
|
0
|
|
|
|
|
|
return $self; |
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
0
|
|
|
|
|
|
return $self->{geocoder}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub __geocode_failure { |
|
83
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
|
84
|
0
|
|
|
|
|
|
my $geocoder = $self->geocoder(); |
|
85
|
0
|
0
|
|
|
|
|
my $resp = $geocoder->response() |
|
86
|
|
|
|
|
|
|
or $self->wail( 'No HTTP response found' ); |
|
87
|
0
|
0
|
|
|
|
|
$resp->is_success() |
|
88
|
|
|
|
|
|
|
and $self->wail( 'No match found for location' ); |
|
89
|
0
|
|
|
|
|
|
$self->wail( $resp->status_line() ); |
|
90
|
0
|
|
|
|
|
|
return; # wail() does not return, but Perl::Critic does not know |
|
91
|
|
|
|
|
|
|
# this. |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->create_attribute_methods(); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |