| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Wikimapia; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$WebService::Wikimapia::VERSION = '0.13'; |
|
4
|
|
|
|
|
|
|
$WebService::Wikimapia::AUTHORITY = 'cpan:MANWAR'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WebService::Wikimapia - Interface to Wikimapia API. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.13 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
7
|
|
|
7
|
|
56859
|
use 5.006; |
|
|
7
|
|
|
|
|
75
|
|
|
17
|
7
|
|
|
7
|
|
3677
|
use JSON; |
|
|
7
|
|
|
|
|
66588
|
|
|
|
7
|
|
|
|
|
28
|
|
|
18
|
7
|
|
|
7
|
|
4035
|
use Data::Dumper; |
|
|
7
|
|
|
|
|
42981
|
|
|
|
7
|
|
|
|
|
376
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
|
2550
|
use WebService::Wikimapia::UserAgent; |
|
|
7
|
|
|
|
|
29
|
|
|
|
7
|
|
|
|
|
204
|
|
|
21
|
7
|
|
|
7
|
|
2595
|
use WebService::Wikimapia::Category; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
182
|
|
|
22
|
7
|
|
|
7
|
|
2610
|
use WebService::Wikimapia::Place; |
|
|
7
|
|
|
|
|
19
|
|
|
|
7
|
|
|
|
|
215
|
|
|
23
|
7
|
|
|
7
|
|
2673
|
use WebService::Wikimapia::Object; |
|
|
7
|
|
|
|
|
19
|
|
|
|
7
|
|
|
|
|
187
|
|
|
24
|
7
|
|
|
7
|
|
3239
|
use WebService::Wikimapia::Street; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
289
|
|
|
25
|
7
|
|
|
7
|
|
40
|
use WebService::Wikimapia::Params qw($Disable $Format $Pack $FIELDS $Language $Num validate); |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
940
|
|
|
26
|
7
|
|
|
7
|
|
44
|
use WebService::Wikimapia::UserAgent::Exception; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
166
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
7
|
|
|
7
|
|
31
|
use Moo; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
27
|
|
|
29
|
7
|
|
|
7
|
|
2174
|
use namespace::clean; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
23
|
|
|
30
|
|
|
|
|
|
|
extends 'WebService::Wikimapia::UserAgent'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'base_url' => (is => 'ro', default => sub { return 'http://api.wikimapia.org/'; }); |
|
33
|
|
|
|
|
|
|
has 'disable' => (is => 'ro', isa => $Disable); |
|
34
|
|
|
|
|
|
|
has 'page' => (is => 'ro', isa => $Num, default => sub { return 1; }); |
|
35
|
|
|
|
|
|
|
has 'count' => (is => 'ro', isa => $Num, default => sub { return 50; }); |
|
36
|
|
|
|
|
|
|
has 'language' => (is => 'ro', isa => $Language, default => sub { return 'en'; }); |
|
37
|
|
|
|
|
|
|
has 'pack' => (is => 'ro', isa => $Pack, default => sub { return 'none'; }); |
|
38
|
|
|
|
|
|
|
has 'format' => (is => 'ro', isa => $Format, default => sub { return 'json'; }); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Wikimapia API is a system that allows you to receive data from Wikimapia map and |
|
43
|
|
|
|
|
|
|
that can easily be integrate Wikimapia Geo Data into your external application / |
|
44
|
|
|
|
|
|
|
web site. And it's all free. You need to get the API Key first from L. |
|
45
|
|
|
|
|
|
|
Please note API is still in developing stage (beta). |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Recent changes to the API by Wikimapia, marked the method search(), box() and |
|
48
|
|
|
|
|
|
|
object() deprecated. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
The only key required is 'api_key' which is an api key.Rest of them are optional. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
55
|
|
|
|
|
|
|
| Key | Description | |
|
56
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
57
|
|
|
|
|
|
|
| api_key | Wikimapia API Key. | |
|
58
|
|
|
|
|
|
|
| page | This is page number. 1 is default. | |
|
59
|
|
|
|
|
|
|
| count | Determines the number of results/page. 50 is default. | |
|
60
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
61
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use strict; use warnings; |
|
64
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $key = 'Your_API_Key'; |
|
67
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 LANGUAGE |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
+-----------------------+----------------+ |
|
72
|
|
|
|
|
|
|
| Language Name | ISO 639-1 Code | |
|
73
|
|
|
|
|
|
|
+-----------------------+----------------+ |
|
74
|
|
|
|
|
|
|
| Abkhaz | ab | |
|
75
|
|
|
|
|
|
|
| Afar | aa | |
|
76
|
|
|
|
|
|
|
| Afrikaans | af | |
|
77
|
|
|
|
|
|
|
| Akan | ak | |
|
78
|
|
|
|
|
|
|
| Albanian | sq | |
|
79
|
|
|
|
|
|
|
| Amharic | am | |
|
80
|
|
|
|
|
|
|
| Arabic | ar | |
|
81
|
|
|
|
|
|
|
| Aragonese | an | |
|
82
|
|
|
|
|
|
|
| Armenian | hy | |
|
83
|
|
|
|
|
|
|
| Assamese | as | |
|
84
|
|
|
|
|
|
|
| Avaric | av | |
|
85
|
|
|
|
|
|
|
| Avestan | ae | |
|
86
|
|
|
|
|
|
|
| Aymara | ay | |
|
87
|
|
|
|
|
|
|
| Azerbaijani | az | |
|
88
|
|
|
|
|
|
|
| Bambara | bm | |
|
89
|
|
|
|
|
|
|
| Bashkir | ba | |
|
90
|
|
|
|
|
|
|
| Basque | eu | |
|
91
|
|
|
|
|
|
|
| Belarusian | be | |
|
92
|
|
|
|
|
|
|
| Bengali | bn | |
|
93
|
|
|
|
|
|
|
| Bihari | bh | |
|
94
|
|
|
|
|
|
|
| Bislama | bi | |
|
95
|
|
|
|
|
|
|
| Bosnian | bs | |
|
96
|
|
|
|
|
|
|
| Breton | br | |
|
97
|
|
|
|
|
|
|
| Bulgarian | bg | |
|
98
|
|
|
|
|
|
|
| Burmese | my | |
|
99
|
|
|
|
|
|
|
| Catalan | ca | |
|
100
|
|
|
|
|
|
|
| Chamorro | ch | |
|
101
|
|
|
|
|
|
|
| Chechen | ce | |
|
102
|
|
|
|
|
|
|
| Chichewa | ny | |
|
103
|
|
|
|
|
|
|
| Chinese | zh | |
|
104
|
|
|
|
|
|
|
| Chuvash | cv | |
|
105
|
|
|
|
|
|
|
| Cornish | kw | |
|
106
|
|
|
|
|
|
|
| Corsican | co | |
|
107
|
|
|
|
|
|
|
| Cree | cr | |
|
108
|
|
|
|
|
|
|
| Croatian | hr | |
|
109
|
|
|
|
|
|
|
| Czech | cs | |
|
110
|
|
|
|
|
|
|
| Danish | da | |
|
111
|
|
|
|
|
|
|
| Divehi | dv | |
|
112
|
|
|
|
|
|
|
| Dutch | nl | |
|
113
|
|
|
|
|
|
|
| Dzongkha | dz | |
|
114
|
|
|
|
|
|
|
| English | en | |
|
115
|
|
|
|
|
|
|
| Esperanto | eo | |
|
116
|
|
|
|
|
|
|
| Estonian | et | |
|
117
|
|
|
|
|
|
|
| Ewe | ee | |
|
118
|
|
|
|
|
|
|
| Faroese | fo | |
|
119
|
|
|
|
|
|
|
| Fijian | fj | |
|
120
|
|
|
|
|
|
|
| Finnish | fi | |
|
121
|
|
|
|
|
|
|
| French | fr | |
|
122
|
|
|
|
|
|
|
| Fula | ff | |
|
123
|
|
|
|
|
|
|
| Galician | gl | |
|
124
|
|
|
|
|
|
|
| Georgian | ka | |
|
125
|
|
|
|
|
|
|
| German | de | |
|
126
|
|
|
|
|
|
|
| Greek, Modern | el | |
|
127
|
|
|
|
|
|
|
| Guarani | gn | |
|
128
|
|
|
|
|
|
|
| Gujarati | gu | |
|
129
|
|
|
|
|
|
|
| Haitian | ht | |
|
130
|
|
|
|
|
|
|
| Hausa | ha | |
|
131
|
|
|
|
|
|
|
| Hebrew (modern) | he | |
|
132
|
|
|
|
|
|
|
| Herero | hz | |
|
133
|
|
|
|
|
|
|
| Hindi | hi | |
|
134
|
|
|
|
|
|
|
| Hiri Motu | ho | |
|
135
|
|
|
|
|
|
|
| Hungarian | hu | |
|
136
|
|
|
|
|
|
|
| Interlingua | ia | |
|
137
|
|
|
|
|
|
|
| Indonesian | id | |
|
138
|
|
|
|
|
|
|
| Interlingue | ie | |
|
139
|
|
|
|
|
|
|
| Irish | ga | |
|
140
|
|
|
|
|
|
|
| Igbo | ig | |
|
141
|
|
|
|
|
|
|
| Inupiaq | ik | |
|
142
|
|
|
|
|
|
|
| Ido | io | |
|
143
|
|
|
|
|
|
|
| Icelandic | is | |
|
144
|
|
|
|
|
|
|
| Italian | it | |
|
145
|
|
|
|
|
|
|
| Inuktitut | iu | |
|
146
|
|
|
|
|
|
|
| Japanese | ja | |
|
147
|
|
|
|
|
|
|
| Javanese | jv | |
|
148
|
|
|
|
|
|
|
| Kalaallisut | kl | |
|
149
|
|
|
|
|
|
|
| Kannada | kn | |
|
150
|
|
|
|
|
|
|
| Kanuri | kr | |
|
151
|
|
|
|
|
|
|
| Kashmiri | ks | |
|
152
|
|
|
|
|
|
|
| Kazaq | kk | |
|
153
|
|
|
|
|
|
|
| Khmer | km | |
|
154
|
|
|
|
|
|
|
| Kikuyu | ki | |
|
155
|
|
|
|
|
|
|
| Kinyarwanda | rw | |
|
156
|
|
|
|
|
|
|
| Kirghiz | ky | |
|
157
|
|
|
|
|
|
|
| Komi | kv | |
|
158
|
|
|
|
|
|
|
| Kongo | kg | |
|
159
|
|
|
|
|
|
|
| Korean | ko | |
|
160
|
|
|
|
|
|
|
| Kurdish | ku | |
|
161
|
|
|
|
|
|
|
| Kwanyama | kj | |
|
162
|
|
|
|
|
|
|
| Latin | la | |
|
163
|
|
|
|
|
|
|
| Luxembourgish | lb | |
|
164
|
|
|
|
|
|
|
| Luganda | lg | |
|
165
|
|
|
|
|
|
|
| Limburgish | li | |
|
166
|
|
|
|
|
|
|
| Lingala | ln | |
|
167
|
|
|
|
|
|
|
| Lao | lo | |
|
168
|
|
|
|
|
|
|
| Lithuanian | lt | |
|
169
|
|
|
|
|
|
|
| Luba-Katanga | lu | |
|
170
|
|
|
|
|
|
|
| Latvian | lv | |
|
171
|
|
|
|
|
|
|
| Manx | gv | |
|
172
|
|
|
|
|
|
|
| Macedonian | mk | |
|
173
|
|
|
|
|
|
|
| Malagasy | mg | |
|
174
|
|
|
|
|
|
|
| Malay | ms | |
|
175
|
|
|
|
|
|
|
| Malayalam | ml | |
|
176
|
|
|
|
|
|
|
| Maltese | mt | |
|
177
|
|
|
|
|
|
|
| Ma-ori | mi | |
|
178
|
|
|
|
|
|
|
| Marathi | mr | |
|
179
|
|
|
|
|
|
|
| Marshallese | mh | |
|
180
|
|
|
|
|
|
|
| Mongolian | mn | |
|
181
|
|
|
|
|
|
|
| Nauru | na | |
|
182
|
|
|
|
|
|
|
| Navajo | nv | |
|
183
|
|
|
|
|
|
|
| Norwegian | nb | |
|
184
|
|
|
|
|
|
|
| North Ndebele | nd | |
|
185
|
|
|
|
|
|
|
| Nepali | ne | |
|
186
|
|
|
|
|
|
|
| Ndonga | ng | |
|
187
|
|
|
|
|
|
|
| Norwegian Nynorsk | nn | |
|
188
|
|
|
|
|
|
|
| Norwegian | no | |
|
189
|
|
|
|
|
|
|
| Nuosu | ii | |
|
190
|
|
|
|
|
|
|
| South Ndebele | nr | |
|
191
|
|
|
|
|
|
|
| Occitan | oc | |
|
192
|
|
|
|
|
|
|
| Ojibwe | oj | |
|
193
|
|
|
|
|
|
|
| Old Church Slavonic | cu | |
|
194
|
|
|
|
|
|
|
| Oromo | om | |
|
195
|
|
|
|
|
|
|
| Oriya | or | |
|
196
|
|
|
|
|
|
|
| Ossetian | os | |
|
197
|
|
|
|
|
|
|
| Punjabi | pa | |
|
198
|
|
|
|
|
|
|
| Pa-li | pi | |
|
199
|
|
|
|
|
|
|
| Persian | fa | |
|
200
|
|
|
|
|
|
|
| Polish | pl | |
|
201
|
|
|
|
|
|
|
| Pashto | ps | |
|
202
|
|
|
|
|
|
|
| Portuguese | pt | |
|
203
|
|
|
|
|
|
|
| Quechua | qu | |
|
204
|
|
|
|
|
|
|
| Romansh | rm | |
|
205
|
|
|
|
|
|
|
| Kirundi | rn | |
|
206
|
|
|
|
|
|
|
| Romanian | ro | |
|
207
|
|
|
|
|
|
|
| Russian | ru | |
|
208
|
|
|
|
|
|
|
| Sanskrit | sa | |
|
209
|
|
|
|
|
|
|
| Sardinian | sc | |
|
210
|
|
|
|
|
|
|
| Sindhi | sd | |
|
211
|
|
|
|
|
|
|
| Northern Sami | se | |
|
212
|
|
|
|
|
|
|
| Samoan | sm | |
|
213
|
|
|
|
|
|
|
| Sango | sg | |
|
214
|
|
|
|
|
|
|
| Serbian | sr | |
|
215
|
|
|
|
|
|
|
| Scottish Gaelic; | gd | |
|
216
|
|
|
|
|
|
|
| Shona | sn | |
|
217
|
|
|
|
|
|
|
| Sinhala | si | |
|
218
|
|
|
|
|
|
|
| Slovak | sk | |
|
219
|
|
|
|
|
|
|
| Slovene | sl | |
|
220
|
|
|
|
|
|
|
| Somali | af | |
|
221
|
|
|
|
|
|
|
| Southern Sotho | st | |
|
222
|
|
|
|
|
|
|
| Spanish | es | |
|
223
|
|
|
|
|
|
|
| Sundanese | su | |
|
224
|
|
|
|
|
|
|
| Swahili | sw | |
|
225
|
|
|
|
|
|
|
| Swati | ss | |
|
226
|
|
|
|
|
|
|
| Swedish | sv | |
|
227
|
|
|
|
|
|
|
| Tamil | ta | |
|
228
|
|
|
|
|
|
|
| Telugu | te | |
|
229
|
|
|
|
|
|
|
| Tajik | tg | |
|
230
|
|
|
|
|
|
|
| Thai | th | |
|
231
|
|
|
|
|
|
|
| Tigrinya | ti | |
|
232
|
|
|
|
|
|
|
| Tibetan Standard | bo | |
|
233
|
|
|
|
|
|
|
| Turkmen | tk | |
|
234
|
|
|
|
|
|
|
| Tagalog | tl | |
|
235
|
|
|
|
|
|
|
| Tswana | tn | |
|
236
|
|
|
|
|
|
|
| Tonga (Tonga Islands) | to | |
|
237
|
|
|
|
|
|
|
| Turkish | tr | |
|
238
|
|
|
|
|
|
|
| Tsonga | ts | |
|
239
|
|
|
|
|
|
|
| Tatar | tt | |
|
240
|
|
|
|
|
|
|
| Twi | tw | |
|
241
|
|
|
|
|
|
|
| Tahitian | ty | |
|
242
|
|
|
|
|
|
|
| Uighur | ug | |
|
243
|
|
|
|
|
|
|
| Ukrainian | uk | |
|
244
|
|
|
|
|
|
|
| Urdu | ur | |
|
245
|
|
|
|
|
|
|
| Uzbek | uz | |
|
246
|
|
|
|
|
|
|
| Venda | ve | |
|
247
|
|
|
|
|
|
|
| Vietnamese | vi | |
|
248
|
|
|
|
|
|
|
| Volapuk | vo | |
|
249
|
|
|
|
|
|
|
| Walloon | wa | |
|
250
|
|
|
|
|
|
|
| Welsh | cy | |
|
251
|
|
|
|
|
|
|
| Wolof | wo | |
|
252
|
|
|
|
|
|
|
| Western Frisian | fy | |
|
253
|
|
|
|
|
|
|
| Xhosa | xh | |
|
254
|
|
|
|
|
|
|
| Yiddish | yi | |
|
255
|
|
|
|
|
|
|
| Yoruba | yo | |
|
256
|
|
|
|
|
|
|
| Zhuang | za | |
|
257
|
|
|
|
|
|
|
| Zulu | zu | |
|
258
|
|
|
|
|
|
|
+-----------------------+----------------+ |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 METHODS |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 place_getbyid() |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Returns an object of type L. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
267
|
|
|
|
|
|
|
| Key | Description | |
|
268
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
269
|
|
|
|
|
|
|
| id | Place Id (required). | |
|
270
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
271
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
use strict; use warnings; |
|
274
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
277
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
278
|
|
|
|
|
|
|
my $place = $wikimapia->place_getbyid({ id => 55 }); |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
print "Place title: ", $place->title, "\n"; |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub place_getbyid { |
|
285
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
286
|
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
0
|
my $fields = { 'id' => 1, 'language' => 0 }; |
|
288
|
0
|
|
|
|
|
0
|
my $url = $self->_url('place.getbyid', $fields, $params); |
|
289
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
290
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
291
|
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
0
|
return WebService::Wikimapia::Place->new($contents); |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head2 place_getbyarea() |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Returns ref to the list of object of type L. |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
300
|
|
|
|
|
|
|
| Key | Description | |
|
301
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
302
|
|
|
|
|
|
|
| lon_min | Longiture Min. | |
|
303
|
|
|
|
|
|
|
| lat_min | Latitude Min. | |
|
304
|
|
|
|
|
|
|
| lon_max | Longitude Max. | |
|
305
|
|
|
|
|
|
|
| lat_max | Latitude Max. | |
|
306
|
|
|
|
|
|
|
| x | Tile's x co-ordinate. | |
|
307
|
|
|
|
|
|
|
| y | Tile's y co-ordinate. | |
|
308
|
|
|
|
|
|
|
| z | Tile's z co-ordinate. | |
|
309
|
|
|
|
|
|
|
| page | This is page number. 1 is default. | |
|
310
|
|
|
|
|
|
|
| count | Determines the number of results/page. 50 is default. | |
|
311
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
312
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
use strict; use warnings; |
|
315
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
318
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
319
|
|
|
|
|
|
|
my $places = $wikimapia->place_getbyarea({ |
|
320
|
|
|
|
|
|
|
'lon_min' => 2.292493, |
|
321
|
|
|
|
|
|
|
'lat_min' => 48.8590143, |
|
322
|
|
|
|
|
|
|
'lon_max' => 2.293493, |
|
323
|
|
|
|
|
|
|
'lat_max' => 48.8599143 |
|
324
|
|
|
|
|
|
|
}); |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
print "Place title: ", $places->[0]->title, "\n"; |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=cut |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub place_getbyarea { |
|
331
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
332
|
|
|
|
|
|
|
|
|
333
|
0
|
0
|
|
|
|
0
|
die "ERROR: Missing params list." unless (defined $params); |
|
334
|
0
|
0
|
|
|
|
0
|
die "ERROR: Parameters have to be hash ref" unless (ref($params) eq 'HASH'); |
|
335
|
|
|
|
|
|
|
|
|
336
|
0
|
|
|
|
|
0
|
my $fields = {}; |
|
337
|
0
|
0
|
0
|
|
|
0
|
if (exists $params->{'lon_min'} |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|| exists $params->{'lat_min'} |
|
339
|
|
|
|
|
|
|
|| exists $params->{'lon_max'} |
|
340
|
|
|
|
|
|
|
|| exists $params->{'lat_max'}) { |
|
341
|
0
|
|
|
|
|
0
|
$fields->{'lon_min'} = 1; |
|
342
|
0
|
|
|
|
|
0
|
$fields->{'lat_min'} = 1; |
|
343
|
0
|
|
|
|
|
0
|
$fields->{'lon_max'} = 1; |
|
344
|
0
|
|
|
|
|
0
|
$fields->{'lat_max'} = 1; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
elsif (exists $params->{'x'} |
|
347
|
|
|
|
|
|
|
|| exists $params->{'y'} |
|
348
|
|
|
|
|
|
|
|| exists $params->{'z'}) { |
|
349
|
0
|
|
|
|
|
0
|
$fields->{'x'} = 1; |
|
350
|
0
|
|
|
|
|
0
|
$fields->{'y'} = 1; |
|
351
|
0
|
|
|
|
|
0
|
$fields->{'z'} = 1; |
|
352
|
|
|
|
|
|
|
}; |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
# Optional params |
|
355
|
0
|
|
|
|
|
0
|
$fields->{'page'} = 0; |
|
356
|
0
|
|
|
|
|
0
|
$fields->{'count'} = 0; |
|
357
|
0
|
|
|
|
|
0
|
$fields->{'language'} = 0; |
|
358
|
|
|
|
|
|
|
|
|
359
|
0
|
|
|
|
|
0
|
my $url = $self->_url('place.getbyarea', $fields, $params); |
|
360
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
361
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
362
|
|
|
|
|
|
|
|
|
363
|
0
|
|
|
|
|
0
|
my $places = []; |
|
364
|
0
|
|
|
|
|
0
|
foreach my $place (@{$contents->{'places'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
365
|
0
|
|
|
|
|
0
|
push @$places, WebService::Wikimapia::Place->new($place); |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
0
|
|
|
|
|
0
|
return $places; |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head2 place_getnearest() |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
Returns ref to the list of object of type L. |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
376
|
|
|
|
|
|
|
| Key | Description | |
|
377
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
378
|
|
|
|
|
|
|
| lon | Longitude. | |
|
379
|
|
|
|
|
|
|
| lat | Latitude. | |
|
380
|
|
|
|
|
|
|
| count | Determines the number of results/page. 50 is default. | |
|
381
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
382
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
use strict; use warnings; |
|
385
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
388
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
389
|
|
|
|
|
|
|
my $places = $wikimapia->place_getnearest({ 'lon' => 2.29451, 'lat' => 48.858252 }); |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
print "Place title: ", $places->[0]->title, "\n"; |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=cut |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub place_getnearest { |
|
396
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
397
|
|
|
|
|
|
|
|
|
398
|
0
|
|
|
|
|
0
|
my $fields = { 'lat' => 1, 'lon' => 1, 'count' => 0, 'language' => 0 }; |
|
399
|
0
|
|
|
|
|
0
|
my $url = $self->_url('place.getnearest', $fields, $params); |
|
400
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
401
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
402
|
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
0
|
my $places = []; |
|
404
|
0
|
|
|
|
|
0
|
foreach my $place (@{$contents->{'places'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
405
|
0
|
|
|
|
|
0
|
push @$places, WebService::Wikimapia::Place->new($place); |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
|
|
408
|
0
|
|
|
|
|
0
|
return $places; |
|
409
|
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head2 place_search() |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
Returns ref to the list of object of type L. |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
416
|
|
|
|
|
|
|
| Key | Description | |
|
417
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
418
|
|
|
|
|
|
|
| q | Query to search in wikimapia (UTF-8). | |
|
419
|
|
|
|
|
|
|
| lat | Coordinates of the "search point" lat means latitude. | |
|
420
|
|
|
|
|
|
|
| lon | Coordinates of the "search point" lon means longitude. | |
|
421
|
|
|
|
|
|
|
| page | This is page number. 1 is default. | |
|
422
|
|
|
|
|
|
|
| count | Determines the number of results/page. 50 is default. | |
|
423
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
424
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
use strict; use warnings; |
|
427
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
430
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
431
|
|
|
|
|
|
|
my $places = $wikimapia->place_search({ q => 'Recreation', lat => 37.7887088, lon => -122.4997044 }); |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
print "Place title: ", $places->[0]->title, "\n"; |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=cut |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
sub place_search { |
|
438
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
439
|
|
|
|
|
|
|
|
|
440
|
0
|
|
|
|
|
0
|
my $fields = { 'q' => 1, 'lat' => 1, 'lon' => 1, 'page' => 0, 'count' => 0, 'language' => 0 }; |
|
441
|
0
|
|
|
|
|
0
|
my $url = $self->_url('place.search', $fields, $params); |
|
442
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
443
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
444
|
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
0
|
my $places = []; |
|
446
|
0
|
|
|
|
|
0
|
foreach my $place (@{$contents->{'places'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
447
|
0
|
|
|
|
|
0
|
push @$places, WebService::Wikimapia::Place->new($place); |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
|
|
450
|
0
|
|
|
|
|
0
|
return $places; |
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
0
|
0
|
|
sub place_update { |
|
454
|
|
|
|
|
|
|
# TODO |
|
455
|
|
|
|
|
|
|
} |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=head2 street_getbyid() |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
Returns an object of type L. |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
462
|
|
|
|
|
|
|
| Key | Description | |
|
463
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
464
|
|
|
|
|
|
|
| id | Street Id (required). | |
|
465
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
466
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
use strict; use warnings; |
|
469
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
472
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
473
|
|
|
|
|
|
|
my $street = $wikimapia->street_getbyid({ id => 1 }); |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
print "Street title: ", $street->title, "\n"; |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=cut |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
sub street_getbyid { |
|
480
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
481
|
|
|
|
|
|
|
|
|
482
|
0
|
|
|
|
|
0
|
my $fields = { 'id' => 1, 'language' => 0 }; |
|
483
|
0
|
|
|
|
|
0
|
my $url = $self->_url('street.getbyid', $fields, $params); |
|
484
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
485
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
486
|
|
|
|
|
|
|
|
|
487
|
0
|
|
|
|
|
0
|
return WebService::Wikimapia::Street->new($contents); |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=head2 category_getbyid() |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
Returns an object of type L. |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
495
|
|
|
|
|
|
|
| Key | Description | |
|
496
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
497
|
|
|
|
|
|
|
| id | Category Id (required). | |
|
498
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
499
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
use strict; use warnings; |
|
502
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
505
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
506
|
|
|
|
|
|
|
my $category = $wikimapia->category_getbyid({ id => 203 }); |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
print "Category name: ", $category->name, "\n"; |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=cut |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
sub category_getbyid { |
|
513
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
514
|
|
|
|
|
|
|
|
|
515
|
0
|
|
|
|
|
0
|
my $fields = { 'id' => 1, 'language' => 0 }; |
|
516
|
0
|
|
|
|
|
0
|
my $url = $self->_url('category.getbyid', $fields, $params); |
|
517
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
518
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
519
|
|
|
|
|
|
|
|
|
520
|
0
|
|
|
|
|
0
|
return WebService::Wikimapia::Category->new($contents->{'category'}); |
|
521
|
|
|
|
|
|
|
} |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=head2 category_getall() |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
Returns ref to the list of object of type L. |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
528
|
|
|
|
|
|
|
| Key | Description | |
|
529
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
530
|
|
|
|
|
|
|
| page | This is page number. 1 is default. | |
|
531
|
|
|
|
|
|
|
| count | Determines the number of results/page. 50 is default. | |
|
532
|
|
|
|
|
|
|
| language | Language in ISO 639-1 format. Default is 'en'. | |
|
533
|
|
|
|
|
|
|
+----------+----------------------------------------------------------------+ |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
use strict; use warnings; |
|
536
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
539
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
540
|
|
|
|
|
|
|
my $categories = $wikimapia->category_getall; |
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
print "Category name: ", $categories->[0]->name, "\n"; |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=cut |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
sub category_getall { |
|
547
|
0
|
|
|
0
|
1
|
0
|
my ($self, $params) = @_; |
|
548
|
|
|
|
|
|
|
|
|
549
|
0
|
|
|
|
|
0
|
my ($url); |
|
550
|
0
|
0
|
|
|
|
0
|
if (defined $params) { |
|
551
|
0
|
|
|
|
|
0
|
my $fields = { 'page' => 0, 'count' => 0, 'language' => 0 }; |
|
552
|
0
|
|
|
|
|
0
|
$url = $self->_url('category.getall', $fields, $params); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
else { |
|
555
|
0
|
|
|
|
|
0
|
$url = $self->_url('category.getall'); |
|
556
|
|
|
|
|
|
|
} |
|
557
|
|
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
559
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
560
|
|
|
|
|
|
|
|
|
561
|
0
|
|
|
|
|
0
|
my $categories = []; |
|
562
|
0
|
|
|
|
|
0
|
foreach my $category (@{$contents->{categories}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
563
|
0
|
|
|
|
|
0
|
push @$categories, WebService::Wikimapia::Category->new($category); |
|
564
|
|
|
|
|
|
|
} |
|
565
|
|
|
|
|
|
|
|
|
566
|
0
|
|
|
|
|
0
|
return $categories; |
|
567
|
|
|
|
|
|
|
} |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=head2 search() [DEPRECATED] |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
Returns ref to the list object of type L. |
|
572
|
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
+-----+---------------------------------------------------------------------+ |
|
574
|
|
|
|
|
|
|
| Key | Description | |
|
575
|
|
|
|
|
|
|
+-----+---------------------------------------------------------------------+ |
|
576
|
|
|
|
|
|
|
| q | Query to search in wikimapia (UTF-8). | |
|
577
|
|
|
|
|
|
|
| lat | Coordinates of the "search point" lat means latitude. | |
|
578
|
|
|
|
|
|
|
| lon | Coordinates of the "search point" lon means longitude. | |
|
579
|
|
|
|
|
|
|
+-----+---------------------------------------------------------------------+ |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
use strict; use warnings; |
|
582
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
583
|
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
585
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
586
|
|
|
|
|
|
|
my $places = $wikimapia->search({ q => 'Recreation', lat => 37.7887088, lon => -122.4997044 }); |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
print "Place name: ", $places->[0]->name, "\n"; |
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=cut |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
sub search { |
|
593
|
3
|
|
|
3
|
1
|
1141
|
my ($self, $params) = @_; |
|
594
|
|
|
|
|
|
|
|
|
595
|
3
|
|
|
|
|
4
|
print {*STDERR} "WARNING: Deprecated method search(), please refer the perldoc.\n"; |
|
|
3
|
|
|
|
|
52
|
|
|
596
|
3
|
|
|
|
|
16
|
my $fields = { 'q' => 1, 'lat' => 1, 'lon' => 1 }; |
|
597
|
3
|
|
|
|
|
10
|
my $url = $self->_url('search', $fields, $params); |
|
598
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
599
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
600
|
|
|
|
|
|
|
|
|
601
|
0
|
|
|
|
|
0
|
my $places = []; |
|
602
|
0
|
|
|
|
|
0
|
foreach my $place (@{$contents->{'folder'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
603
|
0
|
|
|
|
|
0
|
push @$places, WebService::Wikimapia::Place->new($place); |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
|
|
606
|
0
|
|
|
|
|
0
|
return $places; |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=head2 box() [DEPRECATED] |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Returns ref to the list of object of type L. |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
+---------+-------------------------------------------------------------------+ |
|
614
|
|
|
|
|
|
|
| Key | Description | |
|
615
|
|
|
|
|
|
|
+---------+-------------------------------------------------------------------+ |
|
616
|
|
|
|
|
|
|
| bbox | Coordinates of the selected box [lon_min,lat_min,lon_max,lat_max].| |
|
617
|
|
|
|
|
|
|
| lon_min | Longiture Min. | |
|
618
|
|
|
|
|
|
|
| lat_min | Latitude Min. | |
|
619
|
|
|
|
|
|
|
| lon_max | Longitude Max. | |
|
620
|
|
|
|
|
|
|
| lat_max | Latitude Max. | |
|
621
|
|
|
|
|
|
|
| x | Tile's x co-ordinate. | |
|
622
|
|
|
|
|
|
|
| y | Tile's y co-ordinate. | |
|
623
|
|
|
|
|
|
|
| z | Tile's z co-ordinate. | |
|
624
|
|
|
|
|
|
|
+---------+-------------------------------------------------------------------+ |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
use strict; use warnings; |
|
627
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
630
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
631
|
|
|
|
|
|
|
my $places = $wikimapia->box({ bbox => '37.617188,55.677586,37.70507,55.7271128' }); |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
print "Place name: ", $places->[0]->name, "\n"; |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=cut |
|
636
|
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
sub box { |
|
638
|
3
|
|
|
3
|
1
|
1225
|
my ($self, $params) = @_; |
|
639
|
|
|
|
|
|
|
|
|
640
|
3
|
|
|
|
|
5
|
print {*STDERR} "WARNING: Deprecated method box(), please refer the perldoc.\n"; |
|
|
3
|
|
|
|
|
57
|
|
|
641
|
3
|
100
|
|
|
|
23
|
die "ERROR: Missing params list." unless (defined $params); |
|
642
|
2
|
50
|
|
|
|
8
|
die "ERROR: Parameters have to be hash ref" unless (ref($params) eq 'HASH'); |
|
643
|
|
|
|
|
|
|
|
|
644
|
2
|
|
|
|
|
4
|
my $fields = {}; |
|
645
|
2
|
100
|
|
|
|
6
|
if (exists $params->{bbox}) { |
|
646
|
1
|
|
|
|
|
3
|
$fields->{'bbox'} = 1; |
|
647
|
|
|
|
|
|
|
} |
|
648
|
|
|
|
|
|
|
else { |
|
649
|
1
|
|
|
|
|
3
|
$fields->{'lon_min'} = 1; |
|
650
|
1
|
|
|
|
|
2
|
$fields->{'lon_max'} = 1; |
|
651
|
1
|
|
|
|
|
2
|
$fields->{'lat_min'} = 1; |
|
652
|
1
|
|
|
|
|
2
|
$fields->{'lat_max'} = 1; |
|
653
|
1
|
|
|
|
|
2
|
$fields->{'x'} = 1; |
|
654
|
1
|
|
|
|
|
2
|
$fields->{'y'} = 1; |
|
655
|
1
|
|
|
|
|
1
|
$fields->{'z'} = 1; |
|
656
|
|
|
|
|
|
|
} |
|
657
|
|
|
|
|
|
|
|
|
658
|
2
|
|
|
|
|
7
|
my $url = $self->_url('box', $fields, $params); |
|
659
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
660
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
661
|
|
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
0
|
my $places = []; |
|
663
|
0
|
|
|
|
|
0
|
foreach my $content (@{$contents->{folder}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
664
|
0
|
|
|
|
|
0
|
push @$places, WebService::Wikimapia::Place->new($content); |
|
665
|
|
|
|
|
|
|
} |
|
666
|
|
|
|
|
|
|
|
|
667
|
0
|
|
|
|
|
0
|
return $places; |
|
668
|
|
|
|
|
|
|
} |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=head2 object() [DEPRECATED] |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
Returns an object of type L. |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
+---------+-----------------------------------------------------------------+ |
|
675
|
|
|
|
|
|
|
| Key | Description | |
|
676
|
|
|
|
|
|
|
+---------+-----------------------------------------------------------------+ |
|
677
|
|
|
|
|
|
|
| id | Identifier of the object you want to get information about. | |
|
678
|
|
|
|
|
|
|
+---------+-----------------------------------------------------------------+ |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
use strict; use warnings; |
|
681
|
|
|
|
|
|
|
use WebService::Wikimapia; |
|
682
|
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
|
684
|
|
|
|
|
|
|
my $wikimapia = WebService::Wikimapia->new({ api_key => $api_key }); |
|
685
|
|
|
|
|
|
|
my $object = $wikimapia->object(22139); |
|
686
|
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
print "Title: ", $object->title, "\n"; |
|
688
|
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=cut |
|
690
|
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub object { |
|
692
|
1
|
|
|
1
|
1
|
80
|
my ($self, $id) = @_; |
|
693
|
|
|
|
|
|
|
|
|
694
|
1
|
|
|
|
|
2
|
print {*STDERR} "WARNING: Deprecated method object(), please refer the perldoc.\n"; |
|
|
1
|
|
|
|
|
36
|
|
|
695
|
1
|
|
|
|
|
7
|
my $fields = { 'id' => 1 }; |
|
696
|
1
|
|
|
|
|
3
|
my $params = { 'id' => $id }; |
|
697
|
1
|
|
|
|
|
4
|
my $url = $self->_url('object', $fields, $params); |
|
698
|
0
|
|
|
|
|
0
|
my $response = $self->get($url); |
|
699
|
0
|
|
|
|
|
0
|
my $contents = from_json($response->{content}); |
|
700
|
|
|
|
|
|
|
|
|
701
|
0
|
|
|
|
|
0
|
return WebService::Wikimapia::Object->new($contents); |
|
702
|
|
|
|
|
|
|
} |
|
703
|
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
# |
|
705
|
|
|
|
|
|
|
# |
|
706
|
|
|
|
|
|
|
# PRIVATE METHODS |
|
707
|
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
sub _url { |
|
709
|
6
|
|
|
6
|
|
12
|
my ($self, $function, $fields, $params) = @_; |
|
710
|
|
|
|
|
|
|
|
|
711
|
6
|
|
|
|
|
22
|
validate($fields, $params); |
|
712
|
|
|
|
|
|
|
|
|
713
|
0
|
|
|
|
|
|
my $url = sprintf("%s?function=%s&key=%s&format=%s", $self->base_url, $function, $self->api_key, $self->format); |
|
714
|
|
|
|
|
|
|
|
|
715
|
0
|
0
|
0
|
|
|
|
if (defined $params && defined $fields) { |
|
716
|
0
|
|
|
|
|
|
foreach my $key (keys %$fields) { |
|
717
|
0
|
|
|
|
|
|
my $_key = "&$key=%" . $FIELDS->{$key}->{type}; |
|
718
|
0
|
0
|
|
|
|
|
$url .= sprintf($_key, $params->{$key}) if defined $params->{$key}; |
|
719
|
|
|
|
|
|
|
} |
|
720
|
|
|
|
|
|
|
} |
|
721
|
|
|
|
|
|
|
|
|
722
|
0
|
|
|
|
|
|
foreach my $key (keys %$fields) { |
|
723
|
0
|
0
|
0
|
|
|
|
if (!exists $params->{$key} && !$fields->{$key}) { |
|
724
|
0
|
|
|
|
|
|
my $_key = "&$key=%" . $FIELDS->{$key}->{type}; |
|
725
|
0
|
|
|
|
|
|
$url .= sprintf($_key, $self->{$key}); |
|
726
|
|
|
|
|
|
|
} |
|
727
|
|
|
|
|
|
|
} |
|
728
|
|
|
|
|
|
|
|
|
729
|
0
|
|
|
|
|
|
return $url; |
|
730
|
|
|
|
|
|
|
} |
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=head1 AUTHOR |
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
|
735
|
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
737
|
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
L |
|
739
|
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=head1 BUGS |
|
741
|
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
|
743
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at L. |
|
744
|
|
|
|
|
|
|
I will be notified and then you'll automatically be notified of progress on your |
|
745
|
|
|
|
|
|
|
bug as I make changes. |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
=head1 SUPPORT |
|
748
|
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
750
|
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
perldoc WebService::Wikimapia |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
You can also look for information at: |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
=over 4 |
|
756
|
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
758
|
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
L |
|
760
|
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
L |
|
764
|
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
L |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=item * Search CPAN |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
L |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
=back |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
776
|
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
Copyright (C) 2011 - 2015 Mohammad S Anwar. |
|
778
|
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
780
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
|
781
|
|
|
|
|
|
|
license at: |
|
782
|
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
L |
|
784
|
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
|
786
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
|
787
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
|
788
|
|
|
|
|
|
|
not accept this license. |
|
789
|
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
|
791
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
|
792
|
|
|
|
|
|
|
complies with the requirements of this license. |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
|
795
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
|
796
|
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
|
798
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
|
799
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
|
800
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
|
801
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
|
802
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
|
803
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
|
804
|
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
|
806
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
|
807
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
|
808
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
|
809
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
|
810
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
|
811
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
812
|
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
=cut |
|
814
|
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
1; # End of WebService::Wikimapia |