mapshaper 0.7.64 → 0.7.65

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
@@ -82789,7 +82789,7 @@ ${svg}
82789
82789
  return name == 'rectangle' || name == 'rectangles' || name == 'filter' && opts.cleanup;
82790
82790
  }
82791
82791
 
82792
- var version = "0.7.64";
82792
+ var version = "0.7.65";
82793
82793
 
82794
82794
  // Parse command line args into commands and run them
82795
82795
  // 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.7.64",
3
+ "version": "0.7.65",
4
4
  "description": "A tool for editing geospatial data for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -16663,10 +16663,15 @@
16663
16663
  // aligned: whether it carries a label-align (see below)
16664
16664
  // delta: {dx, dy} -- how far the pointer has moved, in the same space.
16665
16665
  //
16666
- // Returns {dx, dy, text-anchor, x}, where x is where the text will be drawn
16667
- // once the other three are written -- the same as dx except on an aligned
16668
- // label. The three have to be written together: applying dx without its
16669
- // text-anchor moves the text by half its own width or by all of it.
16666
+ // Returns two descriptions of the same placement:
16667
+ //
16668
+ // dx, dy, text-anchor: what the drag writes to the record. The three have to
16669
+ // be written together: applying dx without its text-anchor moves the text
16670
+ // by half its own width or by all of it.
16671
+ // x, anchor: where the text sits and how it is justified while it is drawn,
16672
+ // which is what the preview writes onto the rendered label. The same as
16673
+ // dx and text-anchor except on an aligned label, whose stored offset is
16674
+ // measured against a justification it is not drawn with.
16670
16675
  function getOffsetDragValues(start, delta) {
16671
16676
  var width = start.width > 0 ? start.width : 0;
16672
16677
  var drawnAnchor = normalizeAnchor(start.anchor);
@@ -16685,12 +16690,18 @@
16685
16690
  // if the alignment were later removed.
16686
16691
  var anchor = start.aligned ? 'start' :
16687
16692
  width > 0 ? getAnchorForCentre(left + width / 2, width) : drawnAnchor;
16693
+ // An aligned label goes on being drawn with the anchor its alignment gives
16694
+ // it, whatever the drag writes: the alignment is unchanged, so the renderer
16695
+ // will justify it the same way afterwards. Drawing it as 'start' instead
16696
+ // would slide the text right by half its width or by all of it for the
16697
+ // length of the drag, and drop it back on release.
16698
+ var drawn = start.aligned ? drawnAnchor : anchor;
16688
16699
  return {
16689
16700
  dx: round$1(left + anchorOffsets[anchor] * width),
16690
16701
  dy: round$1(start.dy + delta.dy),
16691
16702
  'text-anchor': anchor,
16692
- x: round$1(start.aligned ? start.dx + delta.dx :
16693
- left + anchorOffsets[anchor] * width)
16703
+ x: round$1(left + anchorOffsets[drawn] * width),
16704
+ anchor: drawn
16694
16705
  };
16695
16706
  }
16696
16707
 
@@ -17070,8 +17081,12 @@
17070
17081
  applyInlineCss(cssInput.node().value.trim());
17071
17082
  });
17072
17083
 
17084
+ // The caption for the grid and the drag-mode toggle below it, and what
17085
+ // gives Fixed|Draggable something to be an adjective of. "Position" read as
17086
+ // the label's own position -- which a drag moves in either mode -- and made
17087
+ // Fixed sound like a lock on a label that is still perfectly draggable.
17073
17088
  var positionRow = El('label').addClass('label-style-row').appendTo(textSection);
17074
- El('span').appendTo(positionRow).text('Position');
17089
+ El('span').appendTo(positionRow).text('Offset from anchor');
17075
17090
 
17076
17091
  // Whether the label has a symbol is one question and which symbol it has is
17077
17092
  // another, so the first is a switch on the section's heading rather than a
@@ -25332,6 +25347,9 @@
25332
25347
  // See docs/development/label-tool-design.md.
25333
25348
 
25334
25349
  var SVG_NS$2 = 'http://www.w3.org/2000/svg';
25350
+ // How far outside its text a label's outline is drawn. Exported because the
25351
+ // tool grabs a label by the same box: what looks like the object is what takes
25352
+ // a drag on it.
25335
25353
  var BOX_PADDING = 3;
25336
25354
  var ANCHOR_RADIUS = 3.5;
25337
25355
  var KNOT_RADIUS = 3;
@@ -26524,7 +26542,10 @@
26524
26542
  // ended.
26525
26543
  setMultilineAttribute(nodes.text, 'x', o.values.x);
26526
26544
  nodes.text.setAttribute('y', o.values.dy);
26527
- nodes.text.setAttribute('text-anchor', o.values['text-anchor']);
26545
+ // The anchor the label is drawn with, not the one the drag writes: on an
26546
+ // aligned label the two differ, and the stored one belongs with the stored
26547
+ // dx rather than with the x being previewed here.
26548
+ nodes.text.setAttribute('text-anchor', o.values.anchor);
26528
26549
  // The cue is drawn around the text rather than moved with it, so it has to
26529
26550
  // be rebuilt to follow -- one getBBox on one label per mouse move.
26530
26551
  selection.refresh(true);
@@ -26679,9 +26700,34 @@
26679
26700
  hoverTextId = id > -1 && (!hoverHandle || glyphsOutrankHandle(id)) ? id : -1;
26680
26701
  }
26681
26702
 
26703
+ // The exception is about the pointer being on the glyphs, not about the mode:
26704
+ // an offset label's anchor is out from under its text, and taking the handle
26705
+ // away there left it with no anchor handle at all -- dragging the symbol of a
26706
+ // label positioned ne slid its text instead of moving the label.
26682
26707
  function glyphsOutrankHandle(id) {
26683
26708
  return hoverHandle.id == id && labelTextIsDraggable(gui) &&
26684
- !isPathLabel(hit.getHitTarget(), id);
26709
+ !isPathLabel(hit.getHitTarget(), id) && pointerIsOverText(id);
26710
+ }
26711
+
26712
+ // Whether the pointer is within the box drawn around a label's text -- the
26713
+ // outline the selection cue draws, padding and all, so that the thing on
26714
+ // screen that says "this is the object" is the thing that takes the drag.
26715
+ //
26716
+ // From the last hover rather than from an event, because this is asked from
26717
+ // the hit control's 'change' as well, which arrives without a position; the
26718
+ // pointer has not moved since the hover that preceded it.
26719
+ function pointerIsOverText(id) {
26720
+ var target = hit.getHitTarget();
26721
+ var shapes = target && getDisplayShapes(target);
26722
+ var shp = shapes && shapes[id];
26723
+ var nodes = findLabelNodes(target, id);
26724
+ var box = nodes && !nodes.textPath ? measureNode(nodes.text) : null;
26725
+ var pix = hoverPoint && ext.translateCoords(hoverPoint[0], hoverPoint[1]);
26726
+ var p;
26727
+ if (!box || !pix || !shp) return false;
26728
+ p = getLabelSpacePoint(shp[0], {x: pix[0], y: pix[1]});
26729
+ return p.x >= box.x - BOX_PADDING && p.x <= box.x + box.width + BOX_PADDING &&
26730
+ p.y >= box.y - BOX_PADDING && p.y <= box.y + box.height + BOX_PADDING;
26685
26731
  }
26686
26732
 
26687
26733
  // The label a drag on the glyphs would act on, or -1. Only a selected label
package/www/mapshaper.js CHANGED
@@ -82789,7 +82789,7 @@ ${svg}
82789
82789
  return name == 'rectangle' || name == 'rectangles' || name == 'filter' && opts.cleanup;
82790
82790
  }
82791
82791
 
82792
- var version = "0.7.64";
82792
+ var version = "0.7.65";
82793
82793
 
82794
82794
  // Parse command line args into commands and run them
82795
82795
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.