line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::WebService::OpenCellID; |
2
|
4
|
|
|
4
|
|
150565
|
use warnings; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
135
|
|
3
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
143
|
|
4
|
4
|
|
|
4
|
|
21
|
use base qw{Geo::WebService::OpenCellID::Base}; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2816
|
|
5
|
4
|
|
|
4
|
|
2337
|
use Geo::WebService::OpenCellID::cell; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
111
|
|
6
|
4
|
|
|
4
|
|
2375
|
use Geo::WebService::OpenCellID::measure; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
112
|
|
7
|
4
|
|
|
4
|
|
9327
|
use LWP::Simple qw{}; |
|
4
|
|
|
|
|
397999
|
|
|
4
|
|
|
|
|
116
|
|
8
|
4
|
|
|
4
|
|
2775
|
use XML::Simple qw{}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use URI qw{}; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Geo::WebService::OpenCellID - Perl API for the opencellid.org database |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Geo::WebService::OpenCellID; |
20
|
|
|
|
|
|
|
my $gwo=Geo::WebService::OpenCellID->new(key=>$apikey); |
21
|
|
|
|
|
|
|
my $point=$gwo->cell->get(mcc=>$country, |
22
|
|
|
|
|
|
|
mnc=>$network, |
23
|
|
|
|
|
|
|
lac=>$locale, |
24
|
|
|
|
|
|
|
cellid=>$cellid); |
25
|
|
|
|
|
|
|
printf "Lat:%s, Lon:%s\n", $point->latlon; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Perl Interface to the database at http://www.opencellid.org/ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 USAGE |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $obj = Geo::WebService::OpenCellID->new( |
38
|
|
|
|
|
|
|
key=>"myapikey", #default |
39
|
|
|
|
|
|
|
url=>"http://www.opencellid.org/", #default |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub initialize { |
45
|
|
|
|
|
|
|
my $self=shift; |
46
|
|
|
|
|
|
|
%$self=@_; |
47
|
|
|
|
|
|
|
$self->url("http://www.opencellid.org/") unless $self->url; |
48
|
|
|
|
|
|
|
$self->key("myapikey") unless $self->key; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 key |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Sets and returns the API key. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub key { |
60
|
|
|
|
|
|
|
my $self=shift; |
61
|
|
|
|
|
|
|
$self->{"key"}=shift if @_; |
62
|
|
|
|
|
|
|
return $self->{"key"}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 url |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Sets and returns the URL. Defaults to http://www.opencellid.org/ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub url { |
72
|
|
|
|
|
|
|
my $self=shift; |
73
|
|
|
|
|
|
|
$self->{"url"}=shift if @_; |
74
|
|
|
|
|
|
|
return $self->{"url"}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 cell |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns a L object. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub cell { |
84
|
|
|
|
|
|
|
my $self=shift; |
85
|
|
|
|
|
|
|
unless (defined($self->{"cell"})) { |
86
|
|
|
|
|
|
|
$self->{"cell"}=Geo::WebService::OpenCellID::cell->new(parent=>$self); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
return $self->{"cell"}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 measure |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns a L object. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub measure { |
98
|
|
|
|
|
|
|
my $self=shift; |
99
|
|
|
|
|
|
|
unless (defined($self->{"measure"})) { |
100
|
|
|
|
|
|
|
$self->{"measure"}=Geo::WebService::OpenCellID::measure->new(parent=>$self); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
return $self->{"measure"}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS (INTERNAL) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 call |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Calls the web service. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $data=$gwo->call($method_path, $response_class, %parameters); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub call { |
116
|
|
|
|
|
|
|
my $self=shift; |
117
|
|
|
|
|
|
|
my $path=shift or die; |
118
|
|
|
|
|
|
|
my $class=shift or die; |
119
|
|
|
|
|
|
|
my $uri=URI->new($self->url); |
120
|
|
|
|
|
|
|
$uri->path($path); |
121
|
|
|
|
|
|
|
$uri->query_form(key=>$self->key, @_); |
122
|
|
|
|
|
|
|
my $content=LWP::Simple::get($uri->as_string); |
123
|
|
|
|
|
|
|
if ($content) { |
124
|
|
|
|
|
|
|
return $class->new( |
125
|
|
|
|
|
|
|
content => $content, |
126
|
|
|
|
|
|
|
url => $uri, |
127
|
|
|
|
|
|
|
data => $self->data_xml($content), |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
} else { |
130
|
|
|
|
|
|
|
return undef; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 data_xml |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns a data structure given xml |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $ref =$gwo->data_xml(); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub data_xml { |
143
|
|
|
|
|
|
|
my $self=shift; |
144
|
|
|
|
|
|
|
my $xml=shift; |
145
|
|
|
|
|
|
|
return XML::Simple->new(ForceArray=>1)->XMLin($xml); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 BUGS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Submit to RT and email the Author |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SUPPORT |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Try the Author or Try 8motions.com |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Michael R. Davis |
159
|
|
|
|
|
|
|
CPAN ID: MRDVT |
160
|
|
|
|
|
|
|
STOP, LLC |
161
|
|
|
|
|
|
|
domain=>michaelrdavis,tld=>com,account=>perl |
162
|
|
|
|
|
|
|
http://www.stopllc.com/ |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software; you can redistribute |
167
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The full text of the license can be found in the |
170
|
|
|
|
|
|
|
LICENSE file included with this module. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SEE ALSO |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L, L, L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |