line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
113238
|
use 5.014; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
220
|
|
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
34
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
242
|
|
4
|
6
|
|
|
6
|
|
37
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
334
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package WebService::Geocodio; |
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
$WebService::Geocodio::VERSION = '0.04'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
10141
|
use Moo::Lax; |
|
6
|
|
|
|
|
148880
|
|
|
6
|
|
|
|
|
45
|
|
12
|
6
|
|
|
6
|
|
15452
|
use Carp qw(confess); |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
446
|
|
13
|
6
|
|
|
6
|
|
34
|
use Scalar::Util qw(blessed); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4246
|
|
14
|
|
|
|
|
|
|
with('WebService::Geocodio::Request'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ABSTRACT: A Perl interface to Geocod.io |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'api_key' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => sub { confess "$_[0] doesn't look like a valid api key\n" unless $_[0] =~ /[0-9a-f]+/ }, |
23
|
|
|
|
|
|
|
required => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'locations' => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
default => sub { [] }, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'fields' => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
predicate => 1, |
36
|
|
|
|
|
|
|
default => sub { [] }, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add_location { |
41
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
push @{ $self->locations }, @_; |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub show_locations { |
48
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return @{ $self->locations }; |
|
0
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub clear_locations { |
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->locations([]); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub add_field { |
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
push @{ $self->fields }, grep { /cd|cd113|stateleg|timezone|school/ } @_; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub geocode { |
69
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
$self->add_location(@_) if scalar @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
return undef if scalar @{$self->locations} < 1; |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my @r = $self->send_forward( $self->_format('forward') ); |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
wantarray ? return @r : return \@r; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub reverse_geocode { |
82
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
$self->add_location(@_) if scalar @_; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
return undef if scalar @{$self->locations} < 1; |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my @r = $self->send_reverse( $self->_format('reverse') ); |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
wantarray ? return @r : return \@r; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _format { |
94
|
0
|
|
|
0
|
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
my $direction = shift; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
my $method = $direction eq 'forward' ? '_forward_formatting' |
98
|
|
|
|
|
|
|
: '_reverse_formatting'; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
return [ map {; blessed $_ ? $_->$method : $_ } @{$self->locations} ]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |