-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
33 lines (31 loc) · 824 Bytes
/
cli.js
File metadata and controls
33 lines (31 loc) · 824 Bytes
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
/*jshint esversion: 10*/
import fs from 'fs/promises';
import { process_gpx_string } from './main.js';
let trks = [];
if(process.argv.length < 3) {
console.error(`Call: npm run run <input-files...>`);
process.exit(1);
}
for(let i = 2; i < process.argv.length; ++i) {
const file = process.argv[i];
let target = file.replace(/.gpx/, '-pois.kml');
if(target === file) {
target += '-pois.kml';
}
console.log(`Read Input ${file} ...`);
const input = await fs.readFile(file, { encoding: 'utf8' });
const output = await process_gpx_string(input, file, {
cementery: 1,
shelter: 2,
toilet: 3,
water: 3,
gas: 5,
shop: 3,
food: 3,
camping: 10,
bicycle_shop: 20
});
console.log(`Write Output ${target} ...`);
await fs.writeFile(target, output, 'utf8');
}
console.log('Done');