-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
37 lines (34 loc) · 1.51 KB
/
cli.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
#!/usr/bin/env node
const { AixmConverter } = require('./src/aixm-converter');
const program = require('commander');
program
.option('-f, --input-filepath <inFilepath>', 'The input file path to the AIXM file')
.option('-o, --output-filepath <outFilepath>', 'The output filename of the generated GeoJSON file')
.option(
'-T, --type <type>',
'The type to read from AIXM file. Currently only "airspace" is supported. (default: "airspace")'
)
.option('-V, --validate', 'If specified, converter will validate geometries.')
.option('-F, --fix-geometry', 'If specified, converter will try to fix geometries.')
.option(
'-S, --strict-schema-validation',
'If specified, converter will strictly validate the created GeoJSON against the underlying schema. If the GeoJSON does not match the JSON schema, the converter will throw an error.'
)
.parse(process.argv);
(async () => {
const type = program.type || 'airspace';
const validateGeometry = program.validate || false;
const fixGeometry = program.fixGeometry || false;
const strictSchemaValidation = program.strictSchemaValidation || false;
const converter = new AixmConverter({
validateGeometries: validateGeometry,
fixGeometries: fixGeometry,
strictSchemaValidation,
});
try {
await converter.convertFromFile(program.inputFilepath, { type });
await converter.toGeojsonFile(program.outputFilepath);
} catch (e) {
console.log(e.message);
}
})();