line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
32533
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
328
|
|
2
|
7
|
|
|
7
|
|
39
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
412
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package WebService::Geocodio::Location; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$WebService::Geocodio::Location::VERSION = '0.04'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
3620
|
use WebService::Geocodio::Fields; |
|
7
|
|
|
|
|
29
|
|
|
7
|
|
|
|
|
451
|
|
10
|
7
|
|
|
7
|
|
70
|
use Moo::Lax; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
57
|
|
11
|
7
|
|
|
7
|
|
5660
|
use Carp qw(confess); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
4847
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Location object for use with Geocod.io service. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has [qw(number street suffix postdirection city state zip formatted lat lng accuracy fields)] => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
predicate => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub BUILDARGS { |
23
|
7
|
|
|
7
|
0
|
8664
|
my ( $class, @args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
7
|
|
|
|
|
24
|
my $out; |
26
|
7
|
100
|
|
|
|
28
|
if (ref($args[0]) eq "HASH") { |
|
|
100
|
|
|
|
|
|
27
|
2
|
|
|
|
|
6
|
my $hr = $args[0]; |
28
|
2
|
50
|
|
|
|
11
|
$out->{accuracy} = $hr->{accuracy} if exists $hr->{accuracy}; |
29
|
2
|
50
|
|
|
|
9
|
$out->{formatted} = $hr->{formatted_address} if exists $hr->{formatted_address}; |
30
|
2
|
50
|
|
|
|
6
|
$out->{fields} = WebService::Geocodio::Fields->new($hr->{fields}) if exists $hr->{fields}; |
31
|
2
|
100
|
|
|
|
5
|
map { $out->{$_} = $hr->{address_components}->{$_} if exists $hr->{address_components}->{$_} } qw(number street suffix postdirection city state zip); |
|
14
|
|
|
|
|
73
|
|
32
|
2
|
50
|
|
|
|
6
|
map { $out->{$_} = $hr->{location}->{$_} if exists $hr->{location}->{$_} } qw(lat lng); |
|
4
|
|
|
|
|
22
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( @args % 2 == 1 ) { |
35
|
1
|
|
|
|
|
3
|
$out->{formatted} = $args[0]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
4
|
|
|
|
|
15
|
$out = { @args }; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
148
|
return $out; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _forward_formatting { |
45
|
7
|
|
|
7
|
|
3281
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
7
|
100
|
|
|
|
39
|
return $self->formatted if $self->has_formatted; |
48
|
|
|
|
|
|
|
|
49
|
4
|
50
|
33
|
|
|
45
|
if ( ( not $self->has_zip ) && ( not ( $self->has_city && $self->has_state ) ) ) { |
|
|
|
66
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
confess "A zip or city-state pair is required.\n"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
7
|
my $s; |
54
|
4
|
50
|
66
|
|
|
26
|
if ( $self->has_number && $self->has_street && $self->suffix ) { |
|
|
|
66
|
|
|
|
|
55
|
1
|
|
|
|
|
2
|
my @f; |
56
|
1
|
50
|
|
|
|
5
|
if ( $self->has_postdirection ) { |
57
|
1
|
|
|
|
|
4
|
@f = qw(number postdirection street suffix); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
0
|
|
|
|
|
0
|
@f = qw(number street suffix); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
$s .= join " ", (map {; $self->$_ } @f); |
|
4
|
|
|
|
|
14
|
|
64
|
1
|
|
|
|
|
3
|
$s .= ", "; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
4
|
100
|
|
|
|
10
|
if ( $self->has_zip ) { |
68
|
2
|
|
|
|
|
6
|
$s .= $self->zip |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
2
|
|
|
|
|
6
|
$s .= join ", ", (map {; $self->$_ } qw(city state)); |
|
4
|
|
|
|
|
19
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
19
|
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__ |