mapshaper 0.6.9 → 0.6.11
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 +30 -8
- package/package.json +1 -1
- package/www/mapshaper-gui.js +249 -113
- package/www/mapshaper.js +30 -8
- package/www/page.css +8 -2
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.11";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -7311,15 +7311,18 @@
|
|
|
7311
7311
|
// replacing content so ArrayBuffers can be gc'd
|
|
7312
7312
|
obj.content = cli.convertArrayBuffer(obj.content); // convert to Buffer
|
|
7313
7313
|
}
|
|
7314
|
+
if (opts.gzip) {
|
|
7315
|
+
path = path + '.gz';
|
|
7316
|
+
obj.content = require$1('zlib').gzipSync(obj.content);
|
|
7317
|
+
}
|
|
7314
7318
|
if (opts.output) {
|
|
7315
7319
|
opts.output.push({filename: path, content: obj.content});
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
}
|
|
7320
|
-
cli.writeFile(path, obj.content);
|
|
7321
|
-
message("Wrote " + path);
|
|
7320
|
+
return;
|
|
7321
|
+
} if (!opts.force && inputFiles.indexOf(path) > -1) {
|
|
7322
|
+
stop('Need to use the "-o force" option to overwrite input files.');
|
|
7322
7323
|
}
|
|
7324
|
+
cli.writeFile(path, obj.content);
|
|
7325
|
+
message("Wrote " + path);
|
|
7323
7326
|
});
|
|
7324
7327
|
}
|
|
7325
7328
|
if (cb) cb(null);
|
|
@@ -8470,7 +8473,9 @@
|
|
|
8470
8473
|
function getBoundsPrecisionForDisplay(bbox) {
|
|
8471
8474
|
var w = Math.abs(bbox[2] - bbox[0]),
|
|
8472
8475
|
h = Math.abs(bbox[3] - bbox[1]),
|
|
8473
|
-
|
|
8476
|
+
// switched to max bound, based on experience with shift-drag box info
|
|
8477
|
+
// range = Math.min(w, h) + 1e-8,
|
|
8478
|
+
range = Math.max(w, h) + 1e-8,
|
|
8474
8479
|
digits = 0;
|
|
8475
8480
|
while (range < 2000) {
|
|
8476
8481
|
range *= 10;
|
|
@@ -19344,6 +19349,10 @@ ${svg}
|
|
|
19344
19349
|
describe: 'allow overwriting input files',
|
|
19345
19350
|
type: 'flag'
|
|
19346
19351
|
})
|
|
19352
|
+
.option('gzip', {
|
|
19353
|
+
describe: 'apply gzip compression to output files',
|
|
19354
|
+
type: 'flag'
|
|
19355
|
+
})
|
|
19347
19356
|
.option('dry-run', {
|
|
19348
19357
|
// describe: 'do not output any files'
|
|
19349
19358
|
type: 'flag'
|
|
@@ -23798,6 +23807,19 @@ ${svg}
|
|
|
23798
23807
|
} else if (fileType) { // string type, e.g. kml, geojson
|
|
23799
23808
|
content = cli.readFile(path, encoding || 'utf-8', cache);
|
|
23800
23809
|
|
|
23810
|
+
} else if (getFileExtension(path) == 'gz') {
|
|
23811
|
+
var pathgz = path;
|
|
23812
|
+
path = pathgz.replace(/\.gz$/, '');
|
|
23813
|
+
fileType = guessInputFileType(path);
|
|
23814
|
+
if (!fileType) {
|
|
23815
|
+
stop('Unrecognized file type:', path);
|
|
23816
|
+
}
|
|
23817
|
+
// TODO: consider using a temp file, to support incremental reading
|
|
23818
|
+
content = require('zlib').gunzipSync(cli.readFile(pathgz));
|
|
23819
|
+
if (fileType == 'json' || fileType == 'text') {
|
|
23820
|
+
content = trimBOM(decodeString(content, encoding || 'utf-8'));
|
|
23821
|
+
}
|
|
23822
|
+
|
|
23801
23823
|
} else { // type can't be inferred from filename -- try reading as text
|
|
23802
23824
|
content = cli.readFile(path, encoding || 'utf-8', cache);
|
|
23803
23825
|
fileType = guessInputContentType(content);
|
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -2046,7 +2046,7 @@
|
|
|
2046
2046
|
// bbox: display coords
|
|
2047
2047
|
// intended to work with rectangular projections like Mercator
|
|
2048
2048
|
function getBBoxCoords(lyr, bbox) {
|
|
2049
|
-
if (!isProjectedLayer(lyr)) return bbox;
|
|
2049
|
+
if (!isProjectedLayer(lyr)) return bbox.concat();
|
|
2050
2050
|
var a = translateDisplayPoint(lyr, [bbox[0], bbox[1]]);
|
|
2051
2051
|
var b = translateDisplayPoint(lyr, [bbox[2], bbox[3]]);
|
|
2052
2052
|
var bounds = new internal.Bounds();
|
|
@@ -6923,9 +6923,216 @@
|
|
|
6923
6923
|
});
|
|
6924
6924
|
}
|
|
6925
6925
|
|
|
6926
|
+
function HighlightBox(gui, optsArg) {
|
|
6927
|
+
var el = El('div').addClass('zoom-box').appendTo('body'),
|
|
6928
|
+
opts = Object.assign({handles: false, persistent: false}, optsArg),
|
|
6929
|
+
box = new EventDispatcher(),
|
|
6930
|
+
stroke = 2,
|
|
6931
|
+
activeHandle = null,
|
|
6932
|
+
prevXY = null,
|
|
6933
|
+
boxCoords = null,
|
|
6934
|
+
_on = false,
|
|
6935
|
+
handles;
|
|
6936
|
+
|
|
6937
|
+
el.hide();
|
|
6938
|
+
|
|
6939
|
+
gui.on('map_rendered', function() {
|
|
6940
|
+
if (!_on) return;
|
|
6941
|
+
redraw();
|
|
6942
|
+
});
|
|
6943
|
+
|
|
6944
|
+
gui.on('box_drag', function(e) {
|
|
6945
|
+
if (!_on) return;
|
|
6946
|
+
boxCoords = getBoxCoords(e.data);
|
|
6947
|
+
redraw();
|
|
6948
|
+
box.dispatchEvent('drag');
|
|
6949
|
+
});
|
|
6950
|
+
|
|
6951
|
+
gui.on('box_drag_end', function(e) {
|
|
6952
|
+
if (!_on) return;
|
|
6953
|
+
boxCoords = getBoxCoords(e.data);
|
|
6954
|
+
var pix = coordsToPix(boxCoords, gui.map.getExtent());
|
|
6955
|
+
box.dispatchEvent('dragend', {map_bbox: pix});
|
|
6956
|
+
if (!opts.persistent) {
|
|
6957
|
+
box.hide();
|
|
6958
|
+
} else {
|
|
6959
|
+
redraw();
|
|
6960
|
+
}
|
|
6961
|
+
});
|
|
6962
|
+
|
|
6963
|
+
if (opts.handles) {
|
|
6964
|
+
handles = initHandles(el);
|
|
6965
|
+
handles.forEach(function(handle) {
|
|
6966
|
+
handle.el.on('mousedown', function(e) {
|
|
6967
|
+
activeHandle = handle;
|
|
6968
|
+
prevXY = {x: e.pageX, y: e.pageY};
|
|
6969
|
+
});
|
|
6970
|
+
});
|
|
6971
|
+
|
|
6972
|
+
document.addEventListener('mousemove', function(e) {
|
|
6973
|
+
if (!_on || !activeHandle || !prevXY || !boxCoords) return;
|
|
6974
|
+
var xy = {x: e.pageX, y: e.pageY};
|
|
6975
|
+
var scale = gui.map.getExtent().getPixelSize();
|
|
6976
|
+
var dx = (xy.x - prevXY.x) * scale;
|
|
6977
|
+
var dy = -(xy.y - prevXY.y) * scale;
|
|
6978
|
+
if (activeHandle.col == 'left') {
|
|
6979
|
+
boxCoords[0] += dx;
|
|
6980
|
+
} else if (activeHandle.col == 'right') {
|
|
6981
|
+
boxCoords[2] += dx;
|
|
6982
|
+
}
|
|
6983
|
+
if (activeHandle.row == 'top') {
|
|
6984
|
+
boxCoords[3] += dy;
|
|
6985
|
+
} else if (activeHandle.row == 'bottom') {
|
|
6986
|
+
boxCoords[1] += dy;
|
|
6987
|
+
}
|
|
6988
|
+
prevXY = xy;
|
|
6989
|
+
redraw();
|
|
6990
|
+
box.dispatchEvent('handle_drag');
|
|
6991
|
+
});
|
|
6992
|
+
|
|
6993
|
+
document.addEventListener('mouseup', function() {
|
|
6994
|
+
if (activeHandle && _on) {
|
|
6995
|
+
activeHandle = null;
|
|
6996
|
+
prevXY = null;
|
|
6997
|
+
box.dispatchEvent('handle_up');
|
|
6998
|
+
// reset box if it has been inverted (by dragging)
|
|
6999
|
+
fixBounds(boxCoords);
|
|
7000
|
+
redraw();
|
|
7001
|
+
}
|
|
7002
|
+
});
|
|
7003
|
+
}
|
|
7004
|
+
|
|
7005
|
+
box.getDataCoords = function() {
|
|
7006
|
+
if (!boxCoords) return null;
|
|
7007
|
+
var dataBox = getBBoxCoords(gui.map.getActiveLayer(), boxCoords);
|
|
7008
|
+
fixBounds(dataBox);
|
|
7009
|
+
return internal.getRoundedCoords(dataBox, internal.getBoundsPrecisionForDisplay(dataBox));
|
|
7010
|
+
};
|
|
7011
|
+
|
|
7012
|
+
box.turnOn = function() {
|
|
7013
|
+
_on = true;
|
|
7014
|
+
};
|
|
7015
|
+
|
|
7016
|
+
box.turnOff = function() {
|
|
7017
|
+
_on = false;
|
|
7018
|
+
};
|
|
7019
|
+
|
|
7020
|
+
box.hide = function() {
|
|
7021
|
+
el.hide();
|
|
7022
|
+
boxCoords = null;
|
|
7023
|
+
};
|
|
7024
|
+
|
|
7025
|
+
box.show = function(x1, y1, x2, y2) {
|
|
7026
|
+
var w = Math.abs(x1 - x2),
|
|
7027
|
+
h = Math.abs(y1 - y2),
|
|
7028
|
+
props = {
|
|
7029
|
+
top: Math.min(y1, y2),
|
|
7030
|
+
left: Math.min(x1, x2),
|
|
7031
|
+
width: Math.max(w - stroke * 2, 1),
|
|
7032
|
+
height: Math.max(h - stroke * 2, 1)
|
|
7033
|
+
};
|
|
7034
|
+
el.css(props);
|
|
7035
|
+
el.show();
|
|
7036
|
+
if (handles) {
|
|
7037
|
+
showHandles(handles, props);
|
|
7038
|
+
}
|
|
7039
|
+
};
|
|
7040
|
+
|
|
7041
|
+
function getBoxCoords(e) {
|
|
7042
|
+
var bbox = pixToCoords(e.a.concat(e.b), gui.map.getExtent());
|
|
7043
|
+
fixBounds(bbox);
|
|
7044
|
+
return bbox;
|
|
7045
|
+
}
|
|
7046
|
+
|
|
7047
|
+
function redraw() {
|
|
7048
|
+
if (!boxCoords) return;
|
|
7049
|
+
var ext = gui.map.getExtent();
|
|
7050
|
+
var b = coordsToPix(boxCoords, ext);
|
|
7051
|
+
var pos = ext.position();
|
|
7052
|
+
var dx = pos.pageX,
|
|
7053
|
+
dy = pos.pageY;
|
|
7054
|
+
box.show(b[0] + dx, b[1] + dy, b[2] + dx, b[3] + dy);
|
|
7055
|
+
}
|
|
7056
|
+
|
|
7057
|
+
return box;
|
|
7058
|
+
}
|
|
7059
|
+
|
|
7060
|
+
function coordsToPix(bbox, ext) {
|
|
7061
|
+
var a = ext.translateCoords(bbox[0], bbox[1]);
|
|
7062
|
+
var b = ext.translateCoords(bbox[2], bbox[3]);
|
|
7063
|
+
return [Math.round(a[0]), Math.round(b[1]), Math.round(b[0]), Math.round(a[1])];
|
|
7064
|
+
}
|
|
7065
|
+
|
|
7066
|
+
function pixToCoords(bbox, ext) {
|
|
7067
|
+
var a = ext.translatePixelCoords(bbox[0], bbox[1]);
|
|
7068
|
+
var b = ext.translatePixelCoords(bbox[2], bbox[3]);
|
|
7069
|
+
return [a[0], b[1], b[0], a[1]];
|
|
7070
|
+
}
|
|
7071
|
+
|
|
7072
|
+
|
|
7073
|
+
function fixBounds(bbox) {
|
|
7074
|
+
var tmp;
|
|
7075
|
+
if (bbox[0] > bbox[2]) {
|
|
7076
|
+
tmp = bbox[0];
|
|
7077
|
+
bbox[0] = bbox[2];
|
|
7078
|
+
bbox[2] = tmp;
|
|
7079
|
+
}
|
|
7080
|
+
if (bbox[1] > bbox[3]) {
|
|
7081
|
+
tmp = bbox[1];
|
|
7082
|
+
bbox[1] = bbox[3];
|
|
7083
|
+
bbox[3] = tmp;
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
|
|
7087
|
+
function initHandles(el) {
|
|
7088
|
+
var handles = [];
|
|
7089
|
+
for (var i=0; i<9; i++) {
|
|
7090
|
+
if (i == 4) continue;
|
|
7091
|
+
var c = Math.floor(i / 3);
|
|
7092
|
+
var r = i % 3;
|
|
7093
|
+
handles.push({
|
|
7094
|
+
el: El('div').addClass('handle').appendTo(el),
|
|
7095
|
+
col: c == 0 && 'left' || c == 1 && 'center' || 'right',
|
|
7096
|
+
row: r == 0 && 'top' || r == 1 && 'center' || 'bottom'
|
|
7097
|
+
});
|
|
7098
|
+
}
|
|
7099
|
+
return handles;
|
|
7100
|
+
}
|
|
7101
|
+
|
|
7102
|
+
function showHandles(handles, props) {
|
|
7103
|
+
var scaledSize = Math.ceil(Math.min(props.width, props.height) / 5);
|
|
7104
|
+
var HANDLE_SIZE = Math.min(scaledSize, 7);
|
|
7105
|
+
handles.forEach(function(handle) {
|
|
7106
|
+
var top = 0,
|
|
7107
|
+
left = 0;
|
|
7108
|
+
if (handle.col == 'center') {
|
|
7109
|
+
left += props.width / 2 - HANDLE_SIZE / 2;
|
|
7110
|
+
} else if (handle.col == 'right') {
|
|
7111
|
+
left += props.width - HANDLE_SIZE + 1;
|
|
7112
|
+
} else {
|
|
7113
|
+
left -= 1;
|
|
7114
|
+
}
|
|
7115
|
+
if (handle.row == 'center') {
|
|
7116
|
+
top += props.height / 2 - HANDLE_SIZE / 2;
|
|
7117
|
+
} else if (handle.row == 'bottom') {
|
|
7118
|
+
top += props.height - HANDLE_SIZE + 1;
|
|
7119
|
+
} else {
|
|
7120
|
+
top -= 1;
|
|
7121
|
+
}
|
|
7122
|
+
|
|
7123
|
+
handle.el.css({
|
|
7124
|
+
width: HANDLE_SIZE,
|
|
7125
|
+
height: HANDLE_SIZE,
|
|
7126
|
+
top: top,
|
|
7127
|
+
left: left
|
|
7128
|
+
});
|
|
7129
|
+
});
|
|
7130
|
+
}
|
|
7131
|
+
|
|
6926
7132
|
function MapNav(gui, ext, mouse) {
|
|
6927
7133
|
var wheel = new MouseWheel(mouse),
|
|
6928
7134
|
zoomTween = new Tween(Tween.sineInOut),
|
|
7135
|
+
zoomBox = new HighlightBox(gui), // .addClass('zooming'),
|
|
6929
7136
|
boxDrag = false,
|
|
6930
7137
|
zoomScaleMultiplier = 1,
|
|
6931
7138
|
inBtn, outBtn,
|
|
@@ -6978,6 +7185,7 @@
|
|
|
6978
7185
|
// zoomDrag = !!e.metaKey || !!e.ctrlKey; // meta is command on mac, windows key on windows
|
|
6979
7186
|
boxDrag = !!e.shiftKey;
|
|
6980
7187
|
if (boxDrag) {
|
|
7188
|
+
if (useBoxZoom()) zoomBox.turnOn();
|
|
6981
7189
|
dragStartEvt = e;
|
|
6982
7190
|
gui.dispatchEvent('box_drag_start');
|
|
6983
7191
|
}
|
|
@@ -6998,9 +7206,14 @@
|
|
|
6998
7206
|
if (boxDrag) {
|
|
6999
7207
|
boxDrag = false;
|
|
7000
7208
|
gui.dispatchEvent('box_drag_end', getBoxData(e));
|
|
7209
|
+
zoomBox.turnOff();
|
|
7001
7210
|
}
|
|
7002
7211
|
});
|
|
7003
7212
|
|
|
7213
|
+
zoomBox.on('dragend', function(e) {
|
|
7214
|
+
zoomToBbox(e.map_bbox);
|
|
7215
|
+
});
|
|
7216
|
+
|
|
7004
7217
|
wheel.on('mousewheel', function(e) {
|
|
7005
7218
|
var tickFraction = 0.11; // 0.15; // fraction of zoom step per wheel event;
|
|
7006
7219
|
var k = 1 + (tickFraction * e.multiplier * zoomScaleMultiplier),
|
|
@@ -7009,46 +7222,17 @@
|
|
|
7009
7222
|
ext.zoomByPct(delta, e.x / ext.width(), e.y / ext.height());
|
|
7010
7223
|
});
|
|
7011
7224
|
|
|
7012
|
-
function
|
|
7013
|
-
|
|
7014
|
-
swapElements(bbox, 0, 2);
|
|
7015
|
-
}
|
|
7016
|
-
if (bbox[1] > bbox[3]) {
|
|
7017
|
-
swapElements(bbox, 1, 3);
|
|
7018
|
-
}
|
|
7019
|
-
}
|
|
7020
|
-
|
|
7021
|
-
function swapElements(arr, i, j) {
|
|
7022
|
-
var tmp = arr[i];
|
|
7023
|
-
arr[i] = arr[j];
|
|
7024
|
-
arr[j] = tmp;
|
|
7225
|
+
function useBoxZoom() {
|
|
7226
|
+
return gui.getMode() != 'selection_tool' && gui.getMode() != 'box_tool';
|
|
7025
7227
|
}
|
|
7026
7228
|
|
|
7027
7229
|
function getBoxData(e) {
|
|
7028
|
-
var pageBox = [e.pageX, e.pageY, dragStartEvt.pageX, dragStartEvt.pageY];
|
|
7029
|
-
var mapBox = [e.x, e.y, dragStartEvt.x, dragStartEvt.y];
|
|
7030
|
-
var displayBox = pixToCoords(mapBox);
|
|
7031
|
-
var dataBox = getBBoxCoords(gui.map.getActiveLayer(), displayBox);
|
|
7032
|
-
fixBounds(pageBox);
|
|
7033
|
-
fixBounds(mapBox);
|
|
7034
|
-
fixBounds(displayBox);
|
|
7035
|
-
fixBounds(dataBox);
|
|
7036
7230
|
return {
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
// round coords, for nicer 'info' display
|
|
7040
|
-
// (rounded precision should be sub-pixel)
|
|
7041
|
-
map_display_bbox: internal.getRoundedCoords(displayBox, internal.getBoundsPrecisionForDisplay(displayBox)),
|
|
7042
|
-
map_data_bbox: internal.getRoundedCoords(dataBox, internal.getBoundsPrecisionForDisplay(dataBox))
|
|
7231
|
+
a: [e.x, e.y],
|
|
7232
|
+
b: [dragStartEvt.x, dragStartEvt.y]
|
|
7043
7233
|
};
|
|
7044
7234
|
}
|
|
7045
7235
|
|
|
7046
|
-
function pixToCoords(bbox) {
|
|
7047
|
-
var a = ext.translatePixelCoords(bbox[0], bbox[1]);
|
|
7048
|
-
var b = ext.translatePixelCoords(bbox[2], bbox[3]);
|
|
7049
|
-
return [a[0], b[1], b[0], a[1]];
|
|
7050
|
-
}
|
|
7051
|
-
|
|
7052
7236
|
function disabled() {
|
|
7053
7237
|
return !!gui.options.disableNavigation;
|
|
7054
7238
|
}
|
|
@@ -7093,28 +7277,9 @@
|
|
|
7093
7277
|
}
|
|
7094
7278
|
}
|
|
7095
7279
|
|
|
7096
|
-
function HighlightBox() {
|
|
7097
|
-
var box = El('div').addClass('zoom-box').appendTo('body'),
|
|
7098
|
-
show = box.show.bind(box), // original show() function
|
|
7099
|
-
stroke = 2;
|
|
7100
|
-
box.hide();
|
|
7101
|
-
box.show = function(x1, y1, x2, y2) {
|
|
7102
|
-
var w = Math.abs(x1 - x2),
|
|
7103
|
-
h = Math.abs(y1 - y2);
|
|
7104
|
-
box.css({
|
|
7105
|
-
top: Math.min(y1, y2),
|
|
7106
|
-
left: Math.min(x1, x2),
|
|
7107
|
-
width: Math.max(w - stroke * 2, 1),
|
|
7108
|
-
height: Math.max(h - stroke * 2, 1)
|
|
7109
|
-
});
|
|
7110
|
-
show();
|
|
7111
|
-
};
|
|
7112
|
-
return box;
|
|
7113
|
-
}
|
|
7114
|
-
|
|
7115
7280
|
function SelectionTool(gui, ext, hit) {
|
|
7116
7281
|
var popup = gui.container.findChild('.selection-tool-options');
|
|
7117
|
-
var box = new HighlightBox();
|
|
7282
|
+
var box = new HighlightBox(gui);
|
|
7118
7283
|
var _on = false;
|
|
7119
7284
|
|
|
7120
7285
|
gui.addMode('selection_tool', turnOn, turnOff);
|
|
@@ -7127,16 +7292,17 @@
|
|
|
7127
7292
|
}
|
|
7128
7293
|
});
|
|
7129
7294
|
|
|
7130
|
-
|
|
7295
|
+
box.on('drag', function(e) {
|
|
7131
7296
|
if (!_on) return;
|
|
7132
|
-
|
|
7133
|
-
box.show(b[0], b[1], b[2], b[3]);
|
|
7134
|
-
updateSelection(e.map_data_bbox, true);
|
|
7297
|
+
updateSelection(box.getDataCoords(), true);
|
|
7135
7298
|
});
|
|
7136
7299
|
|
|
7137
|
-
|
|
7300
|
+
box.on('dragend', function(e) {
|
|
7138
7301
|
if (!_on) return;
|
|
7139
|
-
box.
|
|
7302
|
+
updateSelection(box.getDataCoords());
|
|
7303
|
+
});
|
|
7304
|
+
|
|
7305
|
+
gui.on('selection_bridge', function(e) {
|
|
7140
7306
|
updateSelection(e.map_data_bbox);
|
|
7141
7307
|
});
|
|
7142
7308
|
|
|
@@ -7151,10 +7317,12 @@
|
|
|
7151
7317
|
}
|
|
7152
7318
|
|
|
7153
7319
|
function turnOn() {
|
|
7320
|
+
box.turnOn();
|
|
7154
7321
|
_on = true;
|
|
7155
7322
|
}
|
|
7156
7323
|
|
|
7157
7324
|
function turnOff() {
|
|
7325
|
+
box.turnOff();
|
|
7158
7326
|
reset();
|
|
7159
7327
|
_on = false;
|
|
7160
7328
|
if (gui.interaction.getMode() == 'selection') {
|
|
@@ -9367,15 +9535,14 @@
|
|
|
9367
9535
|
}
|
|
9368
9536
|
}
|
|
9369
9537
|
|
|
9370
|
-
// Controls
|
|
9371
|
-
|
|
9372
|
-
function BoxTool(gui, ext,
|
|
9538
|
+
// Controls the shift-drag box editing tool
|
|
9539
|
+
//
|
|
9540
|
+
function BoxTool(gui, ext, nav) {
|
|
9373
9541
|
var self = new EventDispatcher();
|
|
9374
|
-
var box = new HighlightBox();
|
|
9542
|
+
var box = new HighlightBox(gui, {persistent: true, handles: true});
|
|
9375
9543
|
var popup = gui.container.findChild('.box-tool-options');
|
|
9376
9544
|
var coords = popup.findChild('.box-coords');
|
|
9377
9545
|
var _on = false;
|
|
9378
|
-
var bboxData;
|
|
9379
9546
|
|
|
9380
9547
|
var infoBtn = new SimpleButton(popup.findChild('.info-btn')).on('click', function() {
|
|
9381
9548
|
if (coords.visible()) hideCoords(); else showCoords();
|
|
@@ -9385,28 +9552,19 @@
|
|
|
9385
9552
|
reset();
|
|
9386
9553
|
});
|
|
9387
9554
|
|
|
9388
|
-
// Removing zoom-in button -- cumbersome way to zoom
|
|
9389
|
-
// new SimpleButton(popup.findChild('.zoom-btn')).on('click', function() {
|
|
9390
|
-
// nav.zoomToBbox(bboxPixels);
|
|
9391
|
-
// reset();
|
|
9392
|
-
// });
|
|
9393
|
-
|
|
9394
|
-
// Removing button for creating a layer containing a single rectangle.
|
|
9395
|
-
// You can get the bbox with the Info button and create a rectangle in the console
|
|
9396
|
-
// using -rectangle bbox=<coordinates>
|
|
9397
|
-
// new SimpleButton(popup.findChild('.rectangle-btn')).on('click', function() {
|
|
9398
|
-
// runCommand('-rectangle bbox=' + bbox.join(','));
|
|
9399
|
-
// });
|
|
9400
|
-
|
|
9401
9555
|
new SimpleButton(popup.findChild('.select-btn')).on('click', function() {
|
|
9556
|
+
var coords = box.getDataCoords();
|
|
9557
|
+
if (!coords) return;
|
|
9402
9558
|
gui.enterMode('selection_tool');
|
|
9403
9559
|
gui.interaction.setMode('selection');
|
|
9404
9560
|
// kludge to pass bbox to the selection tool
|
|
9405
|
-
gui.dispatchEvent('
|
|
9561
|
+
gui.dispatchEvent('selection_bridge', {
|
|
9562
|
+
map_data_bbox: coords
|
|
9563
|
+
});
|
|
9406
9564
|
});
|
|
9407
9565
|
|
|
9408
9566
|
new SimpleButton(popup.findChild('.clip-btn')).on('click', function() {
|
|
9409
|
-
runCommand('-clip bbox=' +
|
|
9567
|
+
runCommand('-clip bbox=' + box.getDataCoords().join(','));
|
|
9410
9568
|
});
|
|
9411
9569
|
|
|
9412
9570
|
gui.addMode('box_tool', turnOn, turnOff);
|
|
@@ -9419,37 +9577,18 @@
|
|
|
9419
9577
|
}
|
|
9420
9578
|
});
|
|
9421
9579
|
|
|
9422
|
-
// Update the visible rectangle when the map view changes
|
|
9423
|
-
// (e.g. during zooming or panning)
|
|
9424
|
-
ext.on('change', function() {
|
|
9425
|
-
if (!_on || !box.visible() || !bboxData) return;
|
|
9426
|
-
var b = coordsToPix(bboxData.map_display_bbox);
|
|
9427
|
-
var pos = ext.position();
|
|
9428
|
-
var dx = pos.pageX,
|
|
9429
|
-
dy = pos.pageY;
|
|
9430
|
-
box.show(b[0] + dx, b[1] + dy, b[2] + dx, b[3] + dy);
|
|
9431
|
-
});
|
|
9432
|
-
|
|
9433
9580
|
gui.on('box_drag_start', function() {
|
|
9434
|
-
box.classed('zooming', inZoomMode());
|
|
9581
|
+
// box.classed('zooming', inZoomMode());
|
|
9435
9582
|
hideCoords();
|
|
9436
9583
|
});
|
|
9437
9584
|
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
bboxData = e.data;
|
|
9441
|
-
if (_on || inZoomMode()) {
|
|
9442
|
-
box.show(b[0], b[1], b[2], b[3]);
|
|
9443
|
-
}
|
|
9585
|
+
box.on('dragend', function(e) {
|
|
9586
|
+
if (_on) popup.show();
|
|
9444
9587
|
});
|
|
9445
9588
|
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
box.hide();
|
|
9450
|
-
nav.zoomToBbox(e.map_bbox);
|
|
9451
|
-
} else if (_on) {
|
|
9452
|
-
popup.show();
|
|
9589
|
+
box.on('handle_drag', function() {
|
|
9590
|
+
if (coords.visible()) {
|
|
9591
|
+
showCoords();
|
|
9453
9592
|
}
|
|
9454
9593
|
});
|
|
9455
9594
|
|
|
@@ -9468,7 +9607,7 @@
|
|
|
9468
9607
|
|
|
9469
9608
|
function showCoords() {
|
|
9470
9609
|
El(infoBtn.node()).addClass('selected-btn');
|
|
9471
|
-
coords.text(
|
|
9610
|
+
coords.text(box.getDataCoords().join(','));
|
|
9472
9611
|
coords.show();
|
|
9473
9612
|
GUI.selectElement(coords.node());
|
|
9474
9613
|
}
|
|
@@ -9479,10 +9618,12 @@
|
|
|
9479
9618
|
}
|
|
9480
9619
|
|
|
9481
9620
|
function turnOn() {
|
|
9621
|
+
box.turnOn();
|
|
9482
9622
|
_on = true;
|
|
9483
9623
|
}
|
|
9484
9624
|
|
|
9485
9625
|
function turnOff() {
|
|
9626
|
+
box.turnOff();
|
|
9486
9627
|
if (gui.interaction.getMode() == 'box') {
|
|
9487
9628
|
// mode change was not initiated by interactive menu -- turn off interactivity
|
|
9488
9629
|
gui.interaction.turnOff();
|
|
@@ -9497,12 +9638,6 @@
|
|
|
9497
9638
|
hideCoords();
|
|
9498
9639
|
}
|
|
9499
9640
|
|
|
9500
|
-
function coordsToPix(bbox) {
|
|
9501
|
-
var a = ext.translateCoords(bbox[0], bbox[1]);
|
|
9502
|
-
var b = ext.translateCoords(bbox[2], bbox[3]);
|
|
9503
|
-
return [a[0], b[1], b[0], a[1]];
|
|
9504
|
-
}
|
|
9505
|
-
|
|
9506
9641
|
return self;
|
|
9507
9642
|
}
|
|
9508
9643
|
|
|
@@ -10019,7 +10154,7 @@
|
|
|
10019
10154
|
_ext = new MapExtent(position),
|
|
10020
10155
|
_hit = new InteractiveSelection(gui, _ext, _mouse),
|
|
10021
10156
|
_nav = new MapNav(gui, _ext, _mouse),
|
|
10022
|
-
_boxTool = new BoxTool(gui, _ext,
|
|
10157
|
+
_boxTool = new BoxTool(gui, _ext, _nav),
|
|
10023
10158
|
_selectionTool = new SelectionTool(gui, _ext, _hit),
|
|
10024
10159
|
_visibleLayers = [], // cached visible map layers
|
|
10025
10160
|
_fullBounds = null,
|
|
@@ -10470,6 +10605,7 @@
|
|
|
10470
10605
|
_stack.drawOverlayLayer(_overlayLyr, action);
|
|
10471
10606
|
// draw furniture
|
|
10472
10607
|
_stack.drawFurnitureLayers(furnitureLayers, action);
|
|
10608
|
+
gui.dispatchEvent('map_rendered');
|
|
10473
10609
|
}
|
|
10474
10610
|
}
|
|
10475
10611
|
|
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.11";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -7311,15 +7311,18 @@
|
|
|
7311
7311
|
// replacing content so ArrayBuffers can be gc'd
|
|
7312
7312
|
obj.content = cli.convertArrayBuffer(obj.content); // convert to Buffer
|
|
7313
7313
|
}
|
|
7314
|
+
if (opts.gzip) {
|
|
7315
|
+
path = path + '.gz';
|
|
7316
|
+
obj.content = require$1('zlib').gzipSync(obj.content);
|
|
7317
|
+
}
|
|
7314
7318
|
if (opts.output) {
|
|
7315
7319
|
opts.output.push({filename: path, content: obj.content});
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
}
|
|
7320
|
-
cli.writeFile(path, obj.content);
|
|
7321
|
-
message("Wrote " + path);
|
|
7320
|
+
return;
|
|
7321
|
+
} if (!opts.force && inputFiles.indexOf(path) > -1) {
|
|
7322
|
+
stop('Need to use the "-o force" option to overwrite input files.');
|
|
7322
7323
|
}
|
|
7324
|
+
cli.writeFile(path, obj.content);
|
|
7325
|
+
message("Wrote " + path);
|
|
7323
7326
|
});
|
|
7324
7327
|
}
|
|
7325
7328
|
if (cb) cb(null);
|
|
@@ -8470,7 +8473,9 @@
|
|
|
8470
8473
|
function getBoundsPrecisionForDisplay(bbox) {
|
|
8471
8474
|
var w = Math.abs(bbox[2] - bbox[0]),
|
|
8472
8475
|
h = Math.abs(bbox[3] - bbox[1]),
|
|
8473
|
-
|
|
8476
|
+
// switched to max bound, based on experience with shift-drag box info
|
|
8477
|
+
// range = Math.min(w, h) + 1e-8,
|
|
8478
|
+
range = Math.max(w, h) + 1e-8,
|
|
8474
8479
|
digits = 0;
|
|
8475
8480
|
while (range < 2000) {
|
|
8476
8481
|
range *= 10;
|
|
@@ -19344,6 +19349,10 @@ ${svg}
|
|
|
19344
19349
|
describe: 'allow overwriting input files',
|
|
19345
19350
|
type: 'flag'
|
|
19346
19351
|
})
|
|
19352
|
+
.option('gzip', {
|
|
19353
|
+
describe: 'apply gzip compression to output files',
|
|
19354
|
+
type: 'flag'
|
|
19355
|
+
})
|
|
19347
19356
|
.option('dry-run', {
|
|
19348
19357
|
// describe: 'do not output any files'
|
|
19349
19358
|
type: 'flag'
|
|
@@ -23798,6 +23807,19 @@ ${svg}
|
|
|
23798
23807
|
} else if (fileType) { // string type, e.g. kml, geojson
|
|
23799
23808
|
content = cli.readFile(path, encoding || 'utf-8', cache);
|
|
23800
23809
|
|
|
23810
|
+
} else if (getFileExtension(path) == 'gz') {
|
|
23811
|
+
var pathgz = path;
|
|
23812
|
+
path = pathgz.replace(/\.gz$/, '');
|
|
23813
|
+
fileType = guessInputFileType(path);
|
|
23814
|
+
if (!fileType) {
|
|
23815
|
+
stop('Unrecognized file type:', path);
|
|
23816
|
+
}
|
|
23817
|
+
// TODO: consider using a temp file, to support incremental reading
|
|
23818
|
+
content = require('zlib').gunzipSync(cli.readFile(pathgz));
|
|
23819
|
+
if (fileType == 'json' || fileType == 'text') {
|
|
23820
|
+
content = trimBOM(decodeString(content, encoding || 'utf-8'));
|
|
23821
|
+
}
|
|
23822
|
+
|
|
23801
23823
|
} else { // type can't be inferred from filename -- try reading as text
|
|
23802
23824
|
content = cli.readFile(path, encoding || 'utf-8', cache);
|
|
23803
23825
|
fileType = guessInputContentType(content);
|
package/www/page.css
CHANGED
|
@@ -184,6 +184,7 @@ body {
|
|
|
184
184
|
|
|
185
185
|
.selection-tool-options .info-box {
|
|
186
186
|
pointer-events: initial;
|
|
187
|
+
text-align: center;
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
/* --- Box tool dialog --------- */
|
|
@@ -200,6 +201,7 @@ body {
|
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
.box-tool-options .box-coords {
|
|
204
|
+
margin-top: 7px;
|
|
203
205
|
pointer-events: initial;
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -1241,8 +1243,12 @@ div.basemap-style-btn.active img {
|
|
|
1241
1243
|
pointer-events: none;
|
|
1242
1244
|
}
|
|
1243
1245
|
|
|
1244
|
-
.zoom-box.
|
|
1245
|
-
|
|
1246
|
+
.zoom-box .handle {
|
|
1247
|
+
position: absolute;
|
|
1248
|
+
z-index: 16;
|
|
1249
|
+
/* cursor: pointer; */
|
|
1250
|
+
background: #cc6acc;
|
|
1251
|
+
pointer-events: all;
|
|
1246
1252
|
}
|
|
1247
1253
|
|
|
1248
1254
|
/* Simplification control ------------ */
|