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.
@@ -51,6 +51,7 @@ export declare class DPoint {
51
51
  height(z: number): DPoint;
52
52
  toWKT(): string;
53
53
  distance(p: DPoint): number;
54
+ distanceLatLon(p: DPoint): number;
54
55
  distance3d(p: DPoint): number;
55
56
  setX(x: number): DPoint;
56
57
  setX(f: SetterFunction<number>): DPoint;
@@ -266,6 +266,23 @@ var DPoint = (function () {
266
266
  var dy = p.y - this.y;
267
267
  return Math.sqrt(dx * dx + dy * dy);
268
268
  };
269
+ DPoint.prototype.distanceLatLon = function (p) {
270
+ (0, utils_1.checkFunction)('distance')
271
+ .checkArgument('this')
272
+ .shouldBeDegree(this)
273
+ .checkArgument('p')
274
+ .shouldBeDegree(p);
275
+ var d = p.clone().move(this.clone().minus())
276
+ .degreeToRadians();
277
+ var t1 = this.clone().degreeToRadians();
278
+ var t2 = p.clone().degreeToRadians();
279
+ var a = Math.pow(Math.sin(d.lat / 2), 2) +
280
+ Math.cos(t1.lat) *
281
+ Math.cos(t2.lat) *
282
+ (Math.pow((Math.sin(d.lon / 2)), 2));
283
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
284
+ return exports.EARTH_RADIUS_IN_METERS * c;
285
+ };
269
286
  DPoint.prototype.distance3d = function (p) {
270
287
  (0, utils_1.checkFunction)('distance3d')
271
288
  .checkArgument('this')
@@ -44,7 +44,9 @@ export declare class DPolygon {
44
44
  get maxPoint(): DPoint;
45
45
  get length(): number;
46
46
  get fullLength(): number;
47
+ get fullLengthLatLon(): number;
47
48
  get perimeter(): number;
49
+ get perimeterLatLon(): number;
48
50
  get area(): number;
49
51
  get filledDeintersection(): DPolygon;
50
52
  get deintersection(): DPolygon;
@@ -395,6 +395,13 @@ var DPolygon = (function () {
395
395
  enumerable: false,
396
396
  configurable: true
397
397
  });
398
+ Object.defineProperty(DPolygon.prototype, "fullLengthLatLon", {
399
+ get: function () {
400
+ return this.clone().open().perimeterLatLon;
401
+ },
402
+ enumerable: false,
403
+ configurable: true
404
+ });
398
405
  Object.defineProperty(DPolygon.prototype, "perimeter", {
399
406
  get: function () {
400
407
  var e_4, _a;
@@ -417,9 +424,31 @@ var DPolygon = (function () {
417
424
  enumerable: false,
418
425
  configurable: true
419
426
  });
420
- Object.defineProperty(DPolygon.prototype, "area", {
427
+ Object.defineProperty(DPolygon.prototype, "perimeterLatLon", {
421
428
  get: function () {
422
429
  var e_5, _a;
430
+ var p = 0;
431
+ try {
432
+ for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
433
+ var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
434
+ p += p1.distanceLatLon(p2);
435
+ }
436
+ }
437
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
438
+ finally {
439
+ try {
440
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
441
+ }
442
+ finally { if (e_5) throw e_5.error; }
443
+ }
444
+ return p;
445
+ },
446
+ enumerable: false,
447
+ configurable: true
448
+ });
449
+ Object.defineProperty(DPolygon.prototype, "area", {
450
+ get: function () {
451
+ var e_6, _a;
423
452
  var sum = 0;
424
453
  try {
425
454
  for (var _b = __values(this.deintersection.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -427,12 +456,12 @@ var DPolygon = (function () {
427
456
  sum += x * b - y * a;
428
457
  }
429
458
  }
430
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
459
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
431
460
  finally {
432
461
  try {
433
462
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
434
463
  }
435
- finally { if (e_5) throw e_5.error; }
464
+ finally { if (e_6) throw e_6.error; }
436
465
  }
437
466
  return Math.abs(sum / 2) - this.holes.reduce(function (a, hole) { return a + hole.area; }, 0);
438
467
  },
@@ -475,7 +504,7 @@ var DPolygon = (function () {
475
504
  });
476
505
  Object.defineProperty(DPolygon.prototype, "deintersection", {
477
506
  get: function () {
478
- var e_6, _a;
507
+ var e_7, _a;
479
508
  var p = this.clone().close();
480
509
  var store = {};
481
510
  for (var i = 0; i < p.length - 1; i++) {
@@ -521,12 +550,12 @@ var DPolygon = (function () {
521
550
  }
522
551
  }
523
552
  }
524
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
553
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
525
554
  finally {
526
555
  try {
527
556
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
528
557
  }
529
- finally { if (e_6) throw e_6.error; }
558
+ finally { if (e_7) throw e_7.error; }
530
559
  }
531
560
  return p;
532
561
  },
@@ -563,7 +592,7 @@ var DPolygon = (function () {
563
592
  });
564
593
  Object.defineProperty(DPolygon.prototype, "minAreaRectangle", {
565
594
  get: function () {
566
- var e_7, _a, e_8, _b;
595
+ var e_8, _a, e_9, _b;
567
596
  var p = this.convex;
568
597
  var resultPolygon = new DPolygon();
569
598
  var resultArea = Infinity;
@@ -576,7 +605,7 @@ var DPolygon = (function () {
576
605
  var maxHeight = 0;
577
606
  var maxHeightPoint = null;
578
607
  try {
579
- for (var _f = (e_8 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
608
+ for (var _f = (e_9 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
580
609
  var _h = __read(_g.value, 4), z = _h[0], i = _h[3];
581
610
  var p1 = l.findPoint(l.findPerpendicular(z));
582
611
  var h = p1.distance(z);
@@ -595,12 +624,12 @@ var DPolygon = (function () {
595
624
  }
596
625
  }
597
626
  }
598
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
627
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
599
628
  finally {
600
629
  try {
601
630
  if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
602
631
  }
603
- finally { if (e_8) throw e_8.error; }
632
+ finally { if (e_9) throw e_9.error; }
604
633
  }
605
634
  if (!maxWidthPoint1 || !maxWidthPoint2 || !maxHeightPoint) {
606
635
  continue;
@@ -620,12 +649,12 @@ var DPolygon = (function () {
620
649
  }
621
650
  }
622
651
  }
623
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
652
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
624
653
  finally {
625
654
  try {
626
655
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
627
656
  }
628
- finally { if (e_7) throw e_7.error; }
657
+ finally { if (e_8) throw e_8.error; }
629
658
  }
630
659
  return resultPolygon;
631
660
  },
@@ -678,7 +707,7 @@ var DPolygon = (function () {
678
707
  });
679
708
  Object.defineProperty(DPolygon.prototype, "isClockwise", {
680
709
  get: function () {
681
- var e_9, _a;
710
+ var e_10, _a;
682
711
  var sum = 0;
683
712
  try {
684
713
  for (var _b = __values(this.clone().close()
@@ -687,12 +716,12 @@ var DPolygon = (function () {
687
716
  sum += (a - x) * (b + y);
688
717
  }
689
718
  }
690
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
719
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
691
720
  finally {
692
721
  try {
693
722
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
694
723
  }
695
- finally { if (e_9) throw e_9.error; }
724
+ finally { if (e_10) throw e_10.error; }
696
725
  }
697
726
  return sum < 0;
698
727
  },
@@ -722,7 +751,7 @@ var DPolygon = (function () {
722
751
  return this.pPoints.reduce(f, v);
723
752
  };
724
753
  DPolygon.prototype.intersection = function (l, includeOnly) {
725
- var e_10, _a;
754
+ var e_11, _a;
726
755
  if (includeOnly === void 0) { includeOnly = false; }
727
756
  var res = [];
728
757
  try {
@@ -734,12 +763,12 @@ var DPolygon = (function () {
734
763
  }
735
764
  }
736
765
  }
737
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
766
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
738
767
  finally {
739
768
  try {
740
769
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
741
770
  }
742
- finally { if (e_10) throw e_10.error; }
771
+ finally { if (e_11) throw e_11.error; }
743
772
  }
744
773
  return res;
745
774
  };
@@ -945,7 +974,7 @@ var DPolygon = (function () {
945
974
  ctx.globalCompositeOperation = old;
946
975
  };
947
976
  DPolygon.prototype.contain = function (p, isBorderInside) {
948
- var e_11, _a;
977
+ var e_12, _a;
949
978
  if (isBorderInside === void 0) { isBorderInside = false; }
950
979
  var simpleInclude = this.simpleInclude(p);
951
980
  if (!simpleInclude) {
@@ -971,12 +1000,12 @@ var DPolygon = (function () {
971
1000
  }
972
1001
  }
973
1002
  }
974
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1003
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
975
1004
  finally {
976
1005
  try {
977
1006
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
978
1007
  }
979
- finally { if (e_11) throw e_11.error; }
1008
+ finally { if (e_12) throw e_12.error; }
980
1009
  }
981
1010
  var eps = Math.PI / 10000;
982
1011
  var absTotalFi = Math.abs(totalFi);
@@ -989,7 +1018,7 @@ var DPolygon = (function () {
989
1018
  throw new Error('contains2 faild');
990
1019
  };
991
1020
  DPolygon.prototype.onBorder = function (p) {
992
- var e_12, _a;
1021
+ var e_13, _a;
993
1022
  var simpleInclude = this.simpleInclude(p);
994
1023
  if (simpleInclude) {
995
1024
  var poly = this.deintersection;
@@ -1006,12 +1035,12 @@ var DPolygon = (function () {
1006
1035
  }
1007
1036
  }
1008
1037
  }
1009
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1038
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1010
1039
  finally {
1011
1040
  try {
1012
1041
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1013
1042
  }
1014
- finally { if (e_12) throw e_12.error; }
1043
+ finally { if (e_13) throw e_13.error; }
1015
1044
  }
1016
1045
  }
1017
1046
  return false;
@@ -1135,7 +1164,7 @@ var DPolygon = (function () {
1135
1164
  };
1136
1165
  };
1137
1166
  DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
1138
- var e_13, _a;
1167
+ var e_14, _a;
1139
1168
  if (withAltitude === void 0) { withAltitude = false; }
1140
1169
  var fullLength = this.fullLength;
1141
1170
  var pieceLength = fullLength / piecesCount;
@@ -1170,17 +1199,17 @@ var DPolygon = (function () {
1170
1199
  _loop_3(p1, p2, i);
1171
1200
  }
1172
1201
  }
1173
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
1202
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1174
1203
  finally {
1175
1204
  try {
1176
1205
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1177
1206
  }
1178
- finally { if (e_13) throw e_13.error; }
1207
+ finally { if (e_14) throw e_14.error; }
1179
1208
  }
1180
1209
  return this;
1181
1210
  };
1182
1211
  DPolygon.prototype.prepareToFastSearch = function () {
1183
- var e_14, _a;
1212
+ var e_15, _a;
1184
1213
  this.searchStore = {};
1185
1214
  try {
1186
1215
  for (var _b = __values(this.points), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1194,12 +1223,12 @@ var DPolygon = (function () {
1194
1223
  this.searchStore[x][y][z || 'undefined'] = true;
1195
1224
  }
1196
1225
  }
1197
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
1226
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1198
1227
  finally {
1199
1228
  try {
1200
1229
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1201
1230
  }
1202
- finally { if (e_14) throw e_14.error; }
1231
+ finally { if (e_15) throw e_15.error; }
1203
1232
  }
1204
1233
  };
1205
1234
  DPolygon.prototype.fastHas = function (_a) {
@@ -1219,8 +1248,8 @@ var DPolygon = (function () {
1219
1248
  get: function () {
1220
1249
  var polygon = this;
1221
1250
  return function () {
1222
- var r, _a, _b, p, e_15_1;
1223
- var e_15, _c;
1251
+ var r, _a, _b, p, e_16_1;
1252
+ var e_16, _c;
1224
1253
  return __generator(this, function (_d) {
1225
1254
  switch (_d.label) {
1226
1255
  case 0:
@@ -1244,14 +1273,14 @@ var DPolygon = (function () {
1244
1273
  return [3, 2];
1245
1274
  case 5: return [3, 8];
1246
1275
  case 6:
1247
- e_15_1 = _d.sent();
1248
- e_15 = { error: e_15_1 };
1276
+ e_16_1 = _d.sent();
1277
+ e_16 = { error: e_16_1 };
1249
1278
  return [3, 8];
1250
1279
  case 7:
1251
1280
  try {
1252
1281
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1253
1282
  }
1254
- finally { if (e_15) throw e_15.error; }
1283
+ finally { if (e_16) throw e_16.error; }
1255
1284
  return [7];
1256
1285
  case 8: return [2, r.clone()];
1257
1286
  }
@@ -1283,12 +1312,12 @@ var DPolygon = (function () {
1283
1312
  return this.simpleLogicFunction(p, true, false);
1284
1313
  };
1285
1314
  DPolygon.prototype.smartUnion = function (p) {
1286
- var e_16, _a;
1315
+ var e_17, _a;
1287
1316
  var res = this.clone().simpleUnion(p);
1288
1317
  if (res) {
1289
1318
  var allHoles = __spreadArray(__spreadArray(__spreadArray([], __read(this.holes), false), __read(p.holes), false), __read(res.holes), false).map(function (h) { return h.clone(); });
1290
1319
  var _loop_4 = function (a) {
1291
- var e_17, _b;
1320
+ var e_18, _b;
1292
1321
  var _loop_5 = function (b) {
1293
1322
  if (a.equal(b)) {
1294
1323
  return "continue";
@@ -1300,17 +1329,17 @@ var DPolygon = (function () {
1300
1329
  }
1301
1330
  };
1302
1331
  try {
1303
- 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()) {
1332
+ 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()) {
1304
1333
  var b = allHoles_2_1.value;
1305
1334
  _loop_5(b);
1306
1335
  }
1307
1336
  }
1308
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
1337
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
1309
1338
  finally {
1310
1339
  try {
1311
1340
  if (allHoles_2_1 && !allHoles_2_1.done && (_b = allHoles_2.return)) _b.call(allHoles_2);
1312
1341
  }
1313
- finally { if (e_17) throw e_17.error; }
1342
+ finally { if (e_18) throw e_18.error; }
1314
1343
  }
1315
1344
  };
1316
1345
  try {
@@ -1319,12 +1348,12 @@ var DPolygon = (function () {
1319
1348
  _loop_4(a);
1320
1349
  }
1321
1350
  }
1322
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
1351
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
1323
1352
  finally {
1324
1353
  try {
1325
1354
  if (allHoles_1_1 && !allHoles_1_1.done && (_a = allHoles_1.return)) _a.call(allHoles_1);
1326
1355
  }
1327
- finally { if (e_16) throw e_16.error; }
1356
+ finally { if (e_17) throw e_17.error; }
1328
1357
  }
1329
1358
  res.holes = allHoles;
1330
1359
  }
@@ -1540,7 +1569,7 @@ var DPolygon = (function () {
1540
1569
  };
1541
1570
  };
1542
1571
  DPolygon.prototype.getBezierPoint = function (v) {
1543
- var e_18, _a;
1572
+ var e_19, _a;
1544
1573
  if (this.length === 1) {
1545
1574
  return this.first;
1546
1575
  }
@@ -1551,12 +1580,12 @@ var DPolygon = (function () {
1551
1580
  .scale(v));
1552
1581
  }
1553
1582
  }
1554
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
1583
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
1555
1584
  finally {
1556
1585
  try {
1557
1586
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1558
1587
  }
1559
- finally { if (e_18) throw e_18.error; }
1588
+ finally { if (e_19) throw e_19.error; }
1560
1589
  }
1561
1590
  this.pop();
1562
1591
  return this.getBezierPoint(v);
@@ -1615,7 +1644,7 @@ var DPolygon = (function () {
1615
1644
  return undefined;
1616
1645
  };
1617
1646
  DPolygon.prototype.simpleLogicFunction = function (p, unionThis, unionThat) {
1618
- var e_19, _a, e_20, _b, e_21, _c, e_22, _d;
1647
+ var e_20, _a, e_21, _b, e_22, _c, e_23, _d;
1619
1648
  var c = this.getJSTSGeometry(p, unionThis, unionThat);
1620
1649
  if (c) {
1621
1650
  var coordinates_1 = c.getCoordinates();
@@ -1655,31 +1684,31 @@ var DPolygon = (function () {
1655
1684
  }
1656
1685
  };
1657
1686
  try {
1658
- 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()) {
1687
+ 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()) {
1659
1688
  var r = result_2_1.value;
1660
1689
  var state_1 = _loop_6(r);
1661
1690
  if (state_1 === "break")
1662
1691
  break;
1663
1692
  }
1664
1693
  }
1665
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
1694
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
1666
1695
  finally {
1667
1696
  try {
1668
1697
  if (result_2_1 && !result_2_1.done && (_b = result_2.return)) _b.call(result_2);
1669
1698
  }
1670
- finally { if (e_20) throw e_20.error; }
1699
+ finally { if (e_21) throw e_21.error; }
1671
1700
  }
1672
1701
  if (result.length < 2) {
1673
1702
  break;
1674
1703
  }
1675
1704
  }
1676
1705
  }
1677
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1706
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
1678
1707
  finally {
1679
1708
  try {
1680
1709
  if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
1681
1710
  }
1682
- finally { if (e_19) throw e_19.error; }
1711
+ finally { if (e_20) throw e_20.error; }
1683
1712
  }
1684
1713
  }
1685
1714
  result = result.filter(function (h) { return h.length > 2; }).map(function (h) { return h.close(); });
@@ -1698,31 +1727,31 @@ var DPolygon = (function () {
1698
1727
  }
1699
1728
  };
1700
1729
  try {
1701
- 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()) {
1730
+ 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()) {
1702
1731
  var r = result_4_1.value;
1703
1732
  var state_2 = _loop_7(r);
1704
1733
  if (state_2 === "break")
1705
1734
  break;
1706
1735
  }
1707
1736
  }
1708
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1737
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
1709
1738
  finally {
1710
1739
  try {
1711
1740
  if (result_4_1 && !result_4_1.done && (_d = result_4.return)) _d.call(result_4);
1712
1741
  }
1713
- finally { if (e_22) throw e_22.error; }
1742
+ finally { if (e_23) throw e_23.error; }
1714
1743
  }
1715
1744
  if (result.length < 2) {
1716
1745
  break;
1717
1746
  }
1718
1747
  }
1719
1748
  }
1720
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1749
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
1721
1750
  finally {
1722
1751
  try {
1723
1752
  if (result_3_1 && !result_3_1.done && (_c = result_3.return)) _c.call(result_3);
1724
1753
  }
1725
- finally { if (e_21) throw e_21.error; }
1754
+ finally { if (e_22) throw e_22.error; }
1726
1755
  }
1727
1756
  if (result.length === 0) {
1728
1757
  return null;
@@ -226,6 +226,23 @@ export class DPoint {
226
226
  const dy = p.y - this.y;
227
227
  return Math.sqrt(dx * dx + dy * dy);
228
228
  }
229
+ distanceLatLon(p) {
230
+ checkFunction('distance')
231
+ .checkArgument('this')
232
+ .shouldBeDegree(this)
233
+ .checkArgument('p')
234
+ .shouldBeDegree(p);
235
+ const d = p.clone().move(this.clone().minus())
236
+ .degreeToRadians();
237
+ const t1 = this.clone().degreeToRadians();
238
+ const t2 = p.clone().degreeToRadians();
239
+ const a = Math.pow(Math.sin(d.lat / 2), 2) +
240
+ Math.cos(t1.lat) *
241
+ Math.cos(t2.lat) *
242
+ (Math.pow((Math.sin(d.lon / 2)), 2));
243
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
244
+ return EARTH_RADIUS_IN_METERS * c;
245
+ }
229
246
  distance3d(p) {
230
247
  checkFunction('distance3d')
231
248
  .checkArgument('this')
@@ -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,13 @@ export class DPolygon {
216
219
  }
217
220
  return p;
218
221
  }
222
+ get perimeterLatLon() {
223
+ let p = 0;
224
+ for (const [p1, p2] of this.loopPointsGenerator()()) {
225
+ p += p1.distanceLatLon(p2);
226
+ }
227
+ return p;
228
+ }
219
229
  get area() {
220
230
  let sum = 0;
221
231
  for (const [{ x, y }, { x: a, y: b }] of this.deintersection.loopPointsGenerator()()) {
@@ -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')