line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Wikimapia::Params; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$WebService::Wikimapia::Params::VERSION = '0.13'; |
4
|
|
|
|
|
|
|
$WebService::Wikimapia::Params::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WebService::Wikimapia::Params - Placeholder for parameters for WebService::Wikimapia. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.13 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
7
|
|
97
|
use 5.006; |
|
7
|
|
|
|
|
21
|
|
17
|
7
|
|
|
7
|
|
29
|
use strict; use warnings; |
|
7
|
|
|
7
|
|
13
|
|
|
7
|
|
|
|
|
115
|
|
|
7
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
136
|
|
18
|
7
|
|
|
7
|
|
29
|
use Data::Dumper; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
256
|
|
19
|
7
|
|
|
7
|
|
2387
|
use parent 'Exporter'; |
|
7
|
|
|
|
|
1665
|
|
|
7
|
|
|
|
|
29
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw(validate $API_KEY $Language $Disable $Format $Pack $Num $FIELDS); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $API_KEY = sub { die "[$_[0]" unless check_api_key($_[0]); }; |
24
|
12
|
|
|
12
|
0
|
222
|
sub check_api_key { return ($_[0] =~ m/^[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}\-[A-Z0-9]{8}$/i); } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $DISABLE = { 'location' => 1, 'polygon' => 1 }; |
27
|
|
|
|
|
|
|
our $Disable = sub { die "ERROR: Invalid data type 'disable' found [$_[0]]" unless check_disable($_[0]); }; |
28
|
1
|
|
|
1
|
0
|
25
|
sub check_disable { return exists $DISABLE->{lc($_[0])}; } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $FORMAT = { 'xml' => 1, 'json' => 1, 'jsonp' => 1, 'kml'=> 1, 'binary' => 1 }; |
31
|
|
|
|
|
|
|
our $Format = sub { die "ERROR: Invalid data type 'format' found [$_[0]]" unless check_format($_[0]); }; |
32
|
8
|
|
|
8
|
0
|
144
|
sub check_format { return exists $FORMAT->{lc($_[0])} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $PACK = { 'none' => 1, 'gzip' => 1 }; |
35
|
|
|
|
|
|
|
our $Pack = sub { die "ERROR: Invalid data type 'pack' found [$_[0]]" unless check_pack($_[0]); }; |
36
|
6
|
|
|
6
|
0
|
95
|
sub check_pack { return exists $PACK->{lc($_[0])} } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $LANGUAGE = { |
39
|
|
|
|
|
|
|
'ab' => 1, 'aa' => 1, 'af' => 1, 'ak' => 1, 'sq' => 1, 'am' => 1, 'ar' => 1, 'an' => 1, 'hy' => 1, |
40
|
|
|
|
|
|
|
'as' => 1, 'av' => 1, 'ae' => 1, 'ay' => 1, 'az' => 1, 'bm' => 1, 'ba' => 1, 'eu' => 1, 'be' => 1, |
41
|
|
|
|
|
|
|
'bn' => 1, 'bh' => 1, 'bi' => 1, 'bs' => 1, 'br' => 1, 'bg' => 1, 'my' => 1, 'ca' => 1, 'ch' => 1, |
42
|
|
|
|
|
|
|
'ce' => 1, 'ny' => 1, 'zh' => 1, 'cv' => 1, 'kw' => 1, 'co' => 1, 'cr' => 1, 'hr' => 1, 'cs' => 1, |
43
|
|
|
|
|
|
|
'da' => 1, 'dv' => 1, 'nl' => 1, 'dz' => 1, 'en' => 1, 'eo' => 1, 'et' => 1, 'ee' => 1, 'fo' => 1, |
44
|
|
|
|
|
|
|
'fj' => 1, 'fi' => 1, 'fr' => 1, 'ff' => 1, 'gl' => 1, 'ka' => 1, 'de' => 1, 'el' => 1, 'gn' => 1, |
45
|
|
|
|
|
|
|
'gu' => 1, 'ht' => 1, 'ha' => 1, 'he' => 1, 'hz' => 1, 'hi' => 1, 'ho' => 1, 'hu' => 1, 'ia' => 1, |
46
|
|
|
|
|
|
|
'id' => 1, 'ie' => 1, 'ga' => 1, 'ig' => 1, 'ik' => 1, 'io' => 1, 'is' => 1, 'it' => 1, 'iu' => 1, |
47
|
|
|
|
|
|
|
'ja' => 1, 'jv' => 1, 'kl' => 1, 'kn' => 1, 'kr' => 1, 'ks' => 1, 'kk' => 1, 'km' => 1, 'ki' => 1, |
48
|
|
|
|
|
|
|
'rw' => 1, 'ky' => 1, 'kv' => 1, 'kg' => 1, 'ko' => 1, 'ku' => 1, 'kj' => 1, 'la' => 1, 'lb' => 1, |
49
|
|
|
|
|
|
|
'lg' => 1, 'li' => 1, 'ln' => 1, 'lo' => 1, 'lt' => 1, 'lu' => 1, 'lv' => 1, 'gv' => 1, 'mk' => 1, |
50
|
|
|
|
|
|
|
'mg' => 1, 'ms' => 1, 'ml' => 1, 'mt' => 1, 'mi' => 1, 'mr' => 1, 'mh' => 1, 'mn' => 1, 'na' => 1, |
51
|
|
|
|
|
|
|
'nv' => 1, 'nb' => 1, 'nd' => 1, 'ne' => 1, 'ng' => 1, 'nn' => 1, 'no' => 1, 'ii' => 1, 'nr' => 1, |
52
|
|
|
|
|
|
|
'oc' => 1, 'oj' => 1, 'cu' => 1, 'om' => 1, 'or' => 1, 'os' => 1, 'pa' => 1, 'pi' => 1, 'fa' => 1, |
53
|
|
|
|
|
|
|
'pl' => 1, 'ps' => 1, 'pt' => 1, 'qu' => 1, 'rm' => 1, 'rn' => 1, 'ro' => 1, 'ru' => 1, 'sa' => 1, |
54
|
|
|
|
|
|
|
'sc' => 1, 'sd' => 1, 'se' => 1, 'sm' => 1, 'sg' => 1, 'sr' => 1, 'gd' => 1, 'sn' => 1, 'si' => 1, |
55
|
|
|
|
|
|
|
'sk' => 1, 'sl' => 1, 'af' => 1, 'st' => 1, 'es' => 1, 'su' => 1, 'sw' => 1, 'ss' => 1, 'sv' => 1, |
56
|
|
|
|
|
|
|
'ta' => 1, 'te' => 1, 'tg' => 1, 'th' => 1, 'ti' => 1, 'bo' => 1, 'tk' => 1, 'tl' => 1, 'tn' => 1, |
57
|
|
|
|
|
|
|
'to' => 1, 'tr' => 1, 'ts' => 1, 'tt' => 1, 'tw' => 1, 'ty' => 1, 'ug' => 1, 'uk' => 1, 'ur' => 1, |
58
|
|
|
|
|
|
|
'uz' => 1, 've' => 1, 'vi' => 1, 'vo' => 1, 'wa' => 1, 'cy' => 1, 'wo' => 1, 'fy' => 1, 'xh' => 1, |
59
|
|
|
|
|
|
|
'yi' => 1, 'yo' => 1, 'za' => 1, 'zu' => 1, |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
our $Language = sub { die "ERROR: Invalid data type 'language' found [$_[0]]" unless check_language($_[0]); }; |
62
|
7
|
|
|
7
|
0
|
114
|
sub check_language { return exists $LANGUAGE->{lc($_[0])}; } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
our $Num = sub { return check_num($_[0]); }; |
65
|
|
|
|
|
|
|
sub check_num { |
66
|
16
|
|
|
16
|
0
|
30
|
my ($num) = @_; |
67
|
|
|
|
|
|
|
|
68
|
16
|
100
|
66
|
|
|
308
|
die "ERROR: Invalid NUM data type [$num]" unless (defined $num && $num =~ /^\d+$/); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub check_str { |
72
|
1
|
|
|
1
|
0
|
2
|
my ($str) = @_; |
73
|
|
|
|
|
|
|
|
74
|
1
|
50
|
33
|
|
|
15
|
die "ERROR: Invalid STR data type [$str]" if (defined $str && $str =~ /^\d+$/); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub check_bbox { |
78
|
1
|
|
|
1
|
0
|
3
|
my ($str) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1
|
50
|
33
|
|
|
7
|
if ((defined $str) && ($str =~ /\,/)) { |
81
|
1
|
|
|
|
|
4
|
my ($lon_min,$lat_min,$lon_max,$lat_max) = split /\,/,$str,4; |
82
|
1
|
0
|
33
|
|
|
6
|
if (((defined $lon_min) && ($lon_min =~ /\-?\d+\.?\d+$/)) |
|
|
|
0
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
83
|
|
|
|
|
|
|
&& |
84
|
|
|
|
|
|
|
((defined $lat_min) && ($lat_min =~ /\-?\d+\.?\d+$/)) |
85
|
|
|
|
|
|
|
&& |
86
|
|
|
|
|
|
|
((defined $lon_max) && ($lon_max =~ /\-?\d+\.?\d+$/)) |
87
|
|
|
|
|
|
|
&& |
88
|
|
|
|
|
|
|
((defined $lat_max) && ($lat_max =~ /\-?\d+\.?\d+$/))) { |
89
|
0
|
|
|
|
|
0
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
8
|
die "ERROR: Invalid data type 'bbox' [$str]"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
our $FIELDS = { |
97
|
|
|
|
|
|
|
'disable' => { check => sub { check_location(@_) }, type => 's' }, |
98
|
|
|
|
|
|
|
'page' => { check => sub { check_num(@_) }, type => 'd' }, |
99
|
|
|
|
|
|
|
'id' => { check => sub { check_num(@_) }, type => 'd' }, |
100
|
|
|
|
|
|
|
'count' => { check => sub { check_num(@_) }, type => 'd' }, |
101
|
|
|
|
|
|
|
'language' => { check => sub { check_language(@_) }, type => 's' }, |
102
|
|
|
|
|
|
|
'format' => { check => sub { check_format(@_) }, type => 's' }, |
103
|
|
|
|
|
|
|
'pack' => { check => sub { check_pack(@_) }, type => 's' }, |
104
|
|
|
|
|
|
|
'bbox' => { check => sub { check_bbox(@_) }, type => 's' }, |
105
|
|
|
|
|
|
|
'lon_min' => { check => sub { check_str(@_) }, type => 's' }, |
106
|
|
|
|
|
|
|
'lon_max' => { check => sub { check_str(@_) }, type => 's' }, |
107
|
|
|
|
|
|
|
'lat_min' => { check => sub { check_str(@_) }, type => 's' }, |
108
|
|
|
|
|
|
|
'lat_max' => { check => sub { check_str(@_) }, type => 's' }, |
109
|
|
|
|
|
|
|
'x' => { check => sub { check_num(@_) }, type => 'd' }, |
110
|
|
|
|
|
|
|
'y' => { check => sub { check_num(@_) }, type => 'd' }, |
111
|
|
|
|
|
|
|
'z' => { check => sub { check_num(@_) }, type => 'd' }, |
112
|
|
|
|
|
|
|
'lon' => { check => sub { check_str(@_) }, type => 's' }, |
113
|
|
|
|
|
|
|
'lat' => { check => sub { check_str(@_) }, type => 's' }, |
114
|
|
|
|
|
|
|
'q' => { check => sub { check_str(@_) }, type => 's' }, |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub validate { |
119
|
6
|
|
|
6
|
0
|
12
|
my ($fields, $values) = @_; |
120
|
|
|
|
|
|
|
|
121
|
6
|
100
|
|
|
|
25
|
die "ERROR: Missing params list." unless (defined $values); |
122
|
|
|
|
|
|
|
|
123
|
5
|
100
|
|
|
|
21
|
die "ERROR: Parameters have to be hash ref" unless (ref($values) eq 'HASH'); |
124
|
|
|
|
|
|
|
|
125
|
4
|
|
|
|
|
7
|
foreach my $field (sort keys %{$fields}) { |
|
4
|
|
|
|
|
22
|
|
126
|
|
|
|
|
|
|
die "ERROR: Received invalid param: $field" |
127
|
5
|
50
|
|
|
|
17
|
unless (exists $FIELDS->{$field}); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
die "ERROR: Missing mandatory param: $field" |
130
|
5
|
100
|
66
|
|
|
37
|
if ($fields->{$field} && !exists $values->{$field}); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
die "ERROR: Received undefined mandatory param: $field" |
133
|
3
|
100
|
66
|
|
|
24
|
if ($fields->{$field} && !defined $values->{$field}); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$FIELDS->{$field}->{check}->($values->{$field}) |
136
|
2
|
50
|
|
|
|
10
|
if defined $values->{$field}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 REPOSITORY |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 BUGS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
151
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at L. |
152
|
|
|
|
|
|
|
I will be notified and then you'll automatically be notified of progress on your |
153
|
|
|
|
|
|
|
bug as I make changes. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SUPPORT |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
perldoc WebService::Wikimapia::Params |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
You can also look for information at: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * CPAN Ratings |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * Search CPAN |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Copyright (C) 2011 - 2015 Mohammad S Anwar. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
188
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
189
|
|
|
|
|
|
|
license at: |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
194
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
195
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
196
|
|
|
|
|
|
|
not accept this license. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
199
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
200
|
|
|
|
|
|
|
complies with the requirements of this license. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
203
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
206
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
207
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
208
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
209
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
210
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
211
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
214
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
215
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
216
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
217
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
218
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
219
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; # End of WebService::Wikimapia::Params |