mapshaper 0.6.36 → 0.6.37

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
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.36";
3
+ var VERSION = "0.6.37";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -42346,7 +42346,7 @@ ${svg}
42346
42346
  headDx = size.headWidth / 2,
42347
42347
  stemDx = size.stemWidth / 2,
42348
42348
  baseDx = stemDx * (1 - stemTaper),
42349
- head, stem, coords, dx, dy;
42349
+ coords, dx, dy;
42350
42350
 
42351
42351
  if (curvature) {
42352
42352
  // make curved stem
@@ -42359,11 +42359,11 @@ ${svg}
42359
42359
  dy = stemLen * Math.cos(theta / 2);
42360
42360
 
42361
42361
  if (stickArrow) {
42362
- stem = getCurvedStemCoords(-ax, -ay, dx, dy);
42362
+ coords = getCurvedStemCoords(-ax, -ay, dx, dy);
42363
42363
  } else {
42364
42364
  var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy);
42365
42365
  var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy);
42366
- stem = leftStem.concat(rightStem.reverse());
42366
+ coords = leftStem.concat(rightStem.reverse());
42367
42367
  }
42368
42368
 
42369
42369
  } else {
@@ -42371,23 +42371,26 @@ ${svg}
42371
42371
  dx = 0;
42372
42372
  dy = stemLen;
42373
42373
  if (stickArrow) {
42374
- stem = [[0, 0], [0, stemLen]];
42374
+ coords = [[0, 0], [0, stemLen]];
42375
42375
  } else {
42376
- stem = [[-baseDx, 0], [baseDx, 0]];
42376
+ coords = [[-baseDx, 0], [baseDx, 0]];
42377
42377
  }
42378
42378
  }
42379
42379
 
42380
42380
  if (stickArrow) {
42381
42381
  // make stick arrow
42382
- head = [[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]];
42383
- coords = [stem, head]; // MultiLineString coords
42382
+ coords = [coords]; // MultiLineString coords
42383
+ if (headLen > 0) {
42384
+ coords.push([[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]]);
42385
+ }
42384
42386
  } else {
42385
42387
  // make filled arrow
42386
42388
  // coordinates go counter clockwise, starting from the leftmost head coordinate
42387
- head = [[stemDx + dx, dy], [headDx + dx, dy],
42388
- [dx, headLen + dy], [-headDx + dx, dy], [-stemDx + dx, dy]];
42389
- coords = stem.concat(head);
42390
- coords.push(stem[0].concat()); // closed path
42389
+ coords.push([stemDx + dx, dy]);
42390
+ if (headLen > 0) {
42391
+ coords.push([headDx + dx, dy], [dx, headLen + dy], [-headDx + dx, dy]);
42392
+ }
42393
+ coords.push([-stemDx + dx, dy], coords[0].concat()); // close path
42391
42394
  coords = [coords]; // Polygon coords
42392
42395
  }
42393
42396
 
@@ -42416,7 +42419,6 @@ ${svg}
42416
42419
  var totalLen = Math.max(d.radius || d.length || d.r || 0, 0),
42417
42420
  scale = 1,
42418
42421
  o = initArrowSize(d); // calc several parameters
42419
-
42420
42422
  if (totalLen >= 0) {
42421
42423
  scale = calcScale(totalLen, o.headLen, d);
42422
42424
  o.stemWidth *= scale;
@@ -42425,7 +42427,7 @@ ${svg}
42425
42427
  o.stemLen = stickArrow ? totalLen : totalLen - o.headLen;
42426
42428
  }
42427
42429
 
42428
- if (o.headWidth < o.stemWidth) {
42430
+ if (o.headWidth < o.stemWidth && o.headWidth > 0) {
42429
42431
  stop('Arrow head must be at least as wide as the stem.');
42430
42432
  }
42431
42433
  return o;
@@ -42454,14 +42456,18 @@ ${svg}
42454
42456
  headWidth: d['head-width'],
42455
42457
  headLen: d['head-length']
42456
42458
  };
42457
- if (!o.headWidth) {
42458
- if (o.headLen) {
42459
+ if (o.headWidth === 0) {
42460
+ o.headLen = 0;
42461
+ } else if (o.headWidth > 0 === false) {
42462
+ if (o.headLen > 0) {
42459
42463
  o.headWidth = o.headLen / sizeRatio;
42464
+ } else if (o.headLen === 0) {
42465
+ o.headWidth = 0;
42460
42466
  } else {
42461
42467
  o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
42462
42468
  }
42463
42469
  }
42464
- if (!o.headLen) {
42470
+ if (o.headLen >= 0 === false) {
42465
42471
  o.headLen = o.headWidth * sizeRatio;
42466
42472
  }
42467
42473
  return o;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.36",
3
+ "version": "0.6.37",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.36";
3
+ var VERSION = "0.6.37";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -42346,7 +42346,7 @@ ${svg}
42346
42346
  headDx = size.headWidth / 2,
42347
42347
  stemDx = size.stemWidth / 2,
42348
42348
  baseDx = stemDx * (1 - stemTaper),
42349
- head, stem, coords, dx, dy;
42349
+ coords, dx, dy;
42350
42350
 
42351
42351
  if (curvature) {
42352
42352
  // make curved stem
@@ -42359,11 +42359,11 @@ ${svg}
42359
42359
  dy = stemLen * Math.cos(theta / 2);
42360
42360
 
42361
42361
  if (stickArrow) {
42362
- stem = getCurvedStemCoords(-ax, -ay, dx, dy);
42362
+ coords = getCurvedStemCoords(-ax, -ay, dx, dy);
42363
42363
  } else {
42364
42364
  var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy);
42365
42365
  var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy);
42366
- stem = leftStem.concat(rightStem.reverse());
42366
+ coords = leftStem.concat(rightStem.reverse());
42367
42367
  }
42368
42368
 
42369
42369
  } else {
@@ -42371,23 +42371,26 @@ ${svg}
42371
42371
  dx = 0;
42372
42372
  dy = stemLen;
42373
42373
  if (stickArrow) {
42374
- stem = [[0, 0], [0, stemLen]];
42374
+ coords = [[0, 0], [0, stemLen]];
42375
42375
  } else {
42376
- stem = [[-baseDx, 0], [baseDx, 0]];
42376
+ coords = [[-baseDx, 0], [baseDx, 0]];
42377
42377
  }
42378
42378
  }
42379
42379
 
42380
42380
  if (stickArrow) {
42381
42381
  // make stick arrow
42382
- head = [[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]];
42383
- coords = [stem, head]; // MultiLineString coords
42382
+ coords = [coords]; // MultiLineString coords
42383
+ if (headLen > 0) {
42384
+ coords.push([[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]]);
42385
+ }
42384
42386
  } else {
42385
42387
  // make filled arrow
42386
42388
  // coordinates go counter clockwise, starting from the leftmost head coordinate
42387
- head = [[stemDx + dx, dy], [headDx + dx, dy],
42388
- [dx, headLen + dy], [-headDx + dx, dy], [-stemDx + dx, dy]];
42389
- coords = stem.concat(head);
42390
- coords.push(stem[0].concat()); // closed path
42389
+ coords.push([stemDx + dx, dy]);
42390
+ if (headLen > 0) {
42391
+ coords.push([headDx + dx, dy], [dx, headLen + dy], [-headDx + dx, dy]);
42392
+ }
42393
+ coords.push([-stemDx + dx, dy], coords[0].concat()); // close path
42391
42394
  coords = [coords]; // Polygon coords
42392
42395
  }
42393
42396
 
@@ -42416,7 +42419,6 @@ ${svg}
42416
42419
  var totalLen = Math.max(d.radius || d.length || d.r || 0, 0),
42417
42420
  scale = 1,
42418
42421
  o = initArrowSize(d); // calc several parameters
42419
-
42420
42422
  if (totalLen >= 0) {
42421
42423
  scale = calcScale(totalLen, o.headLen, d);
42422
42424
  o.stemWidth *= scale;
@@ -42425,7 +42427,7 @@ ${svg}
42425
42427
  o.stemLen = stickArrow ? totalLen : totalLen - o.headLen;
42426
42428
  }
42427
42429
 
42428
- if (o.headWidth < o.stemWidth) {
42430
+ if (o.headWidth < o.stemWidth && o.headWidth > 0) {
42429
42431
  stop('Arrow head must be at least as wide as the stem.');
42430
42432
  }
42431
42433
  return o;
@@ -42454,14 +42456,18 @@ ${svg}
42454
42456
  headWidth: d['head-width'],
42455
42457
  headLen: d['head-length']
42456
42458
  };
42457
- if (!o.headWidth) {
42458
- if (o.headLen) {
42459
+ if (o.headWidth === 0) {
42460
+ o.headLen = 0;
42461
+ } else if (o.headWidth > 0 === false) {
42462
+ if (o.headLen > 0) {
42459
42463
  o.headWidth = o.headLen / sizeRatio;
42464
+ } else if (o.headLen === 0) {
42465
+ o.headWidth = 0;
42460
42466
  } else {
42461
42467
  o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
42462
42468
  }
42463
42469
  }
42464
- if (!o.headLen) {
42470
+ if (o.headLen >= 0 === false) {
42465
42471
  o.headLen = o.headWidth * sizeRatio;
42466
42472
  }
42467
42473
  return o;