-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-index.js
72 lines (59 loc) · 2.62 KB
/
post-index.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
const fs = require('fs');
const path = require('path');
const PDFMerger = require('pdf-merger-js');
if (process.argv.length <= 2) {
console.log("usage: node post-index.js 2023-04-22");
process.exit(0);
}
const effectiveAiracDate = process.argv[2].substring(0, 10);
(async () => {
// merge RKSS area chart
if (!fs.existsSync(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART.pdf`)) {
var rkssMerger = new PDFMerger();
await rkssMerger.add(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART(DEP).pdf`);
await rkssMerger.add(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART(ARR).pdf`);
await rkssMerger.save(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART.pdf`);
fs.unlinkSync(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART(DEP).pdf`)
fs.unlinkSync(`AIP/${effectiveAiracDate}/AD/RKSS/AREA CHART(ARR).pdf`)
}
// copy RKSI MSA from RKSI to RKSS
fs.copyFileSync(
`AIP/${effectiveAiracDate}/AD/RKSI/ATC SURVEILLANCE MINIMUM ALTITUDE CHART.pdf`,
`AIP/${effectiveAiracDate}/AD/RKSS/ATC SURVEILLANCE MINIMUM ALTITUDE CHART.pdf`
);
// copy RKPD OBST CHART from A to B
fs.copyFileSync(
`AIP/${effectiveAiracDate}/AD/RKPD/AD OBSTACLE CHART TYPE A.pdf`,
`AIP/${effectiveAiracDate}/AD/RKPD/AD OBSTACLE CHART TYPE B.pdf`
);
// generate json
const chartTypes =
[
"AD CHART",
"AD GROUND MOVEMENT CHART",
"AD OBSTACLE CHART TYPE A",
"AD OBSTACLE CHART TYPE B",
"AIRCRAFT PARKING DOCKING CHART",
"AREA CHART",
"ATC SURVEILLANCE MINIMUM ALTITUDE CHART",
"BIRD CONCENTRATION CHART",
"INSTR APCH CHART",
"PRECISION APP TERRAIN CHART",
"SID",
"STAR",
"TEXT",
"VISUAL APCH CHART"
];
var airportList = fs.readdirSync(`AIP/${effectiveAiracDate}/AD`).filter(e => !e.startsWith("AD") && !e.startsWith("chartInformation.json"));
var map = {};
airportList.forEach(e => {
map[e] = {};
chartTypes.forEach(f => {
map[e][f] = fs.existsSync(`AIP/${effectiveAiracDate}/AD/${e}/${f}.pdf`);
console.log(`AIP/${effectiveAiracDate}/AD/${e}/${f}.pdf : ${map[e][f]}`);
});
});
fs.writeFileSync(`AIP/${effectiveAiracDate}/AD/chartInformation.json`, JSON.stringify(map, null, '\t'));
// generate effective date
fs.writeFileSync(`AIP/effectiveDateInformation.json`, JSON.stringify(fs.readdirSync('AIP').filter(e => e.length == 10).sort().reverse(), null, '\t'));
})();