mapshaper 0.6.41 → 0.6.43
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 +223 -83
- package/package.json +1 -1
- package/www/index.html +1 -1
- package/www/mapshaper-gui.js +97 -28
- package/www/mapshaper.js +223 -83
- package/www/page.css +33 -18
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.43";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -1267,6 +1267,26 @@
|
|
|
1267
1267
|
_stop = stop;
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
|
+
// get detailed error information from error stack (if available)
|
|
1271
|
+
// Example stack string (Node.js):
|
|
1272
|
+
/*
|
|
1273
|
+
/Users/someuser/somescript.js:226
|
|
1274
|
+
opacity: Math.round(weight * 5 / 5 // 0.2 0.4 0.6 etc
|
|
1275
|
+
^
|
|
1276
|
+
|
|
1277
|
+
SyntaxError: missing ) after argument list
|
|
1278
|
+
at internalCompileFunction (node:internal/vm:73:18)
|
|
1279
|
+
at wrapSafe (node:internal/modules/cjs/loader:1149:20)
|
|
1280
|
+
at Module._compile (node:internal/modules/cjs/loader:1190:27)
|
|
1281
|
+
...
|
|
1282
|
+
*/
|
|
1283
|
+
function getErrorDetail(e) {
|
|
1284
|
+
var parts = (typeof e.stack == 'string') ? e.stack.split(/\n\s*\n/) : [];
|
|
1285
|
+
if (parts.length > 1 || true) {
|
|
1286
|
+
return '\nError details:\n' + parts[0];
|
|
1287
|
+
}
|
|
1288
|
+
return '';
|
|
1289
|
+
}
|
|
1270
1290
|
|
|
1271
1291
|
// print a message to stdout
|
|
1272
1292
|
function print() {
|
|
@@ -1389,6 +1409,7 @@
|
|
|
1389
1409
|
interrupt: interrupt,
|
|
1390
1410
|
message: message,
|
|
1391
1411
|
setLoggingFunctions: setLoggingFunctions,
|
|
1412
|
+
getErrorDetail: getErrorDetail,
|
|
1392
1413
|
print: print,
|
|
1393
1414
|
verbose: verbose,
|
|
1394
1415
|
debug: debug,
|
|
@@ -6359,9 +6380,10 @@
|
|
|
6359
6380
|
function mergeDatasets(arr) {
|
|
6360
6381
|
var arcSources = [],
|
|
6361
6382
|
arcCount = 0,
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6383
|
+
merged = {
|
|
6384
|
+
info: {},
|
|
6385
|
+
layers: []
|
|
6386
|
+
};
|
|
6365
6387
|
|
|
6366
6388
|
// Error if incompatible CRS
|
|
6367
6389
|
requireDatasetsHaveCompatibleCRS(arr);
|
|
@@ -6372,38 +6394,35 @@
|
|
|
6372
6394
|
arcSources.push(dataset.arcs);
|
|
6373
6395
|
}
|
|
6374
6396
|
|
|
6375
|
-
mergeDatasetInfo(
|
|
6397
|
+
mergeDatasetInfo$1(merged, dataset);
|
|
6376
6398
|
dataset.layers.forEach(function(lyr) {
|
|
6377
6399
|
if (lyr.geometry_type == 'polygon' || lyr.geometry_type == 'polyline') {
|
|
6378
6400
|
forEachArcId(lyr.shapes, function(id) {
|
|
6379
6401
|
return id < 0 ? id - arcCount : id + arcCount;
|
|
6380
6402
|
});
|
|
6381
6403
|
}
|
|
6382
|
-
|
|
6404
|
+
merged.layers.push(lyr);
|
|
6383
6405
|
});
|
|
6384
6406
|
arcCount += n;
|
|
6385
6407
|
});
|
|
6386
6408
|
|
|
6387
6409
|
if (arcSources.length > 0) {
|
|
6388
|
-
|
|
6389
|
-
if (
|
|
6410
|
+
merged.arcs = mergeArcs(arcSources);
|
|
6411
|
+
if (merged.arcs.size() != arcCount) {
|
|
6390
6412
|
error("[mergeDatasets()] Arc indexing error");
|
|
6391
6413
|
}
|
|
6392
6414
|
}
|
|
6393
6415
|
|
|
6394
|
-
return
|
|
6395
|
-
info: mergedInfo,
|
|
6396
|
-
arcs: mergedArcs,
|
|
6397
|
-
layers: mergedLayers
|
|
6398
|
-
};
|
|
6416
|
+
return merged;
|
|
6399
6417
|
}
|
|
6400
6418
|
|
|
6401
|
-
function mergeDatasetInfo(merged, dataset) {
|
|
6402
|
-
var
|
|
6403
|
-
|
|
6404
|
-
|
|
6419
|
+
function mergeDatasetInfo$1(merged, dataset) {
|
|
6420
|
+
var src = dataset.info || {};
|
|
6421
|
+
var dest = merged.info || (merged.info = {});
|
|
6422
|
+
dest.input_files = utils.uniq((dest.input_files || []).concat(src.input_files || []));
|
|
6423
|
+
dest.input_formats = utils.uniq((dest.input_formats || []).concat(src.input_formats || []));
|
|
6405
6424
|
// merge other info properties (e.g. input_geojson_crs, input_delimiter, prj, crs)
|
|
6406
|
-
utils.defaults(
|
|
6425
|
+
utils.defaults(dest, src);
|
|
6407
6426
|
}
|
|
6408
6427
|
|
|
6409
6428
|
function mergeArcs(arr) {
|
|
@@ -6450,6 +6469,7 @@
|
|
|
6450
6469
|
mergeDatasetsForExport: mergeDatasetsForExport,
|
|
6451
6470
|
mergeCommandTargets: mergeCommandTargets,
|
|
6452
6471
|
mergeDatasets: mergeDatasets,
|
|
6472
|
+
mergeDatasetInfo: mergeDatasetInfo$1,
|
|
6453
6473
|
mergeArcs: mergeArcs
|
|
6454
6474
|
});
|
|
6455
6475
|
|
|
@@ -6900,6 +6920,18 @@
|
|
|
6900
6920
|
});
|
|
6901
6921
|
}
|
|
6902
6922
|
|
|
6923
|
+
// dest: destination dataset
|
|
6924
|
+
// src: source dataset
|
|
6925
|
+
function mergeDatasetInfo(dest, src) {
|
|
6926
|
+
var srcInfo = src.info || {};
|
|
6927
|
+
var destInfo = dest.info || (dest.info = {});
|
|
6928
|
+
destInfo.input_files = utils.uniq((destInfo.input_files || []).concat(srcInfo.input_files || []));
|
|
6929
|
+
destInfo.input_formats = utils.uniq((destInfo.input_formats || []).concat(srcInfo.input_formats || []));
|
|
6930
|
+
// merge other info properties (e.g. input_geojson_crs, input_delimiter, prj, crs)
|
|
6931
|
+
utils.defaults(destInfo, srcInfo);
|
|
6932
|
+
}
|
|
6933
|
+
|
|
6934
|
+
|
|
6903
6935
|
function splitApartLayers(dataset, layers) {
|
|
6904
6936
|
var datasets = [];
|
|
6905
6937
|
dataset.layers = dataset.layers.filter(function(lyr) {
|
|
@@ -7064,6 +7096,7 @@
|
|
|
7064
7096
|
var DatasetUtils = /*#__PURE__*/Object.freeze({
|
|
7065
7097
|
__proto__: null,
|
|
7066
7098
|
splitDataset: splitDataset,
|
|
7099
|
+
mergeDatasetInfo: mergeDatasetInfo,
|
|
7067
7100
|
splitApartLayers: splitApartLayers,
|
|
7068
7101
|
copyDataset: copyDataset,
|
|
7069
7102
|
copyDatasetForExport: copyDatasetForExport,
|
|
@@ -11205,20 +11238,43 @@
|
|
|
11205
11238
|
return dest;
|
|
11206
11239
|
};
|
|
11207
11240
|
|
|
11241
|
+
// Receives a directory path, in which the final subdirectory may include the
|
|
11242
|
+
// "*" wildcard, e.g. '.' 'data' '*' 'data/*' '2023-*'
|
|
11243
|
+
// Returns an array of expanded directory names
|
|
11244
|
+
// TODO: add support for wildcards in other subdirectories
|
|
11245
|
+
cli.expandDirectoryName = function(name) {
|
|
11246
|
+
var info = parseLocalPath(name);
|
|
11247
|
+
// final directory name is parsed as info.filename
|
|
11248
|
+
if (!info.filename.includes('*')) {
|
|
11249
|
+
return [name];
|
|
11250
|
+
}
|
|
11251
|
+
var rxp = utils.wildcardToRegExp(info.filename);
|
|
11252
|
+
var dirs = [];
|
|
11253
|
+
require$1('fs').readdirSync(info.directory || '.').forEach(function(item) {
|
|
11254
|
+
var path = info.directory ? require$1('path').join(info.directory, item) : item;
|
|
11255
|
+
if (rxp.test(item) && cli.isDirectory(path)) {
|
|
11256
|
+
dirs.push(path);
|
|
11257
|
+
}
|
|
11258
|
+
});
|
|
11259
|
+
return dirs;
|
|
11260
|
+
};
|
|
11261
|
+
|
|
11208
11262
|
// Expand any "*" wild cards in file name
|
|
11209
11263
|
// (For the Windows command line; unix shells do this automatically)
|
|
11210
11264
|
cli.expandFileName = function(name) {
|
|
11211
11265
|
var info = parseLocalPath(name),
|
|
11212
11266
|
rxp = utils.wildcardToRegExp(info.filename),
|
|
11213
|
-
|
|
11267
|
+
dirs = cli.expandDirectoryName(info.directory || '.'),
|
|
11214
11268
|
files = [];
|
|
11215
11269
|
|
|
11216
11270
|
try {
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11271
|
+
dirs.forEach(function(dir) {
|
|
11272
|
+
require$1('fs').readdirSync(dir).forEach(function(item) {
|
|
11273
|
+
var path = require$1('path').join(dir, item);
|
|
11274
|
+
if (rxp.test(item) && cli.isFile(path)) {
|
|
11275
|
+
files.push(path);
|
|
11276
|
+
}
|
|
11277
|
+
});
|
|
11222
11278
|
});
|
|
11223
11279
|
} catch(e) {}
|
|
11224
11280
|
|
|
@@ -16382,19 +16438,40 @@
|
|
|
16382
16438
|
buildPolygonMosaic: buildPolygonMosaic
|
|
16383
16439
|
});
|
|
16384
16440
|
|
|
16441
|
+
// Map non-negative integers to non-negative integer ids
|
|
16442
|
+
function IdLookupIndex(n) {
|
|
16443
|
+
var index = new Uint32Array(n);
|
|
16444
|
+
|
|
16445
|
+
this.setId = function(id, val) {
|
|
16446
|
+
if (id >= 0 && val >= 0 && val < n - 1) {
|
|
16447
|
+
index[id] = val + 1;
|
|
16448
|
+
} else {
|
|
16449
|
+
error('Invalid value');
|
|
16450
|
+
}
|
|
16451
|
+
};
|
|
16452
|
+
|
|
16453
|
+
this.hasId = function(id) {
|
|
16454
|
+
return this.getId(id) > -1;
|
|
16455
|
+
};
|
|
16456
|
+
|
|
16457
|
+
this.getId = function(id) {
|
|
16458
|
+
if (id >= 0 && id < n) {
|
|
16459
|
+
return index[id] - 1;
|
|
16460
|
+
} else {
|
|
16461
|
+
error('Invalid index');
|
|
16462
|
+
}
|
|
16463
|
+
};
|
|
16464
|
+
}
|
|
16465
|
+
|
|
16466
|
+
|
|
16385
16467
|
// Map positive or negative integer ids to non-negative integer ids
|
|
16386
|
-
function
|
|
16468
|
+
function ArcLookupIndex(n) {
|
|
16387
16469
|
var fwdIndex = new Int32Array(n);
|
|
16388
16470
|
var revIndex = new Int32Array(n);
|
|
16389
|
-
var index = this;
|
|
16390
|
-
var setList = [];
|
|
16391
16471
|
utils.initializeArray(fwdIndex, -1);
|
|
16392
16472
|
utils.initializeArray(revIndex, -1);
|
|
16393
16473
|
|
|
16394
16474
|
this.setId = function(id, val) {
|
|
16395
|
-
if (clearable && !index.hasId(id)) {
|
|
16396
|
-
setList.push(id);
|
|
16397
|
-
}
|
|
16398
16475
|
if (id < 0) {
|
|
16399
16476
|
revIndex[~id] = val;
|
|
16400
16477
|
} else {
|
|
@@ -16402,25 +16479,8 @@
|
|
|
16402
16479
|
}
|
|
16403
16480
|
};
|
|
16404
16481
|
|
|
16405
|
-
this.clear = function() {
|
|
16406
|
-
if (!clearable) {
|
|
16407
|
-
error('Index is not clearable');
|
|
16408
|
-
}
|
|
16409
|
-
setList.forEach(function(id) {
|
|
16410
|
-
index.setId(id, -1);
|
|
16411
|
-
});
|
|
16412
|
-
setList = [];
|
|
16413
|
-
};
|
|
16414
|
-
|
|
16415
|
-
this.clearId = function(id) {
|
|
16416
|
-
if (!index.hasId(id)) {
|
|
16417
|
-
error('Tried to clear an unset id');
|
|
16418
|
-
}
|
|
16419
|
-
index.setId(id, -1);
|
|
16420
|
-
};
|
|
16421
|
-
|
|
16422
16482
|
this.hasId = function(id) {
|
|
16423
|
-
var val =
|
|
16483
|
+
var val = this.getId(id);
|
|
16424
16484
|
return val > -1;
|
|
16425
16485
|
};
|
|
16426
16486
|
|
|
@@ -16433,6 +16493,36 @@
|
|
|
16433
16493
|
};
|
|
16434
16494
|
}
|
|
16435
16495
|
|
|
16496
|
+
// Support clearing the index (for efficient reuse)
|
|
16497
|
+
function ClearableArcLookupIndex(n) {
|
|
16498
|
+
var setList = [];
|
|
16499
|
+
var idx = new ArcLookupIndex(n);
|
|
16500
|
+
var _setId = idx.setId;
|
|
16501
|
+
|
|
16502
|
+
idx.setId = function(id, val) {
|
|
16503
|
+
if (!idx.hasId(id)) {
|
|
16504
|
+
setList.push(id);
|
|
16505
|
+
}
|
|
16506
|
+
_setId(id, val);
|
|
16507
|
+
};
|
|
16508
|
+
|
|
16509
|
+
idx.clear = function() {
|
|
16510
|
+
setList.forEach(function(id) {
|
|
16511
|
+
_setId(id, -1);
|
|
16512
|
+
});
|
|
16513
|
+
setList = [];
|
|
16514
|
+
};
|
|
16515
|
+
|
|
16516
|
+
this.clearId = function(id) {
|
|
16517
|
+
if (!idx.hasId(id)) {
|
|
16518
|
+
error('Tried to clear an unset id');
|
|
16519
|
+
}
|
|
16520
|
+
_setId(id, -1);
|
|
16521
|
+
};
|
|
16522
|
+
|
|
16523
|
+
return idx;
|
|
16524
|
+
}
|
|
16525
|
+
|
|
16436
16526
|
// Associate mosaic tiles with shapes (i.e. identify the groups of tiles that
|
|
16437
16527
|
// belong to each shape)
|
|
16438
16528
|
//
|
|
@@ -16684,7 +16774,7 @@
|
|
|
16684
16774
|
// Supports looking up a shape id using an arc id.
|
|
16685
16775
|
function ShapeArcIndex(shapes, arcs) {
|
|
16686
16776
|
var n = arcs.size();
|
|
16687
|
-
var index = new
|
|
16777
|
+
var index = new ArcLookupIndex(n);
|
|
16688
16778
|
var shapeId;
|
|
16689
16779
|
shapes.forEach(onShape);
|
|
16690
16780
|
|
|
@@ -16836,7 +16926,7 @@
|
|
|
16836
16926
|
var arcs = dataset.arcs;
|
|
16837
16927
|
var filter = getArcPresenceTest(lyr.shapes, arcs);
|
|
16838
16928
|
var nodes = new NodeCollection(arcs, filter);
|
|
16839
|
-
var arcIndex = new
|
|
16929
|
+
var arcIndex = new ClearableArcLookupIndex(arcs.size());
|
|
16840
16930
|
lyr.shapes = lyr.shapes.map(function(shp, i) {
|
|
16841
16931
|
if (!shp) return null;
|
|
16842
16932
|
// split parts at nodes (where multiple arcs intersect)
|
|
@@ -28239,20 +28329,23 @@ ${svg}
|
|
|
28239
28329
|
};
|
|
28240
28330
|
|
|
28241
28331
|
this.setDefaultTarget = function(layers, dataset) {
|
|
28242
|
-
|
|
28243
|
-
datasets.push(dataset);
|
|
28244
|
-
}
|
|
28245
|
-
defaultTargets = [{
|
|
28332
|
+
this.setDefaultTargets([{
|
|
28246
28333
|
// Copy layers array, in case layers is a reference to dataset.layers.
|
|
28247
28334
|
// This prevents layers that are added to the dataset inside a command from
|
|
28248
28335
|
// being added to the next command's target, e.g. debugging layers added
|
|
28249
28336
|
// by '-join unmatched unjoined'.
|
|
28250
28337
|
layers: layers.concat(),
|
|
28251
28338
|
dataset: dataset
|
|
28252
|
-
}];
|
|
28339
|
+
}]);
|
|
28253
28340
|
};
|
|
28254
28341
|
|
|
28342
|
+
// arr: array of target objects {layers:[], dataset:{}}
|
|
28255
28343
|
this.setDefaultTargets = function(arr) {
|
|
28344
|
+
arr.forEach(function(target) {
|
|
28345
|
+
if (datasets.indexOf(target.dataset) == -1) {
|
|
28346
|
+
datasets.push(target.dataset);
|
|
28347
|
+
}
|
|
28348
|
+
});
|
|
28256
28349
|
defaultTargets = arr;
|
|
28257
28350
|
};
|
|
28258
28351
|
|
|
@@ -28345,6 +28438,30 @@ ${svg}
|
|
|
28345
28438
|
stashVar('input_files', job.input_files);
|
|
28346
28439
|
}
|
|
28347
28440
|
|
|
28441
|
+
// Apply a command to an array of target layers
|
|
28442
|
+
function applyCommandToEachLayer(func, targetLayers) {
|
|
28443
|
+
var args = utils.toArray(arguments).slice(2);
|
|
28444
|
+
return targetLayers.reduce(function(memo, lyr) {
|
|
28445
|
+
var result = func.apply(null, [lyr].concat(args));
|
|
28446
|
+
if (utils.isArray(result)) { // some commands return an array of layers
|
|
28447
|
+
memo = memo.concat(result);
|
|
28448
|
+
} else if (result) { // assuming result is a layer
|
|
28449
|
+
memo.push(result);
|
|
28450
|
+
}
|
|
28451
|
+
return memo;
|
|
28452
|
+
}, []);
|
|
28453
|
+
}
|
|
28454
|
+
|
|
28455
|
+
function applyCommandToEachTarget(func, targets) {
|
|
28456
|
+
var args = utils.toArray(arguments).slice(2);
|
|
28457
|
+
targets.forEach(function(target) {
|
|
28458
|
+
var result = func.apply(null, [target].concat(args));
|
|
28459
|
+
if (result) {
|
|
28460
|
+
error('Unexpected output from command');
|
|
28461
|
+
}
|
|
28462
|
+
});
|
|
28463
|
+
}
|
|
28464
|
+
|
|
28348
28465
|
cmd.addShape = addShape;
|
|
28349
28466
|
|
|
28350
28467
|
function addShape(targetLayers, targetDataset, opts) {
|
|
@@ -36290,6 +36407,7 @@ ${svg}
|
|
|
36290
36407
|
var opts = parseExternalCommand(name, cmdDefn, cmdOpts._);
|
|
36291
36408
|
var targets = catalog.findCommandTargets(opts.target || '*');
|
|
36292
36409
|
var target = targets[0];
|
|
36410
|
+
var output;
|
|
36293
36411
|
if (!target) {
|
|
36294
36412
|
stop('Missing a target');
|
|
36295
36413
|
}
|
|
@@ -36300,12 +36418,34 @@ ${svg}
|
|
|
36300
36418
|
stop("Targetting layers from multiple datasets is not supported");
|
|
36301
36419
|
}
|
|
36302
36420
|
if (targetType == 'layer') {
|
|
36303
|
-
cmdDefn.command(target.layers[0], target.dataset, opts.options);
|
|
36421
|
+
output = cmdDefn.command(target.layers[0], target.dataset, opts.options);
|
|
36304
36422
|
} else if (targetType == 'layers') {
|
|
36305
|
-
cmdDefn.command(target.layers, target.dataset, opts.options);
|
|
36423
|
+
output = cmdDefn.command(target.layers, target.dataset, opts.options);
|
|
36424
|
+
}
|
|
36425
|
+
if (output) {
|
|
36426
|
+
integrateOutput(output, target, catalog, opts);
|
|
36306
36427
|
}
|
|
36307
36428
|
};
|
|
36308
36429
|
|
|
36430
|
+
// TODO: remove restrictions on output data
|
|
36431
|
+
function integrateOutput(output, input, catalog, opts) {
|
|
36432
|
+
if (!output.dataset || !output.layers || output.layers.length > 0 === false) {
|
|
36433
|
+
stop('Invalid command output');
|
|
36434
|
+
}
|
|
36435
|
+
if (output.dataset == input.dataset) {
|
|
36436
|
+
stop('External commands are not currently allowed to modify input datasets');
|
|
36437
|
+
}
|
|
36438
|
+
if (output.dataset.layers.length != output.layers.length) {
|
|
36439
|
+
stop('Currently not supported: targetting a subset of output layers');
|
|
36440
|
+
}
|
|
36441
|
+
if (!opts.no_replace) {
|
|
36442
|
+
input.layers.forEach(function(lyr) {
|
|
36443
|
+
catalog.deleteLayer(lyr, input.dataset);
|
|
36444
|
+
});
|
|
36445
|
+
}
|
|
36446
|
+
catalog.addDataset(output.dataset);
|
|
36447
|
+
}
|
|
36448
|
+
|
|
36309
36449
|
function parseExternalCommand(name, cmdDefn, tokens) {
|
|
36310
36450
|
var parser = new CommandParser();
|
|
36311
36451
|
var cmd = parser.command(name);
|
|
@@ -38156,7 +38296,7 @@ ${svg}
|
|
|
38156
38296
|
// polygon layer, @clipData). This avoids performing unnecessary intersection
|
|
38157
38297
|
// tests on each line segment.
|
|
38158
38298
|
var layers = dataset.layers.filter(function(lyr) {
|
|
38159
|
-
return !layerIsFullyEnclosed(lyr, dataset, clipData);
|
|
38299
|
+
return layerHasGeometry(lyr) && !layerIsFullyEnclosed(lyr, dataset, clipData);
|
|
38160
38300
|
});
|
|
38161
38301
|
if (layers.length > 0) {
|
|
38162
38302
|
clipLayersInPlace(layers, clipData, dataset, 'clip');
|
|
@@ -40720,7 +40860,8 @@ ${svg}
|
|
|
40720
40860
|
function makeCircleCoords(center, opts) {
|
|
40721
40861
|
var margin = opts.cell_margin > 0 ? opts.cell_margin : 1e-6;
|
|
40722
40862
|
var radius = opts.interval / 2 * (1 - margin);
|
|
40723
|
-
|
|
40863
|
+
var vertices = opts.vertices || 20;
|
|
40864
|
+
return getPointBufferCoordinates(center, radius, vertices, getPlanarSegmentEndpoint);
|
|
40724
40865
|
}
|
|
40725
40866
|
|
|
40726
40867
|
// Returns a function that receives a cell index and returns indices of points
|
|
@@ -40731,12 +40872,15 @@ ${svg}
|
|
|
40731
40872
|
var bboxIndex = new Flatbush(points.length);
|
|
40732
40873
|
var empty = [];
|
|
40733
40874
|
points.forEach(function(p) {
|
|
40875
|
+
var bbox = getPointBounds(p, radius);
|
|
40734
40876
|
addPointToGridIndex(p, gridIndex, grid);
|
|
40735
|
-
bboxIndex.add.apply(bboxIndex,
|
|
40877
|
+
bboxIndex.add.apply(bboxIndex, bbox);
|
|
40736
40878
|
});
|
|
40737
40879
|
bboxIndex.finish();
|
|
40738
40880
|
return function(i) {
|
|
40739
|
-
if (!gridIndex.hasId(i))
|
|
40881
|
+
if (!gridIndex.hasId(i)) {
|
|
40882
|
+
return empty;
|
|
40883
|
+
}
|
|
40740
40884
|
var bbox = grid.idxToBBox(i);
|
|
40741
40885
|
var indices = bboxIndex.search.apply(bboxIndex, bbox);
|
|
40742
40886
|
return indices;
|
|
@@ -40870,6 +41014,7 @@ ${svg}
|
|
|
40870
41014
|
calcWeights: calcWeights,
|
|
40871
41015
|
twoCircleIntersection: twoCircleIntersection,
|
|
40872
41016
|
makeCellPolygon: makeCellPolygon,
|
|
41017
|
+
makeCircleCoords: makeCircleCoords,
|
|
40873
41018
|
getPointIndex: getPointIndex,
|
|
40874
41019
|
getAlignedGridBounds: getAlignedGridBounds,
|
|
40875
41020
|
getCenteredGridBounds: getCenteredGridBounds,
|
|
@@ -41198,8 +41343,7 @@ ${svg}
|
|
|
41198
41343
|
}
|
|
41199
41344
|
}
|
|
41200
41345
|
} catch(e) {
|
|
41201
|
-
|
|
41202
|
-
stop('Unable to load external module:', e.message);
|
|
41346
|
+
stop('Unable to load external module:', e.message, getErrorDetail(e));
|
|
41203
41347
|
}
|
|
41204
41348
|
if (moduleName || opts.alias) {
|
|
41205
41349
|
defs[opts.alias || moduleName] = mod;
|
|
@@ -42230,9 +42374,10 @@ ${svg}
|
|
|
42230
42374
|
}
|
|
42231
42375
|
};
|
|
42232
42376
|
|
|
42233
|
-
cmd.snap = function(
|
|
42377
|
+
cmd.snap = function(target, opts) {
|
|
42234
42378
|
var interval = 0;
|
|
42235
42379
|
var snapCount = 0;
|
|
42380
|
+
var dataset = target.dataset;
|
|
42236
42381
|
var arcs = dataset.arcs;
|
|
42237
42382
|
var arcBounds = arcs && arcs.getBounds();
|
|
42238
42383
|
if (!arcBounds || !arcBounds.hasBounds()) {
|
|
@@ -43367,7 +43512,7 @@ ${svg}
|
|
|
43367
43512
|
function commandAcceptsMultipleTargetDatasets(name) {
|
|
43368
43513
|
return name == 'rotate' || name == 'info' || name == 'proj' || name == 'require' ||
|
|
43369
43514
|
name == 'drop' || name == 'target' || name == 'if' || name == 'elif' ||
|
|
43370
|
-
name == 'else' || name == 'endif' || name == 'run' || name == 'i';
|
|
43515
|
+
name == 'else' || name == 'endif' || name == 'run' || name == 'i' || name == 'snap';
|
|
43371
43516
|
}
|
|
43372
43517
|
|
|
43373
43518
|
function commandAcceptsEmptyTarget(name) {
|
|
@@ -43449,6 +43594,10 @@ ${svg}
|
|
|
43449
43594
|
source = findCommandSource(convertSourceName(opts.source, targets), job.catalog, opts);
|
|
43450
43595
|
}
|
|
43451
43596
|
|
|
43597
|
+
// identify command target/input (for postprocessing)
|
|
43598
|
+
// TODO: support commands with multiple target datasets
|
|
43599
|
+
// target = name == 'i' ? null : targets[0];
|
|
43600
|
+
|
|
43452
43601
|
if (name == 'add-shape') {
|
|
43453
43602
|
if (!targetDataset) {
|
|
43454
43603
|
targetDataset = {info: {}, layers: []};
|
|
@@ -43556,6 +43705,9 @@ ${svg}
|
|
|
43556
43705
|
} else if (name == 'graticule') {
|
|
43557
43706
|
job.catalog.addDataset(cmd.graticule(targetDataset, opts));
|
|
43558
43707
|
|
|
43708
|
+
} else if (name == 'grid') {
|
|
43709
|
+
outputDataset = cmd.polygonGrid(targetLayers, targetDataset, opts);
|
|
43710
|
+
|
|
43559
43711
|
} else if (name == 'help') {
|
|
43560
43712
|
// placing help command here to handle errors from invalid command names
|
|
43561
43713
|
cmd.printHelp(command.options);
|
|
@@ -43627,9 +43779,6 @@ ${svg}
|
|
|
43627
43779
|
} else if (name == 'point-to-grid') {
|
|
43628
43780
|
outputLayers = cmd.pointToGrid(targetLayers, targetDataset, opts);
|
|
43629
43781
|
|
|
43630
|
-
} else if (name == 'grid') {
|
|
43631
|
-
outputDataset = cmd.polygonGrid(targetLayers, targetDataset, opts);
|
|
43632
|
-
|
|
43633
43782
|
} else if (name == 'points') {
|
|
43634
43783
|
outputLayers = applyCommandToEachLayer(cmd.createPointLayer, targetLayers, targetDataset, opts);
|
|
43635
43784
|
|
|
@@ -43693,7 +43842,8 @@ ${svg}
|
|
|
43693
43842
|
outputLayers = cmd.sliceLayers(targetLayers, source, targetDataset, opts);
|
|
43694
43843
|
|
|
43695
43844
|
} else if (name == 'snap') {
|
|
43696
|
-
cmd.snap(targetDataset, opts);
|
|
43845
|
+
// cmd.snap(targetDataset, opts);
|
|
43846
|
+
applyCommandToEachTarget(targets, opts);
|
|
43697
43847
|
|
|
43698
43848
|
} else if (name == 'sort') {
|
|
43699
43849
|
applyCommandToEachLayer(cmd.sortFeatures, targetLayers, arcs, opts);
|
|
@@ -43784,9 +43934,12 @@ ${svg}
|
|
|
43784
43934
|
|
|
43785
43935
|
// delete arcs if no longer needed (e.g. after -points command)
|
|
43786
43936
|
// (after output layers have been integrated)
|
|
43937
|
+
// TODO: be more selective (e.g. -i command doesn't need cleanup)
|
|
43938
|
+
// or: detect if arcs have been changed
|
|
43787
43939
|
if (targetDataset) {
|
|
43788
43940
|
cleanupArcs(targetDataset);
|
|
43789
43941
|
}
|
|
43942
|
+
|
|
43790
43943
|
} catch(e) {
|
|
43791
43944
|
return done(e);
|
|
43792
43945
|
}
|
|
@@ -43808,20 +43961,6 @@ ${svg}
|
|
|
43808
43961
|
});
|
|
43809
43962
|
}
|
|
43810
43963
|
|
|
43811
|
-
// Apply a command to an array of target layers
|
|
43812
|
-
function applyCommandToEachLayer(func, targetLayers) {
|
|
43813
|
-
var args = utils.toArray(arguments).slice(2);
|
|
43814
|
-
return targetLayers.reduce(function(memo, lyr) {
|
|
43815
|
-
var result = func.apply(null, [lyr].concat(args));
|
|
43816
|
-
if (utils.isArray(result)) { // some commands return an array of layers
|
|
43817
|
-
memo = memo.concat(result);
|
|
43818
|
-
} else if (result) { // assuming result is a layer
|
|
43819
|
-
memo.push(result);
|
|
43820
|
-
}
|
|
43821
|
-
return memo;
|
|
43822
|
-
}, []);
|
|
43823
|
-
}
|
|
43824
|
-
|
|
43825
43964
|
// Parse command line args into commands and run them
|
|
43826
43965
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
|
43827
43966
|
// function(argv[, input], callback)
|
|
@@ -44465,6 +44604,7 @@ ${svg}
|
|
|
44465
44604
|
editArcs,
|
|
44466
44605
|
GeoJSONReader,
|
|
44467
44606
|
Heap,
|
|
44607
|
+
IdLookupIndex,
|
|
44468
44608
|
NodeCollection,
|
|
44469
44609
|
parseDMS,
|
|
44470
44610
|
formatDMS,
|
package/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -172,7 +172,7 @@ precision=0.001. Click to see all options.</div></div></div></a>
|
|
|
172
172
|
|
|
173
173
|
<!-- <div class="cancel-btn btn dialog-btn">Cancel</div> -->
|
|
174
174
|
<div class="save-btn btn dialog-btn">Export</div>
|
|
175
|
-
<span id="save-preference"><input type="checkbox"/>choose directory</span>
|
|
175
|
+
<span id="save-preference" class="inline-checkbox" style="display: none;"><input type="checkbox"/>choose directory</span>
|
|
176
176
|
|
|
177
177
|
</div>
|
|
178
178
|
</div>
|