-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·67 lines (63 loc) · 2 KB
/
index.js
File metadata and controls
executable file
·67 lines (63 loc) · 2 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/env node
'use strict'
/*
* Cogran.js
* A command line tool for working with geodata.
*
* index.js
* The entry point of the application. Parses user arguments and executes the desired code.
*/
const Optimist = require('optimist');
const ArealInterpolate = require('./lib/areal-interpolate');
const FileWriter = require('./lib/filewriter');
const Pckg = require('./package.json');
const Errors = require('./lib/errors');
const Logger = require('./lib/logger');
let argv = Optimist
.usage('Usage: cogran --input <input_shape.shp> --target <target_shape.shp> --output <output_shape.shp> --attr <attribute_name>')
.options('d', {
describe: 'Use (dis)aggregate mode'
})
.options('i', {
alias: 'input',
describe: 'path and name of the input geojson that will be used for aggregation/disaggregation',
demand: true
})
.options('t', {
alias: 'target',
describe: 'path and name of the target geojson',
demand: true
})
.options('o', {
alias: 'output',
describe: 'path and name of the output geojson'
})
.options('attr', {
describe: 'The attribute that will be used',
demand: true
})
.options('m', {
alias: 'mode',
describe: 'Possible values: arealWeightingAdvanced, arealWeightingRelative, attributeWeighting, attributeWeightingAdvanced, attributeWeightingRelative, binaryDasymetricWeighting, binaryDasymetricWeightingRelative, nClassDasymetricWeighting, nClassDasymetricWeightingRelative, linearRegression'
})
.options('mask', {
describe: 'path and name of the geojson with ancillary information'
})
.options('weight', {
describe: 'The attribute from target geojson that is used for weighting'
})
.check(main)
.argv;
function main(argv) {
if(argv.help) return Optimist.showHelp();
if(argv.version) return Logger.log(Pckg.version);
return ArealInterpolate(argv, res => {
if(argv.output) {
FileWriter.write(res, argv.output);
}
else {
Logger.info('no output file specified');
}
});
return Optimist.showHelp();
}