mapshaper 0.6.30 → 0.6.32
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 +69 -55
- package/package.json +2 -2
- package/www/index.html +21 -12
- package/www/mapshaper-gui.js +22 -10
- package/www/mapshaper.js +69 -55
- package/www/modules.js +4 -1
- package/www/page.css +30 -5
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.32";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -24840,13 +24840,12 @@ ${svg}
|
|
|
24840
24840
|
|
|
24841
24841
|
parser.command('run')
|
|
24842
24842
|
.describe('create commands on-the-fly and run them')
|
|
24843
|
-
.option('
|
|
24844
|
-
// TODO: remove this option
|
|
24845
|
-
})
|
|
24846
|
-
.option('commands', {
|
|
24843
|
+
.option('expression', {
|
|
24847
24844
|
DEFAULT: true,
|
|
24848
|
-
describe: '
|
|
24845
|
+
describe: 'JS expression to generate command(s)'
|
|
24849
24846
|
})
|
|
24847
|
+
// deprecated
|
|
24848
|
+
.option('commands', {alias_to: 'expression'})
|
|
24850
24849
|
.option('target', targetOpt);
|
|
24851
24850
|
|
|
24852
24851
|
parser.command('scalebar')
|
|
@@ -34730,7 +34729,64 @@ ${svg}
|
|
|
34730
34729
|
};
|
|
34731
34730
|
}
|
|
34732
34731
|
|
|
34733
|
-
|
|
34732
|
+
function compileIfCommandExpression(expr, catalog, opts) {
|
|
34733
|
+
return compileLayerExpression(expr, catalog, opts);
|
|
34734
|
+
}
|
|
34735
|
+
|
|
34736
|
+
|
|
34737
|
+
function compileLayerExpression(expr, catalog, opts) {
|
|
34738
|
+
var targetId = opts.layer || opts.target || null;
|
|
34739
|
+
var targets = catalog.findCommandTargets(targetId);
|
|
34740
|
+
var isSingle = targets.length == 1 && targets[0].layers.length == 1;
|
|
34741
|
+
if (targets.length === 0 && targetId) {
|
|
34742
|
+
stop('Layer not found:', targetId);
|
|
34743
|
+
}
|
|
34744
|
+
// var vars = getAssignedVars(exp);
|
|
34745
|
+
var defs = getStashedVar('defs') || {};
|
|
34746
|
+
|
|
34747
|
+
var ctx;
|
|
34748
|
+
if (isSingle) {
|
|
34749
|
+
ctx = getLayerProxy(targets[0].layers[0], targets[0].dataset.arcs);
|
|
34750
|
+
} else {
|
|
34751
|
+
ctx = getNullLayerProxy(targets);
|
|
34752
|
+
}
|
|
34753
|
+
ctx.global = defs; // TODO: remove duplication with mapshaper.expressions.mjs
|
|
34754
|
+
var exprOpts = Object.assign({returns: true}, opts);
|
|
34755
|
+
var func = compileExpressionToFunction(expr, exprOpts);
|
|
34756
|
+
|
|
34757
|
+
// @geoType: optional geometry type (polygon, polyline, point, null);
|
|
34758
|
+
ctx.layer_exists = function(name, geoType) {
|
|
34759
|
+
try {
|
|
34760
|
+
var targets = catalog.findCommandTargets(name, geoType);
|
|
34761
|
+
if (targets.length > 0) return true;
|
|
34762
|
+
} catch(e) {}
|
|
34763
|
+
return false;
|
|
34764
|
+
};
|
|
34765
|
+
|
|
34766
|
+
ctx.file_exists = function(file) {
|
|
34767
|
+
return cli.isFile(file);
|
|
34768
|
+
};
|
|
34769
|
+
|
|
34770
|
+
return function() {
|
|
34771
|
+
try {
|
|
34772
|
+
return func.call(ctx, defs, ctx);
|
|
34773
|
+
} catch(e) {
|
|
34774
|
+
// if (opts.quiet) throw e;
|
|
34775
|
+
stop(e.name, "in expression [" + expr + "]:", e.message);
|
|
34776
|
+
}
|
|
34777
|
+
};
|
|
34778
|
+
}
|
|
34779
|
+
|
|
34780
|
+
/*
|
|
34781
|
+
cmd.define_v2 = function(catalog, opts) {
|
|
34782
|
+
if (!opts.expression) {
|
|
34783
|
+
stop('Missing an assignment expression');
|
|
34784
|
+
}
|
|
34785
|
+
compileLayerExpression(opts.expression, catalog, opts)();
|
|
34786
|
+
};
|
|
34787
|
+
*/
|
|
34788
|
+
|
|
34789
|
+
cmd.define = function(catalog, opts) {
|
|
34734
34790
|
if (!opts.expression) {
|
|
34735
34791
|
stop('Missing an assignment expression');
|
|
34736
34792
|
}
|
|
@@ -38418,46 +38474,6 @@ ${svg}
|
|
|
38418
38474
|
return job.control || (job.control = {});
|
|
38419
38475
|
}
|
|
38420
38476
|
|
|
38421
|
-
function compileIfCommandExpression(expr, catalog, opts) {
|
|
38422
|
-
var targetId = opts.layer || opts.target || null;
|
|
38423
|
-
var targets = catalog.findCommandTargets(targetId);
|
|
38424
|
-
var isSingle = targets.length == 1 && targets[0].layers.length == 1;
|
|
38425
|
-
if (targets.length === 0 && targetId) {
|
|
38426
|
-
stop('Layer not found:', targetId);
|
|
38427
|
-
}
|
|
38428
|
-
var ctx;
|
|
38429
|
-
if (isSingle) {
|
|
38430
|
-
ctx = getLayerProxy(targets[0].layers[0], targets[0].dataset.arcs);
|
|
38431
|
-
} else {
|
|
38432
|
-
ctx = getNullLayerProxy(targets);
|
|
38433
|
-
}
|
|
38434
|
-
ctx.global = getStashedVar('defs') || {}; // TODO: remove duplication with mapshaper.expressions.mjs
|
|
38435
|
-
var exprOpts = Object.assign({returns: true}, opts);
|
|
38436
|
-
var func = compileExpressionToFunction(expr, exprOpts);
|
|
38437
|
-
|
|
38438
|
-
// @geoType: optional geometry type (polygon, polyline, point, null);
|
|
38439
|
-
ctx.layer_exists = function(name, geoType) {
|
|
38440
|
-
try {
|
|
38441
|
-
var targets = catalog.findCommandTargets(name, geoType);
|
|
38442
|
-
if (targets.length > 0) return true;
|
|
38443
|
-
} catch(e) {}
|
|
38444
|
-
return false;
|
|
38445
|
-
};
|
|
38446
|
-
|
|
38447
|
-
ctx.file_exists = function(file) {
|
|
38448
|
-
return cli.isFile(file);
|
|
38449
|
-
};
|
|
38450
|
-
|
|
38451
|
-
return function() {
|
|
38452
|
-
try {
|
|
38453
|
-
return func.call(ctx, {}, ctx);
|
|
38454
|
-
} catch(e) {
|
|
38455
|
-
// if (opts.quiet) throw e;
|
|
38456
|
-
stop(e.name, "in expression [" + expr + "]:", e.message);
|
|
38457
|
-
}
|
|
38458
|
-
};
|
|
38459
|
-
}
|
|
38460
|
-
|
|
38461
38477
|
function skipCommand(cmdName, job) {
|
|
38462
38478
|
// allow all control commands to run
|
|
38463
38479
|
if (jobIsStopped(job)) return true;
|
|
@@ -40914,13 +40930,10 @@ ${svg}
|
|
|
40914
40930
|
|
|
40915
40931
|
cmd.run = function(job, targets, opts, cb) {
|
|
40916
40932
|
var commandStr, commands;
|
|
40917
|
-
if (opts.
|
|
40918
|
-
|
|
40919
|
-
}
|
|
40920
|
-
if (!opts.commands) {
|
|
40921
|
-
stop("Missing commands parameter");
|
|
40933
|
+
if (!opts.expression) {
|
|
40934
|
+
stop("Missing expression parameter");
|
|
40922
40935
|
}
|
|
40923
|
-
commandStr = runGlobalExpression(opts.
|
|
40936
|
+
commandStr = runGlobalExpression(opts.expression, targets);
|
|
40924
40937
|
if (commandStr) {
|
|
40925
40938
|
commands = parseCommands(commandStr);
|
|
40926
40939
|
runParsedCommands(commands, job, cb);
|
|
@@ -40937,6 +40950,8 @@ ${svg}
|
|
|
40937
40950
|
targetData = getRunCommandData(targets[0]);
|
|
40938
40951
|
Object.defineProperty(ctx, 'target', {value: targetData});
|
|
40939
40952
|
}
|
|
40953
|
+
// Add defined functions and data to the expression context
|
|
40954
|
+
// (Such as functions imported via the -require command)
|
|
40940
40955
|
utils.extend(ctx, getStashedVar('defs'));
|
|
40941
40956
|
try {
|
|
40942
40957
|
output = Function('ctx', 'with(ctx) {return (' + expression + ');}').call({}, ctx);
|
|
@@ -43220,7 +43235,7 @@ ${svg}
|
|
|
43220
43235
|
applyCommandToEachLayer(cmd.dashlines, targetLayers, targetDataset, opts);
|
|
43221
43236
|
|
|
43222
43237
|
} else if (name == 'define') {
|
|
43223
|
-
cmd.define(opts);
|
|
43238
|
+
cmd.define(job.catalog, opts);
|
|
43224
43239
|
|
|
43225
43240
|
} else if (name == 'dissolve') {
|
|
43226
43241
|
outputLayers = applyCommandToEachLayer(cmd.dissolve, targetLayers, arcs, opts);
|
|
@@ -43648,7 +43663,6 @@ ${svg}
|
|
|
43648
43663
|
|
|
43649
43664
|
// Unified function for processing calls to runCommands() and applyCommands()
|
|
43650
43665
|
function _runCommands(argv, opts, callback) {
|
|
43651
|
-
|
|
43652
43666
|
var outputArr = opts.output || null,
|
|
43653
43667
|
inputObj = opts.input,
|
|
43654
43668
|
commands;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.32",
|
|
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.37",
|
|
60
60
|
"msgpackr": "^1.8.5",
|
|
61
61
|
"opn": "^5.3.0",
|
|
62
62
|
"rw": "~1.3.3",
|
package/www/index.html
CHANGED
|
@@ -100,7 +100,8 @@
|
|
|
100
100
|
<img class="pin-btn pinned" src="images/eye2.png">
|
|
101
101
|
</div>
|
|
102
102
|
<div class="layer-list"></div>
|
|
103
|
-
<h4>Sources</h4>
|
|
103
|
+
<!-- <h4>Sources</h4> -->
|
|
104
|
+
<h4>Source files</h4>
|
|
104
105
|
<div class="file-list"></div>
|
|
105
106
|
<div>
|
|
106
107
|
<div id="add-file-btn" class="dialog-btn btn">Add a file</div>
|
|
@@ -153,9 +154,14 @@
|
|
|
153
154
|
<div class="export-formats option-menu">
|
|
154
155
|
</div>
|
|
155
156
|
|
|
156
|
-
<div class="option-menu"><input type="text" class="advanced-options" placeholder="command line options"
|
|
157
|
-
<
|
|
158
|
-
"
|
|
157
|
+
<div class="option-menu"><input type="text" class="advanced-options" placeholder="command line options" />
|
|
158
|
+
<a href="https://github.com/mbloch/mapshaper/wiki/Command-Reference#-o-output" target="_mapshaper_output_docs">
|
|
159
|
+
<div class="tip-button">?<div class="tip-anchor">
|
|
160
|
+
<div class="tip">Enter options from the command line interface for
|
|
161
|
+
the -o command. Examples: bbox no-quantization
|
|
162
|
+
precision=0.001. Click to see all options.</div></div></div></a>
|
|
163
|
+
|
|
164
|
+
</div>
|
|
159
165
|
<!-- <div class="cancel-btn btn dialog-btn">Cancel</div> -->
|
|
160
166
|
<div class="save-btn btn dialog-btn">Export</div>
|
|
161
167
|
<span id="save-preference"><input type="checkbox"/>choose directory</span>
|
|
@@ -192,8 +198,8 @@ the largest ring of multi-ring features.
|
|
|
192
198
|
</div></div></div></div>
|
|
193
199
|
<div class="planar-opt-wrapper"><label for="planar-opt"><input type="checkbox" class="checkbox planar-opt"/>use planar geometry</label>
|
|
194
200
|
<div class="tip-button">?<div class="tip-anchor">
|
|
195
|
-
<div class="tip">
|
|
196
|
-
on a plane, rather than longitude, latitude
|
|
201
|
+
<div class="tip">Treat x, y values as Cartesian coordinates
|
|
202
|
+
on a plane, rather than as longitude, latitude
|
|
197
203
|
coordinates on a sphere.
|
|
198
204
|
</div></div></div></div>
|
|
199
205
|
</div>
|
|
@@ -256,7 +262,7 @@ a smoother appearance.</div></div></div></div>
|
|
|
256
262
|
|
|
257
263
|
<div id="import-options" class="main-area popup-dialog">
|
|
258
264
|
<div class="info-box">
|
|
259
|
-
|
|
265
|
+
<h3 class="list-header">Files</h3>
|
|
260
266
|
|
|
261
267
|
<div class="dropped-file-list"></div>
|
|
262
268
|
|
|
@@ -272,20 +278,23 @@ a smoother appearance.</div></div></div></div>
|
|
|
272
278
|
self-intersections, to help identify
|
|
273
279
|
topological errors in a dataset.</div></div></div></div>
|
|
274
280
|
|
|
275
|
-
<div><label for="snap-points-opt"><input type="checkbox" class="checkbox" id="snap-points-opt" />snap vertices</label>
|
|
281
|
+
<!-- <div><label for="snap-points-opt"><input type="checkbox" class="checkbox" id="snap-points-opt" />snap vertices</label>
|
|
276
282
|
<div class="tip-button">?<div class="tip-anchor">
|
|
277
283
|
<div class="tip">Fix topology errors by snapping
|
|
278
284
|
together points with nearly identical
|
|
279
285
|
coordinates. This option does not
|
|
280
|
-
apply to TopoJSON files.</div></div></div></div>
|
|
286
|
+
apply to TopoJSON files.</div></div></div></div> -->
|
|
281
287
|
<div style="height:5px"></div>
|
|
282
288
|
|
|
283
289
|
</div>
|
|
284
290
|
|
|
285
|
-
<div><input type="text" class="advanced-options" placeholder="import options"
|
|
291
|
+
<div><input type="text" class="advanced-options" placeholder="import options" />
|
|
292
|
+
<a href="https://github.com/mbloch/mapshaper/wiki/Command-Reference#-i-input" target="_mapshaper_import_docs">
|
|
293
|
+
<div class="tip-button">?<div class="tip-anchor">
|
|
286
294
|
<div class="tip">Enter options from the command line
|
|
287
|
-
interface. Examples: "no-topology
|
|
288
|
-
|
|
295
|
+
interface. Examples: <span id="import-option-examples">snap no-topology
|
|
296
|
+
encoding=big5</span>. Click to see all options.</div></div></div></div>
|
|
297
|
+
</a>
|
|
289
298
|
|
|
290
299
|
</div>
|
|
291
300
|
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -1834,6 +1834,7 @@
|
|
|
1834
1834
|
var importCount = 0;
|
|
1835
1835
|
var importTotal = 0;
|
|
1836
1836
|
var overQuickView = false;
|
|
1837
|
+
var useQuickView = false;
|
|
1837
1838
|
var queuedFiles = [];
|
|
1838
1839
|
var manifestFiles = opts.files || [];
|
|
1839
1840
|
var catalog;
|
|
@@ -1863,21 +1864,17 @@
|
|
|
1863
1864
|
}
|
|
1864
1865
|
});
|
|
1865
1866
|
|
|
1866
|
-
function useQuickView() {
|
|
1867
|
-
return initialImport && (opts.quick_view || overQuickView);
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
1867
|
function initDropArea(el, isQuick) {
|
|
1871
1868
|
var area = El(el)
|
|
1872
1869
|
.on('dragleave', onout)
|
|
1873
|
-
.on('dragover', onover)
|
|
1870
|
+
.on('dragover', function() {overQuickView = !!isQuick; onover();})
|
|
1874
1871
|
.on('mouseover', onover)
|
|
1875
1872
|
.on('mouseout', onout);
|
|
1876
1873
|
|
|
1877
1874
|
function onover() {
|
|
1878
|
-
overQuickView = !!isQuick;
|
|
1879
1875
|
area.addClass('dragover');
|
|
1880
1876
|
}
|
|
1877
|
+
|
|
1881
1878
|
function onout() {
|
|
1882
1879
|
overQuickView = false;
|
|
1883
1880
|
area.removeClass('dragover');
|
|
@@ -1959,7 +1956,21 @@
|
|
|
1959
1956
|
function showQueuedFiles() {
|
|
1960
1957
|
var list = gui.container.findChild('.dropped-file-list').empty();
|
|
1961
1958
|
queuedFiles.forEach(function(f) {
|
|
1962
|
-
|
|
1959
|
+
var html = '<span>' + f.name + '</span><img class="close-btn" draggable="false" src="images/close.png">';
|
|
1960
|
+
var entry = El('<div>').html(html);
|
|
1961
|
+
entry.appendTo(list);
|
|
1962
|
+
// init delete button
|
|
1963
|
+
GUI.onClick(entry.findChild('img.close-btn'), function(e) {
|
|
1964
|
+
e.stopPropagation();
|
|
1965
|
+
queuedFiles = queuedFiles.filter(function(item) {
|
|
1966
|
+
return item != f;
|
|
1967
|
+
});
|
|
1968
|
+
if (queuedFiles.length > 0) {
|
|
1969
|
+
showQueuedFiles();
|
|
1970
|
+
} else {
|
|
1971
|
+
gui.clearMode();
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1963
1974
|
});
|
|
1964
1975
|
}
|
|
1965
1976
|
|
|
@@ -1967,6 +1978,7 @@
|
|
|
1967
1978
|
var names = getFileNames(files);
|
|
1968
1979
|
var expanded = [];
|
|
1969
1980
|
if (files.length === 0) return;
|
|
1981
|
+
useQuickView = importCount === 0 && (opts.quick_view || overQuickView);
|
|
1970
1982
|
try {
|
|
1971
1983
|
expanded = await expandFiles(files);
|
|
1972
1984
|
} catch(e) {
|
|
@@ -1981,7 +1993,7 @@
|
|
|
1981
1993
|
return;
|
|
1982
1994
|
}
|
|
1983
1995
|
gui.enterMode('import');
|
|
1984
|
-
if (useQuickView
|
|
1996
|
+
if (useQuickView) {
|
|
1985
1997
|
await importQueuedFiles();
|
|
1986
1998
|
} else {
|
|
1987
1999
|
gui.container.addClass('queued-files');
|
|
@@ -2077,13 +2089,13 @@
|
|
|
2077
2089
|
|
|
2078
2090
|
function readImportOpts() {
|
|
2079
2091
|
var importOpts;
|
|
2080
|
-
if (useQuickView
|
|
2092
|
+
if (useQuickView) {
|
|
2081
2093
|
importOpts = {}; // default opts using quickview
|
|
2082
2094
|
} else {
|
|
2083
2095
|
var freeform = El('#import-options .advanced-options').node().value;
|
|
2084
2096
|
importOpts = GUI.parseFreeformOptions(freeform, 'i');
|
|
2085
2097
|
importOpts.no_repair = !El("#repair-intersections-opt").node().checked;
|
|
2086
|
-
importOpts.snap = !!El("#snap-points-opt").node().checked;
|
|
2098
|
+
// importOpts.snap = !!El("#snap-points-opt").node().checked;
|
|
2087
2099
|
}
|
|
2088
2100
|
return importOpts;
|
|
2089
2101
|
}
|
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.32";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -24840,13 +24840,12 @@ ${svg}
|
|
|
24840
24840
|
|
|
24841
24841
|
parser.command('run')
|
|
24842
24842
|
.describe('create commands on-the-fly and run them')
|
|
24843
|
-
.option('
|
|
24844
|
-
// TODO: remove this option
|
|
24845
|
-
})
|
|
24846
|
-
.option('commands', {
|
|
24843
|
+
.option('expression', {
|
|
24847
24844
|
DEFAULT: true,
|
|
24848
|
-
describe: '
|
|
24845
|
+
describe: 'JS expression to generate command(s)'
|
|
24849
24846
|
})
|
|
24847
|
+
// deprecated
|
|
24848
|
+
.option('commands', {alias_to: 'expression'})
|
|
24850
24849
|
.option('target', targetOpt);
|
|
24851
24850
|
|
|
24852
24851
|
parser.command('scalebar')
|
|
@@ -34730,7 +34729,64 @@ ${svg}
|
|
|
34730
34729
|
};
|
|
34731
34730
|
}
|
|
34732
34731
|
|
|
34733
|
-
|
|
34732
|
+
function compileIfCommandExpression(expr, catalog, opts) {
|
|
34733
|
+
return compileLayerExpression(expr, catalog, opts);
|
|
34734
|
+
}
|
|
34735
|
+
|
|
34736
|
+
|
|
34737
|
+
function compileLayerExpression(expr, catalog, opts) {
|
|
34738
|
+
var targetId = opts.layer || opts.target || null;
|
|
34739
|
+
var targets = catalog.findCommandTargets(targetId);
|
|
34740
|
+
var isSingle = targets.length == 1 && targets[0].layers.length == 1;
|
|
34741
|
+
if (targets.length === 0 && targetId) {
|
|
34742
|
+
stop('Layer not found:', targetId);
|
|
34743
|
+
}
|
|
34744
|
+
// var vars = getAssignedVars(exp);
|
|
34745
|
+
var defs = getStashedVar('defs') || {};
|
|
34746
|
+
|
|
34747
|
+
var ctx;
|
|
34748
|
+
if (isSingle) {
|
|
34749
|
+
ctx = getLayerProxy(targets[0].layers[0], targets[0].dataset.arcs);
|
|
34750
|
+
} else {
|
|
34751
|
+
ctx = getNullLayerProxy(targets);
|
|
34752
|
+
}
|
|
34753
|
+
ctx.global = defs; // TODO: remove duplication with mapshaper.expressions.mjs
|
|
34754
|
+
var exprOpts = Object.assign({returns: true}, opts);
|
|
34755
|
+
var func = compileExpressionToFunction(expr, exprOpts);
|
|
34756
|
+
|
|
34757
|
+
// @geoType: optional geometry type (polygon, polyline, point, null);
|
|
34758
|
+
ctx.layer_exists = function(name, geoType) {
|
|
34759
|
+
try {
|
|
34760
|
+
var targets = catalog.findCommandTargets(name, geoType);
|
|
34761
|
+
if (targets.length > 0) return true;
|
|
34762
|
+
} catch(e) {}
|
|
34763
|
+
return false;
|
|
34764
|
+
};
|
|
34765
|
+
|
|
34766
|
+
ctx.file_exists = function(file) {
|
|
34767
|
+
return cli.isFile(file);
|
|
34768
|
+
};
|
|
34769
|
+
|
|
34770
|
+
return function() {
|
|
34771
|
+
try {
|
|
34772
|
+
return func.call(ctx, defs, ctx);
|
|
34773
|
+
} catch(e) {
|
|
34774
|
+
// if (opts.quiet) throw e;
|
|
34775
|
+
stop(e.name, "in expression [" + expr + "]:", e.message);
|
|
34776
|
+
}
|
|
34777
|
+
};
|
|
34778
|
+
}
|
|
34779
|
+
|
|
34780
|
+
/*
|
|
34781
|
+
cmd.define_v2 = function(catalog, opts) {
|
|
34782
|
+
if (!opts.expression) {
|
|
34783
|
+
stop('Missing an assignment expression');
|
|
34784
|
+
}
|
|
34785
|
+
compileLayerExpression(opts.expression, catalog, opts)();
|
|
34786
|
+
};
|
|
34787
|
+
*/
|
|
34788
|
+
|
|
34789
|
+
cmd.define = function(catalog, opts) {
|
|
34734
34790
|
if (!opts.expression) {
|
|
34735
34791
|
stop('Missing an assignment expression');
|
|
34736
34792
|
}
|
|
@@ -38418,46 +38474,6 @@ ${svg}
|
|
|
38418
38474
|
return job.control || (job.control = {});
|
|
38419
38475
|
}
|
|
38420
38476
|
|
|
38421
|
-
function compileIfCommandExpression(expr, catalog, opts) {
|
|
38422
|
-
var targetId = opts.layer || opts.target || null;
|
|
38423
|
-
var targets = catalog.findCommandTargets(targetId);
|
|
38424
|
-
var isSingle = targets.length == 1 && targets[0].layers.length == 1;
|
|
38425
|
-
if (targets.length === 0 && targetId) {
|
|
38426
|
-
stop('Layer not found:', targetId);
|
|
38427
|
-
}
|
|
38428
|
-
var ctx;
|
|
38429
|
-
if (isSingle) {
|
|
38430
|
-
ctx = getLayerProxy(targets[0].layers[0], targets[0].dataset.arcs);
|
|
38431
|
-
} else {
|
|
38432
|
-
ctx = getNullLayerProxy(targets);
|
|
38433
|
-
}
|
|
38434
|
-
ctx.global = getStashedVar('defs') || {}; // TODO: remove duplication with mapshaper.expressions.mjs
|
|
38435
|
-
var exprOpts = Object.assign({returns: true}, opts);
|
|
38436
|
-
var func = compileExpressionToFunction(expr, exprOpts);
|
|
38437
|
-
|
|
38438
|
-
// @geoType: optional geometry type (polygon, polyline, point, null);
|
|
38439
|
-
ctx.layer_exists = function(name, geoType) {
|
|
38440
|
-
try {
|
|
38441
|
-
var targets = catalog.findCommandTargets(name, geoType);
|
|
38442
|
-
if (targets.length > 0) return true;
|
|
38443
|
-
} catch(e) {}
|
|
38444
|
-
return false;
|
|
38445
|
-
};
|
|
38446
|
-
|
|
38447
|
-
ctx.file_exists = function(file) {
|
|
38448
|
-
return cli.isFile(file);
|
|
38449
|
-
};
|
|
38450
|
-
|
|
38451
|
-
return function() {
|
|
38452
|
-
try {
|
|
38453
|
-
return func.call(ctx, {}, ctx);
|
|
38454
|
-
} catch(e) {
|
|
38455
|
-
// if (opts.quiet) throw e;
|
|
38456
|
-
stop(e.name, "in expression [" + expr + "]:", e.message);
|
|
38457
|
-
}
|
|
38458
|
-
};
|
|
38459
|
-
}
|
|
38460
|
-
|
|
38461
38477
|
function skipCommand(cmdName, job) {
|
|
38462
38478
|
// allow all control commands to run
|
|
38463
38479
|
if (jobIsStopped(job)) return true;
|
|
@@ -40914,13 +40930,10 @@ ${svg}
|
|
|
40914
40930
|
|
|
40915
40931
|
cmd.run = function(job, targets, opts, cb) {
|
|
40916
40932
|
var commandStr, commands;
|
|
40917
|
-
if (opts.
|
|
40918
|
-
|
|
40919
|
-
}
|
|
40920
|
-
if (!opts.commands) {
|
|
40921
|
-
stop("Missing commands parameter");
|
|
40933
|
+
if (!opts.expression) {
|
|
40934
|
+
stop("Missing expression parameter");
|
|
40922
40935
|
}
|
|
40923
|
-
commandStr = runGlobalExpression(opts.
|
|
40936
|
+
commandStr = runGlobalExpression(opts.expression, targets);
|
|
40924
40937
|
if (commandStr) {
|
|
40925
40938
|
commands = parseCommands(commandStr);
|
|
40926
40939
|
runParsedCommands(commands, job, cb);
|
|
@@ -40937,6 +40950,8 @@ ${svg}
|
|
|
40937
40950
|
targetData = getRunCommandData(targets[0]);
|
|
40938
40951
|
Object.defineProperty(ctx, 'target', {value: targetData});
|
|
40939
40952
|
}
|
|
40953
|
+
// Add defined functions and data to the expression context
|
|
40954
|
+
// (Such as functions imported via the -require command)
|
|
40940
40955
|
utils.extend(ctx, getStashedVar('defs'));
|
|
40941
40956
|
try {
|
|
40942
40957
|
output = Function('ctx', 'with(ctx) {return (' + expression + ');}').call({}, ctx);
|
|
@@ -43220,7 +43235,7 @@ ${svg}
|
|
|
43220
43235
|
applyCommandToEachLayer(cmd.dashlines, targetLayers, targetDataset, opts);
|
|
43221
43236
|
|
|
43222
43237
|
} else if (name == 'define') {
|
|
43223
|
-
cmd.define(opts);
|
|
43238
|
+
cmd.define(job.catalog, opts);
|
|
43224
43239
|
|
|
43225
43240
|
} else if (name == 'dissolve') {
|
|
43226
43241
|
outputLayers = applyCommandToEachLayer(cmd.dissolve, targetLayers, arcs, opts);
|
|
@@ -43648,7 +43663,6 @@ ${svg}
|
|
|
43648
43663
|
|
|
43649
43664
|
// Unified function for processing calls to runCommands() and applyCommands()
|
|
43650
43665
|
function _runCommands(argv, opts, callback) {
|
|
43651
|
-
|
|
43652
43666
|
var outputArr = opts.output || null,
|
|
43653
43667
|
inputObj = opts.input,
|
|
43654
43668
|
commands;
|
package/www/modules.js
CHANGED
|
@@ -12530,7 +12530,10 @@ function wkt_unpack(str) {
|
|
|
12530
12530
|
str = convert_wkt_quotes(str);
|
|
12531
12531
|
|
|
12532
12532
|
// Convert WKT entities to JSON arrays
|
|
12533
|
-
str = str.replace(/([A-Z0-9]+)\[/g, '["$1",');
|
|
12533
|
+
// str = str.replace(/([A-Z0-9]+)\[/g, '["$1",');
|
|
12534
|
+
// Changed to ignore some names that look like entities, like "GCS_TWD97[2020]"
|
|
12535
|
+
// allow only [ or , character before the next quote (i.e. block close quotes)
|
|
12536
|
+
str = str.replace(/([A-Z0-9]+)\[(?![^"]*[^\[,"]")/g, '["$1",');
|
|
12534
12537
|
|
|
12535
12538
|
// Enclose axis keywords in quotes to create valid JSON strings
|
|
12536
12539
|
str = str.replace(/, *([a-zA-Z]+) *(?=[,\]])/g, ',"$1"');
|
package/www/page.css
CHANGED
|
@@ -472,6 +472,25 @@ body.dragover #import-options-drop-area .drop-area {
|
|
|
472
472
|
overflow-y: auto;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
.dropped-file-list img.close-btn {
|
|
476
|
+
position: absolute;
|
|
477
|
+
cursor: pointer;
|
|
478
|
+
width: 14px;
|
|
479
|
+
height: 14px;
|
|
480
|
+
padding: 0;
|
|
481
|
+
top: 3px;
|
|
482
|
+
right: 0px;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.dropped-file-list > div {
|
|
486
|
+
position: relative;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.dropped-file-list span {
|
|
490
|
+
margin-right: 16px;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
475
494
|
#import-options .dropped-file-list p {
|
|
476
495
|
line-height: 1;
|
|
477
496
|
margin-bottom: 5px;
|
|
@@ -498,7 +517,7 @@ body.dragover #import-options-drop-area .drop-area {
|
|
|
498
517
|
text-align: left;
|
|
499
518
|
margin-top: 12px;
|
|
500
519
|
margin-right: 20px;
|
|
501
|
-
padding: 12px
|
|
520
|
+
padding: 12px 16px 12px 18px;
|
|
502
521
|
vertical-align: top;
|
|
503
522
|
display: inline-block;
|
|
504
523
|
/* border: 1px solid #aaa; */
|
|
@@ -512,6 +531,10 @@ body.dragover #import-options-drop-area .drop-area {
|
|
|
512
531
|
font-weight: normal;
|
|
513
532
|
}
|
|
514
533
|
|
|
534
|
+
.info-box h3.list-header {
|
|
535
|
+
margin-bottom: 0.1em;
|
|
536
|
+
}
|
|
537
|
+
|
|
515
538
|
.info-box h4 {
|
|
516
539
|
font-size: 1.085em;
|
|
517
540
|
font-weight: normal;
|
|
@@ -541,8 +564,8 @@ body.dragover #import-options-drop-area .drop-area {
|
|
|
541
564
|
}
|
|
542
565
|
|
|
543
566
|
.info-box .tip-button {
|
|
544
|
-
margin
|
|
545
|
-
|
|
567
|
+
margin: 3px 2px 0 10px;
|
|
568
|
+
|
|
546
569
|
}
|
|
547
570
|
|
|
548
571
|
.info-box input[type="checkbox"] {
|
|
@@ -762,8 +785,10 @@ body.simplify .layer-control-btn {
|
|
|
762
785
|
padding: 0px 14px 2px 14px;
|
|
763
786
|
}
|
|
764
787
|
|
|
788
|
+
|
|
765
789
|
.pin-all img,
|
|
766
|
-
.layer-item img
|
|
790
|
+
.layer-item img
|
|
791
|
+
{
|
|
767
792
|
position: absolute;
|
|
768
793
|
width: 16px;
|
|
769
794
|
height: 16px;
|
|
@@ -784,7 +809,7 @@ img.close-btn {
|
|
|
784
809
|
height: 18px;
|
|
785
810
|
width: 18px;
|
|
786
811
|
margin-top: 1px;
|
|
787
|
-
margin-right: -
|
|
812
|
+
margin-right: -3px;
|
|
788
813
|
cursor: pointer;
|
|
789
814
|
border-radius: 4px;
|
|
790
815
|
}
|