mapshaper 0.6.86 → 0.6.87

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 CHANGED
@@ -4236,12 +4236,16 @@
4236
4236
  function pathIsRectangle(ids, arcs) {
4237
4237
  var bbox = arcs.getSimpleShapeBounds(ids).toArray();
4238
4238
  var iter = arcs.getShapeIter(ids);
4239
+ var count = 0;
4239
4240
  while (iter.hasNext()) {
4240
4241
  if (iter.x != bbox[0] && iter.x != bbox[2] ||
4241
4242
  iter.y != bbox[1] && iter.y != bbox[3]) {
4242
4243
  return false;
4243
4244
  }
4245
+ count++;
4244
4246
  }
4247
+ if (count < 5) return false;
4248
+ if (bbox[2] > bbox[0] === false || bbox[3] > bbox[1] === false) return false;
4245
4249
  return true;
4246
4250
  }
4247
4251
 
@@ -45574,7 +45578,7 @@ ${svg}
45574
45578
  });
45575
45579
  }
45576
45580
 
45577
- var version = "0.6.86";
45581
+ var version = "0.6.87";
45578
45582
 
45579
45583
  // Parse command line args into commands and run them
45580
45584
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.86",
3
+ "version": "0.6.87",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -5811,11 +5811,14 @@
5811
5811
  var altDown = false;
5812
5812
  var spaceDown = false;
5813
5813
 
5814
- function updateControlKeys(e) {
5814
+ function updateControlKeys(e, evtName) {
5815
5815
  shiftDown = e.shiftKey;
5816
5816
  ctrlDown = e.ctrlKey;
5817
5817
  metaDown = e.metaKey;
5818
5818
  altDown = e.altKey;
5819
+ if (e.keyCode == 32) {
5820
+ spaceDown = evtName == 'keydown';
5821
+ }
5819
5822
  }
5820
5823
 
5821
5824
  function mouseIsPressed() {
@@ -5823,17 +5826,14 @@
5823
5826
  }
5824
5827
 
5825
5828
  document.addEventListener('keyup', function(e) {
5826
- if (!GUI.isActiveInstance(gui) || e.repeat) return;
5827
- // this can fail to fire if keyup occurs over a context menu
5828
- if (e.keyCode == 32) spaceDown = false;
5829
- updateControlKeys(e);
5829
+ if (!GUI.isActiveInstance(gui) || e.repeat && e.keyCode == 32) return;
5830
+ updateControlKeys(e, 'keyup');
5830
5831
  self.dispatchEvent('keyup', getEventData(e));
5831
5832
  });
5832
5833
 
5833
5834
  document.addEventListener('keydown', function(e) {
5834
- if (!GUI.isActiveInstance(gui) || e.repeat) return;
5835
- if (e.keyCode == 32) spaceDown = true;
5836
- updateControlKeys(e);
5835
+ if (!GUI.isActiveInstance(gui) || e.repeat && e.keyCode == 32) return;
5836
+ updateControlKeys(e, 'keyup');
5837
5837
  self.dispatchEvent('keydown', getEventData(e));
5838
5838
  });
5839
5839
 
@@ -5886,7 +5886,7 @@
5886
5886
  standard: ['info', 'selection', 'box'],
5887
5887
  empty: ['edit_points', 'edit_lines', 'edit_polygons', 'box'],
5888
5888
  polygons: ['info', 'selection', 'box', 'edit_polygons'],
5889
- rectangles: ['info', 'selection', 'box', 'rectangles'],
5889
+ rectangles: ['info', 'selection', 'box', 'rectangles', 'edit_polygons'],
5890
5890
  lines: ['info', 'selection', 'box' , 'edit_lines'],
5891
5891
  table: ['info', 'selection'],
5892
5892
  labels: ['info', 'selection', 'box', 'labels', 'edit_points'],
@@ -10387,6 +10387,7 @@
10387
10387
 
10388
10388
  gui.on('redo_path_extend', function(e) {
10389
10389
  var target = hit.getHitTarget();
10390
+
10390
10391
  if (pathDrawing() && prevHoverEvent) {
10391
10392
  updatePathEndpoint(e.p);
10392
10393
  appendVertex$1(target, pixToDataCoords(prevHoverEvent.x, prevHoverEvent.y));
@@ -10651,8 +10652,6 @@
10651
10652
  var p = pixToDataCoords(e.x, e.y);
10652
10653
  if (pathDrawing()) {
10653
10654
  extendCurrentPath(hoverVertexInfo?.point || p);
10654
- } else if (gui.keyboard.shiftIsPressed()) {
10655
- deleteActiveVertex(e);
10656
10655
  } else if (hoverVertexInfo?.type == 'interpolated') {
10657
10656
  // don't start new path if hovering along a segment -- this is
10658
10657
  // likely to be an attempt to add a new vertex, not start a new path
@@ -10754,7 +10753,8 @@
10754
10753
  if (!pathDrawing()) return;
10755
10754
  var target = hit.getHitTarget();
10756
10755
  if (getLastArcLength(target) <= 2) { // includes hover point
10757
- deleteLastPath(target);
10756
+ // deleteLastPath(target);
10757
+ gui.undo.undo(); // assume previous undo event was path_add
10758
10758
  } else {
10759
10759
  deleteLastVertex(target);
10760
10760
  }
package/www/mapshaper.js CHANGED
@@ -4236,12 +4236,16 @@
4236
4236
  function pathIsRectangle(ids, arcs) {
4237
4237
  var bbox = arcs.getSimpleShapeBounds(ids).toArray();
4238
4238
  var iter = arcs.getShapeIter(ids);
4239
+ var count = 0;
4239
4240
  while (iter.hasNext()) {
4240
4241
  if (iter.x != bbox[0] && iter.x != bbox[2] ||
4241
4242
  iter.y != bbox[1] && iter.y != bbox[3]) {
4242
4243
  return false;
4243
4244
  }
4245
+ count++;
4244
4246
  }
4247
+ if (count < 5) return false;
4248
+ if (bbox[2] > bbox[0] === false || bbox[3] > bbox[1] === false) return false;
4245
4249
  return true;
4246
4250
  }
4247
4251
 
@@ -45574,7 +45578,7 @@ ${svg}
45574
45578
  });
45575
45579
  }
45576
45580
 
45577
- var version = "0.6.86";
45581
+ var version = "0.6.87";
45578
45582
 
45579
45583
  // Parse command line args into commands and run them
45580
45584
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.