forked from perliedman/query-overpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·35 lines (31 loc) · 910 Bytes
/
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
#!/usr/bin/env node
var concat = require('concat-stream'),
argv = require('minimist')(process.argv.slice(2), {
string: 'overpass-url',
boolean: 'flat-properties',
boolean: 'version',
default: {
'flat-properties': false
}
}),
fs = require('fs'),
overpass = require('./');
if (argv['version']) {
process.stdout.write(require('./package.json').version+'\n');
process.exit(0);
}
function openData(s) {
var query = s.toString();
overpass(query, function(err, geojson) {
if (!err) {
console.log(JSON.stringify(geojson));
} else {
console.error(err);
process.exit(1);
}
}, {
overpassUrl: argv['overpass-url'],
flatProperties: argv['flat-properties']
});
}
((argv._[0] && fs.createReadStream(argv._[0])) || process.stdin).pipe(concat(openData));