dgeoutils 2.4.39 → 2.4.40

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.
@@ -1297,6 +1297,14 @@ var DPolygon = (function () {
1297
1297
  return res;
1298
1298
  };
1299
1299
  DPolygon.prototype.toTriangles = function () {
1300
+ var q = this.clone().removeDuplicates()
1301
+ .open();
1302
+ if (q.length < 3) {
1303
+ return [];
1304
+ }
1305
+ if (q.length === 3) {
1306
+ return [q];
1307
+ }
1300
1308
  var innerAndNotIntersect = function (poly, p1, p2) {
1301
1309
  var l = p1.findLine(p2);
1302
1310
  var center = l.center;
@@ -1324,7 +1332,7 @@ var DPolygon = (function () {
1324
1332
  }
1325
1333
  return undefined;
1326
1334
  };
1327
- var p = this.clone().clockWise.open();
1335
+ var p = this.clone().removeDuplicates().clockWise.open();
1328
1336
  while (p.holes.length) {
1329
1337
  var h = p.holes.shift()
1330
1338
  .clone()
@@ -844,6 +844,14 @@ export class DPolygon {
844
844
  return res;
845
845
  }
846
846
  toTriangles() {
847
+ const q = this.clone().removeDuplicates()
848
+ .open();
849
+ if (q.length < 3) {
850
+ return [];
851
+ }
852
+ if (q.length === 3) {
853
+ return [q];
854
+ }
847
855
  const innerAndNotIntersect = (poly, p1, p2) => {
848
856
  const l = p1.findLine(p2);
849
857
  const { center } = l;
@@ -871,7 +879,7 @@ export class DPolygon {
871
879
  }
872
880
  return undefined;
873
881
  };
874
- const p = this.clone().clockWise.open();
882
+ const p = this.clone().removeDuplicates().clockWise.open();
875
883
  while (p.holes.length) {
876
884
  const h = p.holes.shift()
877
885
  .clone()
@@ -1294,6 +1294,14 @@ var DPolygon = (function () {
1294
1294
  return res;
1295
1295
  };
1296
1296
  DPolygon.prototype.toTriangles = function () {
1297
+ var q = this.clone().removeDuplicates()
1298
+ .open();
1299
+ if (q.length < 3) {
1300
+ return [];
1301
+ }
1302
+ if (q.length === 3) {
1303
+ return [q];
1304
+ }
1297
1305
  var innerAndNotIntersect = function (poly, p1, p2) {
1298
1306
  var l = p1.findLine(p2);
1299
1307
  var center = l.center;
@@ -1321,7 +1329,7 @@ var DPolygon = (function () {
1321
1329
  }
1322
1330
  return undefined;
1323
1331
  };
1324
- var p = this.clone().clockWise.open();
1332
+ var p = this.clone().removeDuplicates().clockWise.open();
1325
1333
  while (p.holes.length) {
1326
1334
  var h = p.holes.shift()
1327
1335
  .clone()