mapshaper 0.6.88 → 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 +2 -2
- package/www/index.html +2 -2
- package/www/mapshaper-gui.js +69 -58
- package/www/mapshaper.js +31 -19
- package/www/page.css +6 -5
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.90",
|
|
4
4
|
"description": "A tool for editing vector datasets for mapping and GIS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapefile",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"iconv-lite": "^0.6.3",
|
|
57
57
|
"idb-keyval": "^6.2.0",
|
|
58
58
|
"kdbush": "^3.0.0",
|
|
59
|
-
"mproj": "0.0.
|
|
59
|
+
"mproj": "0.0.39",
|
|
60
60
|
"msgpackr": "^1.10.1",
|
|
61
61
|
"opn": "^5.3.0",
|
|
62
62
|
"rw": "~1.3.3",
|
package/www/index.html
CHANGED
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
<div class="erase-btn btn sidebar-btn">Erase</div>
|
|
124
124
|
<div class="rect-btn btn sidebar-btn">Rectangle</div>
|
|
125
125
|
<div class="frame-btn btn sidebar-btn">Frame</div>
|
|
126
|
-
<div class="info-btn btn sidebar-btn">
|
|
126
|
+
<div class="info-btn btn sidebar-btn">Bounds</div>
|
|
127
127
|
<div class="box-coords selectable"></div>
|
|
128
128
|
<div class="cancel-btn btn sidebar-btn">Cancel</div>
|
|
129
129
|
</div>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
<div class="filter-btn btn sidebar-btn">Keep</div>
|
|
136
136
|
<div class="duplicate-btn btn sidebar-btn">Duplicate</div>
|
|
137
137
|
<div class="split-btn btn sidebar-btn">Split</div>
|
|
138
|
-
<div class="coords-btn btn sidebar-btn toggle-btn">
|
|
138
|
+
<div class="coords-btn btn sidebar-btn toggle-btn">Bounds</div>
|
|
139
139
|
<div class="box-coords selectable"></div>
|
|
140
140
|
<div class="data-btn btn sidebar-btn toggle-btn">Edit data</div>
|
|
141
141
|
<div class="cancel-btn btn sidebar-btn">Clear</div>
|
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
|
}
|
|
@@ -3500,15 +3498,6 @@
|
|
|
3500
3498
|
}
|
|
3501
3499
|
}
|
|
3502
3500
|
|
|
3503
|
-
function deleteFeature(lyr, fid) {
|
|
3504
|
-
var records = lyr.data?.getRecords();
|
|
3505
|
-
if (records) records.splice(fid, 1);
|
|
3506
|
-
lyr.shapes.splice(fid, 1);
|
|
3507
|
-
if (isProjectedLayer(lyr) && lyr.shapes != lyr.gui.displayLayer.shapes) {
|
|
3508
|
-
lyr.gui.displayLayer.shapes.splice(fid, 1);
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
|
|
3512
3501
|
// p: one point in source data coords
|
|
3513
3502
|
function appendNewPoint(lyr, p) {
|
|
3514
3503
|
lyr.shapes.push([p]);
|
|
@@ -3521,15 +3510,20 @@
|
|
|
3521
3510
|
}
|
|
3522
3511
|
}
|
|
3523
3512
|
|
|
3524
|
-
function
|
|
3525
|
-
|
|
3513
|
+
function deleteFeature(lyr, fid) {
|
|
3514
|
+
var records = lyr.data?.getRecords();
|
|
3515
|
+
if (records) records.splice(fid, 1);
|
|
3516
|
+
lyr.shapes.splice(fid, 1);
|
|
3517
|
+
if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
|
|
3518
|
+
lyr.gui.displayLayer.shapes.splice(fid, 1); // point layer
|
|
3519
|
+
}
|
|
3526
3520
|
}
|
|
3527
3521
|
|
|
3528
|
-
function
|
|
3522
|
+
function insertFeature(lyr, fid, shp, d) {
|
|
3529
3523
|
var records = lyr.data?.getRecords();
|
|
3530
3524
|
if (records) records.splice(fid, 0, d);
|
|
3531
3525
|
lyr.shapes.splice(fid, 0, shp);
|
|
3532
|
-
if (isProjectedLayer(lyr)) {
|
|
3526
|
+
if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
|
|
3533
3527
|
var shp2 = projectPointCoords(shp, lyr.gui.projectPoint);
|
|
3534
3528
|
lyr.gui.displayLayer.shapes.splice(fid, 0, shp2);
|
|
3535
3529
|
}
|
|
@@ -4255,6 +4249,10 @@
|
|
|
4255
4249
|
setDisplayProjection(gui, cmd);
|
|
4256
4250
|
} else {
|
|
4257
4251
|
line.hide(); // hide cursor while command is being run
|
|
4252
|
+
// quit certain edit modes
|
|
4253
|
+
if (!gui.interaction.modeWorksWithConsole(gui.interaction.getMode())) {
|
|
4254
|
+
gui.interaction.turnOff();
|
|
4255
|
+
}
|
|
4258
4256
|
runMapshaperCommands(cmd, function(err, flags) {
|
|
4259
4257
|
if (flags) {
|
|
4260
4258
|
gui.clearMode();
|
|
@@ -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
|
|
|
@@ -5606,12 +5604,12 @@
|
|
|
5606
5604
|
addHistoryState(undo, redo);
|
|
5607
5605
|
});
|
|
5608
5606
|
|
|
5609
|
-
gui.on('
|
|
5607
|
+
gui.on('feature_delete', function(e) {
|
|
5610
5608
|
var redo = function() {
|
|
5611
|
-
|
|
5609
|
+
deleteFeature(e.data.target, e.fid);
|
|
5612
5610
|
};
|
|
5613
5611
|
var undo = function() {
|
|
5614
|
-
|
|
5612
|
+
insertFeature(e.data.target, e.fid, e.coords, e.d);
|
|
5615
5613
|
};
|
|
5616
5614
|
addHistoryState(undo, redo);
|
|
5617
5615
|
});
|
|
@@ -5966,6 +5964,10 @@
|
|
|
5966
5964
|
setMode('off');
|
|
5967
5965
|
};
|
|
5968
5966
|
|
|
5967
|
+
this.modeWorksWithConsole = function(mode) {
|
|
5968
|
+
return ['off', 'info'];
|
|
5969
|
+
};
|
|
5970
|
+
|
|
5969
5971
|
this.modeUsesHitDetection = function(mode) {
|
|
5970
5972
|
return ['info', 'selection', 'data', 'labels', 'edit_points', 'vertices', 'rectangles', 'edit_lines', 'edit_polygons'].includes(mode);
|
|
5971
5973
|
};
|
|
@@ -10243,8 +10245,8 @@
|
|
|
10243
10245
|
function removePoint(target, id) {
|
|
10244
10246
|
var d = target.data ? target.data.getRecords()[id] : null;
|
|
10245
10247
|
var coords = target.shapes[id];
|
|
10246
|
-
|
|
10247
|
-
gui.dispatchEvent('
|
|
10248
|
+
deleteFeature(target, id);
|
|
10249
|
+
gui.dispatchEvent('feature_delete', {coords, d, target, fid: id});
|
|
10248
10250
|
gui.dispatchEvent('map-needs-refresh');
|
|
10249
10251
|
hit.setHitId(-1);
|
|
10250
10252
|
}
|
|
@@ -10492,7 +10494,7 @@
|
|
|
10492
10494
|
}
|
|
10493
10495
|
|
|
10494
10496
|
gui.keyboard.on('keydown', function(e) {
|
|
10495
|
-
if (
|
|
10497
|
+
if (pathDrawing() && e.keyName == 'space') {
|
|
10496
10498
|
e.stopPropagation(); // prevent console from opening if shift-panning
|
|
10497
10499
|
}
|
|
10498
10500
|
}, null, 1);
|
|
@@ -10506,6 +10508,7 @@
|
|
|
10506
10508
|
deleteActiveVertex(e, vInfo);
|
|
10507
10509
|
};
|
|
10508
10510
|
}
|
|
10511
|
+
|
|
10509
10512
|
// don't allow copying of open paths as geojson in polygon mode
|
|
10510
10513
|
gui.contextMenu.open(e, target);
|
|
10511
10514
|
});
|
|
@@ -10669,7 +10672,7 @@
|
|
|
10669
10672
|
|
|
10670
10673
|
// esc or enter key finishes a path
|
|
10671
10674
|
gui.keyboard.on('keydown', function(e) {
|
|
10672
|
-
if (
|
|
10675
|
+
if (pathDrawing() && (e.keyName == 'esc' || e.keyName == 'enter')) {
|
|
10673
10676
|
e.stopPropagation();
|
|
10674
10677
|
finishCurrentPath();
|
|
10675
10678
|
e.originalEvent.preventDefault(); // block console "enter"
|
|
@@ -12402,6 +12405,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12402
12405
|
|
|
12403
12406
|
this.pixelCoordsToLngLatCoords = function(x, y) {
|
|
12404
12407
|
var crsFrom = this.getDisplayCRS();
|
|
12408
|
+
if (!crsFrom) return null; // e.g. table view
|
|
12405
12409
|
var p1 = internal.toLngLat(_ext.translatePixelCoords(x, y), crsFrom);
|
|
12406
12410
|
var p2 = internal.toLngLat(_ext.translatePixelCoords(x+1, y+1), crsFrom);
|
|
12407
12411
|
return p1 && p2 && p1[1] <= 90 && p1[1] >= -90 ?
|
|
@@ -12893,10 +12897,12 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12893
12897
|
}
|
|
12894
12898
|
|
|
12895
12899
|
function addMenuItem(label, func) {
|
|
12900
|
+
var prefix = '• ';
|
|
12901
|
+
|
|
12896
12902
|
El('div')
|
|
12897
12903
|
.appendTo(menu)
|
|
12898
12904
|
.addClass('contextmenu-item')
|
|
12899
|
-
.html(label)
|
|
12905
|
+
.html(prefix + label)
|
|
12900
12906
|
.on('click', func)
|
|
12901
12907
|
.show();
|
|
12902
12908
|
}
|
|
@@ -12909,28 +12915,36 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12909
12915
|
}
|
|
12910
12916
|
|
|
12911
12917
|
this.open = function(e, lyr) {
|
|
12918
|
+
var copyable = e.ids?.length;
|
|
12912
12919
|
if (lyr && !lyr.gui.geographic) return; // no popup for tabular data
|
|
12913
12920
|
menu.empty();
|
|
12914
12921
|
|
|
12915
12922
|
// menu contents
|
|
12916
12923
|
//
|
|
12917
|
-
if (e.deleteVertex) {
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12924
|
+
if (e.deleteVertex || e.deletePoint || copyable || e.deleteFeature) {
|
|
12925
|
+
|
|
12926
|
+
addMenuLabel('selection');
|
|
12927
|
+
if (e.deleteVertex) {
|
|
12928
|
+
addMenuItem('delete vertex', e.deleteVertex);
|
|
12929
|
+
}
|
|
12930
|
+
if (e.deletePoint) {
|
|
12931
|
+
addMenuItem('delete point', e.deletePoint);
|
|
12932
|
+
}
|
|
12933
|
+
if (e.ids?.length) {
|
|
12934
|
+
addMenuItem('copy as GeoJSON', copyGeoJSON);
|
|
12935
|
+
}
|
|
12936
|
+
if (e.deleteFeature) {
|
|
12937
|
+
addMenuItem(getDeleteLabel(), e.deleteFeature);
|
|
12938
|
+
}
|
|
12928
12939
|
}
|
|
12940
|
+
|
|
12929
12941
|
if (e.lonlat_coordinates) {
|
|
12930
|
-
|
|
12942
|
+
addMenuLabel('longitude, latitude');
|
|
12943
|
+
addCoords(e.lonlat_coordinates);
|
|
12931
12944
|
}
|
|
12932
12945
|
if (e.projected_coordinates) {
|
|
12933
|
-
|
|
12946
|
+
addMenuLabel('easting, northing');
|
|
12947
|
+
addCoords(e.projected_coordinates);
|
|
12934
12948
|
}
|
|
12935
12949
|
|
|
12936
12950
|
if (menu.node().childNodes.length === 0) {
|
|
@@ -12952,16 +12966,13 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12952
12966
|
menu.show();
|
|
12953
12967
|
|
|
12954
12968
|
function getDeleteLabel() {
|
|
12955
|
-
return '
|
|
12969
|
+
return 'delete ' + (lyr.geometry_type == 'point' ? 'point' : 'shape');
|
|
12956
12970
|
}
|
|
12957
12971
|
|
|
12958
|
-
function addCoords(p
|
|
12972
|
+
function addCoords(p) {
|
|
12959
12973
|
var coordStr = p[0] + ',' + p[1];
|
|
12960
12974
|
// var displayStr = '• ' + coordStr.replace(/-/g, '–').replace(',', ', ');
|
|
12961
12975
|
var displayStr = coordStr.replace(/-/g, '–').replace(',', ', ');
|
|
12962
|
-
if (label) {
|
|
12963
|
-
addMenuLabel(label);
|
|
12964
|
-
}
|
|
12965
12976
|
addMenuItem(displayStr, function() {
|
|
12966
12977
|
saveFileContentToClipboard(coordStr);
|
|
12967
12978
|
});
|
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.
|
package/www/page.css
CHANGED
|
@@ -1380,17 +1380,18 @@ body.pan.panning .map-layers:not(.drawing) {
|
|
|
1380
1380
|
.contextmenu-item {
|
|
1381
1381
|
background-color: #fff;
|
|
1382
1382
|
white-space: nowrap;
|
|
1383
|
-
padding:
|
|
1384
|
-
line-height: 11px;
|
|
1383
|
+
padding: 3px 10px 4px 10px;
|
|
1385
1384
|
cursor: pointer;
|
|
1385
|
+
font-size: 13px;
|
|
1386
|
+
line-height: 13px;
|
|
1386
1387
|
}
|
|
1387
1388
|
|
|
1388
1389
|
.contextmenu-label {
|
|
1389
1390
|
color: #999;
|
|
1390
|
-
font-size: 82%;
|
|
1391
1391
|
white-space: nowrap;
|
|
1392
|
-
padding:
|
|
1393
|
-
|
|
1392
|
+
padding: 4px 10px 1px 10px;
|
|
1393
|
+
font-size: 12px;
|
|
1394
|
+
line-height: 12px;
|
|
1394
1395
|
margin-top: -2px;
|
|
1395
1396
|
}
|
|
1396
1397
|
|