mapshaper 0.7.19 → 0.7.20
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 +338 -35
- package/package.json +2 -2
- package/www/mapshaper-gui.js +118 -52
- package/www/mapshaper.js +338 -35
- 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;
|
|
@@ -17302,18 +17310,18 @@
|
|
|
17302
17310
|
height = 0;
|
|
17303
17311
|
|
|
17304
17312
|
el.on('mouseover', update);
|
|
17305
|
-
if (window.onorientationchange) window.addEventListener('orientationchange', update);
|
|
17313
|
+
if (window.onorientationchange) window.addEventListener('orientationchange', function() { update('window'); });
|
|
17306
17314
|
window.addEventListener('scroll', update);
|
|
17307
|
-
window.addEventListener('resize', update);
|
|
17315
|
+
window.addEventListener('resize', function() { update('window'); });
|
|
17308
17316
|
|
|
17309
17317
|
// trigger an update, e.g. when map container is resized
|
|
17310
|
-
this.update = function() {
|
|
17311
|
-
update();
|
|
17318
|
+
this.update = function(source) {
|
|
17319
|
+
update(source);
|
|
17312
17320
|
};
|
|
17313
17321
|
|
|
17314
|
-
this.resize = function(w, h) {
|
|
17322
|
+
this.resize = function(w, h, source) {
|
|
17315
17323
|
el.css('width', w).css('height', h);
|
|
17316
|
-
update();
|
|
17324
|
+
update(source);
|
|
17317
17325
|
};
|
|
17318
17326
|
|
|
17319
17327
|
this.width = function() { return width; };
|
|
@@ -17328,7 +17336,7 @@
|
|
|
17328
17336
|
};
|
|
17329
17337
|
};
|
|
17330
17338
|
|
|
17331
|
-
function update() {
|
|
17339
|
+
function update(source) {
|
|
17332
17340
|
var div = el.node(),
|
|
17333
17341
|
xy = getPageXY(div),
|
|
17334
17342
|
w = div.clientWidth,
|
|
@@ -17344,7 +17352,7 @@
|
|
|
17344
17352
|
height = h;
|
|
17345
17353
|
self.dispatchEvent('change', self.position());
|
|
17346
17354
|
if (resized) {
|
|
17347
|
-
self.dispatchEvent('resize', self.position());
|
|
17355
|
+
self.dispatchEvent('resize', Object.assign(self.position(), {source: source}));
|
|
17348
17356
|
}
|
|
17349
17357
|
}
|
|
17350
17358
|
}
|
|
@@ -20307,7 +20315,7 @@
|
|
|
20307
20315
|
_position.on('resize', function(e) {
|
|
20308
20316
|
if (ready()) {
|
|
20309
20317
|
// triggerChangeEvent({resize: true});
|
|
20310
|
-
triggerChangeEvent();
|
|
20318
|
+
triggerChangeEvent({resize: true, resizeSource: e.source});
|
|
20311
20319
|
}
|
|
20312
20320
|
});
|
|
20313
20321
|
|
|
@@ -20478,8 +20486,8 @@
|
|
|
20478
20486
|
_scale = scale;
|
|
20479
20487
|
}
|
|
20480
20488
|
|
|
20481
|
-
function triggerChangeEvent() {
|
|
20482
|
-
_self.dispatchEvent('change');
|
|
20489
|
+
function triggerChangeEvent(data) {
|
|
20490
|
+
_self.dispatchEvent('change', data);
|
|
20483
20491
|
}
|
|
20484
20492
|
|
|
20485
20493
|
// stop zooming before rounding errors become too obvious
|
|
@@ -20571,7 +20579,7 @@
|
|
|
20571
20579
|
function getCachedRasterViewportPreview(layer, ext) {
|
|
20572
20580
|
var entry = cache$1.get(layer);
|
|
20573
20581
|
var params = getRasterViewportPreviewParams(layer, ext);
|
|
20574
|
-
if (!entry || !params || entry
|
|
20582
|
+
if (!entry || !params || !rasterViewportCacheEntryMatches(entry, params)) return null;
|
|
20575
20583
|
return entry.preview;
|
|
20576
20584
|
}
|
|
20577
20585
|
|
|
@@ -20580,9 +20588,9 @@
|
|
|
20580
20588
|
var entry = cache$1.get(layer);
|
|
20581
20589
|
var id, stats, timing, preview;
|
|
20582
20590
|
if (!params || !params.needed) return;
|
|
20583
|
-
if (entry && entry
|
|
20591
|
+
if (entry && rasterViewportCacheEntryMatches(entry, params)) return;
|
|
20584
20592
|
id = ++requestId$1;
|
|
20585
|
-
cache$1.set(layer,
|
|
20593
|
+
cache$1.set(layer, getRasterViewportCacheEntry(params, {pending: id}));
|
|
20586
20594
|
setTimeout(function() {
|
|
20587
20595
|
var current = cache$1.get(layer);
|
|
20588
20596
|
if (!current || current.pending != id) return;
|
|
@@ -20594,10 +20602,7 @@
|
|
|
20594
20602
|
logRasterPreviewTiming(params, timing);
|
|
20595
20603
|
current = cache$1.get(layer);
|
|
20596
20604
|
if (!preview || !current || current.pending != id) return;
|
|
20597
|
-
cache$1.set(layer, {
|
|
20598
|
-
key: params.key,
|
|
20599
|
-
preview: preview
|
|
20600
|
-
});
|
|
20605
|
+
cache$1.set(layer, getRasterViewportCacheEntry(params, {preview: preview}));
|
|
20601
20606
|
onReady();
|
|
20602
20607
|
}, 0);
|
|
20603
20608
|
}
|
|
@@ -20659,6 +20664,17 @@
|
|
|
20659
20664
|
};
|
|
20660
20665
|
}
|
|
20661
20666
|
|
|
20667
|
+
function rasterViewportCacheEntryMatches(entry, params) {
|
|
20668
|
+
return entry.key == params.key && entry.grid == params.grid && entry.samples == params.grid.samples;
|
|
20669
|
+
}
|
|
20670
|
+
|
|
20671
|
+
function getRasterViewportCacheEntry(params, entry) {
|
|
20672
|
+
entry.key = params.key;
|
|
20673
|
+
entry.grid = params.grid;
|
|
20674
|
+
entry.samples = params.grid.samples;
|
|
20675
|
+
return entry;
|
|
20676
|
+
}
|
|
20677
|
+
|
|
20662
20678
|
function getCachedRasterScalingStats(params, timing) {
|
|
20663
20679
|
var cached = params.raster.view && params.raster.view.scalingStats;
|
|
20664
20680
|
var key;
|
|
@@ -20764,6 +20780,7 @@
|
|
|
20764
20780
|
var params = getRasterReprojectedPreviewParams(layer, ext);
|
|
20765
20781
|
var entry = cache.get(layer);
|
|
20766
20782
|
if (!entry || !entry.preview) return null;
|
|
20783
|
+
if (params && !rasterReprojectedCacheSourceMatches(entry, params)) return null;
|
|
20767
20784
|
if (!params || entry.key != params.key) return entry.preview;
|
|
20768
20785
|
return entry.preview;
|
|
20769
20786
|
}
|
|
@@ -20773,9 +20790,9 @@
|
|
|
20773
20790
|
var entry = cache.get(layer);
|
|
20774
20791
|
var id, timing;
|
|
20775
20792
|
if (!params) return;
|
|
20776
|
-
if (entry && entry
|
|
20793
|
+
if (entry && rasterReprojectedCacheEntryMatches(entry, params)) return;
|
|
20777
20794
|
id = ++requestId;
|
|
20778
|
-
cache.set(layer,
|
|
20795
|
+
cache.set(layer, getRasterReprojectedCacheEntry(params, {pending: id}));
|
|
20779
20796
|
setTimeout(function() {
|
|
20780
20797
|
var current = cache.get(layer);
|
|
20781
20798
|
var grid, preview;
|
|
@@ -20805,7 +20822,7 @@
|
|
|
20805
20822
|
preview.bbox = grid.bbox;
|
|
20806
20823
|
current = cache.get(layer);
|
|
20807
20824
|
if (!current || current.pending != id) return;
|
|
20808
|
-
cache.set(layer,
|
|
20825
|
+
cache.set(layer, getRasterReprojectedCacheEntry(params, {preview: preview}));
|
|
20809
20826
|
onReady();
|
|
20810
20827
|
}, 0);
|
|
20811
20828
|
}
|
|
@@ -20871,6 +20888,21 @@
|
|
|
20871
20888
|
].join('|');
|
|
20872
20889
|
}
|
|
20873
20890
|
|
|
20891
|
+
function rasterReprojectedCacheEntryMatches(entry, params) {
|
|
20892
|
+
return entry.key == params.key && rasterReprojectedCacheSourceMatches(entry, params);
|
|
20893
|
+
}
|
|
20894
|
+
|
|
20895
|
+
function rasterReprojectedCacheSourceMatches(entry, params) {
|
|
20896
|
+
return entry.grid == params.grid && entry.samples == params.grid.samples;
|
|
20897
|
+
}
|
|
20898
|
+
|
|
20899
|
+
function getRasterReprojectedCacheEntry(params, entry) {
|
|
20900
|
+
entry.key = params.key;
|
|
20901
|
+
entry.grid = params.grid;
|
|
20902
|
+
entry.samples = params.grid.samples;
|
|
20903
|
+
return entry;
|
|
20904
|
+
}
|
|
20905
|
+
|
|
20874
20906
|
function applyCoverageMask(preview, coverage) {
|
|
20875
20907
|
var pixels = preview && preview.pixels;
|
|
20876
20908
|
if (!pixels || !coverage) return;
|
|
@@ -22377,7 +22409,10 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
22377
22409
|
_visibleLayers = [], // cached visible map layers
|
|
22378
22410
|
_hit, _nav,
|
|
22379
22411
|
_intersectionLyr, _activeLyr, _overlayLayers,
|
|
22380
|
-
_renderer, _dynamicCRS
|
|
22412
|
+
_renderer, _dynamicCRS,
|
|
22413
|
+
_resizeRedrawTimer = null;
|
|
22414
|
+
|
|
22415
|
+
var RESIZE_REDRAW_DELAY = 200;
|
|
22381
22416
|
|
|
22382
22417
|
_mouse.disable(); // wait for gui.focus() to activate mouse events
|
|
22383
22418
|
|
|
@@ -22527,14 +22562,44 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
22527
22562
|
|
|
22528
22563
|
_ext.on('change', function(e) {
|
|
22529
22564
|
gui?.basemap.refresh(); // keep basemap synced up (if enabled)
|
|
22530
|
-
|
|
22565
|
+
if (e.resize) {
|
|
22566
|
+
drawLayersForResize(e.resizeSource);
|
|
22567
|
+
} else {
|
|
22568
|
+
cancelResizeRedraw();
|
|
22569
|
+
drawLayers(e.redraw ? '' : 'nav');
|
|
22570
|
+
}
|
|
22531
22571
|
});
|
|
22532
22572
|
|
|
22533
|
-
gui.on('resize', function() {
|
|
22534
|
-
position.update(); // kludge to detect new map size after console toggle
|
|
22573
|
+
gui.on('resize', function(e) {
|
|
22574
|
+
position.update(e.source); // kludge to detect new map size after console toggle
|
|
22535
22575
|
});
|
|
22536
22576
|
};
|
|
22537
22577
|
|
|
22578
|
+
function drawLayersForResize(source) {
|
|
22579
|
+
if (source == 'sidebar') {
|
|
22580
|
+
cancelResizeRedraw();
|
|
22581
|
+
drawLayers();
|
|
22582
|
+
} else {
|
|
22583
|
+
drawLayers('nav');
|
|
22584
|
+
scheduleResizeRedraw();
|
|
22585
|
+
}
|
|
22586
|
+
}
|
|
22587
|
+
|
|
22588
|
+
function scheduleResizeRedraw() {
|
|
22589
|
+
cancelResizeRedraw();
|
|
22590
|
+
_resizeRedrawTimer = setTimeout(function() {
|
|
22591
|
+
_resizeRedrawTimer = null;
|
|
22592
|
+
drawLayers();
|
|
22593
|
+
}, RESIZE_REDRAW_DELAY);
|
|
22594
|
+
}
|
|
22595
|
+
|
|
22596
|
+
function cancelResizeRedraw() {
|
|
22597
|
+
if (_resizeRedrawTimer) {
|
|
22598
|
+
clearTimeout(_resizeRedrawTimer);
|
|
22599
|
+
_resizeRedrawTimer = null;
|
|
22600
|
+
}
|
|
22601
|
+
}
|
|
22602
|
+
|
|
22538
22603
|
function getGlobalStyleOptions(opts) {
|
|
22539
22604
|
var mode = gui.state.interaction_mode;
|
|
22540
22605
|
return Object.assign({
|
|
@@ -23633,6 +23698,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23633
23698
|
|
|
23634
23699
|
initModeRules(gui);
|
|
23635
23700
|
startRasterSourceStoreLifecycle();
|
|
23701
|
+
cleanupStaleUndoPayloads(gui).catch(function() {});
|
|
23636
23702
|
gui.map.init();
|
|
23637
23703
|
|
|
23638
23704
|
if (opts.saveControl) {
|
|
@@ -23694,7 +23760,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23694
23760
|
.classed('layers-open', sidebarPanel == 'layers')
|
|
23695
23761
|
.classed('console-open', sidebarPanel == 'console');
|
|
23696
23762
|
gui.dispatchEvent('sidebar', {name: sidebarPanel, prev: prev});
|
|
23697
|
-
gui.dispatchEvent('resize');
|
|
23763
|
+
gui.dispatchEvent('resize', {source: 'sidebar'});
|
|
23698
23764
|
};
|
|
23699
23765
|
|
|
23700
23766
|
gui.toggleSidebarPanel = function(name) {
|
|
@@ -23797,7 +23863,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
23797
23863
|
if (sidebarResizeFrame) return;
|
|
23798
23864
|
sidebarResizeFrame = requestAnimationFrame(function() {
|
|
23799
23865
|
sidebarResizeFrame = null;
|
|
23800
|
-
gui.dispatchEvent('resize');
|
|
23866
|
+
gui.dispatchEvent('resize', {source: 'sidebar-resize'});
|
|
23801
23867
|
});
|
|
23802
23868
|
}
|
|
23803
23869
|
}
|