| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::Coder::Many::Response; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
60
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
587
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Geo::Coder::Many::Response - standard geocoder response container object |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module provides a standard response format for geocoder results - the |
|
15
|
|
|
|
|
|
|
various geocoder plugins should all do the necessary conversions to return a |
|
16
|
|
|
|
|
|
|
response in this format. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 new |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Constructs and returns a new, empty response object. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
2411
|
|
|
2411
|
1
|
131039
|
my $class = shift; |
|
28
|
2411
|
|
|
|
|
2777
|
my $args = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
2411
|
|
|
|
|
9417
|
my $self = { |
|
31
|
|
|
|
|
|
|
location => $args->{location}, |
|
32
|
|
|
|
|
|
|
responses => [], |
|
33
|
|
|
|
|
|
|
response_code => 401, |
|
34
|
|
|
|
|
|
|
geocoder => undef, |
|
35
|
|
|
|
|
|
|
}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
2411
|
|
|
|
|
6519
|
bless $self, $class; |
|
38
|
|
|
|
|
|
|
|
|
39
|
2411
|
|
|
|
|
6239
|
return $self; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 add_response |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Takes a response, together with the name of the geocoder used to produce it, |
|
45
|
|
|
|
|
|
|
and stores it. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_response { |
|
50
|
2411
|
|
|
2411
|
1
|
266966
|
my $self = shift; |
|
51
|
2411
|
|
|
|
|
3426
|
my $response = shift; |
|
52
|
2411
|
|
|
|
|
2640
|
my $geocoder = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
2411
|
|
|
|
|
3897
|
$self->{geocoder} = $geocoder; |
|
55
|
|
|
|
|
|
|
|
|
56
|
2411
|
100
|
66
|
|
|
8849
|
if ( $response->{longitude} && $response->{latitude} ) { |
|
57
|
1205
|
|
|
|
|
1383
|
push @{$self->{responses}}, $response; |
|
|
1205
|
|
|
|
|
2575
|
|
|
58
|
1205
|
|
|
|
|
1756
|
$self->{response_code} = 200; |
|
59
|
1205
|
|
|
|
|
2624
|
return 1; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
1206
|
|
|
|
|
2379
|
return 0; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 set_response_code |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub set_response_code { |
|
69
|
2411
|
|
|
2411
|
1
|
26022
|
my $self = shift; |
|
70
|
2411
|
|
|
|
|
2892
|
my $response_code = shift; |
|
71
|
2411
|
|
|
|
|
3128
|
$self->{response_code} = $response_code; |
|
72
|
2411
|
|
|
|
|
4483
|
return $response_code; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 get_location |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Getter for the location string |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
0
|
sub get_location { return shift->{location}; } |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 get_response_code |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Getter for the response code |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
4822
|
|
|
4822
|
1
|
17772
|
sub get_response_code { return shift->{response_code}; } |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 get_geocoder |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Getter for the geocoder name |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
1
|
0
|
sub get_geocoder { return shift->{geocoder}; } |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 get_responses |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
In list context, returns all of the responses. In scalar context, returns the |
|
102
|
|
|
|
|
|
|
first response. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub get_responses { |
|
107
|
1205
|
|
|
1205
|
1
|
1527
|
my $self = shift; |
|
108
|
1205
|
50
|
|
|
|
2028
|
return wantarray ? @{$self->{responses}} : $self->{responses}->[0]; |
|
|
1205
|
|
|
|
|
4035
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |