line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Coder::Many::Response; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
41
|
|
4
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
441
|
|
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
|
2418
|
|
|
2418
|
1
|
71116
|
my $class = shift; |
28
|
2418
|
|
|
|
|
1623
|
my $args = shift; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $self = { |
31
|
|
|
|
|
|
|
location => $args->{location}, |
32
|
2418
|
|
|
|
|
4598
|
responses => [], |
33
|
|
|
|
|
|
|
response_code => 401, |
34
|
|
|
|
|
|
|
geocoder => undef, |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
2418
|
|
|
|
|
2492
|
bless $self, $class; |
38
|
|
|
|
|
|
|
|
39
|
2418
|
|
|
|
|
2586
|
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
|
2418
|
|
|
2418
|
1
|
140810
|
my $self = shift; |
51
|
2418
|
|
|
|
|
1612
|
my $response = shift; |
52
|
2418
|
|
|
|
|
1723
|
my $geocoder = shift; |
53
|
|
|
|
|
|
|
|
54
|
2418
|
|
|
|
|
2051
|
$self->{geocoder} = $geocoder; |
55
|
|
|
|
|
|
|
|
56
|
2418
|
50
|
66
|
|
|
4911
|
if ( $response->{longitude} && $response->{latitude} ) { |
57
|
1195
|
|
|
|
|
755
|
push @{$self->{responses}}, $response; |
|
1195
|
|
|
|
|
1515
|
|
58
|
1195
|
|
|
|
|
903
|
$self->{response_code} = 200; |
59
|
1195
|
|
|
|
|
1344
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
1223
|
|
|
|
|
1172
|
return 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 set_response_code |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub set_response_code { |
69
|
2418
|
|
|
2418
|
1
|
13831
|
my $self = shift; |
70
|
2418
|
|
|
|
|
1591
|
my $response_code = shift; |
71
|
2418
|
|
|
|
|
1747
|
$self->{response_code} = $response_code; |
72
|
2418
|
|
|
|
|
2049
|
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
|
4836
|
|
|
4836
|
1
|
8342
|
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
|
1195
|
|
|
1195
|
1
|
800
|
my $self = shift; |
108
|
1195
|
50
|
|
|
|
1274
|
return wantarray ? @{$self->{responses}} : $self->{responses}->[0]; |
|
1195
|
|
|
|
|
2024
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |