mapshaper 0.7.19 → 0.7.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/bin/mapshaper-gui +47 -3
- package/mapshaper.js +377 -52
- package/package.json +2 -2
- package/www/mapshaper-gui.js +121 -52
- package/www/mapshaper.js +377 -52
- package/www/modules.js +71 -0
- package/www/page.css +2 -0
- package/www/sponsor.html +3 -5
package/www/mapshaper-gui.js
CHANGED
|
@@ -6611,34 +6611,42 @@
|
|
|
6611
6611
|
|
|
6612
6612
|
function getPayloadStore() {
|
|
6613
6613
|
if (!gui.undoPayloadStore) {
|
|
6614
|
-
gui.undoPayloadStore = createUndoPayloadStore(getUndoPayloadStoreOptions());
|
|
6615
|
-
gui.undoPayloadStore.startLifecycle();
|
|
6616
|
-
gui.undoPayloadStore.cleanupStaleSessions().then(function(result) {
|
|
6617
|
-
logStartupCleanup({
|
|
6618
|
-
count: result.keys.length,
|
|
6619
|
-
sessionCount: result.sessionCount,
|
|
6620
|
-
singular: 'undo payload',
|
|
6621
|
-
plural: 'undo payloads',
|
|
6622
|
-
sizeBytes: result.sizeBytes
|
|
6623
|
-
});
|
|
6624
|
-
}).catch(function() {});
|
|
6614
|
+
gui.undoPayloadStore = createUndoPayloadStore(getUndoPayloadStoreOptions(gui));
|
|
6625
6615
|
}
|
|
6616
|
+
gui.undoPayloadStore.startLifecycle();
|
|
6626
6617
|
return gui.undoPayloadStore;
|
|
6627
6618
|
}
|
|
6619
|
+
}
|
|
6628
6620
|
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
maxPayloadBytes: getUndoStorageLimit('undoPayloadMaxBytes', 512 * 1024 * 1024)
|
|
6633
|
-
};
|
|
6621
|
+
function cleanupStaleUndoPayloads(gui) {
|
|
6622
|
+
if (!gui.undoPayloadStore) {
|
|
6623
|
+
gui.undoPayloadStore = createUndoPayloadStore(getUndoPayloadStoreOptions(gui));
|
|
6634
6624
|
}
|
|
6625
|
+
var store = gui.undoPayloadStore;
|
|
6626
|
+
return store.cleanupStaleSessions().then(function(result) {
|
|
6627
|
+
logStartupCleanup({
|
|
6628
|
+
count: result.keys.length,
|
|
6629
|
+
sessionCount: result.sessionCount,
|
|
6630
|
+
singular: 'undo payload',
|
|
6631
|
+
plural: 'undo payloads',
|
|
6632
|
+
sizeBytes: result.sizeBytes
|
|
6633
|
+
});
|
|
6634
|
+
return result;
|
|
6635
|
+
});
|
|
6636
|
+
}
|
|
6635
6637
|
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6638
|
+
function getUndoPayloadStoreOptions(gui) {
|
|
6639
|
+
return {
|
|
6640
|
+
maxBytes: getUndoStorageLimit(gui, 'undoStorageMaxBytes', 1024 * 1024 * 1024),
|
|
6641
|
+
maxPayloadBytes: getUndoStorageLimit(gui, 'undoPayloadMaxBytes', 512 * 1024 * 1024)
|
|
6642
|
+
};
|
|
6643
|
+
}
|
|
6644
|
+
|
|
6645
|
+
function getUndoStorageLimit(gui, name, defaultValue) {
|
|
6646
|
+
var opt = gui && gui.options && gui.options[name],
|
|
6647
|
+
query = getQueryValue$2(name);
|
|
6648
|
+
if (query !== null && +query >= 0) return +query;
|
|
6649
|
+
return opt >= 0 ? opt : defaultValue;
|
|
6642
6650
|
}
|
|
6643
6651
|
|
|
6644
6652
|
function getRedoCaptureUnits(units) {
|
|
@@ -6872,7 +6880,7 @@
|
|
|
6872
6880
|
var mapCRS = gui.map.getActiveLayerCRS();
|
|
6873
6881
|
var dataCRS = internal.getDatasetCRS(dataset);
|
|
6874
6882
|
var msg, reproject;
|
|
6875
|
-
if (!dataCRS || !mapCRS || internal.
|
|
6883
|
+
if (!dataCRS || !mapCRS || internal.crsHaveSameTransform(mapCRS, dataCRS)) return;
|
|
6876
6884
|
if (!datasetCanBeReprojected(dataset, dataCRS, mapCRS)) {
|
|
6877
6885
|
notifyProjectionMismatch(gui, dataset);
|
|
6878
6886
|
return;
|
|
@@ -8373,7 +8381,7 @@
|
|
|
8373
8381
|
if (!sourceCRS || !displayCRS) {
|
|
8374
8382
|
return false;
|
|
8375
8383
|
}
|
|
8376
|
-
if (internal.
|
|
8384
|
+
if (internal.crsHaveSameTransform(sourceCRS, displayCRS)) {
|
|
8377
8385
|
return false;
|
|
8378
8386
|
}
|
|
8379
8387
|
return true;
|
|
@@ -8522,7 +8530,7 @@
|
|
|
8522
8530
|
if (!lyr.gui.geographic) {
|
|
8523
8531
|
return;
|
|
8524
8532
|
}
|
|
8525
|
-
if (lyr.gui.dynamic_crs && internal.
|
|
8533
|
+
if (lyr.gui.dynamic_crs && internal.crsHaveSameTransform(sourceCRS, lyr.gui.dynamic_crs)) {
|
|
8526
8534
|
return;
|
|
8527
8535
|
}
|
|
8528
8536
|
var gui = lyr.gui;
|
|
@@ -17016,6 +17024,9 @@
|
|
|
17016
17024
|
}
|
|
17017
17025
|
|
|
17018
17026
|
function selectStyleFeature(id, e) {
|
|
17027
|
+
if (selectionIds.includes(id)) {
|
|
17028
|
+
return utils$1.difference(selectionIds, [id]);
|
|
17029
|
+
}
|
|
17019
17030
|
return eventUsesAdditiveSelection(e) ?
|
|
17020
17031
|
toggleId(id, selectionIds) :
|
|
17021
17032
|
[id];
|
|
@@ -17302,18 +17313,18 @@
|
|
|
17302
17313
|
height = 0;
|
|
17303
17314
|
|
|
17304
17315
|
el.on('mouseover', update);
|
|
17305
|
-
if (window.onorientationchange) window.addEventListener('orientationchange', update);
|
|
17316
|
+
if (window.onorientationchange) window.addEventListener('orientationchange', function() { update('window'); });
|
|
17306
17317
|
window.addEventListener('scroll', update);
|
|
17307
|
-
window.addEventListener('resize', update);
|
|
17318
|
+
window.addEventListener('resize', function() { update('window'); });
|
|
17308
17319
|
|
|
17309
17320
|
// trigger an update, e.g. when map container is resized
|
|
17310
|
-
this.update = function() {
|
|
17311
|
-
update();
|
|
17321
|
+
this.update = function(source) {
|
|
17322
|
+
update(source);
|
|
17312
17323
|
};
|
|
17313
17324
|
|
|
17314
|
-
this.resize = function(w, h) {
|
|
17325
|
+
this.resize = function(w, h, source) {
|
|
17315
17326
|
el.css('width', w).css('height', h);
|
|
17316
|
-
update();
|
|
17327
|
+
update(source);
|
|
17317
17328
|
};
|
|
17318
17329
|
|
|
17319
17330
|
this.width = function() { return width; };
|
|
@@ -17328,7 +17339,7 @@
|
|
|
17328
17339
|
};
|
|
17329
17340
|
};
|
|
17330
17341
|
|
|
17331
|
-
function update() {
|
|
17342
|
+
function update(source) {
|
|
17332
17343
|
var div = el.node(),
|
|
17333
17344
|
xy = getPageXY(div),
|
|
17334
17345
|
w = div.clientWidth,
|
|
@@ -17344,7 +17355,7 @@
|
|
|
17344
17355
|
height = h;
|
|
17345
17356
|
self.dispatchEvent('change', self.position());
|
|
17346
17357
|
if (resized) {
|
|
17347
|
-
self.dispatchEvent('resize', self.position());
|
|
17358
|
+
self.dispatchEvent('resize', Object.assign(self.position(), {source: source}));
|
|
17348
17359
|
}
|
|
17349
17360
|
}
|
|
17350
17361
|
}
|
|
@@ -20307,7 +20318,7 @@
|
|
|
20307
20318
|
_position.on('resize', function(e) {
|
|
20308
20319
|
if (ready()) {
|
|
20309
20320
|
// triggerChangeEvent({resize: true});
|
|
20310
|
-
triggerChangeEvent();
|
|
20321
|
+
triggerChangeEvent({resize: true, resizeSource: e.source});
|
|
20311
20322
|
}
|
|
20312
20323
|
});
|
|
20313
20324
|
|
|
@@ -20478,8 +20489,8 @@
|
|
|
20478
20489
|
_scale = scale;
|
|
20479
20490
|
}
|
|
20480
20491
|
|
|
20481
|
-
function triggerChangeEvent() {
|
|
20482
|
-
_self.dispatchEvent('change');
|
|
20492
|
+
function triggerChangeEvent(data) {
|
|
20493
|
+
_self.dispatchEvent('change', data);
|
|
20483
20494
|
}
|
|
20484
20495
|
|
|
20485
20496
|
// stop zooming before rounding errors become too obvious
|
|
@@ -20571,7 +20582,7 @@
|
|
|
20571
20582
|
function getCachedRasterViewportPreview(layer, ext) {
|
|
20572
20583
|
var entry = cache$1.get(layer);
|
|
20573
20584
|
var params = getRasterViewportPreviewParams(layer, ext);
|
|
20574
|
-
if (!entry || !params || entry
|
|
20585
|
+
if (!entry || !params || !rasterViewportCacheEntryMatches(entry, params)) return null;
|
|
20575
20586
|
return entry.preview;
|
|
20576
20587
|
}
|
|
20577
20588
|
|
|
@@ -20580,9 +20591,9 @@
|
|
|
20580
20591
|
var entry = cache$1.get(layer);
|
|
20581
20592
|
var id, stats, timing, preview;
|
|
20582
20593
|
if (!params || !params.needed) return;
|
|
20583
|
-
if (entry && entry
|
|
20594
|
+
if (entry && rasterViewportCacheEntryMatches(entry, params)) return;
|
|
20584
20595
|
id = ++requestId$1;
|
|
20585
|
-
cache$1.set(layer,
|
|
20596
|
+
cache$1.set(layer, getRasterViewportCacheEntry(params, {pending: id}));
|
|
20586
20597
|
setTimeout(function() {
|
|
20587
20598
|
var current = cache$1.get(layer);
|
|
20588
20599
|
if (!current || current.pending != id) return;
|
|
@@ -20594,10 +20605,7 @@
|
|
|
20594
20605
|
logRasterPreviewTiming(params, timing);
|
|
20595
20606
|
current = cache$1.get(layer);
|
|
20596
20607
|
if (!preview || !current || current.pending != id) return;
|
|
20597
|
-
cache$1.set(layer, {
|
|
20598
|
-
key: params.key,
|
|
20599
|
-
preview: preview
|
|
20600
|
-
});
|
|
20608
|
+
cache$1.set(layer, getRasterViewportCacheEntry(params, {preview: preview}));
|
|
20601
20609
|
onReady();
|
|
20602
20610
|
}, 0);
|
|
20603
20611
|
}
|
|
@@ -20659,6 +20667,17 @@
|
|
|
20659
20667
|
};
|
|
20660
20668
|
}
|
|
20661
20669
|
|
|
20670
|
+
function rasterViewportCacheEntryMatches(entry, params) {
|
|
20671
|
+
return entry.key == params.key && entry.grid == params.grid && entry.samples == params.grid.samples;
|
|
20672
|
+
}
|
|
20673
|
+
|
|
20674
|
+
function getRasterViewportCacheEntry(params, entry) {
|
|
20675
|
+
entry.key = params.key;
|
|
20676
|
+
entry.grid = params.grid;
|
|
20677
|
+
entry.samples = params.grid.samples;
|
|
20678
|
+
return entry;
|
|
20679
|
+
}
|
|
20680
|
+
|
|
20662
20681
|
function getCachedRasterScalingStats(params, timing) {
|
|
20663
20682
|
var cached = params.raster.view && params.raster.view.scalingStats;
|
|
20664
20683
|
var key;
|
|
@@ -20764,6 +20783,7 @@
|
|
|
20764
20783
|
var params = getRasterReprojectedPreviewParams(layer, ext);
|
|
20765
20784
|
var entry = cache.get(layer);
|
|
20766
20785
|
if (!entry || !entry.preview) return null;
|
|
20786
|
+
if (params && !rasterReprojectedCacheSourceMatches(entry, params)) return null;
|
|
20767
20787
|
if (!params || entry.key != params.key) return entry.preview;
|
|
20768
20788
|
return entry.preview;
|
|
20769
20789
|
}
|
|
@@ -20773,9 +20793,9 @@
|
|
|
20773
20793
|
var entry = cache.get(layer);
|
|
20774
20794
|
var id, timing;
|
|
20775
20795
|
if (!params) return;
|
|
20776
|
-
if (entry && entry
|
|
20796
|
+
if (entry && rasterReprojectedCacheEntryMatches(entry, params)) return;
|
|
20777
20797
|
id = ++requestId;
|
|
20778
|
-
cache.set(layer,
|
|
20798
|
+
cache.set(layer, getRasterReprojectedCacheEntry(params, {pending: id}));
|
|
20779
20799
|
setTimeout(function() {
|
|
20780
20800
|
var current = cache.get(layer);
|
|
20781
20801
|
var grid, preview;
|
|
@@ -20805,7 +20825,7 @@
|
|
|
20805
20825
|
preview.bbox = grid.bbox;
|
|
20806
20826
|
current = cache.get(layer);
|
|
20807
20827
|
if (!current || current.pending != id) return;
|
|
20808
|
-
cache.set(layer,
|
|
20828
|
+
cache.set(layer, getRasterReprojectedCacheEntry(params, {preview: preview}));
|
|
20809
20829
|
onReady();
|
|
20810
20830
|
}, 0);
|
|
20811
20831
|
}
|
|
@@ -20871,6 +20891,21 @@
|
|
|
20871
20891
|
].join('|');
|
|
20872
20892
|
}
|
|
20873
20893
|
|
|
20894
|
+
function rasterReprojectedCacheEntryMatches(entry, params) {
|
|
20895
|
+
return entry.key == params.key && rasterReprojectedCacheSourceMatches(entry, params);
|
|
20896
|
+
}
|
|
20897
|
+
|
|
20898
|
+
function rasterReprojectedCacheSourceMatches(entry, params) {
|
|
20899
|
+
return entry.grid == params.grid && entry.samples == params.grid.samples;
|
|
20900
|
+
}
|
|
20901
|
+
|
|
20902
|
+
function getRasterReprojectedCacheEntry(params, entry) {
|
|
20903
|
+
entry.key = params.key;
|
|
20904
|
+
entry.grid = params.grid;
|
|
20905
|
+
entry.samples = params.grid.samples;
|
|
20906
|
+
return entry;
|
|
20907
|
+
}
|
|
20908
|
+
|
|
20874
20909
|
function applyCoverageMask(preview, coverage) {
|
|
20875
20910
|
var pixels = preview && preview.pixels;
|
|
20876
20911
|
if (!pixels || !coverage) return;
|
|
@@ -22377,7 +22412,10 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
22377
22412
|
_visibleLayers = [], // cached visible map layers
|
|
22378
22413
|
_hit, _nav,
|
|
22379
22414
|
_intersectionLyr, _activeLyr, _overlayLayers,
|
|
22380
|
-
_renderer, _dynamicCRS
|
|
22415
|
+
_renderer, _dynamicCRS,
|
|
22416
|
+
_resizeRedrawTimer = null;
|
|
22417
|
+
|
|
22418
|
+
var RESIZE_REDRAW_DELAY = 200;
|
|
22381
22419
|
|
|
22382
22420
|
_mouse.disable(); // wait for gui.focus() to activate mouse events
|
|
22383
22421
|
|
|
@@ -22527,14 +22565,44 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
22527
22565
|
|
|
22528
22566
|
_ext.on('change', function(e) {
|
|
22529
22567
|
gui?.basemap.refresh(); // keep basemap synced up (if enabled)
|
|
22530
|
-
|
|
22568
|
+
if (e.resize) {
|
|
22569
|
+
drawLayersForResize(e.resizeSource);
|
|
22570
|
+
} else {
|
|
22571
|
+
cancelResizeRedraw();
|
|
22572
|
+
drawLayers(e.redraw ? '' : 'nav');
|
|
22573
|
+
}
|
|
22531
22574
|
});
|
|
22532
22575
|
|
|
22533
|
-
gui.on('resize', function() {
|
|
22534
|
-
position.update(); // kludge to detect new map size after console toggle
|
|
22576
|
+
gui.on('resize', function(e) {
|
|
22577
|
+
position.update(e.source); // kludge to detect new map size after console toggle
|
|
22535
22578
|
});
|
|
22536
22579
|
};
|
|
22537
22580
|
|
|
22581
|
+
function drawLayersForResize(source) {
|
|
22582
|
+
if (source == 'sidebar') {
|
|
22583
|
+
cancelResizeRedraw();
|
|
22584
|
+
drawLayers();
|
|
22585
|
+
} else {
|
|
22586
|
+
drawLayers('nav');
|
|
22587
|
+
scheduleResizeRedraw();
|
|
22588
|
+
}
|
|
22589
|
+
}
|
|
22590
|
+
|
|
22591
|
+
function scheduleResizeRedraw() {
|
|
22592
|
+
cancelResizeRedraw();
|
|
22593
|
+
_resizeRedrawTimer = setTimeout(function() {
|
|
22594
|
+
_resizeRedrawTimer = null;
|
|
22595
|
+
drawLayers();
|
|
22596
|
+
}, RESIZE_REDRAW_DELAY);
|
|
22597
|
+
}
|
|
22598
|
+
|
|
22599
|
+
function cancelResizeRedraw() {
|
|
22600
|
+
if (_resizeRedrawTimer) {
|
|
22601
|
+
clearTimeout(_resizeRedrawTimer);
|
|
22602
|
+
_resizeRedrawTimer = null;
|
|
22603
|
+
}
|
|
22604
|
+
}
|
|
22605
|
+
|
|
22538
22606
|
function getGlobalStyleOptions(opts) {
|
|
22539
22607
|
var mode = gui.state.interaction_mode;
|
|
22540
22608
|
return Object.assign({
|
|
@@ -23633,6 +23701,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23633
23701
|
|
|
23634
23702
|
initModeRules(gui);
|
|
23635
23703
|
startRasterSourceStoreLifecycle();
|
|
23704
|
+
cleanupStaleUndoPayloads(gui).catch(function() {});
|
|
23636
23705
|
gui.map.init();
|
|
23637
23706
|
|
|
23638
23707
|
if (opts.saveControl) {
|
|
@@ -23694,7 +23763,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23694
23763
|
.classed('layers-open', sidebarPanel == 'layers')
|
|
23695
23764
|
.classed('console-open', sidebarPanel == 'console');
|
|
23696
23765
|
gui.dispatchEvent('sidebar', {name: sidebarPanel, prev: prev});
|
|
23697
|
-
gui.dispatchEvent('resize');
|
|
23766
|
+
gui.dispatchEvent('resize', {source: 'sidebar'});
|
|
23698
23767
|
};
|
|
23699
23768
|
|
|
23700
23769
|
gui.toggleSidebarPanel = function(name) {
|
|
@@ -23797,7 +23866,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23797
23866
|
if (sidebarResizeFrame) return;
|
|
23798
23867
|
sidebarResizeFrame = requestAnimationFrame(function() {
|
|
23799
23868
|
sidebarResizeFrame = null;
|
|
23800
|
-
gui.dispatchEvent('resize');
|
|
23869
|
+
gui.dispatchEvent('resize', {source: 'sidebar-resize'});
|
|
23801
23870
|
});
|
|
23802
23871
|
}
|
|
23803
23872
|
}
|