-
Notifications
You must be signed in to change notification settings - Fork 9
/
cli.js
41 lines (34 loc) · 1.22 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
38
39
40
41
#!/usr/bin/env node
const gdal = require("gdal-next")
// const chalk = require('chalk');
const fs = require('fs');
const TiffTile = require('./src/lib/tiffTile');
const pkg = require('./package.json');
const commander = require('commander'); // include commander in git clone of commander repo
const program = new commander.Command();
program
.option('-o, --out <path>', 'output file path, if not input use src path instead')
.option('-s, --src <path>', 'source file path')
.option('-z, --minZoom <type>', '最小等级')
.option('-Z, --maxZoom <type>', '最大等级');
program.parse(process.argv);
// program
// .version(pkg.version)
// .description(chalk.green('GoGoCode 代码转换从未如此简单 https://gogocode.io'));
const options = program.opts();
console.log(options)
if (options.out) {
if (!fs.existsSync(options.out)) {
fs.mkdirSync(options.out)
fs.mkdirSync(`${options.out}/temp`)
}
}
if (options.minZoom && options.maxZoom && options.src) {
var dataset = gdal.open(options.src);
const tiffTile = new TiffTile(dataset,options.out);
for (let i = options.minZoom; i <= options.maxZoom; i++) {
tiffTile.createBoundsTile(i);
}
fs.rm
}
console.log('完成')