mapshaper 0.6.19 → 0.6.21
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 +169 -81
- package/package.json +1 -1
- package/www/index.html +2 -0
- package/www/mapshaper-gui.js +153 -94
- package/www/mapshaper.js +169 -81
- package/www/page.css +17 -7
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.21";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
get defaults () { return defaults; },
|
|
31
31
|
get extend () { return extend$1; },
|
|
32
32
|
get inherit () { return inherit; },
|
|
33
|
+
get promisify () { return promisify; },
|
|
33
34
|
get reduceAsync () { return reduceAsync; },
|
|
34
35
|
get merge () { return merge; },
|
|
35
36
|
get difference () { return difference; },
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
get formatter () { return formatter; },
|
|
88
89
|
get wildcardToRegExp () { return wildcardToRegExp; },
|
|
89
90
|
get createBuffer () { return createBuffer; },
|
|
91
|
+
get toBuffer () { return toBuffer; },
|
|
90
92
|
get expandoBuffer () { return expandoBuffer; },
|
|
91
93
|
get copyElements () { return copyElements; },
|
|
92
94
|
get extendBuffer () { return extendBuffer; },
|
|
@@ -318,6 +320,19 @@
|
|
|
318
320
|
targ.prototype.__super__ = f;
|
|
319
321
|
}
|
|
320
322
|
|
|
323
|
+
function promisify(asyncFn) {
|
|
324
|
+
return function() {
|
|
325
|
+
var args = toArray(arguments);
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
var cb = function(err, data) {
|
|
328
|
+
if (err) reject(err);
|
|
329
|
+
else resolve(data);
|
|
330
|
+
};
|
|
331
|
+
args.push(cb);
|
|
332
|
+
asyncFn.apply(this, args);
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
}
|
|
321
336
|
|
|
322
337
|
// Call @iter on each member of an array (similar to Array#reduce(iter))
|
|
323
338
|
// iter: function(memo, item, callback)
|
|
@@ -1019,6 +1034,15 @@
|
|
|
1019
1034
|
}
|
|
1020
1035
|
}
|
|
1021
1036
|
|
|
1037
|
+
function toBuffer(src) {
|
|
1038
|
+
if (src instanceof B$3) return src;
|
|
1039
|
+
if (src instanceof ArrayBuffer) return B$3.from(src);
|
|
1040
|
+
if (src instanceof Uint8Array) {
|
|
1041
|
+
return B$3.from(src.buffer, src.byteOffset, src.byteLength);
|
|
1042
|
+
}
|
|
1043
|
+
error('Unexpected argument type');
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1022
1046
|
function expandoBuffer(constructor, rate) {
|
|
1023
1047
|
var capacity = 0,
|
|
1024
1048
|
k = rate >= 1 ? rate : 1.2,
|
|
@@ -9956,6 +9980,10 @@
|
|
|
9956
9980
|
// base async inflate fn
|
|
9957
9981
|
var bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gu8]; };
|
|
9958
9982
|
var bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };
|
|
9983
|
+
// gzip extra
|
|
9984
|
+
var gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };
|
|
9985
|
+
// gunzip extra
|
|
9986
|
+
var guze = function () { return [gzs, gzl]; };
|
|
9959
9987
|
// post buf
|
|
9960
9988
|
var pbf = function (msg) { return postMessage(msg, [msg.buffer]); };
|
|
9961
9989
|
// get u8
|
|
@@ -10047,6 +10075,17 @@
|
|
|
10047
10075
|
function inflateSync(data, out) {
|
|
10048
10076
|
return inflt(data, out);
|
|
10049
10077
|
}
|
|
10078
|
+
function gzip(data, opts, cb) {
|
|
10079
|
+
if (!cb)
|
|
10080
|
+
cb = opts, opts = {};
|
|
10081
|
+
if (typeof cb != 'function')
|
|
10082
|
+
err(7);
|
|
10083
|
+
return cbify(data, opts, [
|
|
10084
|
+
bDflt,
|
|
10085
|
+
gze,
|
|
10086
|
+
function () { return [gzipSync$1]; }
|
|
10087
|
+
], function (ev) { return pbf(gzipSync$1(ev.data[0], ev.data[1])); }, 2, cb);
|
|
10088
|
+
}
|
|
10050
10089
|
/**
|
|
10051
10090
|
* Compresses data with GZIP
|
|
10052
10091
|
* @param data The data to compress
|
|
@@ -10061,6 +10100,17 @@
|
|
|
10061
10100
|
var d = dopt(data, opts, gzhl(opts), 8), s = d.length;
|
|
10062
10101
|
return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
|
|
10063
10102
|
}
|
|
10103
|
+
function gunzip(data, opts, cb) {
|
|
10104
|
+
if (!cb)
|
|
10105
|
+
cb = opts, opts = {};
|
|
10106
|
+
if (typeof cb != 'function')
|
|
10107
|
+
err(7);
|
|
10108
|
+
return cbify(data, opts, [
|
|
10109
|
+
bInflt,
|
|
10110
|
+
guze,
|
|
10111
|
+
function () { return [gunzipSync$1]; }
|
|
10112
|
+
], function (ev) { return pbf(gunzipSync$1(ev.data[0])); }, 3, cb);
|
|
10113
|
+
}
|
|
10064
10114
|
/**
|
|
10065
10115
|
* Expands GZIP data
|
|
10066
10116
|
* @param data The data to decompress
|
|
@@ -10529,6 +10579,15 @@
|
|
|
10529
10579
|
return files;
|
|
10530
10580
|
}
|
|
10531
10581
|
|
|
10582
|
+
function runningInBrowser() {
|
|
10583
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
10584
|
+
}
|
|
10585
|
+
|
|
10586
|
+
var Env = /*#__PURE__*/Object.freeze({
|
|
10587
|
+
__proto__: null,
|
|
10588
|
+
runningInBrowser: runningInBrowser
|
|
10589
|
+
});
|
|
10590
|
+
|
|
10532
10591
|
// Checks if @arg is a Uint8Array containing gzipped data
|
|
10533
10592
|
function isGzipped(arg) {
|
|
10534
10593
|
return arg.length > 2 && arg.buffer instanceof ArrayBuffer && arg[0] == 0x1f && arg[1] == 0x8b;
|
|
@@ -10540,7 +10599,30 @@
|
|
|
10540
10599
|
if (typeof content == 'string') {
|
|
10541
10600
|
content = strToU8(content);
|
|
10542
10601
|
}
|
|
10543
|
-
|
|
10602
|
+
if (runningInBrowser()) {
|
|
10603
|
+
return gzipSync$1(content, opts);
|
|
10604
|
+
}
|
|
10605
|
+
return require('zlib').gzipSync(content, opts);
|
|
10606
|
+
}
|
|
10607
|
+
|
|
10608
|
+
async function gzipAsync(content, opts) {
|
|
10609
|
+
if (typeof content == 'string') {
|
|
10610
|
+
content = strToU8(content);
|
|
10611
|
+
}
|
|
10612
|
+
var gzip$1 = runningInBrowser() ? utils.promisify(gzip) : utils.promisify(require('zlib').gzip);
|
|
10613
|
+
return gzip$1(content, opts);
|
|
10614
|
+
}
|
|
10615
|
+
|
|
10616
|
+
async function gunzipAsync(buf, opts) {
|
|
10617
|
+
if (buf instanceof ArrayBuffer) {
|
|
10618
|
+
buf = new Uint8Array(buf);
|
|
10619
|
+
}
|
|
10620
|
+
opts = opts || {};
|
|
10621
|
+
var out = await utils.promisify(gunzip)(buf, opts);
|
|
10622
|
+
if (opts.filename && !isImportableAsBinary(opts.filename)) {
|
|
10623
|
+
out = strFromU8(out);
|
|
10624
|
+
}
|
|
10625
|
+
return out;
|
|
10544
10626
|
}
|
|
10545
10627
|
|
|
10546
10628
|
function gunzipSync(buf, filename) {
|
|
@@ -10560,21 +10642,23 @@
|
|
|
10560
10642
|
__proto__: null,
|
|
10561
10643
|
isGzipped: isGzipped,
|
|
10562
10644
|
gzipSync: gzipSync,
|
|
10645
|
+
gzipAsync: gzipAsync,
|
|
10646
|
+
gunzipAsync: gunzipAsync,
|
|
10563
10647
|
gunzipSync: gunzipSync
|
|
10564
10648
|
});
|
|
10565
10649
|
|
|
10566
10650
|
// Export in a column-first format
|
|
10567
10651
|
// Faster than exportTable(), and can handle some data that can't be
|
|
10568
10652
|
// converted to JSON, like Date objects.
|
|
10569
|
-
function exportTable2(table) {
|
|
10653
|
+
async function exportTable2(table) {
|
|
10570
10654
|
var fields = table.getFields();
|
|
10571
10655
|
var records = table.getRecords();
|
|
10572
10656
|
var types = [];
|
|
10573
|
-
var columns = fields.map(function(name) {
|
|
10657
|
+
var columns = await Promise.all(fields.map(function(name) {
|
|
10574
10658
|
var type = getColumnType(name, records);
|
|
10575
10659
|
types.push(type);
|
|
10576
10660
|
return exportColumn(name, type, records);
|
|
10577
|
-
});
|
|
10661
|
+
}));
|
|
10578
10662
|
return ({
|
|
10579
10663
|
fields: fields,
|
|
10580
10664
|
types: types,
|
|
@@ -10632,9 +10716,9 @@
|
|
|
10632
10716
|
}
|
|
10633
10717
|
}
|
|
10634
10718
|
|
|
10635
|
-
function exportColumn(name, type, records) {
|
|
10719
|
+
async function exportColumn(name, type, records) {
|
|
10636
10720
|
if (type == 'number' || type == 'string') {
|
|
10637
|
-
return
|
|
10721
|
+
return gzipAsync(JSON.stringify(getFieldValues(records, name)), {level: 2, consume: true});
|
|
10638
10722
|
}
|
|
10639
10723
|
return getFieldValues(records, name);
|
|
10640
10724
|
}
|
|
@@ -10648,7 +10732,6 @@
|
|
|
10648
10732
|
// return gzipSync(arr, {level: 2});
|
|
10649
10733
|
// }
|
|
10650
10734
|
|
|
10651
|
-
// import { gzipSync, isGzipped } from '../io/mapshaper-gzip';
|
|
10652
10735
|
var PACKAGE_EXT = 'msx';
|
|
10653
10736
|
|
|
10654
10737
|
// libraries
|
|
@@ -10665,10 +10748,11 @@
|
|
|
10665
10748
|
}
|
|
10666
10749
|
*/
|
|
10667
10750
|
|
|
10668
|
-
function exportPackedDatasets(datasets, opts) {
|
|
10751
|
+
async function exportPackedDatasets(datasets, opts) {
|
|
10752
|
+
var content = pack(await exportDatasetsToPack(datasets, opts));
|
|
10669
10753
|
return [{
|
|
10670
|
-
content:
|
|
10671
|
-
filename: opts.file || '
|
|
10754
|
+
content: content,
|
|
10755
|
+
filename: opts.file || 'mapshaper_snapshot.' + PACKAGE_EXT
|
|
10672
10756
|
}];
|
|
10673
10757
|
}
|
|
10674
10758
|
|
|
@@ -10681,25 +10765,19 @@
|
|
|
10681
10765
|
|
|
10682
10766
|
// gui: (optional) gui instance
|
|
10683
10767
|
//
|
|
10684
|
-
function exportDatasetsToPack(datasets, opts) {
|
|
10768
|
+
async function exportDatasetsToPack(datasets, opts) {
|
|
10685
10769
|
return {
|
|
10686
10770
|
version: 1,
|
|
10687
10771
|
created: (new Date).toISOString(),
|
|
10688
|
-
datasets: datasets.map(exportDataset)
|
|
10772
|
+
datasets: await Promise.all(datasets.map(d => exportDataset(d, opts || {})))
|
|
10689
10773
|
};
|
|
10690
10774
|
}
|
|
10691
10775
|
|
|
10692
|
-
|
|
10693
|
-
// export function serializeSession(catalog) {
|
|
10694
|
-
// var obj = exportDatasets(catalog.getDatasets());
|
|
10695
|
-
// return BSON.serialize(obj);
|
|
10696
|
-
// }
|
|
10697
|
-
|
|
10698
|
-
function exportDataset(dataset) {
|
|
10776
|
+
async function exportDataset(dataset, opts) {
|
|
10699
10777
|
return {
|
|
10700
|
-
arcs: dataset.arcs ? exportArcs(dataset.arcs) : null,
|
|
10778
|
+
arcs: dataset.arcs ? await exportArcs(dataset.arcs, opts) : null,
|
|
10701
10779
|
info: dataset.info ? exportInfo(dataset.info) : null,
|
|
10702
|
-
layers: (dataset.layers || []).map(exportLayer)
|
|
10780
|
+
layers: await Promise.all((dataset.layers || []).map(exportLayer))
|
|
10703
10781
|
};
|
|
10704
10782
|
}
|
|
10705
10783
|
|
|
@@ -10707,7 +10785,7 @@
|
|
|
10707
10785
|
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
10708
10786
|
}
|
|
10709
10787
|
|
|
10710
|
-
function exportArcs(arcs) {
|
|
10788
|
+
async function exportArcs(arcs, opts) {
|
|
10711
10789
|
var data = arcs.getVertexData();
|
|
10712
10790
|
var obj = {
|
|
10713
10791
|
nn: typedArrayToBuffer(data.nn),
|
|
@@ -10717,19 +10795,27 @@
|
|
|
10717
10795
|
zlimit: arcs.getRetainedInterval()
|
|
10718
10796
|
};
|
|
10719
10797
|
|
|
10720
|
-
// gzipping typically
|
|
10721
|
-
// -- not worth the time
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10798
|
+
// gzipping typically sees about 70% compression on unrounded coordinates
|
|
10799
|
+
// -- possibly not worth the time
|
|
10800
|
+
if (opts.compact) {
|
|
10801
|
+
var gzipOpts = {level: 1, consume: false};
|
|
10802
|
+
var promises = [gzipAsync(obj.nn, gzipOpts), gzipAsync(obj.xx, gzipOpts), gzipAsync(obj.yy, gzipOpts)];
|
|
10803
|
+
if (obj.zz) promises.push(gzipAsync(obj.zz, gzipOpts));
|
|
10804
|
+
var results = await Promise.all(promises);
|
|
10805
|
+
obj.nn = results.shift();
|
|
10806
|
+
obj.xx = results.shift();
|
|
10807
|
+
obj.yy = results.shift();
|
|
10808
|
+
if (obj.zz) obj.zz = results.shift();
|
|
10809
|
+
}
|
|
10727
10810
|
return obj;
|
|
10728
10811
|
}
|
|
10729
10812
|
|
|
10730
|
-
function exportLayer(lyr) {
|
|
10813
|
+
async function exportLayer(lyr) {
|
|
10731
10814
|
// console.time('table')
|
|
10732
|
-
var data =
|
|
10815
|
+
var data = null;
|
|
10816
|
+
if (lyr.data) {
|
|
10817
|
+
data = await exportTable2(lyr.data);
|
|
10818
|
+
}
|
|
10733
10819
|
// console.timeEnd('table')
|
|
10734
10820
|
return {
|
|
10735
10821
|
name: lyr.name || null,
|
|
@@ -10894,15 +10980,6 @@
|
|
|
10894
10980
|
filenameIsUnsupportedOutputType: filenameIsUnsupportedOutputType
|
|
10895
10981
|
});
|
|
10896
10982
|
|
|
10897
|
-
function runningInBrowser() {
|
|
10898
|
-
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
10899
|
-
}
|
|
10900
|
-
|
|
10901
|
-
var Env = /*#__PURE__*/Object.freeze({
|
|
10902
|
-
__proto__: null,
|
|
10903
|
-
runningInBrowser: runningInBrowser
|
|
10904
|
-
});
|
|
10905
|
-
|
|
10906
10983
|
// input: A file path or a buffer
|
|
10907
10984
|
function unzipSync(input) {
|
|
10908
10985
|
if (input instanceof ArrayBuffer) {
|
|
@@ -21084,7 +21161,7 @@ ${svg}
|
|
|
21084
21161
|
|
|
21085
21162
|
// @targets - non-empty output from Catalog#findCommandTargets()
|
|
21086
21163
|
//
|
|
21087
|
-
function exportTargetLayers(targets, opts) {
|
|
21164
|
+
async function exportTargetLayers(targets, opts) {
|
|
21088
21165
|
// convert target fmt to dataset fmt
|
|
21089
21166
|
var datasets = targets.map(function(target) {
|
|
21090
21167
|
return utils.defaults({layers: target.layers}, target.dataset);
|
|
@@ -21094,10 +21171,11 @@ ${svg}
|
|
|
21094
21171
|
|
|
21095
21172
|
//
|
|
21096
21173
|
//
|
|
21097
|
-
function exportDatasets(datasets, opts) {
|
|
21174
|
+
async function exportDatasets(datasets, opts) {
|
|
21098
21175
|
var format = getOutputFormat(datasets[0], opts);
|
|
21099
21176
|
var files;
|
|
21100
21177
|
if (format == PACKAGE_EXT) {
|
|
21178
|
+
opts = utils.defaults({compact: true}, opts);
|
|
21101
21179
|
return exportPackedDatasets(datasets, opts);
|
|
21102
21180
|
}
|
|
21103
21181
|
if (format == 'kml' || format == 'svg' || format == 'topojson' || format == 'geojson' && opts.combine_layers) {
|
|
@@ -21201,7 +21279,7 @@ ${svg}
|
|
|
21201
21279
|
}
|
|
21202
21280
|
|
|
21203
21281
|
var exporters = {
|
|
21204
|
-
[PACKAGE_EXT]: exportPackedDatasets,
|
|
21282
|
+
// [PACKAGE_EXT]: exportPackedDatasets, // handled as a special case
|
|
21205
21283
|
geojson: exportGeoJSON2,
|
|
21206
21284
|
topojson: exportTopoJSON,
|
|
21207
21285
|
shapefile: exportShapefile,
|
|
@@ -21379,7 +21457,8 @@ ${svg}
|
|
|
21379
21457
|
|
|
21380
21458
|
function buffer() {
|
|
21381
21459
|
if (!buf) {
|
|
21382
|
-
buf = (src instanceof ArrayBuffer) ? utils.createBuffer(src) : src;
|
|
21460
|
+
// buf = (src instanceof ArrayBuffer) ? utils.createBuffer(src) : src;
|
|
21461
|
+
buf = utils.toBuffer(src);
|
|
21383
21462
|
}
|
|
21384
21463
|
return buf;
|
|
21385
21464
|
}
|
|
@@ -27373,18 +27452,16 @@ ${svg}
|
|
|
27373
27452
|
importFileContent: importFileContent
|
|
27374
27453
|
});
|
|
27375
27454
|
|
|
27376
|
-
// import { gunzipSync, isGzipped } from '../io/mapshaper-gzip';
|
|
27377
|
-
|
|
27378
27455
|
// Import datasets contained in a BSON blob
|
|
27379
27456
|
// Return command target as a dataset
|
|
27380
27457
|
//
|
|
27381
|
-
function unpackSession(buf) {
|
|
27458
|
+
async function unpackSession(buf) {
|
|
27382
27459
|
var obj = unpack(buf, {});
|
|
27383
27460
|
if (!isValidSession(obj)) {
|
|
27384
27461
|
stop('Invalid mapshaper session data object');
|
|
27385
27462
|
}
|
|
27386
27463
|
|
|
27387
|
-
var datasets = obj.datasets.map(importDataset);
|
|
27464
|
+
var datasets = await Promise.all(obj.datasets.map(importDataset));
|
|
27388
27465
|
return Object.assign(obj, {datasets: datasets});
|
|
27389
27466
|
}
|
|
27390
27467
|
|
|
@@ -27395,11 +27472,13 @@ ${svg}
|
|
|
27395
27472
|
return true;
|
|
27396
27473
|
}
|
|
27397
27474
|
|
|
27398
|
-
function importDataset(obj) {
|
|
27475
|
+
async function importDataset(obj) {
|
|
27476
|
+
var arcs = null;
|
|
27477
|
+
if (obj.arcs) arcs = await importArcs(obj.arcs);
|
|
27399
27478
|
return {
|
|
27400
27479
|
info: importInfo(obj.info || {}),
|
|
27401
27480
|
layers: (obj.layers || []).map(importLayer),
|
|
27402
|
-
arcs:
|
|
27481
|
+
arcs: arcs
|
|
27403
27482
|
};
|
|
27404
27483
|
}
|
|
27405
27484
|
|
|
@@ -27409,7 +27488,23 @@ ${svg}
|
|
|
27409
27488
|
// return new constructor(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
27410
27489
|
}
|
|
27411
27490
|
|
|
27412
|
-
function importArcs(obj) {
|
|
27491
|
+
async function importArcs(obj) {
|
|
27492
|
+
if (isGzipped(obj.xx)) {
|
|
27493
|
+
var promises = [];
|
|
27494
|
+
promises.push(gunzipAsync(obj.nn));
|
|
27495
|
+
promises.push(gunzipAsync(obj.xx));
|
|
27496
|
+
promises.push(gunzipAsync(obj.yy));
|
|
27497
|
+
if (obj.zz) {
|
|
27498
|
+
promises.push(gunzipAsync(obj.zz));
|
|
27499
|
+
}
|
|
27500
|
+
var data = await Promise.all(promises);
|
|
27501
|
+
obj.nn = data.shift();
|
|
27502
|
+
obj.xx = data.shift();
|
|
27503
|
+
obj.yy = data.shift();
|
|
27504
|
+
if (obj.zz) {
|
|
27505
|
+
obj.zz = data.shift();
|
|
27506
|
+
}
|
|
27507
|
+
}
|
|
27413
27508
|
var nn = bufferToDataView(obj.nn, Uint32Array);
|
|
27414
27509
|
var xx = bufferToDataView(obj.xx, Float64Array);
|
|
27415
27510
|
var yy = bufferToDataView(obj.yy, Float64Array);
|
|
@@ -27445,7 +27540,7 @@ ${svg}
|
|
|
27445
27540
|
unpackSession: unpackSession
|
|
27446
27541
|
});
|
|
27447
27542
|
|
|
27448
|
-
cmd.importFiles = function(catalog, opts) {
|
|
27543
|
+
cmd.importFiles = async function(catalog, opts) {
|
|
27449
27544
|
var files = opts.files || [];
|
|
27450
27545
|
var dataset;
|
|
27451
27546
|
|
|
@@ -27475,7 +27570,7 @@ ${svg}
|
|
|
27475
27570
|
if (files.length > 1) {
|
|
27476
27571
|
stop('Expected a single package file');
|
|
27477
27572
|
}
|
|
27478
|
-
dataset = importMshpFile(files[0], catalog, opts);
|
|
27573
|
+
dataset = await importMshpFile(files[0], catalog, opts);
|
|
27479
27574
|
return dataset;
|
|
27480
27575
|
}
|
|
27481
27576
|
|
|
@@ -27494,12 +27589,10 @@ ${svg}
|
|
|
27494
27589
|
return dataset;
|
|
27495
27590
|
};
|
|
27496
27591
|
|
|
27497
|
-
function importMshpFile(file, catalog, opts) {
|
|
27592
|
+
async function importMshpFile(file, catalog, opts) {
|
|
27498
27593
|
var buf = cli.readFile(file, null, opts.input);
|
|
27499
|
-
var obj = unpackSession(buf);
|
|
27500
|
-
obj.datasets.forEach(
|
|
27501
|
-
catalog.addDataset(dataset);
|
|
27502
|
-
});
|
|
27594
|
+
var obj = await unpackSession(buf);
|
|
27595
|
+
obj.datasets.forEach(catalog.addDataset, catalog);
|
|
27503
27596
|
return obj.target;
|
|
27504
27597
|
}
|
|
27505
27598
|
|
|
@@ -42648,7 +42741,7 @@ ${svg}
|
|
|
42648
42741
|
name == 'else' || name == 'endif' || name == 'stop';
|
|
42649
42742
|
}
|
|
42650
42743
|
|
|
42651
|
-
function runCommand(command, job
|
|
42744
|
+
async function runCommand(command, job) {
|
|
42652
42745
|
var name = command.name,
|
|
42653
42746
|
opts = command.options,
|
|
42654
42747
|
source,
|
|
@@ -42824,7 +42917,7 @@ ${svg}
|
|
|
42824
42917
|
|
|
42825
42918
|
} else if (name == 'i') {
|
|
42826
42919
|
if (opts.replace) job.catalog = new Catalog(); // is this what we want?
|
|
42827
|
-
targetDataset = cmd.importFiles(job.catalog, command.options);
|
|
42920
|
+
targetDataset = await cmd.importFiles(job.catalog, command.options);
|
|
42828
42921
|
if (targetDataset) {
|
|
42829
42922
|
outputLayers = targetDataset.layers; // kludge to allow layer naming below
|
|
42830
42923
|
}
|
|
@@ -42872,14 +42965,13 @@ ${svg}
|
|
|
42872
42965
|
outputLayers = cmd.mosaic(targetLayers, targetDataset, opts);
|
|
42873
42966
|
|
|
42874
42967
|
} else if (name == 'o') {
|
|
42875
|
-
outputFiles = exportTargetLayers(targets, opts);
|
|
42968
|
+
outputFiles = await exportTargetLayers(targets, opts);
|
|
42876
42969
|
if (opts.final) {
|
|
42877
42970
|
// don't propagate data if output is final
|
|
42878
42971
|
//// catalog = null;
|
|
42879
42972
|
job.catalog = new Catalog();
|
|
42880
42973
|
}
|
|
42881
|
-
writeFiles(outputFiles, opts
|
|
42882
|
-
return; // async command
|
|
42974
|
+
await utils.promisify(writeFiles)(outputFiles, opts);
|
|
42883
42975
|
|
|
42884
42976
|
} else if (name == 'point-grid') {
|
|
42885
42977
|
outputLayers = [cmd.pointGrid(targetDataset, opts)];
|
|
@@ -42903,19 +42995,11 @@ ${svg}
|
|
|
42903
42995
|
cmd.print(command._.join(' '));
|
|
42904
42996
|
|
|
42905
42997
|
} else if (name == 'proj') {
|
|
42906
|
-
initProjLibrary(opts
|
|
42907
|
-
|
|
42908
|
-
|
|
42909
|
-
|
|
42910
|
-
targets.forEach(function(targ) {
|
|
42911
|
-
cmd.proj(targ.dataset, job.catalog, opts);
|
|
42912
|
-
});
|
|
42913
|
-
} catch(e) {
|
|
42914
|
-
err = e;
|
|
42915
|
-
}
|
|
42916
|
-
done(err);
|
|
42998
|
+
await utils.promisify(initProjLibrary)(opts);
|
|
42999
|
+
job.resumeCommand();
|
|
43000
|
+
targets.forEach(function(targ) {
|
|
43001
|
+
cmd.proj(targ.dataset, job.catalog, opts);
|
|
42917
43002
|
});
|
|
42918
|
-
return; // async command
|
|
42919
43003
|
|
|
42920
43004
|
} else if (name == 'rectangle') {
|
|
42921
43005
|
if (source || opts.bbox || targets.length === 0) {
|
|
@@ -42942,8 +43026,7 @@ ${svg}
|
|
|
42942
43026
|
});
|
|
42943
43027
|
|
|
42944
43028
|
} else if (name == 'run') {
|
|
42945
|
-
cmd.run(job, targets, opts
|
|
42946
|
-
return; // async command
|
|
43029
|
+
await utils.promisify(cmd.run)(job, targets, opts);
|
|
42947
43030
|
|
|
42948
43031
|
} else if (name == 'scalebar') {
|
|
42949
43032
|
cmd.scalebar(job.catalog, opts);
|
|
@@ -43064,12 +43147,13 @@ ${svg}
|
|
|
43064
43147
|
}
|
|
43065
43148
|
|
|
43066
43149
|
// non-erroring synchronous commands are done
|
|
43067
|
-
done(null);
|
|
43150
|
+
return done(null);
|
|
43068
43151
|
|
|
43069
43152
|
function done(err) {
|
|
43070
43153
|
job.endCommand();
|
|
43071
43154
|
verbose('-', T$1.stop());
|
|
43072
|
-
|
|
43155
|
+
if (err) throw err;
|
|
43156
|
+
return job;
|
|
43073
43157
|
}
|
|
43074
43158
|
}
|
|
43075
43159
|
|
|
@@ -43318,7 +43402,11 @@ ${svg}
|
|
|
43318
43402
|
utils.reduceAsync(commands, job, nextCommand, done);
|
|
43319
43403
|
|
|
43320
43404
|
function nextCommand(job, cmd, next) {
|
|
43321
|
-
runCommand(cmd, job
|
|
43405
|
+
runCommand(cmd, job).then(function(result) {
|
|
43406
|
+
next(null, result);
|
|
43407
|
+
}).catch(function(e) {
|
|
43408
|
+
next(e);
|
|
43409
|
+
});
|
|
43322
43410
|
}
|
|
43323
43411
|
}
|
|
43324
43412
|
|
package/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -102,6 +102,8 @@
|
|
|
102
102
|
<img class="pin-btn pinned" src="images/eye2.png">
|
|
103
103
|
</div>
|
|
104
104
|
<div class="layer-list"></div>
|
|
105
|
+
<h3>Files</h3>
|
|
106
|
+
<div class="file-list"></div>
|
|
105
107
|
<div>
|
|
106
108
|
<div id="add-file-btn" class="dialog-btn btn">Add a file</div>
|
|
107
109
|
<!-- <div id="add-empty-btn" class="dialog-btn btn">Empty layer</div> -->
|