mapshaper 0.5.80 → 0.5.81

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 CHANGED
@@ -1,3 +1,6 @@
1
+ v0.5.81
2
+ * Bug fixes
3
+
1
4
  v0.5.80
2
5
  * Added arrows, stars and polygons to undocumented -symbols command.
3
6
 
package/mapshaper.js CHANGED
@@ -18032,9 +18032,9 @@ ${svg}
18032
18032
  // Updated: don't trim space from tokens like [delimeter= ]
18033
18033
  argv = argv.map(function(s) {
18034
18034
  if (!/= $/.test(s)) {
18035
- s = s.trimEnd();
18035
+ s = utils.rtrim(s);
18036
18036
  }
18037
- s = s.trimStart();
18037
+ s = utils.ltrim(s);
18038
18038
  return s;
18039
18039
  });
18040
18040
  argv = argv.filter(function(s) {return s !== '';}); // remove empty tokens
@@ -37968,13 +37968,16 @@ ${svg}
37968
37968
  stemWidth = unscaledStemWidth * scale,
37969
37969
  stemTaper = d['arrow-stem-taper'] || 0,
37970
37970
  stemCurve = d['arrow-stem-curve'] || 0,
37971
- stemLen = totalLen - headLen;
37971
+ stemLen = totalLen - headLen,
37972
+ coords;
37972
37973
 
37973
37974
  var headDx = headWidth / 2,
37974
37975
  stemDx = stemWidth / 2,
37975
37976
  baseDx = stemDx * (1 - stemTaper);
37976
37977
 
37977
- var coords;
37978
+ if (unscaledHeadWidth < unscaledStemWidth) {
37979
+ stop('Arrow head must be at least as wide as the stem.');
37980
+ }
37978
37981
 
37979
37982
  if (!stemCurve || Math.abs(stemCurve) > 90) {
37980
37983
  coords = [[baseDx, 0], [stemDx, stemLen], [headDx, stemLen], [0, stemLen + headLen],
@@ -38028,15 +38031,18 @@ ${svg}
38028
38031
  var ay = baseDx * Math.sin(theta) * -sign;
38029
38032
  var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy, theta);
38030
38033
  var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy, theta);
38031
- // if (stemTaper == 1) leftStem.pop();
38032
38034
  var stem = leftStem.concat(rightStem.reverse());
38033
- stem.pop();
38035
+ // stem.pop();
38034
38036
  return stem.concat(head);
38035
38037
  }
38036
38038
 
38037
38039
  // ax, ay: point on the base
38038
38040
  // bx, by: point on the stem
38039
38041
  function getCurvedStemCoords(ax, ay, bx, by, theta0) {
38042
+ // case: curved side intrudes into head (because stem is too short)
38043
+ if (ay > by) {
38044
+ return [[ax * by / ay, by]];
38045
+ }
38040
38046
  var dx = bx - ax,
38041
38047
  dy = by - ay,
38042
38048
  dy1 = (dy * dy - dx * dx) / (2 * dy),
@@ -38048,10 +38054,9 @@ ${svg}
38048
38054
  leftBend = bx > ax,
38049
38055
  sign = leftBend ? 1 : -1,
38050
38056
  points = Math.round(degrees / 5) + 2,
38051
- // points = theta > 2 && 7 || theta > 1 && 6 || 5,
38052
- increment = theta / (points + 1);
38057
+ increment = theta / (points + 1),
38058
+ coords = [[bx, by]];
38053
38059
 
38054
- var coords = [[bx, by]];
38055
38060
  for (var i=1; i<= points; i++) {
38056
38061
  var phi = i * increment / 2;
38057
38062
  var sinPhi = Math.sin(phi);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.5.80",
3
+ "version": "0.5.81",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -5986,7 +5986,6 @@
5986
5986
  return parent.querySelector(sel);
5987
5987
  }
5988
5988
 
5989
-
5990
5989
  function getTextTarget3(e) {
5991
5990
  if (e.id > -1 === false || !e.container) return null;
5992
5991
  return getSymbolNodeById(e.id, e.container);
package/www/mapshaper.js CHANGED
@@ -18032,9 +18032,9 @@ ${svg}
18032
18032
  // Updated: don't trim space from tokens like [delimeter= ]
18033
18033
  argv = argv.map(function(s) {
18034
18034
  if (!/= $/.test(s)) {
18035
- s = s.trimEnd();
18035
+ s = utils.rtrim(s);
18036
18036
  }
18037
- s = s.trimStart();
18037
+ s = utils.ltrim(s);
18038
18038
  return s;
18039
18039
  });
18040
18040
  argv = argv.filter(function(s) {return s !== '';}); // remove empty tokens
@@ -37968,13 +37968,16 @@ ${svg}
37968
37968
  stemWidth = unscaledStemWidth * scale,
37969
37969
  stemTaper = d['arrow-stem-taper'] || 0,
37970
37970
  stemCurve = d['arrow-stem-curve'] || 0,
37971
- stemLen = totalLen - headLen;
37971
+ stemLen = totalLen - headLen,
37972
+ coords;
37972
37973
 
37973
37974
  var headDx = headWidth / 2,
37974
37975
  stemDx = stemWidth / 2,
37975
37976
  baseDx = stemDx * (1 - stemTaper);
37976
37977
 
37977
- var coords;
37978
+ if (unscaledHeadWidth < unscaledStemWidth) {
37979
+ stop('Arrow head must be at least as wide as the stem.');
37980
+ }
37978
37981
 
37979
37982
  if (!stemCurve || Math.abs(stemCurve) > 90) {
37980
37983
  coords = [[baseDx, 0], [stemDx, stemLen], [headDx, stemLen], [0, stemLen + headLen],
@@ -38028,15 +38031,18 @@ ${svg}
38028
38031
  var ay = baseDx * Math.sin(theta) * -sign;
38029
38032
  var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy, theta);
38030
38033
  var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy, theta);
38031
- // if (stemTaper == 1) leftStem.pop();
38032
38034
  var stem = leftStem.concat(rightStem.reverse());
38033
- stem.pop();
38035
+ // stem.pop();
38034
38036
  return stem.concat(head);
38035
38037
  }
38036
38038
 
38037
38039
  // ax, ay: point on the base
38038
38040
  // bx, by: point on the stem
38039
38041
  function getCurvedStemCoords(ax, ay, bx, by, theta0) {
38042
+ // case: curved side intrudes into head (because stem is too short)
38043
+ if (ay > by) {
38044
+ return [[ax * by / ay, by]];
38045
+ }
38040
38046
  var dx = bx - ax,
38041
38047
  dy = by - ay,
38042
38048
  dy1 = (dy * dy - dx * dx) / (2 * dy),
@@ -38048,10 +38054,9 @@ ${svg}
38048
38054
  leftBend = bx > ax,
38049
38055
  sign = leftBend ? 1 : -1,
38050
38056
  points = Math.round(degrees / 5) + 2,
38051
- // points = theta > 2 && 7 || theta > 1 && 6 || 5,
38052
- increment = theta / (points + 1);
38057
+ increment = theta / (points + 1),
38058
+ coords = [[bx, by]];
38053
38059
 
38054
- var coords = [[bx, by]];
38055
38060
  for (var i=1; i<= points; i++) {
38056
38061
  var phi = i * increment / 2;
38057
38062
  var sinPhi = Math.sin(phi);