-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpredownload.js
28 lines (25 loc) · 996 Bytes
/
predownload.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
const fs = require('fs');
const https = require('https');
const csv = require('csvtojson');
if (!fs.existsSync('temp')) {
fs.mkdirSync('temp');
}
// download whole world airport
if (!fs.existsSync('temp/airports.json')) {
https.get("https://raw.githubusercontent.com/davidmegginson/ourairports-data/main/airports.csv", (response) => {
response.on('end', function () {
csv()
.fromFile('temp/airports.csv')
.then((jsonObj) => {
fs.writeFileSync('temp/airports.json', JSON.stringify(jsonObj, null, '\t'));
})
});
response.pipe(fs.createWriteStream('temp/airports.csv'));
});
}
// download fir boundary
if (!fs.existsSync('temp/boundaries.json')) {
https.get("https://raw.githubusercontent.com/vatsimnetwork/vatspy-data-project/master/Boundaries.geojson", (response) => {
response.pipe(fs.createWriteStream('temp/boundaries.json'));
});
}