Skip to content

Commit

Permalink
refactor: modify file structure (#36)
Browse files Browse the repository at this point in the history
PR Close #36
  • Loading branch information
sarunint committed Jan 14, 2018
1 parent c6d8726 commit 4ee0a04
Show file tree
Hide file tree
Showing 90 changed files with 62 additions and 59 deletions.
13 changes: 8 additions & 5 deletions airac-parser/ivac1/airport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ const aptAirspaceMap: any = {

const basePath = resolve(__dirname);
const buildPath = resolve(basePath, 'build');
const buildAptPath = resolve(buildPath, '05-AIRPORT');
const buildRwyPath = resolve(buildPath, '06-RUNWAY');

ensureDirSync(buildPath);
ensureDirSync(buildAptPath);
ensureDirSync(buildRwyPath);

const db = new sqlite3.Database(
resolve(basePath, '..' , 'little_navmap_navigraph.sqlite')
Expand All @@ -81,8 +84,8 @@ const query = (db: sqlite3.Database, queryStr: string): Promise<any[]> => {
};

const main = async () => {
let out = '[AIRPORT]\n';
let outRwy = '[RUNWAY]\n';
let out = '';
let outRwy = '';
const zeroPadder = '0000000';
const spacePadder = ' ';
const data: {
Expand Down Expand Up @@ -154,8 +157,8 @@ const main = async () => {
outRwy += '\n';
}
}
writeFileSync(resolve(buildPath, '05-1-AIRPORT.txt'), out);
writeFileSync(resolve(buildPath, '06-1-RWY.txt'), outRwy);
writeFileSync(resolve(buildAptPath, '02-AIRPORT.txt'), out);
writeFileSync(resolve(buildRwyPath, '02-RUNWAY.txt'), outRwy);
};

main().then(() => console.log('Done'));
2 changes: 1 addition & 1 deletion airac-parser/ivac1/fir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Coordinate, convertCoordinate, convertPoint } from './latlon';
import { writeFileSync, ensureDirSync } from 'fs-extra';

const basePath = resolve(__dirname);
const buildPath = resolve(basePath, 'build', 'ARTCC');
const buildPath = resolve(basePath, 'build', '11-ARTCC');

ensureDirSync(buildPath);

Expand Down
20 changes: 11 additions & 9 deletions airac-parser/ivac1/ndb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Coordinate, convertCoordinate, convertPoint } from './latlon';
import { writeFileSync, ensureDirSync } from 'fs-extra';

const basePath = resolve(__dirname);
const buildPath = resolve(basePath, 'build');
const buildPath = resolve(basePath, 'build', '03-NDB');

ensureDirSync(buildPath);

Expand Down Expand Up @@ -51,7 +51,8 @@ const main = async () => {
lonx: number;
}[]
) => {
let out = '[NDB]\n';
let out = '';
let outNearby = '';
const padder1 = ' ';
const padder2 = '000';
for (let i = 0; i <= rows.length - 1; i++) {
Expand All @@ -65,7 +66,7 @@ const main = async () => {
out += '\n';
}

out += ';- Followings are NDB outside Bangkok FIR\n';
outNearby += ';- Followings are NDB outside Bangkok FIR\n';

for (let ndb of inclusion) {
const data = await query(
Expand All @@ -85,15 +86,16 @@ const main = async () => {
)
`
);
out += (data.ident + padder1).substr(0, 6);
outNearby += (data.ident + padder1).substr(0, 6);
const num1 = Math.floor(data.frequency / 100);
const num2 = data.frequency % 100;
out += `${num1}.${(num2 + padder2).substr(0, 3)} `;
out += convertPoint([data.laty, data.lonx], true);
out += ` ;- ${data.name}`;
out += '\n';
outNearby += `${num1}.${(num2 + padder2).substr(0, 3)} `;
outNearby += convertPoint([data.laty, data.lonx], true);
outNearby += ` ;- ${data.name}`;
outNearby += '\n';
}
writeFileSync(resolve(buildPath, '03-NDB.txt'), out);
writeFileSync(resolve(buildPath, '02-THAI.txt'), out);
writeFileSync(resolve(buildPath, '03-NEARBY.txt'), outNearby);
}
);
};
Expand Down
20 changes: 11 additions & 9 deletions airac-parser/ivac1/vor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Coordinate, convertCoordinate, convertPoint } from './latlon';
import { writeFileSync, ensureDirSync } from 'fs-extra';

const basePath = resolve(__dirname);
const buildPath = resolve(basePath, 'build');
const buildPath = resolve(basePath, 'build', '02-VOR');

ensureDirSync(buildPath);

Expand Down Expand Up @@ -63,7 +63,8 @@ const main = async () => {
lonx: number;
}[]
) => {
let out = '[VOR]\n';
let out = '';
let outNearby = '';
const padder1 = ' ';
const padder2 = '000';
for (let i = 0; i <= rows.length - 1; i++) {
Expand All @@ -77,7 +78,7 @@ const main = async () => {
out += '\n';
}

out += ';- Followings are VOR outside Bangkok FIR\n';
outNearby += ';- Followings are VOR outside Bangkok FIR\n';

for (let vor of inclusion) {
const data = await query(
Expand All @@ -97,15 +98,16 @@ const main = async () => {
)
`
);
out += (data.ident + padder1).substr(0, 4);
outNearby += (data.ident + padder1).substr(0, 4);
const num1 = Math.floor(data.frequency / 1000);
const num2 = data.frequency % 1000;
out += `${num1}.${(num2 + padder2).substr(0, 3)} `;
out += convertPoint([data.laty, data.lonx], true);
out += ` ;- ${data.name}`;
out += '\n';
outNearby += `${num1}.${(num2 + padder2).substr(0, 3)} `;
outNearby += convertPoint([data.laty, data.lonx], true);
outNearby += ` ;- ${data.name}`;
outNearby += '\n';
}
writeFileSync(resolve(buildPath, '02-VOR.txt'), out);
writeFileSync(resolve(buildPath, '02-THAI.txt'), out);
writeFileSync(resolve(buildPath, '03-NEARBY.txt'), outNearby);
}
);
};
Expand Down
2 changes: 1 addition & 1 deletion airac-parser/ivac1/waypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Coordinate, convertCoordinate, convertPoint } from './latlon';
import { writeFileSync, ensureDirSync } from 'fs-extra';

const basePath = resolve(__dirname);
const buildPath = resolve(basePath, 'build', 'FIXES');
const buildPath = resolve(basePath, 'build', '04-FIXES');

ensureDirSync(buildPath);

Expand Down
1 change: 1 addition & 0 deletions files/02-VOR/01-HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[VOR]
13 changes: 0 additions & 13 deletions files/02-VOR.txt → files/02-VOR/02-THAI.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[VOR]
BKK 117.700 N013.53.36.800 E100.35.46.300 ;- BANGKOK
BRM 117.200 N015.14.22.430 E103.15.31.590 ;- BURI RAM
BTN 115.200 N006.31.24.000 E101.44.42.000 ;- NARATHIWAT
Expand Down Expand Up @@ -45,15 +44,3 @@ TRN 116.600 N007.30.32.170 E099.37.33.670 ;- TRANG
TRT 109.900 N012.16.28.100 E102.18.50.080 ;- TRAT
UBL 112.700 N015.14.42.710 E104.51.57.300 ;- UBON UBON RATCHATHANI
UDN 114.300 N017.23.05.170 E102.46.29.810 ;- UDON THANI
;- Followings are VOR outside Bangkok FIR
BGO 112.600 N017.19.06.580 E096.31.11.550 ;- BAGO
DWI 112.000 N014.06.01.470 E098.12.27.980 ;- DAWEI
LPB 116.600 N019.54.39.460 E102.10.18.870 ;- LUANG PHABANG
PAK 115.000 N015.11.48.300 E105.44.17.000 ;- PAKSE
PNH 114.300 N011.32.38.300 E104.50.38.100 ;- PHNOM PENH
PTN 115.600 N016.48.31.280 E094.46.10.380 ;- PATHEIN
SAV 113.500 N016.33.43.700 E104.46.00.000 ;- SAVANNAKHET
SRE 113.800 N013.24.28.860 E103.48.22.760 ;- SIEM REAP
VAS 113.600 N006.11.08.400 E100.23.49.200 ;- ALOR SETAR
VKB 112.300 N006.09.48.420 E102.18.51.170 ;- KOTA BHARU
VTN 117.500 N018.00.37.300 E102.32.25.700 ;- VIENTIANE
12 changes: 12 additions & 0 deletions files/02-VOR/03-NEARBY.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;- Followings are VOR outside Bangkok FIR
BGO 112.600 N017.19.06.580 E096.31.11.550 ;- BAGO
DWI 112.000 N014.06.01.470 E098.12.27.980 ;- DAWEI
LPB 116.600 N019.54.39.460 E102.10.18.870 ;- LUANG PHABANG
PAK 115.000 N015.11.48.300 E105.44.17.000 ;- PAKSE
PNH 114.300 N011.32.38.300 E104.50.38.100 ;- PHNOM PENH
PTN 115.600 N016.48.31.280 E094.46.10.380 ;- PATHEIN
SAV 113.500 N016.33.43.700 E104.46.00.000 ;- SAVANNAKHET
SRE 113.800 N013.24.28.860 E103.48.22.760 ;- SIEM REAP
VAS 113.600 N006.11.08.400 E100.23.49.200 ;- ALOR SETAR
VKB 112.300 N006.09.48.420 E102.18.51.170 ;- KOTA BHARU
VTN 117.500 N018.00.37.300 E102.32.25.700 ;- VIENTIANE
1 change: 1 addition & 0 deletions files/03-NDB/01-HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[NDB]
3 changes: 0 additions & 3 deletions files/03-NDB.txt → files/03-NDB/02-THAI.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[NDB]
BK 293.000 N013.59.40.700 E100.39.03.200 ;- BANGKOK INTL
BR 303.000 N015.14.19.180 E103.15.09.150 ;- BURIRUM
CP 279.000 N010.43.03.930 E099.21.57.990 ;- CHUMPHON
Expand Down Expand Up @@ -39,5 +38,3 @@ UD 236.000 N017.23.16.160 E102.46.11.540 ;- UDON THANI
UP 414.000 N012.39.43.020 E100.59.41.960 ;- U-TAPHAO
UT 234.000 N012.42.06.000 E101.00.00.000 ;- U-TAPHAO INTL RAYONG
WN 270.000 N013.46.02.620 E102.19.06.280 ;- WATTHANA NAKHON
;- Followings are NDB outside Bangkok FIR
BB 484.000 N013.05.30.000 E103.13.24.000 ;- BATTAMBANG
2 changes: 2 additions & 0 deletions files/03-NDB/03-NEARBY.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
;- Followings are NDB outside Bangkok FIR
BB 484.000 N013.05.30.000 E103.13.24.000 ;- BATTAMBANG
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions files/05-AIRPORT/01-HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[AIRPORT]
1 change: 0 additions & 1 deletion files/05-1-AIRPORT.txt → files/05-AIRPORT/02-AIRPORT.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[AIRPORT]
VTBD 118.100 N013.54.51.998 E100.36.19.990 C ;- Don Mueang Intl
VTBH 122.100 N014.56.54.001 E100.38.30.013 C ;- Sa Pran Nak Aero
VTBI 122.000 N014.04.36.001 E101.22.54.005 C ;- Prachin Buri
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions files/06-RUNWAY/01-HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[RUNWAY]
1 change: 0 additions & 1 deletion files/06-1-RWY.txt → files/06-RUNWAY/02-RUNWAY.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[RUNWAY]
;- VTBD
03L 21R 030 210 N013.53.49.239 E100.35.45.383 N013.55.34.869 E100.36.44.626
03R 21L 029 209 N013.53.58.450 E100.36.05.488 N013.55.28.411 E100.36.55.970
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 12 additions & 16 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,31 @@ ensureDirSync(buildPath);

const files = [
'01-INFO.txt',
'02-VOR.txt',
'03-NDB.txt',
'05-1-AIRPORT.txt',
'05-2-CUSTOM_AIRPORT.txt',
'06-1-RWY.txt',
'06-2-CUSTOM_RWY.txt',
'09-HI_AIRWAY.txt',
'10-LO_AIRWAY.txt',
'12-ARTCC_HI.txt'
];

const folders = [
['FIXES', '04-FIXES.txt'],
['SID', '07-SID.txt'],
['STAR', '08-STAR.txt'],
['ARTCC', '11-ARTCC.txt'],
['ARTCC_LO', '13-ARTCC_LO.txt'],
['GEO', '14-GEO.txt']
['02-VOR', '02-VOR.txt'],
['03-NDB', '03-NDB.txt'],
['04-FIXES', '04-FIXES.txt'],
['05-AIRPORT', '05-AIRPORT.txt'],
['06-RUNWAY', '06-RUNWAY.txt'],
['07-SID', '07-SID.txt'],
['08-STAR', '08-STAR.txt'],
['11-ARTCC', '11-ARTCC.txt'],
['13-ARTCC_LO', '13-ARTCC_LO.txt'],
['14-GEO', '14-GEO.txt']
];

const orders = [
'01-INFO.txt',
'02-VOR.txt',
'03-NDB.txt',
'04-FIXES.txt',
'05-1-AIRPORT.txt',
'05-2-CUSTOM_AIRPORT.txt',
'06-1-RWY.txt',
'06-2-CUSTOM_RWY.txt',
'05-AIRPORT.txt',
'06-RUNWAY.txt',
'07-SID.txt',
'08-STAR.txt',
'09-HI_AIRWAY.txt',
Expand Down

0 comments on commit 4ee0a04

Please sign in to comment.