| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
7
|
|
|
7
|
|
52335
|
use strict; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
174
|
|
|
2
|
7
|
|
|
7
|
|
29
|
use warnings; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
261
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package WebService::Geocodio::Location; |
|
5
|
|
|
|
|
|
|
$WebService::Geocodio::Location::VERSION = '0.05'; |
|
6
|
7
|
|
|
7
|
|
2395
|
use WebService::Geocodio::Fields; |
|
|
7
|
|
|
|
|
109
|
|
|
|
7
|
|
|
|
|
228
|
|
|
7
|
7
|
|
|
7
|
|
45
|
use Moo; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
28
|
|
|
8
|
7
|
|
|
7
|
|
1982
|
use strictures 2; |
|
|
7
|
|
|
|
|
45
|
|
|
|
7
|
|
|
|
|
234
|
|
|
9
|
7
|
|
|
7
|
|
1179
|
use Carp qw(confess); |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
3828
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Location object for use with Geocod.io service. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has [qw(number street suffix postdirection city state zip formatted lat lng accuracy fields)] => ( |
|
15
|
|
|
|
|
|
|
is => 'ro', |
|
16
|
|
|
|
|
|
|
predicate => 1, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub BUILDARGS { |
|
21
|
7
|
|
|
7
|
0
|
2565
|
my ( $class, @args ) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
7
|
|
|
|
|
13
|
my $out; |
|
24
|
7
|
100
|
|
|
|
40
|
if (ref($args[0]) eq "HASH") { |
|
|
|
100
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
4
|
my $hr = $args[0]; |
|
26
|
2
|
50
|
|
|
|
8
|
$out->{accuracy} = $hr->{accuracy} if exists $hr->{accuracy}; |
|
27
|
2
|
50
|
|
|
|
27
|
$out->{formatted} = $hr->{formatted_address} if exists $hr->{formatted_address}; |
|
28
|
2
|
50
|
|
|
|
6
|
$out->{fields} = WebService::Geocodio::Fields->new($hr->{fields}) if exists $hr->{fields}; |
|
29
|
2
|
100
|
|
|
|
4
|
map { $out->{$_} = $hr->{address_components}->{$_} if exists $hr->{address_components}->{$_} } qw(number street suffix postdirection city state zip); |
|
|
14
|
|
|
|
|
57
|
|
|
30
|
2
|
50
|
|
|
|
4
|
map { $out->{$_} = $hr->{location}->{$_} if exists $hr->{location}->{$_} } qw(lat lng); |
|
|
4
|
|
|
|
|
27
|
|
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
elsif ( @args % 2 == 1 ) { |
|
33
|
1
|
|
|
|
|
3
|
$out->{formatted} = $args[0]; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
4
|
|
|
|
|
14
|
$out = { @args }; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
143
|
return $out; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _forward_formatting { |
|
43
|
7
|
|
|
7
|
|
2992
|
my $self = shift; |
|
44
|
|
|
|
|
|
|
|
|
45
|
7
|
100
|
|
|
|
34
|
return $self->formatted if $self->has_formatted; |
|
46
|
|
|
|
|
|
|
|
|
47
|
4
|
50
|
33
|
|
|
36
|
if ( ( not $self->has_zip ) && ( not ( $self->has_city && $self->has_state ) ) ) { |
|
|
|
|
66
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
confess "A zip or city-state pair is required.\n"; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
7
|
my $s; |
|
52
|
4
|
50
|
66
|
|
|
19
|
if ( $self->has_number && $self->has_street && $self->suffix ) { |
|
|
|
|
66
|
|
|
|
|
|
53
|
1
|
|
|
|
|
2
|
my @f; |
|
54
|
1
|
50
|
|
|
|
3
|
if ( $self->has_postdirection ) { |
|
55
|
1
|
|
|
|
|
3
|
@f = qw(number postdirection street suffix); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
else { |
|
58
|
0
|
|
|
|
|
0
|
@f = qw(number street suffix); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
2
|
$s .= join " ", (map {; $self->$_ } @f); |
|
|
4
|
|
|
|
|
11
|
|
|
62
|
1
|
|
|
|
|
2
|
$s .= ", "; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
4
|
100
|
66
|
|
|
19
|
if ( $self->has_city && $self->has_state) { |
|
66
|
3
|
|
|
|
|
7
|
$s .= join ", ", (map {; $self->$_ } qw(city state)); |
|
|
6
|
|
|
|
|
22
|
|
|
67
|
3
|
100
|
|
|
|
10
|
$s .= " " if ( $self->has_zip ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
4
|
100
|
|
|
|
12
|
if ( $self->has_zip ) { |
|
71
|
2
|
|
|
|
|
16
|
$s .= $self->zip |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
20
|
return $s; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _reverse_formatting { |
|
78
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
if ( not ( $self->has_lat && $self->has_lng ) ) { |
|
81
|
0
|
|
|
|
|
|
confess "lat-lng pair is required\n"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return join ",", ( map {; $self->$_ } qw(lat lng) ); |
|
|
0
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |