mapshaper 0.5.105 → 0.5.106
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/CHANGELOG.md +3 -0
- package/mapshaper.js +1 -1
- package/package.json +1 -1
- package/www/mapshaper-gui.js +25 -33
- package/www/mapshaper.js +1 -1
package/CHANGELOG.md
CHANGED
package/mapshaper.js
CHANGED
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -7007,7 +7007,8 @@
|
|
|
7007
7007
|
function getBoxData(e) {
|
|
7008
7008
|
var pageBox = [e.pageX, e.pageY, dragStartEvt.pageX, dragStartEvt.pageY];
|
|
7009
7009
|
var mapBox = [e.x, e.y, dragStartEvt.x, dragStartEvt.y];
|
|
7010
|
-
var
|
|
7010
|
+
var displayBox = pixToCoords(mapBox);
|
|
7011
|
+
var dataBox = getBBoxCoords(gui.map.getActiveLayer(), displayBox);
|
|
7011
7012
|
if (pageBox[0] > pageBox[2]) {
|
|
7012
7013
|
swapElements(pageBox, 0, 2);
|
|
7013
7014
|
swapElements(mapBox, 0, 2);
|
|
@@ -7018,10 +7019,20 @@
|
|
|
7018
7019
|
}
|
|
7019
7020
|
return {
|
|
7020
7021
|
map_bbox: mapBox,
|
|
7021
|
-
page_bbox: pageBox
|
|
7022
|
+
page_bbox: pageBox,
|
|
7023
|
+
// round coords, for nicer 'info' display
|
|
7024
|
+
// (rounded precision should be sub-pixel)
|
|
7025
|
+
map_display_bbox: internal.getRoundedCoords(displayBox, internal.getBoundsPrecisionForDisplay(displayBox)),
|
|
7026
|
+
map_data_bbox: internal.getRoundedCoords(dataBox, internal.getBoundsPrecisionForDisplay(dataBox))
|
|
7022
7027
|
};
|
|
7023
7028
|
}
|
|
7024
7029
|
|
|
7030
|
+
function pixToCoords(bbox) {
|
|
7031
|
+
var a = ext.translatePixelCoords(bbox[0], bbox[1]);
|
|
7032
|
+
var b = ext.translatePixelCoords(bbox[2], bbox[3]);
|
|
7033
|
+
return [a[0], b[1], b[0], a[1]];
|
|
7034
|
+
}
|
|
7035
|
+
|
|
7025
7036
|
function disabled() {
|
|
7026
7037
|
return !!gui.options.disableNavigation;
|
|
7027
7038
|
}
|
|
@@ -7104,17 +7115,16 @@
|
|
|
7104
7115
|
if (!_on) return;
|
|
7105
7116
|
var b = e.page_bbox;
|
|
7106
7117
|
box.show(b[0], b[1], b[2], b[3]);
|
|
7107
|
-
updateSelection(e.
|
|
7118
|
+
updateSelection(e.map_data_bbox, true);
|
|
7108
7119
|
});
|
|
7109
7120
|
|
|
7110
7121
|
gui.on('box_drag_end', function(e) {
|
|
7111
7122
|
if (!_on) return;
|
|
7112
7123
|
box.hide();
|
|
7113
|
-
updateSelection(e.
|
|
7124
|
+
updateSelection(e.map_data_bbox);
|
|
7114
7125
|
});
|
|
7115
7126
|
|
|
7116
|
-
function updateSelection(
|
|
7117
|
-
var bbox = bboxToCoords(bboxPixels);
|
|
7127
|
+
function updateSelection(bbox, transient) {
|
|
7118
7128
|
var active = gui.model.getActiveLayer();
|
|
7119
7129
|
var ids = internal.findShapesIntersectingBBox(bbox, active.layer, active.dataset.arcs);
|
|
7120
7130
|
if (transient) {
|
|
@@ -7128,12 +7138,6 @@
|
|
|
7128
7138
|
_on = true;
|
|
7129
7139
|
}
|
|
7130
7140
|
|
|
7131
|
-
function bboxToCoords(bbox) {
|
|
7132
|
-
var a = ext.translatePixelCoords(bbox[0], bbox[1]);
|
|
7133
|
-
var b = ext.translatePixelCoords(bbox[2], bbox[3]);
|
|
7134
|
-
return [a[0], b[1], b[0], a[1]];
|
|
7135
|
-
}
|
|
7136
|
-
|
|
7137
7141
|
function turnOff() {
|
|
7138
7142
|
reset();
|
|
7139
7143
|
_on = false;
|
|
@@ -9337,7 +9341,7 @@
|
|
|
9337
9341
|
var popup = gui.container.findChild('.box-tool-options');
|
|
9338
9342
|
var coords = popup.findChild('.box-coords');
|
|
9339
9343
|
var _on = false;
|
|
9340
|
-
var
|
|
9344
|
+
var bboxData;
|
|
9341
9345
|
|
|
9342
9346
|
var infoBtn = new SimpleButton(popup.findChild('.info-btn')).on('click', function() {
|
|
9343
9347
|
if (coords.visible()) hideCoords(); else showCoords();
|
|
@@ -9364,11 +9368,11 @@
|
|
|
9364
9368
|
gui.enterMode('selection_tool');
|
|
9365
9369
|
gui.interaction.setMode('selection');
|
|
9366
9370
|
// kludge to pass bbox to the selection tool
|
|
9367
|
-
gui.dispatchEvent('box_drag_end',
|
|
9371
|
+
gui.dispatchEvent('box_drag_end', bboxData);
|
|
9368
9372
|
});
|
|
9369
9373
|
|
|
9370
9374
|
new SimpleButton(popup.findChild('.clip-btn')).on('click', function() {
|
|
9371
|
-
runCommand('-clip bbox2=' +
|
|
9375
|
+
runCommand('-clip bbox2=' + bboxData.map_data_bbox.join(','));
|
|
9372
9376
|
});
|
|
9373
9377
|
|
|
9374
9378
|
gui.addMode('box_tool', turnOn, turnOff);
|
|
@@ -9384,8 +9388,8 @@
|
|
|
9384
9388
|
// Update the visible rectangle when the map view changes
|
|
9385
9389
|
// (e.g. during zooming or panning)
|
|
9386
9390
|
ext.on('change', function() {
|
|
9387
|
-
if (!_on || !box.visible() || !
|
|
9388
|
-
var b = coordsToPix(
|
|
9391
|
+
if (!_on || !box.visible() || !bboxData) return;
|
|
9392
|
+
var b = coordsToPix(bboxData.map_display_bbox);
|
|
9389
9393
|
var pos = ext.position();
|
|
9390
9394
|
var dx = pos.pageX,
|
|
9391
9395
|
dy = pos.pageY;
|
|
@@ -9399,20 +9403,17 @@
|
|
|
9399
9403
|
|
|
9400
9404
|
gui.on('box_drag', function(e) {
|
|
9401
9405
|
var b = e.page_bbox;
|
|
9402
|
-
|
|
9403
|
-
bboxDisplayCoords = pixToCoords(bboxPixels);
|
|
9406
|
+
bboxData = e.data;
|
|
9404
9407
|
if (_on || inZoomMode()) {
|
|
9405
9408
|
box.show(b[0], b[1], b[2], b[3]);
|
|
9406
9409
|
}
|
|
9407
9410
|
});
|
|
9408
9411
|
|
|
9409
9412
|
gui.on('box_drag_end', function(e) {
|
|
9410
|
-
|
|
9411
|
-
bboxDisplayCoords = pixToCoords(bboxPixels);
|
|
9412
|
-
bboxDataCoords = getBBoxCoords(gui.map.getActiveLayer(), bboxDisplayCoords);
|
|
9413
|
+
bboxData = e.data;
|
|
9413
9414
|
if (inZoomMode()) {
|
|
9414
9415
|
box.hide();
|
|
9415
|
-
nav.zoomToBbox(
|
|
9416
|
+
nav.zoomToBbox(e.map_bbox);
|
|
9416
9417
|
} else if (_on) {
|
|
9417
9418
|
popup.show();
|
|
9418
9419
|
}
|
|
@@ -9433,7 +9434,7 @@
|
|
|
9433
9434
|
|
|
9434
9435
|
function showCoords() {
|
|
9435
9436
|
El(infoBtn.node()).addClass('selected-btn');
|
|
9436
|
-
coords.text(
|
|
9437
|
+
coords.text(bboxData.map_data_bbox.join(','));
|
|
9437
9438
|
coords.show();
|
|
9438
9439
|
GUI.selectElement(coords.node());
|
|
9439
9440
|
}
|
|
@@ -9462,15 +9463,6 @@
|
|
|
9462
9463
|
hideCoords();
|
|
9463
9464
|
}
|
|
9464
9465
|
|
|
9465
|
-
function pixToCoords(bbox) {
|
|
9466
|
-
var a = ext.translatePixelCoords(bbox[0], bbox[1]);
|
|
9467
|
-
var b = ext.translatePixelCoords(bbox[2], bbox[3]);
|
|
9468
|
-
var bbox2 = [a[0], b[1], b[0], a[1]];
|
|
9469
|
-
// round coords, for nicer 'info' display
|
|
9470
|
-
// (rounded precision should be sub-pixel)
|
|
9471
|
-
return internal.getRoundedCoords(bbox2, internal.getBoundsPrecisionForDisplay(bbox2));
|
|
9472
|
-
}
|
|
9473
|
-
|
|
9474
9466
|
function coordsToPix(bbox) {
|
|
9475
9467
|
var a = ext.translateCoords(bbox[0], bbox[1]);
|
|
9476
9468
|
var b = ext.translateCoords(bbox[2], bbox[3]);
|