mapshaper 0.6.89 → 0.6.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mapshaper.js +31 -19
- package/package.json +1 -1
- package/www/mapshaper-gui.js +17 -19
- package/www/mapshaper.js +31 -19
- package/www/__New_Hampshire_Political_Boundaries.geojson +0 -266
- package/www/__mapshaper_snapshot_09-29.msx +0 -0
package/mapshaper.js
CHANGED
|
@@ -11557,7 +11557,6 @@
|
|
|
11557
11557
|
return ss && ss.isFile() || false;
|
|
11558
11558
|
};
|
|
11559
11559
|
|
|
11560
|
-
|
|
11561
11560
|
// cli.fileSize = function(path) {
|
|
11562
11561
|
// var ss = cli.statSync(path);
|
|
11563
11562
|
// return ss && ss.size || 0;
|
|
@@ -11600,16 +11599,32 @@
|
|
|
11600
11599
|
};
|
|
11601
11600
|
|
|
11602
11601
|
// content: Buffer or string
|
|
11603
|
-
cli.
|
|
11604
|
-
var fs = require$1('rw');
|
|
11602
|
+
cli.writeFileSync = function(fname, content) {
|
|
11605
11603
|
cli.createDirIfNeeded(fname);
|
|
11606
|
-
if (
|
|
11607
|
-
fs.
|
|
11604
|
+
if (utils.isString(content)) {
|
|
11605
|
+
require$1('fs').writeFileSync(fname, content);
|
|
11608
11606
|
} else {
|
|
11609
|
-
|
|
11607
|
+
// as of Node.js v20, on a typical machine, max buffer size is 4gb but the max
|
|
11608
|
+
// write buffer size is 2gb. An error is thrown when writing >2gb and <4gb.
|
|
11609
|
+
// To support writing files up to 4gb, files are written in chunks.
|
|
11610
|
+
cli.writeFileInChunks(fname, content, 1e7);
|
|
11610
11611
|
}
|
|
11611
11612
|
};
|
|
11612
11613
|
|
|
11614
|
+
cli.writeFileInChunks = function(fname, buffer, chunkSize) {
|
|
11615
|
+
var fs = require$1('fs');
|
|
11616
|
+
var fd = fs.openSync(fname, 'w');
|
|
11617
|
+
var offset = 0;
|
|
11618
|
+
var bufLen = buffer.length;
|
|
11619
|
+
var bytesWritten, bytesToWrite;
|
|
11620
|
+
do {
|
|
11621
|
+
bytesToWrite = Math.min(chunkSize, bufLen - offset);
|
|
11622
|
+
bytesWritten = fs.writeSync(fd, buffer, offset, bytesToWrite);
|
|
11623
|
+
offset += bytesWritten;
|
|
11624
|
+
} while (bytesWritten > 0 && offset < bufLen);
|
|
11625
|
+
fs.closeSync(fd);
|
|
11626
|
+
};
|
|
11627
|
+
|
|
11613
11628
|
// Returns Node Buffer
|
|
11614
11629
|
cli.convertArrayBuffer = function(buf) {
|
|
11615
11630
|
var src = new Uint8Array(buf),
|
|
@@ -11700,9 +11715,8 @@
|
|
|
11700
11715
|
return obj;
|
|
11701
11716
|
};
|
|
11702
11717
|
|
|
11703
|
-
function writeFiles(exports, opts
|
|
11704
|
-
|
|
11705
|
-
return _writeFiles(exports, opts, cb);
|
|
11718
|
+
async function writeFiles(exports, opts) {
|
|
11719
|
+
return _writeFiles(exports, opts);
|
|
11706
11720
|
}
|
|
11707
11721
|
|
|
11708
11722
|
// Used by GUI to replace the CLI version of writeFiles()
|
|
@@ -11711,13 +11725,13 @@
|
|
|
11711
11725
|
_writeFiles = func;
|
|
11712
11726
|
}
|
|
11713
11727
|
|
|
11714
|
-
var _writeFiles = function(exports, opts
|
|
11728
|
+
var _writeFiles = function(exports, opts) {
|
|
11715
11729
|
if (exports.length > 0 === false) {
|
|
11716
11730
|
message("No files to save");
|
|
11717
11731
|
} else if (opts.dry_run) ; else if (opts.stdout) {
|
|
11718
|
-
//
|
|
11719
|
-
// trigger EAGAIN error, e.g. when piped to less
|
|
11720
|
-
|
|
11732
|
+
// Using async writeFile() function -- synchronous output to stdout can
|
|
11733
|
+
// trigger EAGAIN error, e.g. when piped to less.
|
|
11734
|
+
require$1('rw').writeFile('/dev/stdout', exports[0].content, function() {});
|
|
11721
11735
|
} else {
|
|
11722
11736
|
if (opts.zip) {
|
|
11723
11737
|
exports = [{
|
|
@@ -11741,11 +11755,10 @@
|
|
|
11741
11755
|
if (!opts.force && inputFiles.indexOf(path) > -1) {
|
|
11742
11756
|
stop('Need to use the "-o force" option to overwrite input files.');
|
|
11743
11757
|
}
|
|
11744
|
-
cli.
|
|
11758
|
+
cli.writeFileSync(path, obj.content);
|
|
11745
11759
|
message("Wrote " + path);
|
|
11746
11760
|
});
|
|
11747
11761
|
}
|
|
11748
|
-
if (cb) cb(null);
|
|
11749
11762
|
};
|
|
11750
11763
|
|
|
11751
11764
|
function getOutputPaths(files, opts) {
|
|
@@ -23469,8 +23482,7 @@ ${svg}
|
|
|
23469
23482
|
if (pathInfo.directory) {
|
|
23470
23483
|
o.directory = pathInfo.directory;
|
|
23471
23484
|
// no longer checking for missing directory
|
|
23472
|
-
// (cli.
|
|
23473
|
-
// cli.validateOutputDir(o.directory);
|
|
23485
|
+
// (cli.writeFileSync() now creates directories that don't exist)
|
|
23474
23486
|
}
|
|
23475
23487
|
if (/gz/i.test(pathInfo.extension)) {
|
|
23476
23488
|
// handle arguments like -o out.json.gz (the preferred format)
|
|
@@ -45388,7 +45400,7 @@ ${svg}
|
|
|
45388
45400
|
//// catalog = null;
|
|
45389
45401
|
job.catalog = new Catalog();
|
|
45390
45402
|
}
|
|
45391
|
-
await
|
|
45403
|
+
await writeFiles(outputFiles, opts);
|
|
45392
45404
|
|
|
45393
45405
|
} else if (name == 'point-grid') {
|
|
45394
45406
|
outputLayers = [cmd.pointGrid(targetDataset, opts)];
|
|
@@ -45584,7 +45596,7 @@ ${svg}
|
|
|
45584
45596
|
});
|
|
45585
45597
|
}
|
|
45586
45598
|
|
|
45587
|
-
var version = "0.6.
|
|
45599
|
+
var version = "0.6.90";
|
|
45588
45600
|
|
|
45589
45601
|
// Parse command line args into commands and run them
|
|
45590
45602
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -2443,33 +2443,31 @@
|
|
|
2443
2443
|
|
|
2444
2444
|
function WriteFilesProxy(gui) {
|
|
2445
2445
|
// replace CLI version of writeFiles()
|
|
2446
|
-
internal.replaceWriteFiles(function(files, opts
|
|
2446
|
+
internal.replaceWriteFiles(async function(files, opts) {
|
|
2447
2447
|
var filename;
|
|
2448
2448
|
if (!utils$1.isArray(files) || files.length === 0) {
|
|
2449
|
-
|
|
2449
|
+
throw Error("Nothing to export");
|
|
2450
2450
|
} else if (GUI.canSaveToServer() && !opts.save_to_download_folder) {
|
|
2451
2451
|
var paths = internal.getOutputPaths(utils$1.pluck(files, 'filename'), opts);
|
|
2452
2452
|
var data = utils$1.pluck(files, 'content');
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
gui.alert(msg);
|
|
2459
|
-
// fall back to standard method if saving to server fails
|
|
2460
|
-
internal.writeFiles(files, {save_to_download_folder: true}, done);
|
|
2461
|
-
} else {
|
|
2462
|
-
if (files.length >= 1) {
|
|
2463
|
-
gui.alert('<b>Saved</b><br>' + paths.join('<br>'));
|
|
2464
|
-
}
|
|
2465
|
-
done();
|
|
2453
|
+
var msg;
|
|
2454
|
+
try {
|
|
2455
|
+
await utils$1.promisify(saveFilesToServer)(paths, data);
|
|
2456
|
+
if (files.length >= 1) {
|
|
2457
|
+
gui.alert('<b>Saved</b><br>' + paths.join('<br>'));
|
|
2466
2458
|
}
|
|
2467
|
-
})
|
|
2459
|
+
} catch(err) {
|
|
2460
|
+
msg = "<b>Direct save failed</b><br>Reason: " + err.message + ".";
|
|
2461
|
+
msg += "<br>Saving to download folder instead.";
|
|
2462
|
+
gui.alert(msg);
|
|
2463
|
+
// fall back to standard method if saving to server fails
|
|
2464
|
+
await internal.writeFiles(files, {save_to_download_folder: true});
|
|
2465
|
+
}
|
|
2468
2466
|
} else if (files.length == 1) {
|
|
2469
|
-
saveBlobToLocalFile(files[0].filename, new Blob([files[0].content])
|
|
2467
|
+
await gui.promisify(saveBlobToLocalFile)(files[0].filename, new Blob([files[0].content]));
|
|
2470
2468
|
} else {
|
|
2471
2469
|
filename = internal.getCommonFileBase(utils$1.pluck(files, 'filename')) || "output";
|
|
2472
|
-
saveZipFile(filename + ".zip", files
|
|
2470
|
+
await utils$1.promisify(saveZipFile)(filename + ".zip", files);
|
|
2473
2471
|
}
|
|
2474
2472
|
});
|
|
2475
2473
|
}
|
|
@@ -4754,7 +4752,7 @@
|
|
|
4754
4752
|
if (files.length == 1 && checkboxOn(clipboardCheckbox)) {
|
|
4755
4753
|
await saveFileContentToClipboard(files[0].content);
|
|
4756
4754
|
} else {
|
|
4757
|
-
await
|
|
4755
|
+
await internal.writeFiles(files, opts);
|
|
4758
4756
|
}
|
|
4759
4757
|
}
|
|
4760
4758
|
|
package/www/mapshaper.js
CHANGED
|
@@ -11557,7 +11557,6 @@
|
|
|
11557
11557
|
return ss && ss.isFile() || false;
|
|
11558
11558
|
};
|
|
11559
11559
|
|
|
11560
|
-
|
|
11561
11560
|
// cli.fileSize = function(path) {
|
|
11562
11561
|
// var ss = cli.statSync(path);
|
|
11563
11562
|
// return ss && ss.size || 0;
|
|
@@ -11600,16 +11599,32 @@
|
|
|
11600
11599
|
};
|
|
11601
11600
|
|
|
11602
11601
|
// content: Buffer or string
|
|
11603
|
-
cli.
|
|
11604
|
-
var fs = require$1('rw');
|
|
11602
|
+
cli.writeFileSync = function(fname, content) {
|
|
11605
11603
|
cli.createDirIfNeeded(fname);
|
|
11606
|
-
if (
|
|
11607
|
-
fs.
|
|
11604
|
+
if (utils.isString(content)) {
|
|
11605
|
+
require$1('fs').writeFileSync(fname, content);
|
|
11608
11606
|
} else {
|
|
11609
|
-
|
|
11607
|
+
// as of Node.js v20, on a typical machine, max buffer size is 4gb but the max
|
|
11608
|
+
// write buffer size is 2gb. An error is thrown when writing >2gb and <4gb.
|
|
11609
|
+
// To support writing files up to 4gb, files are written in chunks.
|
|
11610
|
+
cli.writeFileInChunks(fname, content, 1e7);
|
|
11610
11611
|
}
|
|
11611
11612
|
};
|
|
11612
11613
|
|
|
11614
|
+
cli.writeFileInChunks = function(fname, buffer, chunkSize) {
|
|
11615
|
+
var fs = require$1('fs');
|
|
11616
|
+
var fd = fs.openSync(fname, 'w');
|
|
11617
|
+
var offset = 0;
|
|
11618
|
+
var bufLen = buffer.length;
|
|
11619
|
+
var bytesWritten, bytesToWrite;
|
|
11620
|
+
do {
|
|
11621
|
+
bytesToWrite = Math.min(chunkSize, bufLen - offset);
|
|
11622
|
+
bytesWritten = fs.writeSync(fd, buffer, offset, bytesToWrite);
|
|
11623
|
+
offset += bytesWritten;
|
|
11624
|
+
} while (bytesWritten > 0 && offset < bufLen);
|
|
11625
|
+
fs.closeSync(fd);
|
|
11626
|
+
};
|
|
11627
|
+
|
|
11613
11628
|
// Returns Node Buffer
|
|
11614
11629
|
cli.convertArrayBuffer = function(buf) {
|
|
11615
11630
|
var src = new Uint8Array(buf),
|
|
@@ -11700,9 +11715,8 @@
|
|
|
11700
11715
|
return obj;
|
|
11701
11716
|
};
|
|
11702
11717
|
|
|
11703
|
-
function writeFiles(exports, opts
|
|
11704
|
-
|
|
11705
|
-
return _writeFiles(exports, opts, cb);
|
|
11718
|
+
async function writeFiles(exports, opts) {
|
|
11719
|
+
return _writeFiles(exports, opts);
|
|
11706
11720
|
}
|
|
11707
11721
|
|
|
11708
11722
|
// Used by GUI to replace the CLI version of writeFiles()
|
|
@@ -11711,13 +11725,13 @@
|
|
|
11711
11725
|
_writeFiles = func;
|
|
11712
11726
|
}
|
|
11713
11727
|
|
|
11714
|
-
var _writeFiles = function(exports, opts
|
|
11728
|
+
var _writeFiles = function(exports, opts) {
|
|
11715
11729
|
if (exports.length > 0 === false) {
|
|
11716
11730
|
message("No files to save");
|
|
11717
11731
|
} else if (opts.dry_run) ; else if (opts.stdout) {
|
|
11718
|
-
//
|
|
11719
|
-
// trigger EAGAIN error, e.g. when piped to less
|
|
11720
|
-
|
|
11732
|
+
// Using async writeFile() function -- synchronous output to stdout can
|
|
11733
|
+
// trigger EAGAIN error, e.g. when piped to less.
|
|
11734
|
+
require$1('rw').writeFile('/dev/stdout', exports[0].content, function() {});
|
|
11721
11735
|
} else {
|
|
11722
11736
|
if (opts.zip) {
|
|
11723
11737
|
exports = [{
|
|
@@ -11741,11 +11755,10 @@
|
|
|
11741
11755
|
if (!opts.force && inputFiles.indexOf(path) > -1) {
|
|
11742
11756
|
stop('Need to use the "-o force" option to overwrite input files.');
|
|
11743
11757
|
}
|
|
11744
|
-
cli.
|
|
11758
|
+
cli.writeFileSync(path, obj.content);
|
|
11745
11759
|
message("Wrote " + path);
|
|
11746
11760
|
});
|
|
11747
11761
|
}
|
|
11748
|
-
if (cb) cb(null);
|
|
11749
11762
|
};
|
|
11750
11763
|
|
|
11751
11764
|
function getOutputPaths(files, opts) {
|
|
@@ -23469,8 +23482,7 @@ ${svg}
|
|
|
23469
23482
|
if (pathInfo.directory) {
|
|
23470
23483
|
o.directory = pathInfo.directory;
|
|
23471
23484
|
// no longer checking for missing directory
|
|
23472
|
-
// (cli.
|
|
23473
|
-
// cli.validateOutputDir(o.directory);
|
|
23485
|
+
// (cli.writeFileSync() now creates directories that don't exist)
|
|
23474
23486
|
}
|
|
23475
23487
|
if (/gz/i.test(pathInfo.extension)) {
|
|
23476
23488
|
// handle arguments like -o out.json.gz (the preferred format)
|
|
@@ -45388,7 +45400,7 @@ ${svg}
|
|
|
45388
45400
|
//// catalog = null;
|
|
45389
45401
|
job.catalog = new Catalog();
|
|
45390
45402
|
}
|
|
45391
|
-
await
|
|
45403
|
+
await writeFiles(outputFiles, opts);
|
|
45392
45404
|
|
|
45393
45405
|
} else if (name == 'point-grid') {
|
|
45394
45406
|
outputLayers = [cmd.pointGrid(targetDataset, opts)];
|
|
@@ -45584,7 +45596,7 @@ ${svg}
|
|
|
45584
45596
|
});
|
|
45585
45597
|
}
|
|
45586
45598
|
|
|
45587
|
-
var version = "0.6.
|
|
45599
|
+
var version = "0.6.90";
|
|
45588
45600
|
|
|
45589
45601
|
// Parse command line args into commands and run them
|
|
45590
45602
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|