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.
- package/README.md +1 -1
- package/dist/cjs/DPoint.d.ts +1 -0
- package/dist/cjs/DPoint.js +17 -0
- package/dist/cjs/DPolygon.d.ts +5 -0
- package/dist/cjs/DPolygon.js +181 -62
- package/dist/es2015/DPoint.js +17 -0
- package/dist/es2015/DPolygon.js +63 -0
- package/dist/esm/DPoint.js +17 -0
- package/dist/esm/DPolygon.js +181 -62
- package/dist/umd/dgeoutils.js +199 -63
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +3 -8
package/README.md
CHANGED
package/dist/cjs/DPoint.d.ts
CHANGED
package/dist/cjs/DPoint.js
CHANGED
|
@@ -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')
|
package/dist/cjs/DPolygon.d.ts
CHANGED
|
@@ -44,7 +44,10 @@ 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 pointsDistanceProportions(): number[];
|
|
50
|
+
get perimeterLatLon(): number;
|
|
48
51
|
get area(): number;
|
|
49
52
|
get filledDeintersection(): DPolygon;
|
|
50
53
|
get deintersection(): DPolygon;
|
|
@@ -126,6 +129,8 @@ export declare class DPolygon {
|
|
|
126
129
|
setGrowingHeight(from: number, to: number): DPolygon;
|
|
127
130
|
loopPointsGenerator(): () => Generator<[DPoint, DPoint, undefined, number]>;
|
|
128
131
|
loopPointsGenerator(withLine: True): () => Generator<[DPoint, DPoint, DLine, number]>;
|
|
132
|
+
cloneByDistanceProportions(proportions: number[]): DPolygon;
|
|
133
|
+
middleLinestring(line: DPolygon): DPolygon;
|
|
129
134
|
private getBezierPoint;
|
|
130
135
|
private simpleIncludeX;
|
|
131
136
|
private simpleIncludeY;
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -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,55 @@ var DPolygon = (function () {
|
|
|
417
424
|
enumerable: false,
|
|
418
425
|
configurable: true
|
|
419
426
|
});
|
|
420
|
-
Object.defineProperty(DPolygon.prototype, "
|
|
427
|
+
Object.defineProperty(DPolygon.prototype, "pointsDistanceProportions", {
|
|
421
428
|
get: function () {
|
|
422
429
|
var e_5, _a;
|
|
430
|
+
var p = 0;
|
|
431
|
+
var res = [0];
|
|
432
|
+
try {
|
|
433
|
+
for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
434
|
+
var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
|
|
435
|
+
p += p1.distance(p2);
|
|
436
|
+
res.push(p);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
440
|
+
finally {
|
|
441
|
+
try {
|
|
442
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
443
|
+
}
|
|
444
|
+
finally { if (e_5) throw e_5.error; }
|
|
445
|
+
}
|
|
446
|
+
return res.map(function (v) { return v / p; });
|
|
447
|
+
},
|
|
448
|
+
enumerable: false,
|
|
449
|
+
configurable: true
|
|
450
|
+
});
|
|
451
|
+
Object.defineProperty(DPolygon.prototype, "perimeterLatLon", {
|
|
452
|
+
get: function () {
|
|
453
|
+
var e_6, _a;
|
|
454
|
+
var p = 0;
|
|
455
|
+
try {
|
|
456
|
+
for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
457
|
+
var _d = __read(_c.value, 2), p1 = _d[0], p2 = _d[1];
|
|
458
|
+
p += p1.distanceLatLon(p2);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
462
|
+
finally {
|
|
463
|
+
try {
|
|
464
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
465
|
+
}
|
|
466
|
+
finally { if (e_6) throw e_6.error; }
|
|
467
|
+
}
|
|
468
|
+
return p;
|
|
469
|
+
},
|
|
470
|
+
enumerable: false,
|
|
471
|
+
configurable: true
|
|
472
|
+
});
|
|
473
|
+
Object.defineProperty(DPolygon.prototype, "area", {
|
|
474
|
+
get: function () {
|
|
475
|
+
var e_7, _a;
|
|
423
476
|
var sum = 0;
|
|
424
477
|
try {
|
|
425
478
|
for (var _b = __values(this.deintersection.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -427,12 +480,12 @@ var DPolygon = (function () {
|
|
|
427
480
|
sum += x * b - y * a;
|
|
428
481
|
}
|
|
429
482
|
}
|
|
430
|
-
catch (
|
|
483
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
431
484
|
finally {
|
|
432
485
|
try {
|
|
433
486
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
434
487
|
}
|
|
435
|
-
finally { if (
|
|
488
|
+
finally { if (e_7) throw e_7.error; }
|
|
436
489
|
}
|
|
437
490
|
return Math.abs(sum / 2) - this.holes.reduce(function (a, hole) { return a + hole.area; }, 0);
|
|
438
491
|
},
|
|
@@ -475,7 +528,7 @@ var DPolygon = (function () {
|
|
|
475
528
|
});
|
|
476
529
|
Object.defineProperty(DPolygon.prototype, "deintersection", {
|
|
477
530
|
get: function () {
|
|
478
|
-
var
|
|
531
|
+
var e_8, _a;
|
|
479
532
|
var p = this.clone().close();
|
|
480
533
|
var store = {};
|
|
481
534
|
for (var i = 0; i < p.length - 1; i++) {
|
|
@@ -521,12 +574,12 @@ var DPolygon = (function () {
|
|
|
521
574
|
}
|
|
522
575
|
}
|
|
523
576
|
}
|
|
524
|
-
catch (
|
|
577
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
525
578
|
finally {
|
|
526
579
|
try {
|
|
527
580
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
528
581
|
}
|
|
529
|
-
finally { if (
|
|
582
|
+
finally { if (e_8) throw e_8.error; }
|
|
530
583
|
}
|
|
531
584
|
return p;
|
|
532
585
|
},
|
|
@@ -563,7 +616,7 @@ var DPolygon = (function () {
|
|
|
563
616
|
});
|
|
564
617
|
Object.defineProperty(DPolygon.prototype, "minAreaRectangle", {
|
|
565
618
|
get: function () {
|
|
566
|
-
var
|
|
619
|
+
var e_9, _a, e_10, _b;
|
|
567
620
|
var p = this.convex;
|
|
568
621
|
var resultPolygon = new DPolygon();
|
|
569
622
|
var resultArea = Infinity;
|
|
@@ -576,7 +629,7 @@ var DPolygon = (function () {
|
|
|
576
629
|
var maxHeight = 0;
|
|
577
630
|
var maxHeightPoint = null;
|
|
578
631
|
try {
|
|
579
|
-
for (var _f = (
|
|
632
|
+
for (var _f = (e_10 = void 0, __values(p.loopPointsGenerator()())), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
580
633
|
var _h = __read(_g.value, 4), z = _h[0], i = _h[3];
|
|
581
634
|
var p1 = l.findPoint(l.findPerpendicular(z));
|
|
582
635
|
var h = p1.distance(z);
|
|
@@ -595,12 +648,12 @@ var DPolygon = (function () {
|
|
|
595
648
|
}
|
|
596
649
|
}
|
|
597
650
|
}
|
|
598
|
-
catch (
|
|
651
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
599
652
|
finally {
|
|
600
653
|
try {
|
|
601
654
|
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
602
655
|
}
|
|
603
|
-
finally { if (
|
|
656
|
+
finally { if (e_10) throw e_10.error; }
|
|
604
657
|
}
|
|
605
658
|
if (!maxWidthPoint1 || !maxWidthPoint2 || !maxHeightPoint) {
|
|
606
659
|
continue;
|
|
@@ -620,12 +673,12 @@ var DPolygon = (function () {
|
|
|
620
673
|
}
|
|
621
674
|
}
|
|
622
675
|
}
|
|
623
|
-
catch (
|
|
676
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
624
677
|
finally {
|
|
625
678
|
try {
|
|
626
679
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
627
680
|
}
|
|
628
|
-
finally { if (
|
|
681
|
+
finally { if (e_9) throw e_9.error; }
|
|
629
682
|
}
|
|
630
683
|
return resultPolygon;
|
|
631
684
|
},
|
|
@@ -678,7 +731,7 @@ var DPolygon = (function () {
|
|
|
678
731
|
});
|
|
679
732
|
Object.defineProperty(DPolygon.prototype, "isClockwise", {
|
|
680
733
|
get: function () {
|
|
681
|
-
var
|
|
734
|
+
var e_11, _a;
|
|
682
735
|
var sum = 0;
|
|
683
736
|
try {
|
|
684
737
|
for (var _b = __values(this.clone().close()
|
|
@@ -687,12 +740,12 @@ var DPolygon = (function () {
|
|
|
687
740
|
sum += (a - x) * (b + y);
|
|
688
741
|
}
|
|
689
742
|
}
|
|
690
|
-
catch (
|
|
743
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
691
744
|
finally {
|
|
692
745
|
try {
|
|
693
746
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
694
747
|
}
|
|
695
|
-
finally { if (
|
|
748
|
+
finally { if (e_11) throw e_11.error; }
|
|
696
749
|
}
|
|
697
750
|
return sum < 0;
|
|
698
751
|
},
|
|
@@ -722,7 +775,7 @@ var DPolygon = (function () {
|
|
|
722
775
|
return this.pPoints.reduce(f, v);
|
|
723
776
|
};
|
|
724
777
|
DPolygon.prototype.intersection = function (l, includeOnly) {
|
|
725
|
-
var
|
|
778
|
+
var e_12, _a;
|
|
726
779
|
if (includeOnly === void 0) { includeOnly = false; }
|
|
727
780
|
var res = [];
|
|
728
781
|
try {
|
|
@@ -734,12 +787,12 @@ var DPolygon = (function () {
|
|
|
734
787
|
}
|
|
735
788
|
}
|
|
736
789
|
}
|
|
737
|
-
catch (
|
|
790
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
738
791
|
finally {
|
|
739
792
|
try {
|
|
740
793
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
741
794
|
}
|
|
742
|
-
finally { if (
|
|
795
|
+
finally { if (e_12) throw e_12.error; }
|
|
743
796
|
}
|
|
744
797
|
return res;
|
|
745
798
|
};
|
|
@@ -945,7 +998,7 @@ var DPolygon = (function () {
|
|
|
945
998
|
ctx.globalCompositeOperation = old;
|
|
946
999
|
};
|
|
947
1000
|
DPolygon.prototype.contain = function (p, isBorderInside) {
|
|
948
|
-
var
|
|
1001
|
+
var e_13, _a;
|
|
949
1002
|
if (isBorderInside === void 0) { isBorderInside = false; }
|
|
950
1003
|
var simpleInclude = this.simpleInclude(p);
|
|
951
1004
|
if (!simpleInclude) {
|
|
@@ -971,12 +1024,12 @@ var DPolygon = (function () {
|
|
|
971
1024
|
}
|
|
972
1025
|
}
|
|
973
1026
|
}
|
|
974
|
-
catch (
|
|
1027
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
975
1028
|
finally {
|
|
976
1029
|
try {
|
|
977
1030
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
978
1031
|
}
|
|
979
|
-
finally { if (
|
|
1032
|
+
finally { if (e_13) throw e_13.error; }
|
|
980
1033
|
}
|
|
981
1034
|
var eps = Math.PI / 10000;
|
|
982
1035
|
var absTotalFi = Math.abs(totalFi);
|
|
@@ -989,7 +1042,7 @@ var DPolygon = (function () {
|
|
|
989
1042
|
throw new Error('contains2 faild');
|
|
990
1043
|
};
|
|
991
1044
|
DPolygon.prototype.onBorder = function (p) {
|
|
992
|
-
var
|
|
1045
|
+
var e_14, _a;
|
|
993
1046
|
var simpleInclude = this.simpleInclude(p);
|
|
994
1047
|
if (simpleInclude) {
|
|
995
1048
|
var poly = this.deintersection;
|
|
@@ -1006,12 +1059,12 @@ var DPolygon = (function () {
|
|
|
1006
1059
|
}
|
|
1007
1060
|
}
|
|
1008
1061
|
}
|
|
1009
|
-
catch (
|
|
1062
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1010
1063
|
finally {
|
|
1011
1064
|
try {
|
|
1012
1065
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1013
1066
|
}
|
|
1014
|
-
finally { if (
|
|
1067
|
+
finally { if (e_14) throw e_14.error; }
|
|
1015
1068
|
}
|
|
1016
1069
|
}
|
|
1017
1070
|
return false;
|
|
@@ -1135,7 +1188,7 @@ var DPolygon = (function () {
|
|
|
1135
1188
|
};
|
|
1136
1189
|
};
|
|
1137
1190
|
DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
|
|
1138
|
-
var
|
|
1191
|
+
var e_15, _a;
|
|
1139
1192
|
if (withAltitude === void 0) { withAltitude = false; }
|
|
1140
1193
|
var fullLength = this.fullLength;
|
|
1141
1194
|
var pieceLength = fullLength / piecesCount;
|
|
@@ -1170,17 +1223,17 @@ var DPolygon = (function () {
|
|
|
1170
1223
|
_loop_3(p1, p2, i);
|
|
1171
1224
|
}
|
|
1172
1225
|
}
|
|
1173
|
-
catch (
|
|
1226
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1174
1227
|
finally {
|
|
1175
1228
|
try {
|
|
1176
1229
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1177
1230
|
}
|
|
1178
|
-
finally { if (
|
|
1231
|
+
finally { if (e_15) throw e_15.error; }
|
|
1179
1232
|
}
|
|
1180
1233
|
return this;
|
|
1181
1234
|
};
|
|
1182
1235
|
DPolygon.prototype.prepareToFastSearch = function () {
|
|
1183
|
-
var
|
|
1236
|
+
var e_16, _a;
|
|
1184
1237
|
this.searchStore = {};
|
|
1185
1238
|
try {
|
|
1186
1239
|
for (var _b = __values(this.points), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -1194,12 +1247,12 @@ var DPolygon = (function () {
|
|
|
1194
1247
|
this.searchStore[x][y][z || 'undefined'] = true;
|
|
1195
1248
|
}
|
|
1196
1249
|
}
|
|
1197
|
-
catch (
|
|
1250
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1198
1251
|
finally {
|
|
1199
1252
|
try {
|
|
1200
1253
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1201
1254
|
}
|
|
1202
|
-
finally { if (
|
|
1255
|
+
finally { if (e_16) throw e_16.error; }
|
|
1203
1256
|
}
|
|
1204
1257
|
};
|
|
1205
1258
|
DPolygon.prototype.fastHas = function (_a) {
|
|
@@ -1219,8 +1272,8 @@ var DPolygon = (function () {
|
|
|
1219
1272
|
get: function () {
|
|
1220
1273
|
var polygon = this;
|
|
1221
1274
|
return function () {
|
|
1222
|
-
var r, _a, _b, p,
|
|
1223
|
-
var
|
|
1275
|
+
var r, _a, _b, p, e_17_1;
|
|
1276
|
+
var e_17, _c;
|
|
1224
1277
|
return __generator(this, function (_d) {
|
|
1225
1278
|
switch (_d.label) {
|
|
1226
1279
|
case 0:
|
|
@@ -1244,14 +1297,14 @@ var DPolygon = (function () {
|
|
|
1244
1297
|
return [3, 2];
|
|
1245
1298
|
case 5: return [3, 8];
|
|
1246
1299
|
case 6:
|
|
1247
|
-
|
|
1248
|
-
|
|
1300
|
+
e_17_1 = _d.sent();
|
|
1301
|
+
e_17 = { error: e_17_1 };
|
|
1249
1302
|
return [3, 8];
|
|
1250
1303
|
case 7:
|
|
1251
1304
|
try {
|
|
1252
1305
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1253
1306
|
}
|
|
1254
|
-
finally { if (
|
|
1307
|
+
finally { if (e_17) throw e_17.error; }
|
|
1255
1308
|
return [7];
|
|
1256
1309
|
case 8: return [2, r.clone()];
|
|
1257
1310
|
}
|
|
@@ -1283,12 +1336,12 @@ var DPolygon = (function () {
|
|
|
1283
1336
|
return this.simpleLogicFunction(p, true, false);
|
|
1284
1337
|
};
|
|
1285
1338
|
DPolygon.prototype.smartUnion = function (p) {
|
|
1286
|
-
var
|
|
1339
|
+
var e_18, _a;
|
|
1287
1340
|
var res = this.clone().simpleUnion(p);
|
|
1288
1341
|
if (res) {
|
|
1289
1342
|
var allHoles = __spreadArray(__spreadArray(__spreadArray([], __read(this.holes), false), __read(p.holes), false), __read(res.holes), false).map(function (h) { return h.clone(); });
|
|
1290
1343
|
var _loop_4 = function (a) {
|
|
1291
|
-
var
|
|
1344
|
+
var e_19, _b;
|
|
1292
1345
|
var _loop_5 = function (b) {
|
|
1293
1346
|
if (a.equal(b)) {
|
|
1294
1347
|
return "continue";
|
|
@@ -1300,17 +1353,17 @@ var DPolygon = (function () {
|
|
|
1300
1353
|
}
|
|
1301
1354
|
};
|
|
1302
1355
|
try {
|
|
1303
|
-
for (var allHoles_2 = (
|
|
1356
|
+
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()) {
|
|
1304
1357
|
var b = allHoles_2_1.value;
|
|
1305
1358
|
_loop_5(b);
|
|
1306
1359
|
}
|
|
1307
1360
|
}
|
|
1308
|
-
catch (
|
|
1361
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
1309
1362
|
finally {
|
|
1310
1363
|
try {
|
|
1311
1364
|
if (allHoles_2_1 && !allHoles_2_1.done && (_b = allHoles_2.return)) _b.call(allHoles_2);
|
|
1312
1365
|
}
|
|
1313
|
-
finally { if (
|
|
1366
|
+
finally { if (e_19) throw e_19.error; }
|
|
1314
1367
|
}
|
|
1315
1368
|
};
|
|
1316
1369
|
try {
|
|
@@ -1319,12 +1372,12 @@ var DPolygon = (function () {
|
|
|
1319
1372
|
_loop_4(a);
|
|
1320
1373
|
}
|
|
1321
1374
|
}
|
|
1322
|
-
catch (
|
|
1375
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
1323
1376
|
finally {
|
|
1324
1377
|
try {
|
|
1325
1378
|
if (allHoles_1_1 && !allHoles_1_1.done && (_a = allHoles_1.return)) _a.call(allHoles_1);
|
|
1326
1379
|
}
|
|
1327
|
-
finally { if (
|
|
1380
|
+
finally { if (e_18) throw e_18.error; }
|
|
1328
1381
|
}
|
|
1329
1382
|
res.holes = allHoles;
|
|
1330
1383
|
}
|
|
@@ -1539,8 +1592,74 @@ var DPolygon = (function () {
|
|
|
1539
1592
|
});
|
|
1540
1593
|
};
|
|
1541
1594
|
};
|
|
1595
|
+
DPolygon.prototype.cloneByDistanceProportions = function (proportions) {
|
|
1596
|
+
var e_20, _a;
|
|
1597
|
+
var resultedPolygon = new DPolygon();
|
|
1598
|
+
var resultProportions = Array.from(new Set(__spreadArray(__spreadArray([], __read(this.pointsDistanceProportions), false), __read(proportions), false)))
|
|
1599
|
+
.sort(function (a, b) { return a - b; });
|
|
1600
|
+
var fullLength = this.fullLength;
|
|
1601
|
+
resultedPolygon.push(this.at(0));
|
|
1602
|
+
var index = 1;
|
|
1603
|
+
var path = 0;
|
|
1604
|
+
try {
|
|
1605
|
+
for (var _b = __values(this.loopPointsGenerator()()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1606
|
+
var _d = __read(_c.value, 2), p1_ = _d[0], p2 = _d[1];
|
|
1607
|
+
var p1 = p1_;
|
|
1608
|
+
var _loop_6 = function () {
|
|
1609
|
+
var distance = p1.distance(p2);
|
|
1610
|
+
var currentProportion = (path + distance) / fullLength;
|
|
1611
|
+
if (Math.abs(currentProportion - resultProportions[index]) < 1e-7) {
|
|
1612
|
+
path += distance;
|
|
1613
|
+
resultedPolygon.push(p2.clone());
|
|
1614
|
+
index++;
|
|
1615
|
+
return "break";
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
var radius = (resultProportions[index] - resultProportions[index - 1]) * fullLength;
|
|
1619
|
+
var circle = new DCircle_1.DCircle(p1, radius);
|
|
1620
|
+
var line_2 = p1.findLine(p2);
|
|
1621
|
+
var intersectionPoint = line_2.intersectionWithCircle(circle)
|
|
1622
|
+
.filter(function (p) { return line_2.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE); })[0];
|
|
1623
|
+
resultedPolygon.push(intersectionPoint);
|
|
1624
|
+
index++;
|
|
1625
|
+
path += p1.distance(intersectionPoint);
|
|
1626
|
+
p1 = intersectionPoint;
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
while (true) {
|
|
1630
|
+
var state_1 = _loop_6();
|
|
1631
|
+
if (state_1 === "break")
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
1637
|
+
finally {
|
|
1638
|
+
try {
|
|
1639
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1640
|
+
}
|
|
1641
|
+
finally { if (e_20) throw e_20.error; }
|
|
1642
|
+
}
|
|
1643
|
+
return resultedPolygon;
|
|
1644
|
+
};
|
|
1645
|
+
DPolygon.prototype.middleLinestring = function (line) {
|
|
1646
|
+
var thisClone = this.cloneByDistanceProportions(line.pointsDistanceProportions);
|
|
1647
|
+
var thatClone = line.cloneByDistanceProportions(this.pointsDistanceProportions);
|
|
1648
|
+
return thisClone
|
|
1649
|
+
.loop()
|
|
1650
|
+
.setX(function (_a, index) {
|
|
1651
|
+
var x = _a.x;
|
|
1652
|
+
return x + thatClone.at(index).x;
|
|
1653
|
+
})
|
|
1654
|
+
.setY(function (_a, index) {
|
|
1655
|
+
var y = _a.y;
|
|
1656
|
+
return y + thatClone.at(index).y;
|
|
1657
|
+
})
|
|
1658
|
+
.divide(2)
|
|
1659
|
+
.run();
|
|
1660
|
+
};
|
|
1542
1661
|
DPolygon.prototype.getBezierPoint = function (v) {
|
|
1543
|
-
var
|
|
1662
|
+
var e_21, _a;
|
|
1544
1663
|
if (this.length === 1) {
|
|
1545
1664
|
return this.first;
|
|
1546
1665
|
}
|
|
@@ -1551,12 +1670,12 @@ var DPolygon = (function () {
|
|
|
1551
1670
|
.scale(v));
|
|
1552
1671
|
}
|
|
1553
1672
|
}
|
|
1554
|
-
catch (
|
|
1673
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
1555
1674
|
finally {
|
|
1556
1675
|
try {
|
|
1557
1676
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1558
1677
|
}
|
|
1559
|
-
finally { if (
|
|
1678
|
+
finally { if (e_21) throw e_21.error; }
|
|
1560
1679
|
}
|
|
1561
1680
|
this.pop();
|
|
1562
1681
|
return this.getBezierPoint(v);
|
|
@@ -1615,7 +1734,7 @@ var DPolygon = (function () {
|
|
|
1615
1734
|
return undefined;
|
|
1616
1735
|
};
|
|
1617
1736
|
DPolygon.prototype.simpleLogicFunction = function (p, unionThis, unionThat) {
|
|
1618
|
-
var
|
|
1737
|
+
var e_22, _a, e_23, _b, e_24, _c, e_25, _d;
|
|
1619
1738
|
var c = this.getJSTSGeometry(p, unionThis, unionThat);
|
|
1620
1739
|
if (c) {
|
|
1621
1740
|
var coordinates_1 = c.getCoordinates();
|
|
@@ -1642,7 +1761,7 @@ var DPolygon = (function () {
|
|
|
1642
1761
|
try {
|
|
1643
1762
|
for (var result_1 = __values(result), result_1_1 = result_1.next(); !result_1_1.done; result_1_1 = result_1.next()) {
|
|
1644
1763
|
var q = result_1_1.value;
|
|
1645
|
-
var
|
|
1764
|
+
var _loop_7 = function (r) {
|
|
1646
1765
|
var _e;
|
|
1647
1766
|
if (q.has(r.first) && !q.equal(r)) {
|
|
1648
1767
|
var index = q.findIndex(r.first);
|
|
@@ -1655,38 +1774,38 @@ var DPolygon = (function () {
|
|
|
1655
1774
|
}
|
|
1656
1775
|
};
|
|
1657
1776
|
try {
|
|
1658
|
-
for (var result_2 = (
|
|
1777
|
+
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()) {
|
|
1659
1778
|
var r = result_2_1.value;
|
|
1660
|
-
var
|
|
1661
|
-
if (
|
|
1779
|
+
var state_2 = _loop_7(r);
|
|
1780
|
+
if (state_2 === "break")
|
|
1662
1781
|
break;
|
|
1663
1782
|
}
|
|
1664
1783
|
}
|
|
1665
|
-
catch (
|
|
1784
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
1666
1785
|
finally {
|
|
1667
1786
|
try {
|
|
1668
1787
|
if (result_2_1 && !result_2_1.done && (_b = result_2.return)) _b.call(result_2);
|
|
1669
1788
|
}
|
|
1670
|
-
finally { if (
|
|
1789
|
+
finally { if (e_23) throw e_23.error; }
|
|
1671
1790
|
}
|
|
1672
1791
|
if (result.length < 2) {
|
|
1673
1792
|
break;
|
|
1674
1793
|
}
|
|
1675
1794
|
}
|
|
1676
1795
|
}
|
|
1677
|
-
catch (
|
|
1796
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
1678
1797
|
finally {
|
|
1679
1798
|
try {
|
|
1680
1799
|
if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
|
|
1681
1800
|
}
|
|
1682
|
-
finally { if (
|
|
1801
|
+
finally { if (e_22) throw e_22.error; }
|
|
1683
1802
|
}
|
|
1684
1803
|
}
|
|
1685
1804
|
result = result.filter(function (h) { return h.length > 2; }).map(function (h) { return h.close(); });
|
|
1686
1805
|
try {
|
|
1687
1806
|
for (var result_3 = __values(result), result_3_1 = result_3.next(); !result_3_1.done; result_3_1 = result_3.next()) {
|
|
1688
1807
|
var q = result_3_1.value;
|
|
1689
|
-
var
|
|
1808
|
+
var _loop_8 = function (r) {
|
|
1690
1809
|
if (result.length < 2) {
|
|
1691
1810
|
return "break";
|
|
1692
1811
|
}
|
|
@@ -1698,31 +1817,31 @@ var DPolygon = (function () {
|
|
|
1698
1817
|
}
|
|
1699
1818
|
};
|
|
1700
1819
|
try {
|
|
1701
|
-
for (var result_4 = (
|
|
1820
|
+
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()) {
|
|
1702
1821
|
var r = result_4_1.value;
|
|
1703
|
-
var
|
|
1704
|
-
if (
|
|
1822
|
+
var state_3 = _loop_8(r);
|
|
1823
|
+
if (state_3 === "break")
|
|
1705
1824
|
break;
|
|
1706
1825
|
}
|
|
1707
1826
|
}
|
|
1708
|
-
catch (
|
|
1827
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
1709
1828
|
finally {
|
|
1710
1829
|
try {
|
|
1711
1830
|
if (result_4_1 && !result_4_1.done && (_d = result_4.return)) _d.call(result_4);
|
|
1712
1831
|
}
|
|
1713
|
-
finally { if (
|
|
1832
|
+
finally { if (e_25) throw e_25.error; }
|
|
1714
1833
|
}
|
|
1715
1834
|
if (result.length < 2) {
|
|
1716
1835
|
break;
|
|
1717
1836
|
}
|
|
1718
1837
|
}
|
|
1719
1838
|
}
|
|
1720
|
-
catch (
|
|
1839
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
1721
1840
|
finally {
|
|
1722
1841
|
try {
|
|
1723
1842
|
if (result_3_1 && !result_3_1.done && (_c = result_3.return)) _c.call(result_3);
|
|
1724
1843
|
}
|
|
1725
|
-
finally { if (
|
|
1844
|
+
finally { if (e_24) throw e_24.error; }
|
|
1726
1845
|
}
|
|
1727
1846
|
if (result.length === 0) {
|
|
1728
1847
|
return null;
|
package/dist/es2015/DPoint.js
CHANGED
|
@@ -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')
|