-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplace-coord-list-generator.js
332 lines (328 loc) · 6.94 KB
/
place-coord-list-generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
// Use this to get the coordinates for the places in the array
const fs = require("fs");
const path = require('path');
let places = [
"Afghanistan ",
"Albania ",
"Algeria ",
"Andorra ",
"Angola ",
"Antarctica ",
"Antigua and Barbuda ",
"Argentina ",
"Armenia ",
"Australia Australian Capital Territory",
"Australia New South Wales",
"Australia Northern Territory",
"Australia Queensland",
"Australia South Australia",
"Australia Tasmania",
"Australia Victoria",
"Australia Western Australia",
"Austria ",
"Azerbaijan ",
"Bahamas ",
"Bahrain ",
"Bangladesh ",
"Barbados ",
"Belarus ",
"Belgium ",
"Belize ",
"Benin ",
"Bhutan ",
"Bolivia ",
"Bosnia and Herzegovina ",
"Botswana ",
"Brazil ",
"Brunei ",
"Bulgaria ",
"Burkina Faso ",
"Burma ",
"Burundi ",
"Cabo Verde ",
"Cambodia ",
"Cameroon ",
"Canada Alberta",
"Canada British Columbia",
"Canada Diamond Princess",
"Canada Grand Princess",
"Canada Manitoba",
"Canada New Brunswick",
"Canada Newfoundland and Labrador",
"Canada Northwest Territories",
"Canada Nova Scotia",
"Canada Nunavut",
"Canada Ontario",
"Canada Prince Edward Island",
"Canada Quebec",
"Canada Repatriated Travellers",
"Canada Saskatchewan",
"Canada Yukon",
"Central African Republic ",
"Chad ",
"Chile ",
"China Anhui",
"China Beijing",
"China Chongqing",
"China Fujian",
"China Gansu",
"China Guangdong",
"China Guangxi",
"China Guizhou",
"China Hainan",
"China Hebei",
"China Heilongjiang",
"China Henan",
"China Hong Kong",
"China Hubei",
"China Hunan",
"China Inner Mongolia",
"China Jiangsu",
"China Jiangxi",
"China Jilin",
"China Liaoning",
"China Macau",
"China Ningxia",
"China Qinghai",
"China Shaanxi",
"China Shandong",
"China Shanghai",
"China Shanxi",
"China Sichuan",
"China Tianjin",
"China Tibet",
"China Unknown",
"China Xinjiang",
"China Yunnan",
"China Zhejiang",
"Colombia ",
"Comoros ",
"Congo (Brazzaville) ",
"Congo (Kinshasa) ",
"Costa Rica ",
"Cote d'Ivoire ",
"Croatia ",
"Cuba ",
"Cyprus ",
"Czechia ",
"Denmark Faroe Islands",
"Denmark Greenland",
"Denmark ",
"Diamond Princess ",
"Djibouti ",
"Dominica ",
"Dominican Republic ",
"Ecuador ",
"Egypt ",
"El Salvador ",
"Equatorial Guinea ",
"Eritrea ",
"Estonia ",
"Eswatini ",
"Ethiopia ",
"Fiji ",
"Finland ",
"France French Guiana",
"France French Polynesia",
"France Guadeloupe",
"France Martinique",
"France Mayotte",
"France New Caledonia",
"France Reunion",
"France Saint Barthelemy",
"France Saint Pierre and Miquelon",
"France St Martin",
"France Wallis and Futuna",
"France ",
"Gabon ",
"Gambia ",
"Georgia ",
"Germany ",
"Ghana ",
"Greece ",
"Grenada ",
"Guatemala ",
"Guinea ",
"Guinea-Bissau ",
"Guyana ",
"Haiti ",
"Holy See ",
"Honduras ",
"Hungary ",
"Iceland ",
"India ",
"Indonesia ",
"Iran ",
"Iraq ",
"Ireland ",
"Israel ",
"Italy ",
"Jamaica ",
"Japan ",
"Jordan ",
"Kazakhstan ",
"Kenya ",
"Kiribati ",
"Korea, North ",
"Korea, South ",
"Kosovo ",
"Kuwait ",
"Kyrgyzstan ",
"Laos ",
"Latvia ",
"Lebanon ",
"Lesotho ",
"Liberia ",
"Libya ",
"Liechtenstein ",
"Lithuania ",
"Luxembourg ",
"MS Zaandam ",
"Madagascar ",
"Malawi ",
"Malaysia ",
"Maldives ",
"Mali ",
"Malta ",
"Marshall Islands ",
"Mauritania ",
"Mauritius ",
"Mexico ",
"Micronesia ",
"Moldova ",
"Monaco ",
"Mongolia ",
"Montenegro ",
"Morocco ",
"Mozambique ",
"Namibia ",
"Nauru ",
"Nepal ",
"Netherlands Aruba",
"Netherlands Bonaire, Sint Eustatius and Saba",
"Netherlands Curacao",
"Netherlands Sint Maarten",
"Netherlands ",
"New Zealand Cook Islands",
"New Zealand Niue",
"New Zealand ",
"Nicaragua ",
"Niger ",
"Nigeria ",
"North Macedonia ",
"Norway ",
"Oman ",
"Pakistan ",
"Palau ",
"Panama ",
"Papua New Guinea ",
"Paraguay ",
"Peru ",
"Philippines ",
"Poland ",
"Portugal ",
"Qatar ",
"Romania ",
"Russia ",
"Rwanda ",
"Saint Kitts and Nevis ",
"Saint Lucia ",
"Saint Vincent and the Grenadines ",
"Samoa ",
"San Marino ",
"Sao Tome and Principe ",
"Saudi Arabia ",
"Senegal ",
"Serbia ",
"Seychelles ",
"Sierra Leone ",
"Singapore ",
"Slovakia ",
"Slovenia ",
"Solomon Islands ",
"Somalia ",
"South Africa ",
"South Sudan ",
"Spain ",
"Sri Lanka ",
"Sudan ",
"Summer Olympics 2020 ",
"Suriname ",
"Sweden ",
"Switzerland ",
"Syria ",
"Taiwan* ",
"Tajikistan ",
"Tanzania ",
"Thailand ",
"Timor-Leste ",
"Togo ",
"Tonga ",
"Trinidad and Tobago ",
"Tunisia ",
"Turkey ",
"Tuvalu ",
"US ",
"Uganda ",
"Ukraine ",
"United Arab Emirates ",
"United Kingdom Anguilla",
"United Kingdom Bermuda",
"United Kingdom British Virgin Islands",
"United Kingdom Cayman Islands",
"United Kingdom Channel Islands",
"United Kingdom Falkland Islands (Malvinas)",
"United Kingdom Gibraltar",
"United Kingdom Guernsey",
"United Kingdom Isle of Man",
"United Kingdom Jersey",
"United Kingdom Montserrat",
"United Kingdom Pitcairn Islands",
"United Kingdom Saint Helena, Ascension and Tristan da Cunha",
"United Kingdom Turks and Caicos Islands",
"United Kingdom ",
"Uruguay ",
"Uzbekistan ",
"Vanuatu ",
"Venezuela ",
"Vietnam ",
"West Bank and Gaza ",
"Winter Olympics 2022 ",
"Yemen ",
"Zambia ",
"Zimbabwe "
]
let places_coord = {};
let i = 0;
let interval = setInterval(async ()=>{
if(i==places.length){
clearInterval(interval)
fs.writeFileSync('Place-coordinates list.json', JSON.stringify(places_coord), {encoding: 'utf-8'});
}
try {
bindCoordinates(places[i]);
} catch (error) {
console.log(error);
}
}, 600)
async function bindCoordinates(place){
const response = await fetch(`https://geocode.maps.co/search?q=${place}`);
// console.log(response.body)
if(!response.ok)
throw new Error('Something went wrong');
let data = await response.json();
// if(data == []){
// i++;
// throw new Error(`No data found for ${place}`);
// }
data = data[0];
try{
places_coord[place] = [Number(data.lat), Number(data.lon)];
}
catch(e){
console.log(e);
console.log(place);
}
console.log(places_coord[places[i]]);
i++;
}