forked from monsooncollective/yatayat
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli_dataquality.js
executable file
·30 lines (26 loc) · 1.05 KB
/
cli_dataquality.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
var YY = require('./yatayat.js');
var DQ = require('./dataquality.js');
var docopt = require('./docopt.coffee/');
var fs = require("fs");
var docstring = "\n" +
"Usage:\n" +
"./cli_dataquality.js <overpass.xml> [show_correct_routes] [--include-warnings]\n";
var opts = docopt.docopt(docstring);
// Load system as YY.System
var system = YY.fromOSM(fs.readFileSync(opts['<overpass.xml>'], "utf-8"));
// Run tests: this will be silent if there are no errors
if(opts['show_correct_routes']) {
console.log("CORRECT ROUTES");
console.log(DQ.findCorrectRoutes(system).map(function(route) {
return route.name + " (" + route.id + ")";
}));
} else {
var errors = DQ.errorString(system);
if(errors.length > 0)
console.log("\n\n~~~~~~~~~~~ERRORS:~~~~~~~~~~~~~~\n\n" + errors);
if (opts['--include-warnings']) {
var warnings = DQ.errorString(system, 'WARNING');
if(warnings.length > 0)
console.log("\n\n~~~~~~~~~~~WARNINGS:~~~~~~~~~~~~~~\n\n" + warnings);
}
}