dgeoutils 2.4.52 → 2.5.0

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.
@@ -392,6 +392,13 @@ var DPolygon = (function () {
392
392
  enumerable: false,
393
393
  configurable: true
394
394
  });
395
+ Object.defineProperty(DPolygon.prototype, "fullLengthLatLon", {
396
+ get: function () {
397
+ return this.clone().open().perimeterLatLon;
398
+ },
399
+ enumerable: false,
400
+ configurable: true
401
+ });
395
402
  Object.defineProperty(DPolygon.prototype, "perimeter", {
396
403
  get: function () {
397
404
  var e_4, _a;
@@ -414,9 +421,31 @@ var DPolygon = (function () {
414
421
  enumerable: false,
415
422
  configurable: true
416
423
  });
417
- Object.defineProperty(DPolygon.prototype, "area", {
424
+ Object.defineProperty(DPolygon.prototype, "perimeterLatLon", {
418
425
  get: function () {
419
426
  var e_5, _a;
427
+ var p = 0;
428
+ try {
429
+ for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
430
+ var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
431
+ p += p1.distanceLatLon(p2);
432
+ }
433
+ }
434
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
435
+ finally {
436
+ try {
437
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
438
+ }
439
+ finally { if (e_5) throw e_5.error; }
440
+ }
441
+ return p;
442
+ },
443
+ enumerable: false,
444
+ configurable: true
445
+ });
446
+ Object.defineProperty(DPolygon.prototype, "area", {
447
+ get: function () {
448
+ var e_6, _a;
420
449
  var sum = 0;
421
450
  try {
422
451
  for (var _b = __values(this.deintersection.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -424,12 +453,12 @@ var DPolygon = (function () {
424
453
  sum += x * b - y * a;
425
454
  }
426
455
  }
427
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
456
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
428
457
  finally {
429
458
  try {
430
459
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
431
460
  }
432
- finally { if (e_5) throw e_5.error; }
461
+ finally { if (e_6) throw e_6.error; }
433
462
  }
434
463
  return Math.abs(sum / 2) - this.holes.reduce(function (a, hole) { return a + hole.area; }, 0);
435
464
  },
@@ -472,7 +501,7 @@ var DPolygon = (function () {
472
501
  });
473
502
  Object.defineProperty(DPolygon.prototype, "deintersection", {
474
503
  get: function () {
475
- var e_6, _a;
504
+ var e_7, _a;
476
505
  var p = this.clone().close();
477
506
  var store = {};
478
507
  for (var i = 0; i < p.length - 1; i++) {
@@ -518,12 +547,12 @@ var DPolygon = (function () {
518
547
  }
519
548
  }
520
549
  }
521
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
550
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
522
551
  finally {
523
552
  try {
524
553
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
525
554
  }
526
- finally { if (e_6) throw e_6.error; }
555
+ finally { if (e_7) throw e_7.error; }
527
556
  }
528
557
  return p;
529
558
  },
@@ -560,7 +589,7 @@ var DPolygon = (function () {
560
589
  });
561
590
  Object.defineProperty(DPolygon.prototype, "minAreaRectangle", {
562
591
  get: function () {
563
- var e_7, _a, e_8, _b;
592
+ var e_8, _a, e_9, _b;
564
593
  var p = this.convex;
565
594
  var resultPolygon = new DPolygon();
566
595
  var resultArea = Infinity;
@@ -573,7 +602,7 @@ var DPolygon = (function () {
573
602
  var maxHeight = 0;
574
603
  var maxHeightPoint = null;
575
604
  try {
576
- for (var _f = (e_8 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
605
+ for (var _f = (e_9 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
577
606
  var _h = __read(_g.value, 4), z = _h[0], i = _h[3];
578
607
  var p1 = l.findPoint(l.findPerpendicular(z));
579
608
  var h = p1.distance(z);
@@ -592,12 +621,12 @@ var DPolygon = (function () {
592
621
  }
593
622
  }
594
623
  }
595
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
624
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
596
625
  finally {
597
626
  try {
598
627
  if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
599
628
  }
600
- finally { if (e_8) throw e_8.error; }
629
+ finally { if (e_9) throw e_9.error; }
601
630
  }
602
631
  if (!maxWidthPoint1 || !maxWidthPoint2 || !maxHeightPoint) {
603
632
  continue;
@@ -617,12 +646,12 @@ var DPolygon = (function () {
617
646
  }
618
647
  }
619
648
  }
620
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
649
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
621
650
  finally {
622
651
  try {
623
652
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
624
653
  }
625
- finally { if (e_7) throw e_7.error; }
654
+ finally { if (e_8) throw e_8.error; }
626
655
  }
627
656
  return resultPolygon;
628
657
  },
@@ -675,7 +704,7 @@ var DPolygon = (function () {
675
704
  });
676
705
  Object.defineProperty(DPolygon.prototype, "isClockwise", {
677
706
  get: function () {
678
- var e_9, _a;
707
+ var e_10, _a;
679
708
  var sum = 0;
680
709
  try {
681
710
  for (var _b = __values(this.clone().close()
@@ -684,12 +713,12 @@ var DPolygon = (function () {
684
713
  sum += (a - x) * (b + y);
685
714
  }
686
715
  }
687
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
716
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
688
717
  finally {
689
718
  try {
690
719
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
691
720
  }
692
- finally { if (e_9) throw e_9.error; }
721
+ finally { if (e_10) throw e_10.error; }
693
722
  }
694
723
  return sum < 0;
695
724
  },
@@ -719,7 +748,7 @@ var DPolygon = (function () {
719
748
  return this.pPoints.reduce(f, v);
720
749
  };
721
750
  DPolygon.prototype.intersection = function (l, includeOnly) {
722
- var e_10, _a;
751
+ var e_11, _a;
723
752
  if (includeOnly === void 0) { includeOnly = false; }
724
753
  var res = [];
725
754
  try {
@@ -731,12 +760,12 @@ var DPolygon = (function () {
731
760
  }
732
761
  }
733
762
  }
734
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
763
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
735
764
  finally {
736
765
  try {
737
766
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
738
767
  }
739
- finally { if (e_10) throw e_10.error; }
768
+ finally { if (e_11) throw e_11.error; }
740
769
  }
741
770
  return res;
742
771
  };
@@ -942,7 +971,7 @@ var DPolygon = (function () {
942
971
  ctx.globalCompositeOperation = old;
943
972
  };
944
973
  DPolygon.prototype.contain = function (p, isBorderInside) {
945
- var e_11, _a;
974
+ var e_12, _a;
946
975
  if (isBorderInside === void 0) { isBorderInside = false; }
947
976
  var simpleInclude = this.simpleInclude(p);
948
977
  if (!simpleInclude) {
@@ -968,12 +997,12 @@ var DPolygon = (function () {
968
997
  }
969
998
  }
970
999
  }
971
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1000
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
972
1001
  finally {
973
1002
  try {
974
1003
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
975
1004
  }
976
- finally { if (e_11) throw e_11.error; }
1005
+ finally { if (e_12) throw e_12.error; }
977
1006
  }
978
1007
  var eps = Math.PI / 10000;
979
1008
  var absTotalFi = Math.abs(totalFi);
@@ -986,7 +1015,7 @@ var DPolygon = (function () {
986
1015
  throw new Error('contains2 faild');
987
1016
  };
988
1017
  DPolygon.prototype.onBorder = function (p) {
989
- var e_12, _a;
1018
+ var e_13, _a;
990
1019
  var simpleInclude = this.simpleInclude(p);
991
1020
  if (simpleInclude) {
992
1021
  var poly = this.deintersection;
@@ -1003,12 +1032,12 @@ var DPolygon = (function () {
1003
1032
  }
1004
1033
  }
1005
1034
  }
1006
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1035
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1007
1036
  finally {
1008
1037
  try {
1009
1038
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1010
1039
  }
1011
- finally { if (e_12) throw e_12.error; }
1040
+ finally { if (e_13) throw e_13.error; }
1012
1041
  }
1013
1042
  }
1014
1043
  return false;
@@ -1132,7 +1161,7 @@ var DPolygon = (function () {
1132
1161
  };
1133
1162
  };
1134
1163
  DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
1135
- var e_13, _a;
1164
+ var e_14, _a;
1136
1165
  if (withAltitude === void 0) { withAltitude = false; }
1137
1166
  var fullLength = this.fullLength;
1138
1167
  var pieceLength = fullLength / piecesCount;
@@ -1167,17 +1196,17 @@ var DPolygon = (function () {
1167
1196
  _loop_3(p1, p2, i);
1168
1197
  }
1169
1198
  }
1170
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
1199
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1171
1200
  finally {
1172
1201
  try {
1173
1202
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1174
1203
  }
1175
- finally { if (e_13) throw e_13.error; }
1204
+ finally { if (e_14) throw e_14.error; }
1176
1205
  }
1177
1206
  return this;
1178
1207
  };
1179
1208
  DPolygon.prototype.prepareToFastSearch = function () {
1180
- var e_14, _a;
1209
+ var e_15, _a;
1181
1210
  this.searchStore = {};
1182
1211
  try {
1183
1212
  for (var _b = __values(this.points), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1191,12 +1220,12 @@ var DPolygon = (function () {
1191
1220
  this.searchStore[x][y][z || 'undefined'] = true;
1192
1221
  }
1193
1222
  }
1194
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
1223
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1195
1224
  finally {
1196
1225
  try {
1197
1226
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1198
1227
  }
1199
- finally { if (e_14) throw e_14.error; }
1228
+ finally { if (e_15) throw e_15.error; }
1200
1229
  }
1201
1230
  };
1202
1231
  DPolygon.prototype.fastHas = function (_a) {
@@ -1216,8 +1245,8 @@ var DPolygon = (function () {
1216
1245
  get: function () {
1217
1246
  var polygon = this;
1218
1247
  return function () {
1219
- var r, _a, _b, p, e_15_1;
1220
- var e_15, _c;
1248
+ var r, _a, _b, p, e_16_1;
1249
+ var e_16, _c;
1221
1250
  return __generator(this, function (_d) {
1222
1251
  switch (_d.label) {
1223
1252
  case 0:
@@ -1241,14 +1270,14 @@ var DPolygon = (function () {
1241
1270
  return [3, 2];
1242
1271
  case 5: return [3, 8];
1243
1272
  case 6:
1244
- e_15_1 = _d.sent();
1245
- e_15 = { error: e_15_1 };
1273
+ e_16_1 = _d.sent();
1274
+ e_16 = { error: e_16_1 };
1246
1275
  return [3, 8];
1247
1276
  case 7:
1248
1277
  try {
1249
1278
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1250
1279
  }
1251
- finally { if (e_15) throw e_15.error; }
1280
+ finally { if (e_16) throw e_16.error; }
1252
1281
  return [7];
1253
1282
  case 8: return [2, r.clone()];
1254
1283
  }
@@ -1280,12 +1309,12 @@ var DPolygon = (function () {
1280
1309
  return this.simpleLogicFunction(p, true, false);
1281
1310
  };
1282
1311
  DPolygon.prototype.smartUnion = function (p) {
1283
- var e_16, _a;
1312
+ var e_17, _a;
1284
1313
  var res = this.clone().simpleUnion(p);
1285
1314
  if (res) {
1286
1315
  var allHoles = __spreadArray(__spreadArray(__spreadArray([], __read(this.holes), false), __read(p.holes), false), __read(res.holes), false).map(function (h) { return h.clone(); });
1287
1316
  var _loop_4 = function (a) {
1288
- var e_17, _b;
1317
+ var e_18, _b;
1289
1318
  var _loop_5 = function (b) {
1290
1319
  if (a.equal(b)) {
1291
1320
  return "continue";
@@ -1297,17 +1326,17 @@ var DPolygon = (function () {
1297
1326
  }
1298
1327
  };
1299
1328
  try {
1300
- for (var allHoles_2 = (e_17 = void 0, __values(allHoles)), allHoles_2_1 = allHoles_2.next(); !allHoles_2_1.done; allHoles_2_1 = allHoles_2.next()) {
1329
+ for (var allHoles_2 = (e_18 = void 0, __values(allHoles)), allHoles_2_1 = allHoles_2.next(); !allHoles_2_1.done; allHoles_2_1 = allHoles_2.next()) {
1301
1330
  var b = allHoles_2_1.value;
1302
1331
  _loop_5(b);
1303
1332
  }
1304
1333
  }
1305
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
1334
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
1306
1335
  finally {
1307
1336
  try {
1308
1337
  if (allHoles_2_1 && !allHoles_2_1.done && (_b = allHoles_2.return)) _b.call(allHoles_2);
1309
1338
  }
1310
- finally { if (e_17) throw e_17.error; }
1339
+ finally { if (e_18) throw e_18.error; }
1311
1340
  }
1312
1341
  };
1313
1342
  try {
@@ -1316,12 +1345,12 @@ var DPolygon = (function () {
1316
1345
  _loop_4(a);
1317
1346
  }
1318
1347
  }
1319
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
1348
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
1320
1349
  finally {
1321
1350
  try {
1322
1351
  if (allHoles_1_1 && !allHoles_1_1.done && (_a = allHoles_1.return)) _a.call(allHoles_1);
1323
1352
  }
1324
- finally { if (e_16) throw e_16.error; }
1353
+ finally { if (e_17) throw e_17.error; }
1325
1354
  }
1326
1355
  res.holes = allHoles;
1327
1356
  }
@@ -1537,7 +1566,7 @@ var DPolygon = (function () {
1537
1566
  };
1538
1567
  };
1539
1568
  DPolygon.prototype.getBezierPoint = function (v) {
1540
- var e_18, _a;
1569
+ var e_19, _a;
1541
1570
  if (this.length === 1) {
1542
1571
  return this.first;
1543
1572
  }
@@ -1548,12 +1577,12 @@ var DPolygon = (function () {
1548
1577
  .scale(v));
1549
1578
  }
1550
1579
  }
1551
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
1580
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
1552
1581
  finally {
1553
1582
  try {
1554
1583
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1555
1584
  }
1556
- finally { if (e_18) throw e_18.error; }
1585
+ finally { if (e_19) throw e_19.error; }
1557
1586
  }
1558
1587
  this.pop();
1559
1588
  return this.getBezierPoint(v);
@@ -1612,7 +1641,7 @@ var DPolygon = (function () {
1612
1641
  return undefined;
1613
1642
  };
1614
1643
  DPolygon.prototype.simpleLogicFunction = function (p, unionThis, unionThat) {
1615
- var e_19, _a, e_20, _b, e_21, _c, e_22, _d;
1644
+ var e_20, _a, e_21, _b, e_22, _c, e_23, _d;
1616
1645
  var c = this.getJSTSGeometry(p, unionThis, unionThat);
1617
1646
  if (c) {
1618
1647
  var coordinates_1 = c.getCoordinates();
@@ -1652,31 +1681,31 @@ var DPolygon = (function () {
1652
1681
  }
1653
1682
  };
1654
1683
  try {
1655
- for (var result_2 = (e_20 = void 0, __values(result)), result_2_1 = result_2.next(); !result_2_1.done; result_2_1 = result_2.next()) {
1684
+ for (var result_2 = (e_21 = void 0, __values(result)), result_2_1 = result_2.next(); !result_2_1.done; result_2_1 = result_2.next()) {
1656
1685
  var r = result_2_1.value;
1657
1686
  var state_1 = _loop_6(r);
1658
1687
  if (state_1 === "break")
1659
1688
  break;
1660
1689
  }
1661
1690
  }
1662
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
1691
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
1663
1692
  finally {
1664
1693
  try {
1665
1694
  if (result_2_1 && !result_2_1.done && (_b = result_2.return)) _b.call(result_2);
1666
1695
  }
1667
- finally { if (e_20) throw e_20.error; }
1696
+ finally { if (e_21) throw e_21.error; }
1668
1697
  }
1669
1698
  if (result.length < 2) {
1670
1699
  break;
1671
1700
  }
1672
1701
  }
1673
1702
  }
1674
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1703
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
1675
1704
  finally {
1676
1705
  try {
1677
1706
  if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
1678
1707
  }
1679
- finally { if (e_19) throw e_19.error; }
1708
+ finally { if (e_20) throw e_20.error; }
1680
1709
  }
1681
1710
  }
1682
1711
  result = result.filter(function (h) { return h.length > 2; }).map(function (h) { return h.close(); });
@@ -1695,31 +1724,31 @@ var DPolygon = (function () {
1695
1724
  }
1696
1725
  };
1697
1726
  try {
1698
- for (var result_4 = (e_22 = void 0, __values(result)), result_4_1 = result_4.next(); !result_4_1.done; result_4_1 = result_4.next()) {
1727
+ for (var result_4 = (e_23 = void 0, __values(result)), result_4_1 = result_4.next(); !result_4_1.done; result_4_1 = result_4.next()) {
1699
1728
  var r = result_4_1.value;
1700
1729
  var state_2 = _loop_7(r);
1701
1730
  if (state_2 === "break")
1702
1731
  break;
1703
1732
  }
1704
1733
  }
1705
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1734
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
1706
1735
  finally {
1707
1736
  try {
1708
1737
  if (result_4_1 && !result_4_1.done && (_d = result_4.return)) _d.call(result_4);
1709
1738
  }
1710
- finally { if (e_22) throw e_22.error; }
1739
+ finally { if (e_23) throw e_23.error; }
1711
1740
  }
1712
1741
  if (result.length < 2) {
1713
1742
  break;
1714
1743
  }
1715
1744
  }
1716
1745
  }
1717
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1746
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
1718
1747
  finally {
1719
1748
  try {
1720
1749
  if (result_3_1 && !result_3_1.done && (_c = result_3.return)) _c.call(result_3);
1721
1750
  }
1722
- finally { if (e_21) throw e_21.error; }
1751
+ finally { if (e_22) throw e_22.error; }
1723
1752
  }
1724
1753
  if (result.length === 0) {
1725
1754
  return null;