mapshaper 0.6.50 → 0.6.52
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 +92 -31
- package/package.json +2 -2
- package/www/mapshaper.js +92 -31
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.52";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -11259,12 +11259,6 @@
|
|
|
11259
11259
|
return ss && ss.isFile() || false;
|
|
11260
11260
|
};
|
|
11261
11261
|
|
|
11262
|
-
cli.checkCommandEnv = function(cname) {
|
|
11263
|
-
var blocked = ['i', 'include', 'require', 'external'];
|
|
11264
|
-
if (runningInBrowser() && blocked.includes(cname)) {
|
|
11265
|
-
stop('The -' + cname + ' command cannot be run in the browser');
|
|
11266
|
-
}
|
|
11267
|
-
};
|
|
11268
11262
|
|
|
11269
11263
|
// cli.fileSize = function(path) {
|
|
11270
11264
|
// var ss = cli.statSync(path);
|
|
@@ -14580,6 +14574,18 @@
|
|
|
14580
14574
|
return merged[0];
|
|
14581
14575
|
}
|
|
14582
14576
|
|
|
14577
|
+
cmd.calc = function(layers, arcs, opts) {
|
|
14578
|
+
var arr = layers.map(lyr => applyCalcExpression(lyr, arcs, opts));
|
|
14579
|
+
if (!opts.to_layer) return null;
|
|
14580
|
+
return {
|
|
14581
|
+
info: {},
|
|
14582
|
+
layers: [{
|
|
14583
|
+
name: opts.name || 'info',
|
|
14584
|
+
data: new DataTable(arr)
|
|
14585
|
+
}]
|
|
14586
|
+
};
|
|
14587
|
+
};
|
|
14588
|
+
|
|
14583
14589
|
// Calculate an expression across a group of features, print and return the result
|
|
14584
14590
|
// Supported functions include sum(), average(), max(), min(), median(), count()
|
|
14585
14591
|
// Functions receive an expression to be applied to each feature (like the -each command)
|
|
@@ -14587,9 +14593,9 @@
|
|
|
14587
14593
|
// opts.expression Expression to evaluate
|
|
14588
14594
|
// opts.where Optional filter expression (see -filter command)
|
|
14589
14595
|
//
|
|
14590
|
-
|
|
14596
|
+
function applyCalcExpression(lyr, arcs, opts) {
|
|
14591
14597
|
var msg = opts.expression,
|
|
14592
|
-
result, compiled, defs;
|
|
14598
|
+
result, compiled, defs, d;
|
|
14593
14599
|
if (opts.where) {
|
|
14594
14600
|
// TODO: implement no_replace option for filter() instead of this
|
|
14595
14601
|
lyr = getLayerSelection(lyr, arcs, opts);
|
|
@@ -14600,9 +14606,17 @@
|
|
|
14600
14606
|
defs = getStashedVar('defs');
|
|
14601
14607
|
compiled = compileCalcExpression(lyr, arcs, opts.expression);
|
|
14602
14608
|
result = compiled(null, defs);
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14609
|
+
if (!opts.to_layer) {
|
|
14610
|
+
message(msg + ": " + result);
|
|
14611
|
+
}
|
|
14612
|
+
d = {
|
|
14613
|
+
expression: opts.expression,
|
|
14614
|
+
value: result
|
|
14615
|
+
};
|
|
14616
|
+
if (opts.where) d.where = opts.where;
|
|
14617
|
+
if (lyr.name) d.layer_name = lyr.name;
|
|
14618
|
+
return d;
|
|
14619
|
+
}
|
|
14606
14620
|
|
|
14607
14621
|
function evalCalcExpression(lyr, arcs, exp) {
|
|
14608
14622
|
return compileCalcExpression(lyr, arcs, exp)();
|
|
@@ -14812,6 +14826,7 @@
|
|
|
14812
14826
|
|
|
14813
14827
|
var Calc = /*#__PURE__*/Object.freeze({
|
|
14814
14828
|
__proto__: null,
|
|
14829
|
+
applyCalcExpression: applyCalcExpression,
|
|
14815
14830
|
evalCalcExpression: evalCalcExpression,
|
|
14816
14831
|
compileCalcExpression: compileCalcExpression
|
|
14817
14832
|
});
|
|
@@ -23385,9 +23400,17 @@ ${svg}
|
|
|
23385
23400
|
alias: '+',
|
|
23386
23401
|
type: 'flag',
|
|
23387
23402
|
label: '+, no-replace', // show alias as primary option
|
|
23388
|
-
// describe: 'retain the original layer(s) instead of replacing'
|
|
23389
23403
|
describe: 'retain both input and output layer(s)'
|
|
23390
23404
|
},
|
|
23405
|
+
nameOpt2 = { // for -calc and -info
|
|
23406
|
+
describe: 'name the output layer'
|
|
23407
|
+
},
|
|
23408
|
+
noReplaceOpt2 = { // for -calc and -info
|
|
23409
|
+
alias: '+',
|
|
23410
|
+
type: 'flag',
|
|
23411
|
+
label: '+',
|
|
23412
|
+
describe: 'save output to a new layer'
|
|
23413
|
+
},
|
|
23391
23414
|
noSnapOpt = {
|
|
23392
23415
|
// describe: 'don't snap points before applying command'
|
|
23393
23416
|
type: 'flag'
|
|
@@ -24366,12 +24389,12 @@ ${svg}
|
|
|
24366
24389
|
describe: 'side length (e.g. 500m, 12km)',
|
|
24367
24390
|
type: 'distance'
|
|
24368
24391
|
})
|
|
24369
|
-
|
|
24370
|
-
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24392
|
+
.option('cols', {
|
|
24393
|
+
type: 'integer'
|
|
24394
|
+
})
|
|
24395
|
+
.option('rows', {
|
|
24396
|
+
type: 'integer'
|
|
24397
|
+
})
|
|
24375
24398
|
// .option('bbox', {
|
|
24376
24399
|
// type: 'bbox',
|
|
24377
24400
|
// describe: 'xmin,ymin,xmax,ymax (default is bbox of data)'
|
|
@@ -25282,8 +25305,8 @@ ${svg}
|
|
|
25282
25305
|
type: 'flag'
|
|
25283
25306
|
})
|
|
25284
25307
|
.option('calc', calcOpt)
|
|
25285
|
-
.option('name', nameOpt)
|
|
25286
25308
|
.option('target', targetOpt)
|
|
25309
|
+
.option('name', nameOpt)
|
|
25287
25310
|
.option('no-replace', noReplaceOpt);
|
|
25288
25311
|
|
|
25289
25312
|
parser.command('require')
|
|
@@ -25443,7 +25466,9 @@ ${svg}
|
|
|
25443
25466
|
describe: 'functions: sum() average() median() max() min() count()'
|
|
25444
25467
|
})
|
|
25445
25468
|
.option('where', whereOpt)
|
|
25446
|
-
.option('target', targetOpt)
|
|
25469
|
+
.option('target', targetOpt)
|
|
25470
|
+
.option('to-layer', noReplaceOpt2)
|
|
25471
|
+
.option('name', nameOpt2);
|
|
25447
25472
|
|
|
25448
25473
|
parser.command('colors')
|
|
25449
25474
|
.describe('print list of color scheme names');
|
|
@@ -25473,7 +25498,9 @@ ${svg}
|
|
|
25473
25498
|
.option('save-to', {
|
|
25474
25499
|
describe: 'name of file to save info in JSON format'
|
|
25475
25500
|
})
|
|
25476
|
-
.option('target', targetOpt)
|
|
25501
|
+
.option('target', targetOpt)
|
|
25502
|
+
.option('to-layer', noReplaceOpt2)
|
|
25503
|
+
.option('name', nameOpt2);
|
|
25477
25504
|
|
|
25478
25505
|
parser.command('inspect')
|
|
25479
25506
|
.describe('print information about a feature')
|
|
@@ -28106,7 +28133,6 @@ ${svg}
|
|
|
28106
28133
|
var files = opts.files || [];
|
|
28107
28134
|
var dataset;
|
|
28108
28135
|
|
|
28109
|
-
cli.checkCommandEnv('i');
|
|
28110
28136
|
if (opts.stdin) {
|
|
28111
28137
|
dataset = importFile('/dev/stdin', opts);
|
|
28112
28138
|
catalog.addDataset(dataset);
|
|
@@ -28649,7 +28675,7 @@ ${svg}
|
|
|
28649
28675
|
// Apply a command to an array of target layers
|
|
28650
28676
|
function applyCommandToEachLayer(func, targetLayers) {
|
|
28651
28677
|
var args = utils.toArray(arguments).slice(2);
|
|
28652
|
-
|
|
28678
|
+
var output = targetLayers.reduce(function(memo, lyr) {
|
|
28653
28679
|
var result = func.apply(null, [lyr].concat(args));
|
|
28654
28680
|
if (utils.isArray(result)) { // some commands return an array of layers
|
|
28655
28681
|
memo = memo.concat(result);
|
|
@@ -28658,6 +28684,7 @@ ${svg}
|
|
|
28658
28684
|
}
|
|
28659
28685
|
return memo;
|
|
28660
28686
|
}, []);
|
|
28687
|
+
return output.length > 0 ? output : null;
|
|
28661
28688
|
}
|
|
28662
28689
|
|
|
28663
28690
|
function applyCommandToEachTarget(func, targets) {
|
|
@@ -35478,8 +35505,15 @@ ${svg}
|
|
|
35478
35505
|
// Returns array of matching records in src table, or null if no matches
|
|
35479
35506
|
//
|
|
35480
35507
|
function joinTableToLayer(destLyr, src, join, opts) {
|
|
35481
|
-
var dest = destLyr.data
|
|
35482
|
-
|
|
35508
|
+
var dest = destLyr.data;
|
|
35509
|
+
|
|
35510
|
+
if (src == dest) {
|
|
35511
|
+
// self-join... duplicate source records to prevent assignment problems
|
|
35512
|
+
// (in calc= expressions and possibly elsewhere)
|
|
35513
|
+
src = src.clone();
|
|
35514
|
+
}
|
|
35515
|
+
|
|
35516
|
+
var useDuplication = !!opts.duplication,
|
|
35483
35517
|
srcRecords = src.getRecords(),
|
|
35484
35518
|
destRecords = dest.getRecords(),
|
|
35485
35519
|
prefix = opts.prefix || '',
|
|
@@ -35495,7 +35529,7 @@ ${svg}
|
|
|
35495
35529
|
retn = {},
|
|
35496
35530
|
srcRec, srcId, destRec, joins, count, filter, calc, i, j, n, m;
|
|
35497
35531
|
|
|
35498
|
-
// support for duplication of destination records
|
|
35532
|
+
// support for duplication of destination records for many-to-one joins
|
|
35499
35533
|
var duplicateRecords, destShapes;
|
|
35500
35534
|
if (useDuplication) {
|
|
35501
35535
|
if (opts.calc) stop('duplication and calc options cannot be used together');
|
|
@@ -39150,7 +39184,7 @@ ${svg}
|
|
|
39150
39184
|
var arr = layers.map(function(o) {
|
|
39151
39185
|
return getLayerInfo(o.layer, o.dataset);
|
|
39152
39186
|
});
|
|
39153
|
-
|
|
39187
|
+
|
|
39154
39188
|
if (opts.save_to) {
|
|
39155
39189
|
var output = [{
|
|
39156
39190
|
filename: opts.save_to + (opts.save_to.endsWith('.json') ? '' : '.json'),
|
|
@@ -39158,6 +39192,16 @@ ${svg}
|
|
|
39158
39192
|
}];
|
|
39159
39193
|
writeFiles(output, opts);
|
|
39160
39194
|
}
|
|
39195
|
+
if (opts.to_layer) {
|
|
39196
|
+
return {
|
|
39197
|
+
info: {},
|
|
39198
|
+
layers: [{
|
|
39199
|
+
name: opts.name || 'info',
|
|
39200
|
+
data: new DataTable(arr)
|
|
39201
|
+
}]
|
|
39202
|
+
};
|
|
39203
|
+
}
|
|
39204
|
+
message(formatInfo(arr));
|
|
39161
39205
|
};
|
|
39162
39206
|
|
|
39163
39207
|
cmd.printInfo = cmd.info; // old name
|
|
@@ -40658,6 +40702,19 @@ ${svg}
|
|
|
40658
40702
|
// Currently the origin cell is always an "outie" (protruding); in the future
|
|
40659
40703
|
// "innie" origin cells may be supported
|
|
40660
40704
|
|
|
40705
|
+
function getHexGridParams(bbox, interval, opts) {
|
|
40706
|
+
opts.type != 'hex2'; // hex2 is "pointy-top" orientation
|
|
40707
|
+
|
|
40708
|
+
// get origin and counts for centered grid
|
|
40709
|
+
// params.u0 = _getUOrigin();
|
|
40710
|
+
// params.v0 = _getVOrigin();
|
|
40711
|
+
// params.colCounts = _getColCounts(bbox, interval);
|
|
40712
|
+
// params.rowCounts = _getRowCounts(bbox, interval);
|
|
40713
|
+
|
|
40714
|
+
if (opts.aligned) ;
|
|
40715
|
+
}
|
|
40716
|
+
|
|
40717
|
+
|
|
40661
40718
|
// interval: side length in projected coordinates
|
|
40662
40719
|
// bbox: bounding box of area to be enclosed by grid
|
|
40663
40720
|
//
|
|
@@ -40672,6 +40729,8 @@ ${svg}
|
|
|
40672
40729
|
var _uOrigin = _getUOrigin();
|
|
40673
40730
|
var _vOrigin = _getVOrigin();
|
|
40674
40731
|
|
|
40732
|
+
getHexGridParams(bbox, interval, opts);
|
|
40733
|
+
|
|
40675
40734
|
function cells() {
|
|
40676
40735
|
return _rowCounts[0] * _colCounts[0] + _rowCounts[1] * _colCounts[1];
|
|
40677
40736
|
}
|
|
@@ -41821,7 +41880,9 @@ ${svg}
|
|
|
41821
41880
|
var str = standardizeConsoleCommands(raw);
|
|
41822
41881
|
var parsed = parseCommands(str);
|
|
41823
41882
|
parsed.forEach(function(cmd) {
|
|
41824
|
-
|
|
41883
|
+
if (['i', 'include', 'require', 'external'].includes(cmd.name)) {
|
|
41884
|
+
stop('The ' + cmd.name + ' command cannot be run in the web console.');
|
|
41885
|
+
}
|
|
41825
41886
|
});
|
|
41826
41887
|
return parsed;
|
|
41827
41888
|
}
|
|
@@ -44271,7 +44332,7 @@ ${svg}
|
|
|
44271
44332
|
applyCommandToEachLayer(cmd.cluster, targetLayers, arcs, opts);
|
|
44272
44333
|
|
|
44273
44334
|
} else if (name == 'calc') {
|
|
44274
|
-
|
|
44335
|
+
outputDataset = cmd.calc(targetLayers, arcs, opts);
|
|
44275
44336
|
|
|
44276
44337
|
} else if (name == 'classify') {
|
|
44277
44338
|
applyCommandToEachLayer(cmd.classify, targetLayers, targetDataset, opts);
|
|
@@ -44385,7 +44446,7 @@ ${svg}
|
|
|
44385
44446
|
cmd.include(opts);
|
|
44386
44447
|
|
|
44387
44448
|
} else if (name == 'info') {
|
|
44388
|
-
cmd.info(targets, opts);
|
|
44449
|
+
outputDataset = cmd.info(targets, opts);
|
|
44389
44450
|
|
|
44390
44451
|
} else if (name == 'inlay') {
|
|
44391
44452
|
outputLayers = cmd.inlay(targetLayers, source, targetDataset, opts);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.52",
|
|
4
4
|
"description": "A tool for editing vector datasets for mapping and GIS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapefile",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"mocha": {
|
|
77
77
|
"reporter": "dot",
|
|
78
78
|
"node-option": [
|
|
79
|
-
"experimental-
|
|
79
|
+
"experimental-loader=./test/_loader.js"
|
|
80
80
|
],
|
|
81
81
|
"check-leaks": true,
|
|
82
82
|
"parallel": true,
|
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.52";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -11259,12 +11259,6 @@
|
|
|
11259
11259
|
return ss && ss.isFile() || false;
|
|
11260
11260
|
};
|
|
11261
11261
|
|
|
11262
|
-
cli.checkCommandEnv = function(cname) {
|
|
11263
|
-
var blocked = ['i', 'include', 'require', 'external'];
|
|
11264
|
-
if (runningInBrowser() && blocked.includes(cname)) {
|
|
11265
|
-
stop('The -' + cname + ' command cannot be run in the browser');
|
|
11266
|
-
}
|
|
11267
|
-
};
|
|
11268
11262
|
|
|
11269
11263
|
// cli.fileSize = function(path) {
|
|
11270
11264
|
// var ss = cli.statSync(path);
|
|
@@ -14580,6 +14574,18 @@
|
|
|
14580
14574
|
return merged[0];
|
|
14581
14575
|
}
|
|
14582
14576
|
|
|
14577
|
+
cmd.calc = function(layers, arcs, opts) {
|
|
14578
|
+
var arr = layers.map(lyr => applyCalcExpression(lyr, arcs, opts));
|
|
14579
|
+
if (!opts.to_layer) return null;
|
|
14580
|
+
return {
|
|
14581
|
+
info: {},
|
|
14582
|
+
layers: [{
|
|
14583
|
+
name: opts.name || 'info',
|
|
14584
|
+
data: new DataTable(arr)
|
|
14585
|
+
}]
|
|
14586
|
+
};
|
|
14587
|
+
};
|
|
14588
|
+
|
|
14583
14589
|
// Calculate an expression across a group of features, print and return the result
|
|
14584
14590
|
// Supported functions include sum(), average(), max(), min(), median(), count()
|
|
14585
14591
|
// Functions receive an expression to be applied to each feature (like the -each command)
|
|
@@ -14587,9 +14593,9 @@
|
|
|
14587
14593
|
// opts.expression Expression to evaluate
|
|
14588
14594
|
// opts.where Optional filter expression (see -filter command)
|
|
14589
14595
|
//
|
|
14590
|
-
|
|
14596
|
+
function applyCalcExpression(lyr, arcs, opts) {
|
|
14591
14597
|
var msg = opts.expression,
|
|
14592
|
-
result, compiled, defs;
|
|
14598
|
+
result, compiled, defs, d;
|
|
14593
14599
|
if (opts.where) {
|
|
14594
14600
|
// TODO: implement no_replace option for filter() instead of this
|
|
14595
14601
|
lyr = getLayerSelection(lyr, arcs, opts);
|
|
@@ -14600,9 +14606,17 @@
|
|
|
14600
14606
|
defs = getStashedVar('defs');
|
|
14601
14607
|
compiled = compileCalcExpression(lyr, arcs, opts.expression);
|
|
14602
14608
|
result = compiled(null, defs);
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14609
|
+
if (!opts.to_layer) {
|
|
14610
|
+
message(msg + ": " + result);
|
|
14611
|
+
}
|
|
14612
|
+
d = {
|
|
14613
|
+
expression: opts.expression,
|
|
14614
|
+
value: result
|
|
14615
|
+
};
|
|
14616
|
+
if (opts.where) d.where = opts.where;
|
|
14617
|
+
if (lyr.name) d.layer_name = lyr.name;
|
|
14618
|
+
return d;
|
|
14619
|
+
}
|
|
14606
14620
|
|
|
14607
14621
|
function evalCalcExpression(lyr, arcs, exp) {
|
|
14608
14622
|
return compileCalcExpression(lyr, arcs, exp)();
|
|
@@ -14812,6 +14826,7 @@
|
|
|
14812
14826
|
|
|
14813
14827
|
var Calc = /*#__PURE__*/Object.freeze({
|
|
14814
14828
|
__proto__: null,
|
|
14829
|
+
applyCalcExpression: applyCalcExpression,
|
|
14815
14830
|
evalCalcExpression: evalCalcExpression,
|
|
14816
14831
|
compileCalcExpression: compileCalcExpression
|
|
14817
14832
|
});
|
|
@@ -23385,9 +23400,17 @@ ${svg}
|
|
|
23385
23400
|
alias: '+',
|
|
23386
23401
|
type: 'flag',
|
|
23387
23402
|
label: '+, no-replace', // show alias as primary option
|
|
23388
|
-
// describe: 'retain the original layer(s) instead of replacing'
|
|
23389
23403
|
describe: 'retain both input and output layer(s)'
|
|
23390
23404
|
},
|
|
23405
|
+
nameOpt2 = { // for -calc and -info
|
|
23406
|
+
describe: 'name the output layer'
|
|
23407
|
+
},
|
|
23408
|
+
noReplaceOpt2 = { // for -calc and -info
|
|
23409
|
+
alias: '+',
|
|
23410
|
+
type: 'flag',
|
|
23411
|
+
label: '+',
|
|
23412
|
+
describe: 'save output to a new layer'
|
|
23413
|
+
},
|
|
23391
23414
|
noSnapOpt = {
|
|
23392
23415
|
// describe: 'don't snap points before applying command'
|
|
23393
23416
|
type: 'flag'
|
|
@@ -24366,12 +24389,12 @@ ${svg}
|
|
|
24366
24389
|
describe: 'side length (e.g. 500m, 12km)',
|
|
24367
24390
|
type: 'distance'
|
|
24368
24391
|
})
|
|
24369
|
-
|
|
24370
|
-
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24392
|
+
.option('cols', {
|
|
24393
|
+
type: 'integer'
|
|
24394
|
+
})
|
|
24395
|
+
.option('rows', {
|
|
24396
|
+
type: 'integer'
|
|
24397
|
+
})
|
|
24375
24398
|
// .option('bbox', {
|
|
24376
24399
|
// type: 'bbox',
|
|
24377
24400
|
// describe: 'xmin,ymin,xmax,ymax (default is bbox of data)'
|
|
@@ -25282,8 +25305,8 @@ ${svg}
|
|
|
25282
25305
|
type: 'flag'
|
|
25283
25306
|
})
|
|
25284
25307
|
.option('calc', calcOpt)
|
|
25285
|
-
.option('name', nameOpt)
|
|
25286
25308
|
.option('target', targetOpt)
|
|
25309
|
+
.option('name', nameOpt)
|
|
25287
25310
|
.option('no-replace', noReplaceOpt);
|
|
25288
25311
|
|
|
25289
25312
|
parser.command('require')
|
|
@@ -25443,7 +25466,9 @@ ${svg}
|
|
|
25443
25466
|
describe: 'functions: sum() average() median() max() min() count()'
|
|
25444
25467
|
})
|
|
25445
25468
|
.option('where', whereOpt)
|
|
25446
|
-
.option('target', targetOpt)
|
|
25469
|
+
.option('target', targetOpt)
|
|
25470
|
+
.option('to-layer', noReplaceOpt2)
|
|
25471
|
+
.option('name', nameOpt2);
|
|
25447
25472
|
|
|
25448
25473
|
parser.command('colors')
|
|
25449
25474
|
.describe('print list of color scheme names');
|
|
@@ -25473,7 +25498,9 @@ ${svg}
|
|
|
25473
25498
|
.option('save-to', {
|
|
25474
25499
|
describe: 'name of file to save info in JSON format'
|
|
25475
25500
|
})
|
|
25476
|
-
.option('target', targetOpt)
|
|
25501
|
+
.option('target', targetOpt)
|
|
25502
|
+
.option('to-layer', noReplaceOpt2)
|
|
25503
|
+
.option('name', nameOpt2);
|
|
25477
25504
|
|
|
25478
25505
|
parser.command('inspect')
|
|
25479
25506
|
.describe('print information about a feature')
|
|
@@ -28106,7 +28133,6 @@ ${svg}
|
|
|
28106
28133
|
var files = opts.files || [];
|
|
28107
28134
|
var dataset;
|
|
28108
28135
|
|
|
28109
|
-
cli.checkCommandEnv('i');
|
|
28110
28136
|
if (opts.stdin) {
|
|
28111
28137
|
dataset = importFile('/dev/stdin', opts);
|
|
28112
28138
|
catalog.addDataset(dataset);
|
|
@@ -28649,7 +28675,7 @@ ${svg}
|
|
|
28649
28675
|
// Apply a command to an array of target layers
|
|
28650
28676
|
function applyCommandToEachLayer(func, targetLayers) {
|
|
28651
28677
|
var args = utils.toArray(arguments).slice(2);
|
|
28652
|
-
|
|
28678
|
+
var output = targetLayers.reduce(function(memo, lyr) {
|
|
28653
28679
|
var result = func.apply(null, [lyr].concat(args));
|
|
28654
28680
|
if (utils.isArray(result)) { // some commands return an array of layers
|
|
28655
28681
|
memo = memo.concat(result);
|
|
@@ -28658,6 +28684,7 @@ ${svg}
|
|
|
28658
28684
|
}
|
|
28659
28685
|
return memo;
|
|
28660
28686
|
}, []);
|
|
28687
|
+
return output.length > 0 ? output : null;
|
|
28661
28688
|
}
|
|
28662
28689
|
|
|
28663
28690
|
function applyCommandToEachTarget(func, targets) {
|
|
@@ -35478,8 +35505,15 @@ ${svg}
|
|
|
35478
35505
|
// Returns array of matching records in src table, or null if no matches
|
|
35479
35506
|
//
|
|
35480
35507
|
function joinTableToLayer(destLyr, src, join, opts) {
|
|
35481
|
-
var dest = destLyr.data
|
|
35482
|
-
|
|
35508
|
+
var dest = destLyr.data;
|
|
35509
|
+
|
|
35510
|
+
if (src == dest) {
|
|
35511
|
+
// self-join... duplicate source records to prevent assignment problems
|
|
35512
|
+
// (in calc= expressions and possibly elsewhere)
|
|
35513
|
+
src = src.clone();
|
|
35514
|
+
}
|
|
35515
|
+
|
|
35516
|
+
var useDuplication = !!opts.duplication,
|
|
35483
35517
|
srcRecords = src.getRecords(),
|
|
35484
35518
|
destRecords = dest.getRecords(),
|
|
35485
35519
|
prefix = opts.prefix || '',
|
|
@@ -35495,7 +35529,7 @@ ${svg}
|
|
|
35495
35529
|
retn = {},
|
|
35496
35530
|
srcRec, srcId, destRec, joins, count, filter, calc, i, j, n, m;
|
|
35497
35531
|
|
|
35498
|
-
// support for duplication of destination records
|
|
35532
|
+
// support for duplication of destination records for many-to-one joins
|
|
35499
35533
|
var duplicateRecords, destShapes;
|
|
35500
35534
|
if (useDuplication) {
|
|
35501
35535
|
if (opts.calc) stop('duplication and calc options cannot be used together');
|
|
@@ -39150,7 +39184,7 @@ ${svg}
|
|
|
39150
39184
|
var arr = layers.map(function(o) {
|
|
39151
39185
|
return getLayerInfo(o.layer, o.dataset);
|
|
39152
39186
|
});
|
|
39153
|
-
|
|
39187
|
+
|
|
39154
39188
|
if (opts.save_to) {
|
|
39155
39189
|
var output = [{
|
|
39156
39190
|
filename: opts.save_to + (opts.save_to.endsWith('.json') ? '' : '.json'),
|
|
@@ -39158,6 +39192,16 @@ ${svg}
|
|
|
39158
39192
|
}];
|
|
39159
39193
|
writeFiles(output, opts);
|
|
39160
39194
|
}
|
|
39195
|
+
if (opts.to_layer) {
|
|
39196
|
+
return {
|
|
39197
|
+
info: {},
|
|
39198
|
+
layers: [{
|
|
39199
|
+
name: opts.name || 'info',
|
|
39200
|
+
data: new DataTable(arr)
|
|
39201
|
+
}]
|
|
39202
|
+
};
|
|
39203
|
+
}
|
|
39204
|
+
message(formatInfo(arr));
|
|
39161
39205
|
};
|
|
39162
39206
|
|
|
39163
39207
|
cmd.printInfo = cmd.info; // old name
|
|
@@ -40658,6 +40702,19 @@ ${svg}
|
|
|
40658
40702
|
// Currently the origin cell is always an "outie" (protruding); in the future
|
|
40659
40703
|
// "innie" origin cells may be supported
|
|
40660
40704
|
|
|
40705
|
+
function getHexGridParams(bbox, interval, opts) {
|
|
40706
|
+
opts.type != 'hex2'; // hex2 is "pointy-top" orientation
|
|
40707
|
+
|
|
40708
|
+
// get origin and counts for centered grid
|
|
40709
|
+
// params.u0 = _getUOrigin();
|
|
40710
|
+
// params.v0 = _getVOrigin();
|
|
40711
|
+
// params.colCounts = _getColCounts(bbox, interval);
|
|
40712
|
+
// params.rowCounts = _getRowCounts(bbox, interval);
|
|
40713
|
+
|
|
40714
|
+
if (opts.aligned) ;
|
|
40715
|
+
}
|
|
40716
|
+
|
|
40717
|
+
|
|
40661
40718
|
// interval: side length in projected coordinates
|
|
40662
40719
|
// bbox: bounding box of area to be enclosed by grid
|
|
40663
40720
|
//
|
|
@@ -40672,6 +40729,8 @@ ${svg}
|
|
|
40672
40729
|
var _uOrigin = _getUOrigin();
|
|
40673
40730
|
var _vOrigin = _getVOrigin();
|
|
40674
40731
|
|
|
40732
|
+
getHexGridParams(bbox, interval, opts);
|
|
40733
|
+
|
|
40675
40734
|
function cells() {
|
|
40676
40735
|
return _rowCounts[0] * _colCounts[0] + _rowCounts[1] * _colCounts[1];
|
|
40677
40736
|
}
|
|
@@ -41821,7 +41880,9 @@ ${svg}
|
|
|
41821
41880
|
var str = standardizeConsoleCommands(raw);
|
|
41822
41881
|
var parsed = parseCommands(str);
|
|
41823
41882
|
parsed.forEach(function(cmd) {
|
|
41824
|
-
|
|
41883
|
+
if (['i', 'include', 'require', 'external'].includes(cmd.name)) {
|
|
41884
|
+
stop('The ' + cmd.name + ' command cannot be run in the web console.');
|
|
41885
|
+
}
|
|
41825
41886
|
});
|
|
41826
41887
|
return parsed;
|
|
41827
41888
|
}
|
|
@@ -44271,7 +44332,7 @@ ${svg}
|
|
|
44271
44332
|
applyCommandToEachLayer(cmd.cluster, targetLayers, arcs, opts);
|
|
44272
44333
|
|
|
44273
44334
|
} else if (name == 'calc') {
|
|
44274
|
-
|
|
44335
|
+
outputDataset = cmd.calc(targetLayers, arcs, opts);
|
|
44275
44336
|
|
|
44276
44337
|
} else if (name == 'classify') {
|
|
44277
44338
|
applyCommandToEachLayer(cmd.classify, targetLayers, targetDataset, opts);
|
|
@@ -44385,7 +44446,7 @@ ${svg}
|
|
|
44385
44446
|
cmd.include(opts);
|
|
44386
44447
|
|
|
44387
44448
|
} else if (name == 'info') {
|
|
44388
|
-
cmd.info(targets, opts);
|
|
44449
|
+
outputDataset = cmd.info(targets, opts);
|
|
44389
44450
|
|
|
44390
44451
|
} else if (name == 'inlay') {
|
|
44391
44452
|
outputLayers = cmd.inlay(targetLayers, source, targetDataset, opts);
|