dgeoutils 2.4.52 → 2.6.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.
@@ -209,6 +209,9 @@ export class DPolygon {
209
209
  get fullLength() {
210
210
  return this.clone().open().perimeter;
211
211
  }
212
+ get fullLengthLatLon() {
213
+ return this.clone().open().perimeterLatLon;
214
+ }
212
215
  get perimeter() {
213
216
  let p = 0;
214
217
  for (const [p1, p2] of this.loopPointsGenerator()()) {
@@ -216,6 +219,22 @@ export class DPolygon {
216
219
  }
217
220
  return p;
218
221
  }
222
+ get pointsDistanceProportions() {
223
+ let p = 0;
224
+ const res = [0];
225
+ for (const [p1, p2] of this.loopPointsGenerator()()) {
226
+ p += p1.distance(p2);
227
+ res.push(p);
228
+ }
229
+ return res.map((v) => v / p);
230
+ }
231
+ get perimeterLatLon() {
232
+ let p = 0;
233
+ for (const [p1, p2] of this.loopPointsGenerator()()) {
234
+ p += p1.distanceLatLon(p2);
235
+ }
236
+ return p;
237
+ }
219
238
  get area() {
220
239
  let sum = 0;
221
240
  for (const [{ x, y }, { x: a, y: b }] of this.deintersection.loopPointsGenerator()()) {
@@ -1054,6 +1073,50 @@ export class DPolygon {
1054
1073
  }
1055
1074
  };
1056
1075
  }
1076
+ cloneByDistanceProportions(proportions) {
1077
+ const resultedPolygon = new DPolygon();
1078
+ const resultProportions = Array.from(new Set([...this.pointsDistanceProportions, ...proportions]))
1079
+ .sort((a, b) => a - b);
1080
+ const { fullLength } = this;
1081
+ resultedPolygon.push(this.at(0));
1082
+ let index = 1;
1083
+ let path = 0;
1084
+ for (const [p1_, p2] of this.loopPointsGenerator()()) {
1085
+ let p1 = p1_;
1086
+ while (true) {
1087
+ const distance = p1.distance(p2);
1088
+ const currentProportion = (path + distance) / fullLength;
1089
+ if (Math.abs(currentProportion - resultProportions[index]) < 1e-7) {
1090
+ path += distance;
1091
+ resultedPolygon.push(p2.clone());
1092
+ index++;
1093
+ break;
1094
+ }
1095
+ else {
1096
+ const radius = (resultProportions[index] - resultProportions[index - 1]) * fullLength;
1097
+ const circle = new DCircle(p1, radius);
1098
+ const line = p1.findLine(p2);
1099
+ const intersectionPoint = line.intersectionWithCircle(circle)
1100
+ .filter((p) => line.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE))[0];
1101
+ resultedPolygon.push(intersectionPoint);
1102
+ index++;
1103
+ path += p1.distance(intersectionPoint);
1104
+ p1 = intersectionPoint;
1105
+ }
1106
+ }
1107
+ }
1108
+ return resultedPolygon;
1109
+ }
1110
+ middleLinestring(line) {
1111
+ const thisClone = this.cloneByDistanceProportions(line.pointsDistanceProportions);
1112
+ const thatClone = line.cloneByDistanceProportions(this.pointsDistanceProportions);
1113
+ return thisClone
1114
+ .loop()
1115
+ .setX(({ x }, index) => x + thatClone.at(index).x)
1116
+ .setY(({ y }, index) => y + thatClone.at(index).y)
1117
+ .divide(2)
1118
+ .run();
1119
+ }
1057
1120
  getBezierPoint(v) {
1058
1121
  if (this.length === 1) {
1059
1122
  return this.first;
@@ -263,6 +263,23 @@ var DPoint = (function () {
263
263
  var dy = p.y - this.y;
264
264
  return Math.sqrt(dx * dx + dy * dy);
265
265
  };
266
+ DPoint.prototype.distanceLatLon = function (p) {
267
+ checkFunction('distance')
268
+ .checkArgument('this')
269
+ .shouldBeDegree(this)
270
+ .checkArgument('p')
271
+ .shouldBeDegree(p);
272
+ var d = p.clone().move(this.clone().minus())
273
+ .degreeToRadians();
274
+ var t1 = this.clone().degreeToRadians();
275
+ var t2 = p.clone().degreeToRadians();
276
+ var a = Math.pow(Math.sin(d.lat / 2), 2) +
277
+ Math.cos(t1.lat) *
278
+ Math.cos(t2.lat) *
279
+ (Math.pow((Math.sin(d.lon / 2)), 2));
280
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
281
+ return EARTH_RADIUS_IN_METERS * c;
282
+ };
266
283
  DPoint.prototype.distance3d = function (p) {
267
284
  checkFunction('distance3d')
268
285
  .checkArgument('this')
@@ -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,55 @@ var DPolygon = (function () {
414
421
  enumerable: false,
415
422
  configurable: true
416
423
  });
417
- Object.defineProperty(DPolygon.prototype, "area", {
424
+ Object.defineProperty(DPolygon.prototype, "pointsDistanceProportions", {
418
425
  get: function () {
419
426
  var e_5, _a;
427
+ var p = 0;
428
+ var res = [0];
429
+ try {
430
+ for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
431
+ var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
432
+ p += p1.distance(p2);
433
+ res.push(p);
434
+ }
435
+ }
436
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
437
+ finally {
438
+ try {
439
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
440
+ }
441
+ finally { if (e_5) throw e_5.error; }
442
+ }
443
+ return res.map(function (v) { return v / p; });
444
+ },
445
+ enumerable: false,
446
+ configurable: true
447
+ });
448
+ Object.defineProperty(DPolygon.prototype, "perimeterLatLon", {
449
+ get: function () {
450
+ var e_6, _a;
451
+ var p = 0;
452
+ try {
453
+ for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
454
+ var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
455
+ p += p1.distanceLatLon(p2);
456
+ }
457
+ }
458
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
459
+ finally {
460
+ try {
461
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
462
+ }
463
+ finally { if (e_6) throw e_6.error; }
464
+ }
465
+ return p;
466
+ },
467
+ enumerable: false,
468
+ configurable: true
469
+ });
470
+ Object.defineProperty(DPolygon.prototype, "area", {
471
+ get: function () {
472
+ var e_7, _a;
420
473
  var sum = 0;
421
474
  try {
422
475
  for (var _b = __values(this.deintersection.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -424,12 +477,12 @@ var DPolygon = (function () {
424
477
  sum += x * b - y * a;
425
478
  }
426
479
  }
427
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
480
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
428
481
  finally {
429
482
  try {
430
483
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
431
484
  }
432
- finally { if (e_5) throw e_5.error; }
485
+ finally { if (e_7) throw e_7.error; }
433
486
  }
434
487
  return Math.abs(sum / 2) - this.holes.reduce(function (a, hole) { return a + hole.area; }, 0);
435
488
  },
@@ -472,7 +525,7 @@ var DPolygon = (function () {
472
525
  });
473
526
  Object.defineProperty(DPolygon.prototype, "deintersection", {
474
527
  get: function () {
475
- var e_6, _a;
528
+ var e_8, _a;
476
529
  var p = this.clone().close();
477
530
  var store = {};
478
531
  for (var i = 0; i < p.length - 1; i++) {
@@ -518,12 +571,12 @@ var DPolygon = (function () {
518
571
  }
519
572
  }
520
573
  }
521
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
574
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
522
575
  finally {
523
576
  try {
524
577
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
525
578
  }
526
- finally { if (e_6) throw e_6.error; }
579
+ finally { if (e_8) throw e_8.error; }
527
580
  }
528
581
  return p;
529
582
  },
@@ -560,7 +613,7 @@ var DPolygon = (function () {
560
613
  });
561
614
  Object.defineProperty(DPolygon.prototype, "minAreaRectangle", {
562
615
  get: function () {
563
- var e_7, _a, e_8, _b;
616
+ var e_9, _a, e_10, _b;
564
617
  var p = this.convex;
565
618
  var resultPolygon = new DPolygon();
566
619
  var resultArea = Infinity;
@@ -573,7 +626,7 @@ var DPolygon = (function () {
573
626
  var maxHeight = 0;
574
627
  var maxHeightPoint = null;
575
628
  try {
576
- for (var _f = (e_8 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
629
+ for (var _f = (e_10 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
577
630
  var _h = __read(_g.value, 4), z = _h[0], i = _h[3];
578
631
  var p1 = l.findPoint(l.findPerpendicular(z));
579
632
  var h = p1.distance(z);
@@ -592,12 +645,12 @@ var DPolygon = (function () {
592
645
  }
593
646
  }
594
647
  }
595
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
648
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
596
649
  finally {
597
650
  try {
598
651
  if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
599
652
  }
600
- finally { if (e_8) throw e_8.error; }
653
+ finally { if (e_10) throw e_10.error; }
601
654
  }
602
655
  if (!maxWidthPoint1 || !maxWidthPoint2 || !maxHeightPoint) {
603
656
  continue;
@@ -617,12 +670,12 @@ var DPolygon = (function () {
617
670
  }
618
671
  }
619
672
  }
620
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
673
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
621
674
  finally {
622
675
  try {
623
676
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
624
677
  }
625
- finally { if (e_7) throw e_7.error; }
678
+ finally { if (e_9) throw e_9.error; }
626
679
  }
627
680
  return resultPolygon;
628
681
  },
@@ -675,7 +728,7 @@ var DPolygon = (function () {
675
728
  });
676
729
  Object.defineProperty(DPolygon.prototype, "isClockwise", {
677
730
  get: function () {
678
- var e_9, _a;
731
+ var e_11, _a;
679
732
  var sum = 0;
680
733
  try {
681
734
  for (var _b = __values(this.clone().close()
@@ -684,12 +737,12 @@ var DPolygon = (function () {
684
737
  sum += (a - x) * (b + y);
685
738
  }
686
739
  }
687
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
740
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
688
741
  finally {
689
742
  try {
690
743
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
691
744
  }
692
- finally { if (e_9) throw e_9.error; }
745
+ finally { if (e_11) throw e_11.error; }
693
746
  }
694
747
  return sum < 0;
695
748
  },
@@ -719,7 +772,7 @@ var DPolygon = (function () {
719
772
  return this.pPoints.reduce(f, v);
720
773
  };
721
774
  DPolygon.prototype.intersection = function (l, includeOnly) {
722
- var e_10, _a;
775
+ var e_12, _a;
723
776
  if (includeOnly === void 0) { includeOnly = false; }
724
777
  var res = [];
725
778
  try {
@@ -731,12 +784,12 @@ var DPolygon = (function () {
731
784
  }
732
785
  }
733
786
  }
734
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
787
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
735
788
  finally {
736
789
  try {
737
790
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
738
791
  }
739
- finally { if (e_10) throw e_10.error; }
792
+ finally { if (e_12) throw e_12.error; }
740
793
  }
741
794
  return res;
742
795
  };
@@ -942,7 +995,7 @@ var DPolygon = (function () {
942
995
  ctx.globalCompositeOperation = old;
943
996
  };
944
997
  DPolygon.prototype.contain = function (p, isBorderInside) {
945
- var e_11, _a;
998
+ var e_13, _a;
946
999
  if (isBorderInside === void 0) { isBorderInside = false; }
947
1000
  var simpleInclude = this.simpleInclude(p);
948
1001
  if (!simpleInclude) {
@@ -968,12 +1021,12 @@ var DPolygon = (function () {
968
1021
  }
969
1022
  }
970
1023
  }
971
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1024
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
972
1025
  finally {
973
1026
  try {
974
1027
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
975
1028
  }
976
- finally { if (e_11) throw e_11.error; }
1029
+ finally { if (e_13) throw e_13.error; }
977
1030
  }
978
1031
  var eps = Math.PI / 10000;
979
1032
  var absTotalFi = Math.abs(totalFi);
@@ -986,7 +1039,7 @@ var DPolygon = (function () {
986
1039
  throw new Error('contains2 faild');
987
1040
  };
988
1041
  DPolygon.prototype.onBorder = function (p) {
989
- var e_12, _a;
1042
+ var e_14, _a;
990
1043
  var simpleInclude = this.simpleInclude(p);
991
1044
  if (simpleInclude) {
992
1045
  var poly = this.deintersection;
@@ -1003,12 +1056,12 @@ var DPolygon = (function () {
1003
1056
  }
1004
1057
  }
1005
1058
  }
1006
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1059
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1007
1060
  finally {
1008
1061
  try {
1009
1062
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1010
1063
  }
1011
- finally { if (e_12) throw e_12.error; }
1064
+ finally { if (e_14) throw e_14.error; }
1012
1065
  }
1013
1066
  }
1014
1067
  return false;
@@ -1132,7 +1185,7 @@ var DPolygon = (function () {
1132
1185
  };
1133
1186
  };
1134
1187
  DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
1135
- var e_13, _a;
1188
+ var e_15, _a;
1136
1189
  if (withAltitude === void 0) { withAltitude = false; }
1137
1190
  var fullLength = this.fullLength;
1138
1191
  var pieceLength = fullLength / piecesCount;
@@ -1167,17 +1220,17 @@ var DPolygon = (function () {
1167
1220
  _loop_3(p1, p2, i);
1168
1221
  }
1169
1222
  }
1170
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
1223
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1171
1224
  finally {
1172
1225
  try {
1173
1226
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1174
1227
  }
1175
- finally { if (e_13) throw e_13.error; }
1228
+ finally { if (e_15) throw e_15.error; }
1176
1229
  }
1177
1230
  return this;
1178
1231
  };
1179
1232
  DPolygon.prototype.prepareToFastSearch = function () {
1180
- var e_14, _a;
1233
+ var e_16, _a;
1181
1234
  this.searchStore = {};
1182
1235
  try {
1183
1236
  for (var _b = __values(this.points), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1191,12 +1244,12 @@ var DPolygon = (function () {
1191
1244
  this.searchStore[x][y][z || 'undefined'] = true;
1192
1245
  }
1193
1246
  }
1194
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
1247
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
1195
1248
  finally {
1196
1249
  try {
1197
1250
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1198
1251
  }
1199
- finally { if (e_14) throw e_14.error; }
1252
+ finally { if (e_16) throw e_16.error; }
1200
1253
  }
1201
1254
  };
1202
1255
  DPolygon.prototype.fastHas = function (_a) {
@@ -1216,8 +1269,8 @@ var DPolygon = (function () {
1216
1269
  get: function () {
1217
1270
  var polygon = this;
1218
1271
  return function () {
1219
- var r, _a, _b, p, e_15_1;
1220
- var e_15, _c;
1272
+ var r, _a, _b, p, e_17_1;
1273
+ var e_17, _c;
1221
1274
  return __generator(this, function (_d) {
1222
1275
  switch (_d.label) {
1223
1276
  case 0:
@@ -1241,14 +1294,14 @@ var DPolygon = (function () {
1241
1294
  return [3, 2];
1242
1295
  case 5: return [3, 8];
1243
1296
  case 6:
1244
- e_15_1 = _d.sent();
1245
- e_15 = { error: e_15_1 };
1297
+ e_17_1 = _d.sent();
1298
+ e_17 = { error: e_17_1 };
1246
1299
  return [3, 8];
1247
1300
  case 7:
1248
1301
  try {
1249
1302
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1250
1303
  }
1251
- finally { if (e_15) throw e_15.error; }
1304
+ finally { if (e_17) throw e_17.error; }
1252
1305
  return [7];
1253
1306
  case 8: return [2, r.clone()];
1254
1307
  }
@@ -1280,12 +1333,12 @@ var DPolygon = (function () {
1280
1333
  return this.simpleLogicFunction(p, true, false);
1281
1334
  };
1282
1335
  DPolygon.prototype.smartUnion = function (p) {
1283
- var e_16, _a;
1336
+ var e_18, _a;
1284
1337
  var res = this.clone().simpleUnion(p);
1285
1338
  if (res) {
1286
1339
  var allHoles = __spreadArray(__spreadArray(__spreadArray([], __read(this.holes), false), __read(p.holes), false), __read(res.holes), false).map(function (h) { return h.clone(); });
1287
1340
  var _loop_4 = function (a) {
1288
- var e_17, _b;
1341
+ var e_19, _b;
1289
1342
  var _loop_5 = function (b) {
1290
1343
  if (a.equal(b)) {
1291
1344
  return "continue";
@@ -1297,17 +1350,17 @@ var DPolygon = (function () {
1297
1350
  }
1298
1351
  };
1299
1352
  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()) {
1353
+ for (var allHoles_2 = (e_19 = void 0, __values(allHoles)), allHoles_2_1 = allHoles_2.next(); !allHoles_2_1.done; allHoles_2_1 = allHoles_2.next()) {
1301
1354
  var b = allHoles_2_1.value;
1302
1355
  _loop_5(b);
1303
1356
  }
1304
1357
  }
1305
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
1358
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
1306
1359
  finally {
1307
1360
  try {
1308
1361
  if (allHoles_2_1 && !allHoles_2_1.done && (_b = allHoles_2.return)) _b.call(allHoles_2);
1309
1362
  }
1310
- finally { if (e_17) throw e_17.error; }
1363
+ finally { if (e_19) throw e_19.error; }
1311
1364
  }
1312
1365
  };
1313
1366
  try {
@@ -1316,12 +1369,12 @@ var DPolygon = (function () {
1316
1369
  _loop_4(a);
1317
1370
  }
1318
1371
  }
1319
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
1372
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
1320
1373
  finally {
1321
1374
  try {
1322
1375
  if (allHoles_1_1 && !allHoles_1_1.done && (_a = allHoles_1.return)) _a.call(allHoles_1);
1323
1376
  }
1324
- finally { if (e_16) throw e_16.error; }
1377
+ finally { if (e_18) throw e_18.error; }
1325
1378
  }
1326
1379
  res.holes = allHoles;
1327
1380
  }
@@ -1536,8 +1589,74 @@ var DPolygon = (function () {
1536
1589
  });
1537
1590
  };
1538
1591
  };
1592
+ DPolygon.prototype.cloneByDistanceProportions = function (proportions) {
1593
+ var e_20, _a;
1594
+ var resultedPolygon = new DPolygon();
1595
+ var resultProportions = Array.from(new Set(__spreadArray(__spreadArray([], __read(this.pointsDistanceProportions), false), __read(proportions), false)))
1596
+ .sort(function (a, b) { return a - b; });
1597
+ var fullLength = this.fullLength;
1598
+ resultedPolygon.push(this.at(0));
1599
+ var index = 1;
1600
+ var path = 0;
1601
+ try {
1602
+ for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
1603
+ var _d = __read(_c.value, 2), p1_ = _d[0], p2 = _d[1];
1604
+ var p1 = p1_;
1605
+ var _loop_6 = function () {
1606
+ var distance = p1.distance(p2);
1607
+ var currentProportion = (path + distance) / fullLength;
1608
+ if (Math.abs(currentProportion - resultProportions[index]) < 1e-7) {
1609
+ path += distance;
1610
+ resultedPolygon.push(p2.clone());
1611
+ index++;
1612
+ return "break";
1613
+ }
1614
+ else {
1615
+ var radius = (resultProportions[index] - resultProportions[index - 1]) * fullLength;
1616
+ var circle = new DCircle(p1, radius);
1617
+ var line_2 = p1.findLine(p2);
1618
+ var intersectionPoint = line_2.intersectionWithCircle(circle)
1619
+ .filter(function (p) { return line_2.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE); })[0];
1620
+ resultedPolygon.push(intersectionPoint);
1621
+ index++;
1622
+ path += p1.distance(intersectionPoint);
1623
+ p1 = intersectionPoint;
1624
+ }
1625
+ };
1626
+ while (true) {
1627
+ var state_1 = _loop_6();
1628
+ if (state_1 === "break")
1629
+ break;
1630
+ }
1631
+ }
1632
+ }
1633
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
1634
+ finally {
1635
+ try {
1636
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1637
+ }
1638
+ finally { if (e_20) throw e_20.error; }
1639
+ }
1640
+ return resultedPolygon;
1641
+ };
1642
+ DPolygon.prototype.middleLinestring = function (line) {
1643
+ var thisClone = this.cloneByDistanceProportions(line.pointsDistanceProportions);
1644
+ var thatClone = line.cloneByDistanceProportions(this.pointsDistanceProportions);
1645
+ return thisClone
1646
+ .loop()
1647
+ .setX(function (_a, index) {
1648
+ var x = _a.x;
1649
+ return x + thatClone.at(index).x;
1650
+ })
1651
+ .setY(function (_a, index) {
1652
+ var y = _a.y;
1653
+ return y + thatClone.at(index).y;
1654
+ })
1655
+ .divide(2)
1656
+ .run();
1657
+ };
1539
1658
  DPolygon.prototype.getBezierPoint = function (v) {
1540
- var e_18, _a;
1659
+ var e_21, _a;
1541
1660
  if (this.length === 1) {
1542
1661
  return this.first;
1543
1662
  }
@@ -1548,12 +1667,12 @@ var DPolygon = (function () {
1548
1667
  .scale(v));
1549
1668
  }
1550
1669
  }
1551
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
1670
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
1552
1671
  finally {
1553
1672
  try {
1554
1673
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1555
1674
  }
1556
- finally { if (e_18) throw e_18.error; }
1675
+ finally { if (e_21) throw e_21.error; }
1557
1676
  }
1558
1677
  this.pop();
1559
1678
  return this.getBezierPoint(v);
@@ -1612,7 +1731,7 @@ var DPolygon = (function () {
1612
1731
  return undefined;
1613
1732
  };
1614
1733
  DPolygon.prototype.simpleLogicFunction = function (p, unionThis, unionThat) {
1615
- var e_19, _a, e_20, _b, e_21, _c, e_22, _d;
1734
+ var e_22, _a, e_23, _b, e_24, _c, e_25, _d;
1616
1735
  var c = this.getJSTSGeometry(p, unionThis, unionThat);
1617
1736
  if (c) {
1618
1737
  var coordinates_1 = c.getCoordinates();
@@ -1639,7 +1758,7 @@ var DPolygon = (function () {
1639
1758
  try {
1640
1759
  for (var result_1 = __values(result), result_1_1 = result_1.next(); !result_1_1.done; result_1_1 = result_1.next()) {
1641
1760
  var q = result_1_1.value;
1642
- var _loop_6 = function (r) {
1761
+ var _loop_7 = function (r) {
1643
1762
  var _e;
1644
1763
  if (q.has(r.first) && !q.equal(r)) {
1645
1764
  var index = q.findIndex(r.first);
@@ -1652,38 +1771,38 @@ var DPolygon = (function () {
1652
1771
  }
1653
1772
  };
1654
1773
  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()) {
1774
+ for (var result_2 = (e_23 = void 0, __values(result)), result_2_1 = result_2.next(); !result_2_1.done; result_2_1 = result_2.next()) {
1656
1775
  var r = result_2_1.value;
1657
- var state_1 = _loop_6(r);
1658
- if (state_1 === "break")
1776
+ var state_2 = _loop_7(r);
1777
+ if (state_2 === "break")
1659
1778
  break;
1660
1779
  }
1661
1780
  }
1662
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
1781
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
1663
1782
  finally {
1664
1783
  try {
1665
1784
  if (result_2_1 && !result_2_1.done && (_b = result_2.return)) _b.call(result_2);
1666
1785
  }
1667
- finally { if (e_20) throw e_20.error; }
1786
+ finally { if (e_23) throw e_23.error; }
1668
1787
  }
1669
1788
  if (result.length < 2) {
1670
1789
  break;
1671
1790
  }
1672
1791
  }
1673
1792
  }
1674
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1793
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
1675
1794
  finally {
1676
1795
  try {
1677
1796
  if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
1678
1797
  }
1679
- finally { if (e_19) throw e_19.error; }
1798
+ finally { if (e_22) throw e_22.error; }
1680
1799
  }
1681
1800
  }
1682
1801
  result = result.filter(function (h) { return h.length > 2; }).map(function (h) { return h.close(); });
1683
1802
  try {
1684
1803
  for (var result_3 = __values(result), result_3_1 = result_3.next(); !result_3_1.done; result_3_1 = result_3.next()) {
1685
1804
  var q = result_3_1.value;
1686
- var _loop_7 = function (r) {
1805
+ var _loop_8 = function (r) {
1687
1806
  if (result.length < 2) {
1688
1807
  return "break";
1689
1808
  }
@@ -1695,31 +1814,31 @@ var DPolygon = (function () {
1695
1814
  }
1696
1815
  };
1697
1816
  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()) {
1817
+ for (var result_4 = (e_25 = void 0, __values(result)), result_4_1 = result_4.next(); !result_4_1.done; result_4_1 = result_4.next()) {
1699
1818
  var r = result_4_1.value;
1700
- var state_2 = _loop_7(r);
1701
- if (state_2 === "break")
1819
+ var state_3 = _loop_8(r);
1820
+ if (state_3 === "break")
1702
1821
  break;
1703
1822
  }
1704
1823
  }
1705
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1824
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
1706
1825
  finally {
1707
1826
  try {
1708
1827
  if (result_4_1 && !result_4_1.done && (_d = result_4.return)) _d.call(result_4);
1709
1828
  }
1710
- finally { if (e_22) throw e_22.error; }
1829
+ finally { if (e_25) throw e_25.error; }
1711
1830
  }
1712
1831
  if (result.length < 2) {
1713
1832
  break;
1714
1833
  }
1715
1834
  }
1716
1835
  }
1717
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1836
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
1718
1837
  finally {
1719
1838
  try {
1720
1839
  if (result_3_1 && !result_3_1.done && (_c = result_3.return)) _c.call(result_3);
1721
1840
  }
1722
- finally { if (e_21) throw e_21.error; }
1841
+ finally { if (e_24) throw e_24.error; }
1723
1842
  }
1724
1843
  if (result.length === 0) {
1725
1844
  return null;