@glandais/vcyclist-engine 4.1.0 → 4.2.1

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.
@@ -30,96 +30,115 @@
30
30
  var imul = Math.imul;
31
31
  var hypot = Math.hypot;
32
32
  var sign = Math.sign;
33
- var protoOf = kotlin_kotlin.$_$.d7;
34
- var initMetadataForCompanion = kotlin_kotlin.$_$.p6;
33
+ var protoOf = kotlin_kotlin.$_$.j7;
34
+ var initMetadataForCompanion = kotlin_kotlin.$_$.v6;
35
35
  var VOID = kotlin_kotlin.$_$.a;
36
- var getNumberHashCode = kotlin_kotlin.$_$.k6;
37
- var equals = kotlin_kotlin.$_$.h6;
38
- var initMetadataForClass = kotlin_kotlin.$_$.o6;
39
- var toString = kotlin_kotlin.$_$.g7;
40
- var hashCode = kotlin_kotlin.$_$.n6;
41
- var initMetadataForObject = kotlin_kotlin.$_$.u6;
42
- var getBooleanHashCode = kotlin_kotlin.$_$.j6;
36
+ var getNumberHashCode = kotlin_kotlin.$_$.q6;
37
+ var equals = kotlin_kotlin.$_$.n6;
38
+ var initMetadataForClass = kotlin_kotlin.$_$.u6;
39
+ var toString = kotlin_kotlin.$_$.m7;
40
+ var hashCode = kotlin_kotlin.$_$.t6;
41
+ var initMetadataForObject = kotlin_kotlin.$_$.a7;
42
+ var getBooleanHashCode = kotlin_kotlin.$_$.p6;
43
43
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
44
44
  var Unit_instance = kotlin_kotlin.$_$.g1;
45
- var CoroutineImpl = kotlin_kotlin.$_$.y4;
45
+ var CoroutineImpl = kotlin_kotlin.$_$.d5;
46
46
  var PointPerDistance_instance = kotlin_io_github_glandais_gpx.$_$.k;
47
47
  var ElevationStep_instance = kotlin_io_github_glandais_gpx.$_$.h;
48
- var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.j4;
48
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.o4;
49
49
  var PointPerSecond_instance = kotlin_io_github_glandais_gpx.$_$.l;
50
50
  var PathSimplifier_instance = kotlin_io_github_glandais_gpx.$_$.i;
51
- var initMetadataForCoroutine = kotlin_kotlin.$_$.q6;
52
- var enumEntries = kotlin_kotlin.$_$.a5;
53
- var Enum = kotlin_kotlin.$_$.l9;
51
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.w6;
52
+ var enumEntries = kotlin_kotlin.$_$.f5;
53
+ var Enum = kotlin_kotlin.$_$.t9;
54
54
  var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j1;
55
55
  var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i1;
56
- var last = kotlin_kotlin.$_$.p3;
57
- var toIntArray = kotlin_kotlin.$_$.b4;
58
- var sortedWith = kotlin_kotlin.$_$.z3;
59
- var toMutableList = kotlin_kotlin.$_$.f4;
60
- var first = kotlin_kotlin.$_$.i3;
61
- var removeAll = kotlin_kotlin.$_$.u3;
62
- var numberRangeToNumber = kotlin_kotlin.$_$.z6;
56
+ var last = kotlin_kotlin.$_$.q3;
57
+ var toIntArray = kotlin_kotlin.$_$.f4;
58
+ var sortedWith = kotlin_kotlin.$_$.b4;
59
+ var toMutableList = kotlin_kotlin.$_$.j4;
60
+ var first = kotlin_kotlin.$_$.j3;
61
+ var removeAll = kotlin_kotlin.$_$.w3;
62
+ var numberRangeToNumber = kotlin_kotlin.$_$.f7;
63
63
  var collectionSizeOrDefault = kotlin_kotlin.$_$.x2;
64
64
  var Vector3D = kotlin_io_github_glandais_elevation.$_$.g;
65
- var emptyList = kotlin_kotlin.$_$.f3;
66
- var coerceIn = kotlin_kotlin.$_$.n7;
65
+ var emptyList = kotlin_kotlin.$_$.g3;
66
+ var coerceIn = kotlin_kotlin.$_$.u7;
67
67
  var DouglasPeucker_instance = kotlin_io_github_glandais_elevation.$_$.b;
68
- var FunctionAdapter = kotlin_kotlin.$_$.v5;
69
- var isInterface = kotlin_kotlin.$_$.w6;
70
- var Comparator = kotlin_kotlin.$_$.k9;
71
- var compareValues = kotlin_kotlin.$_$.h4;
72
- var until = kotlin_kotlin.$_$.r7;
73
- var Pair = kotlin_kotlin.$_$.r9;
74
- var listOf = kotlin_kotlin.$_$.q3;
68
+ var FunctionAdapter = kotlin_kotlin.$_$.b6;
69
+ var isInterface = kotlin_kotlin.$_$.c7;
70
+ var Comparator = kotlin_kotlin.$_$.s9;
71
+ var compareValues = kotlin_kotlin.$_$.m4;
72
+ var until = kotlin_kotlin.$_$.z7;
73
+ var Pair = kotlin_kotlin.$_$.z9;
74
+ var listOf = kotlin_kotlin.$_$.r3;
75
75
  var Default_getInstance = kotlin_kotlin.$_$.b1;
76
76
  var Companion_instance = kotlin_kotlin.$_$.e1;
77
- var equals_0 = kotlin_kotlin.$_$.h8;
78
- var noWhenBranchMatchedException = kotlin_kotlin.$_$.ia;
79
- var isFinite = kotlin_kotlin.$_$.ea;
77
+ var equals_0 = kotlin_kotlin.$_$.p8;
78
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.qa;
79
+ var isNaN_0 = kotlin_kotlin.$_$.oa;
80
+ var isFinite = kotlin_kotlin.$_$.ma;
80
81
  var PointField_TEMPERATURE_getInstance = kotlin_io_github_glandais_gpx.$_$.c;
81
- var isNaN_0 = kotlin_kotlin.$_$.ga;
82
82
  var get_entries = kotlin_io_github_glandais_gpx.$_$.u;
83
83
  var Path = kotlin_io_github_glandais_gpx.$_$.t;
84
+ var arrayCopy = kotlin_kotlin.$_$.t2;
85
+ var sort = kotlin_kotlin.$_$.d4;
86
+ var numberToInt = kotlin_kotlin.$_$.h7;
87
+ var coerceIn_0 = kotlin_kotlin.$_$.v7;
88
+ var lastOrNull = kotlin_kotlin.$_$.p3;
89
+ var HashMap_init_$Create$ = kotlin_kotlin.$_$.l1;
90
+ var fromInt = kotlin_kotlin.$_$.s5;
91
+ var add = kotlin_kotlin.$_$.i5;
92
+ var numberToLong = kotlin_kotlin.$_$.v5;
93
+ var shiftLeft = kotlin_kotlin.$_$.w5;
94
+ var Long = kotlin_kotlin.$_$.x9;
95
+ var bitwiseAnd = kotlin_kotlin.$_$.j5;
96
+ var bitwiseXor = kotlin_kotlin.$_$.l5;
97
+ var copyOf = kotlin_kotlin.$_$.c3;
98
+ var coerceAtLeast = kotlin_kotlin.$_$.r7;
99
+ var round = kotlin_kotlin.$_$.p7;
100
+ var listOf_0 = kotlin_kotlin.$_$.s3;
101
+ var Collection = kotlin_kotlin.$_$.n2;
102
+ var zipWithNext = kotlin_kotlin.$_$.l4;
103
+ var toDoubleArray = kotlin_kotlin.$_$.e4;
104
+ var joinToString = kotlin_kotlin.$_$.m3;
84
105
  var GpxParser_instance = kotlin_io_github_glandais_gpx.$_$.d;
85
- var copyToArray = kotlin_kotlin.$_$.e3;
106
+ var copyToArray = kotlin_kotlin.$_$.f3;
86
107
  var firstTrackAsPath = kotlin_io_github_glandais_gpx.$_$.n;
87
108
  var tracksAsPaths = kotlin_io_github_glandais_gpx.$_$.q;
88
109
  var segmentsAsPaths = kotlin_io_github_glandais_gpx.$_$.o;
89
110
  var GpxPathKind_TRACK_getInstance = kotlin_io_github_glandais_gpx.$_$.b;
90
- var setOf = kotlin_kotlin.$_$.x3;
111
+ var setOf = kotlin_kotlin.$_$.z3;
91
112
  var GpxPathKind_ROUTE_getInstance = kotlin_io_github_glandais_gpx.$_$.a;
92
113
  var GpxWriter_instance = kotlin_io_github_glandais_gpx.$_$.e;
93
- var toList = kotlin_kotlin.$_$.e4;
114
+ var toList = kotlin_kotlin.$_$.i4;
94
115
  var toGpxDocument = kotlin_io_github_glandais_gpx.$_$.p;
95
116
  var Companion_getInstance = kotlin_kotlin.$_$.d1;
96
- var numberToLong = kotlin_kotlin.$_$.p5;
97
117
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
98
118
  var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
99
119
  var Companion_getInstance_0 = kotlin_io_github_glandais_gpx.$_$.j;
100
120
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.c2;
101
121
  var CsvWriter_instance = kotlin_io_github_glandais_gpx.$_$.f;
102
- var firstOrNull = kotlin_kotlin.$_$.i8;
122
+ var firstOrNull = kotlin_kotlin.$_$.q8;
103
123
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b;
104
- var Char = kotlin_kotlin.$_$.j9;
124
+ var Char = kotlin_kotlin.$_$.r9;
105
125
  var CsvOptions = kotlin_io_github_glandais_gpx.$_$.r;
106
126
  var JsonWriter_instance = kotlin_io_github_glandais_gpx.$_$.g;
107
127
  var JsonOptions = kotlin_io_github_glandais_gpx.$_$.s;
108
128
  var toFitBytes = kotlin_io_github_glandais_fit.$_$.a;
109
129
  var Companion_getInstance_1 = kotlin_kotlin.$_$.c1;
110
130
  var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.w;
111
- var toDuration = kotlin_kotlin.$_$.i9;
131
+ var toDuration = kotlin_kotlin.$_$.q9;
112
132
  var toFitBytes_0 = kotlin_io_github_glandais_fit.$_$.b;
113
- var toNumber = kotlin_kotlin.$_$.u5;
133
+ var toNumber = kotlin_kotlin.$_$.a6;
114
134
  var GpxWaypoint = kotlin_io_github_glandais_gpx.$_$.m;
115
- var joinToString = kotlin_kotlin.$_$.l3;
116
- var sorted = kotlin_kotlin.$_$.a4;
117
- var THROW_CCE = kotlin_kotlin.$_$.u9;
135
+ var sorted = kotlin_kotlin.$_$.c4;
136
+ var THROW_CCE = kotlin_kotlin.$_$.ca;
118
137
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
119
138
  var ElevationProvider = kotlin_io_github_glandais_elevation.$_$.d;
120
- var initMetadataForLambda = kotlin_kotlin.$_$.t6;
121
- var constructCallableReference = kotlin_kotlin.$_$.e6;
122
- var setOf_0 = kotlin_kotlin.$_$.y3;
139
+ var initMetadataForLambda = kotlin_kotlin.$_$.z6;
140
+ var constructCallableReference = kotlin_kotlin.$_$.k6;
141
+ var setOf_0 = kotlin_kotlin.$_$.a4;
123
142
  //endregion
124
143
  //region block: pre-declaration
125
144
  initMetadataForCompanion(Companion);
@@ -178,6 +197,29 @@
178
197
  initMetadataForObject(WindProviderNone, 'WindProviderNone');
179
198
  initMetadataForClass(WindProviderConstant, 'WindProviderConstant');
180
199
  initMetadataForObject(WPrimeBalanceComputer, 'WPrimeBalanceComputer');
200
+ initMetadataForObject(BandedLdl, 'BandedLdl');
201
+ initMetadataForClass(CornerSpan, 'CornerSpan');
202
+ initMetadataForObject(CornerDetector, 'CornerDetector');
203
+ initMetadataForClass(CorridorBounds, 'CorridorBounds');
204
+ initMetadataForObject(Corridor, 'Corridor');
205
+ initMetadataForClass(Fit, 'Fit');
206
+ initMetadataForObject(CurvatureEstimator, 'CurvatureEstimator');
207
+ initMetadataForObject(LocalFrame, 'LocalFrame');
208
+ initMetadataForCompanion(Companion_11);
209
+ initMetadataForClass(OffsetEnergy, 'OffsetEnergy');
210
+ initMetadataForClass(QpResult, 'QpResult');
211
+ initMetadataForObject(OffsetQp, 'OffsetQp');
212
+ initMetadataForCompanion(Companion_12);
213
+ initMetadataForClass(CurvatureOptions, 'CurvatureOptions', CurvatureOptions);
214
+ initMetadataForObject(PathCurvature, 'PathCurvature');
215
+ initMetadataForClass(PlanarFrame, 'PlanarFrame');
216
+ initMetadataForClass(RacingLineReport, 'RacingLineReport');
217
+ initMetadataForObject(RacingLine, 'RacingLine');
218
+ initMetadataForCompanion(Companion_13);
219
+ initMetadataForClass(CorridorMode, 'CorridorMode', VOID, Enum);
220
+ initMetadataForClass(CornerKind, 'CornerKind', VOID, Enum);
221
+ initMetadataForCompanion(Companion_14);
222
+ initMetadataForClass(RacingLineOptions, 'RacingLineOptions', RacingLineOptions);
181
223
  initMetadataForLambda(enhance$slambda, CoroutineImpl, VOID, [1]);
182
224
  initMetadataForLambda(enhanceWithCourse$slambda, CoroutineImpl, VOID, [1]);
183
225
  //endregion
@@ -540,7 +582,7 @@
540
582
  new Companion_2();
541
583
  return Companion_instance_3;
542
584
  }
543
- function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
585
+ function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) {
544
586
  Companion_getInstance_5();
545
587
  fixElevation = fixElevation === VOID ? true : fixElevation;
546
588
  computeMaxSpeeds = computeMaxSpeeds === VOID ? true : computeMaxSpeeds;
@@ -548,27 +590,33 @@
548
590
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? true : computeOnePointPerSecond;
549
591
  simplifyPath = simplifyPath === VOID ? new SimplifyPathOptions() : simplifyPath;
550
592
  wPrimeBalance = wPrimeBalance === VOID ? new WPrimeBalanceOptions() : wPrimeBalance;
593
+ curvature = curvature === VOID ? new CurvatureOptions() : curvature;
594
+ racingLine = racingLine === VOID ? new RacingLineOptions() : racingLine;
551
595
  this.fixElevation_1 = fixElevation;
552
596
  this.computeMaxSpeeds_1 = computeMaxSpeeds;
553
597
  this.virtualizeTrack_1 = virtualizeTrack;
554
598
  this.computeOnePointPerSecond_1 = computeOnePointPerSecond;
555
599
  this.simplifyPath_1 = simplifyPath;
556
600
  this.wPrimeBalance_1 = wPrimeBalance;
601
+ this.curvature_1 = curvature;
602
+ this.racingLine_1 = racingLine;
557
603
  }
558
- protoOf(EnhanceOptions).copy_bazpxz_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
559
- return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
604
+ protoOf(EnhanceOptions).copy_i8t81g_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) {
605
+ return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine);
560
606
  };
561
- protoOf(EnhanceOptions).copy$default_2rfmrp_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, $super) {
607
+ protoOf(EnhanceOptions).copy$default_q3w1nk_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine, $super) {
562
608
  fixElevation = fixElevation === VOID ? this.fixElevation_1 : fixElevation;
563
609
  computeMaxSpeeds = computeMaxSpeeds === VOID ? this.computeMaxSpeeds_1 : computeMaxSpeeds;
564
610
  virtualizeTrack = virtualizeTrack === VOID ? this.virtualizeTrack_1 : virtualizeTrack;
565
611
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? this.computeOnePointPerSecond_1 : computeOnePointPerSecond;
566
612
  simplifyPath = simplifyPath === VOID ? this.simplifyPath_1 : simplifyPath;
567
613
  wPrimeBalance = wPrimeBalance === VOID ? this.wPrimeBalance_1 : wPrimeBalance;
568
- return $super === VOID ? this.copy_bazpxz_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) : $super.copy_bazpxz_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
614
+ curvature = curvature === VOID ? this.curvature_1 : curvature;
615
+ racingLine = racingLine === VOID ? this.racingLine_1 : racingLine;
616
+ return $super === VOID ? this.copy_i8t81g_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) : $super.copy_i8t81g_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine);
569
617
  };
570
618
  protoOf(EnhanceOptions).toString = function () {
571
- return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ', wPrimeBalance=' + this.wPrimeBalance_1.toString() + ')';
619
+ return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ', wPrimeBalance=' + this.wPrimeBalance_1.toString() + ', curvature=' + this.curvature_1.toString() + ', racingLine=' + this.racingLine_1.toString() + ')';
572
620
  };
573
621
  protoOf(EnhanceOptions).hashCode = function () {
574
622
  var result = getBooleanHashCode(this.fixElevation_1);
@@ -577,6 +625,8 @@
577
625
  result = imul(result, 31) + getBooleanHashCode(this.computeOnePointPerSecond_1) | 0;
578
626
  result = imul(result, 31) + this.simplifyPath_1.hashCode() | 0;
579
627
  result = imul(result, 31) + this.wPrimeBalance_1.hashCode() | 0;
628
+ result = imul(result, 31) + this.curvature_1.hashCode() | 0;
629
+ result = imul(result, 31) + this.racingLine_1.hashCode() | 0;
580
630
  return result;
581
631
  };
582
632
  protoOf(EnhanceOptions).equals = function (other) {
@@ -596,6 +646,10 @@
596
646
  return false;
597
647
  if (!this.wPrimeBalance_1.equals(other.wPrimeBalance_1))
598
648
  return false;
649
+ if (!this.curvature_1.equals(other.curvature_1))
650
+ return false;
651
+ if (!this.racingLine_1.equals(other.racingLine_1))
652
+ return false;
599
653
  return true;
600
654
  };
601
655
  function $enhanceCourseCOROUTINE$(_this__u8e3s4, course, options, elevationProvider, resultContinuation) {
@@ -639,6 +693,13 @@
639
693
  case 2:
640
694
  this.path0__1 = PointPerDistance_instance.compute_7vlifv_k$(this.path0__1, 1.0, 2.0);
641
695
  this.path0__1 = ElevationStep_instance.smoothElevation$default_3c035p_k$(this.path0__1);
696
+ var racingLineApplied = this.options_1.racingLine_1.enabled_1;
697
+ if (racingLineApplied) {
698
+ this.path0__1 = RacingLine_instance.compute_uyx32p_k$(this.path0__1, this.options_1.racingLine_1);
699
+ } else if (this.options_1.curvature_1.enabled_1) {
700
+ PathCurvature_instance.compute_s9yd16_k$(this.path0__1, this.options_1.curvature_1);
701
+ }
702
+
642
703
  var working = this.course_1.copy$default_a3dskc_k$(this.course_1.course_1.copy$default_mmxsnj_k$(this.path0__1));
643
704
  if (this.options_1.computeMaxSpeeds_1 || this.options_1.virtualizeTrack_1) {
644
705
  MaxSpeedComputer_instance.computeMaxSpeeds_jc4v4o_k$(working.course_1);
@@ -658,7 +719,16 @@
658
719
  }
659
720
 
660
721
  if (this.options_1.simplifyPath_1.enabled_1) {
661
- this.path0__1 = PathSimplifier_instance.simplify_gxhj7b_k$(this.path0__1, this.options_1.simplifyPath_1.toleranceM_1, this.options_1.simplifyPath_1.zExaggeration_1);
722
+ var tmp_0;
723
+ if (racingLineApplied) {
724
+ var tmp0 = this.options_1.simplifyPath_1.toleranceM_1;
725
+ var b = this.options_1.racingLine_1.simplifyToleranceCapM_1;
726
+ tmp_0 = Math.min(tmp0, b);
727
+ } else {
728
+ tmp_0 = this.options_1.simplifyPath_1.toleranceM_1;
729
+ }
730
+ var tolerance = tmp_0;
731
+ this.path0__1 = PathSimplifier_instance.simplify_gxhj7b_k$(this.path0__1, tolerance, this.options_1.simplifyPath_1.zExaggeration_1);
662
732
  }
663
733
 
664
734
  return this.path0__1;
@@ -682,7 +752,7 @@
682
752
  return new CoursePhysics(new Course(path), RhoProviderEstimate_instance, AeroProviderConstant_instance, WindProviderNone_instance, new PowerProviderConstant(280.0));
683
753
  };
684
754
  protoOf(Enhancer).enhanceCourseDefault_jm937y_k$ = function (path, elevationProvider, options, $completion) {
685
- return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_2rfmrp_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
755
+ return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_q3w1nk_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
686
756
  };
687
757
  protoOf(Enhancer).enhanceCourse_mout3j_k$ = function (course, options, elevationProvider, $completion) {
688
758
  var tmp = new $enhanceCourseCOROUTINE$(this, course, options, elevationProvider, $completion);
@@ -1704,13 +1774,27 @@
1704
1774
  return result;
1705
1775
  }
1706
1776
  function computeRadiusWindowed($this, path, i, k) {
1777
+ var kappa = path.trajectoryCurvature_t4abpc_k$(i);
1778
+ if (!isNaN_0(kappa)) {
1779
+ // Inline function 'kotlin.math.abs' call
1780
+ var tmp0 = Math.abs(kappa);
1781
+ // Inline function 'kotlin.math.max' call
1782
+ var b = 1.0 / 200.0;
1783
+ // Inline function 'kotlin.math.min' call
1784
+ var b_0 = 1.0 / Math.max(tmp0, b);
1785
+ // Inline function 'kotlin.math.max' call
1786
+ var b_1 = Math.min(200.0, b_0);
1787
+ var clamped = Math.max(5.0, b_1);
1788
+ path.setRadius_p1cueq_k$(i, clamped);
1789
+ return clamped;
1790
+ }
1707
1791
  // Inline function 'kotlin.math.max' call
1708
- var b = i - k | 0;
1709
- var mini = Math.max(0, b);
1710
- var tmp0 = path.size_1 - 1 | 0;
1792
+ var b_2 = i - k | 0;
1793
+ var mini = Math.max(0, b_2);
1794
+ var tmp0_0 = path.size_1 - 1 | 0;
1711
1795
  // Inline function 'kotlin.math.min' call
1712
- var b_0 = i + k | 0;
1713
- var maxi = Math.min(tmp0, b_0);
1796
+ var b_3 = i + k | 0;
1797
+ var maxi = Math.min(tmp0_0, b_3);
1714
1798
  var totalBearingChange = $this.normalizeAngleDiff_6gshzi_k$(path.bearing_fz5vxm_k$(maxi) - path.bearing_fz5vxm_k$(mini));
1715
1799
  var totalDistance = path.distance_5s4s77_k$(maxi) - path.distance_5s4s77_k$(mini);
1716
1800
  // Inline function 'kotlin.math.abs' call
@@ -1722,10 +1806,10 @@
1722
1806
  var raw = totalDistance / Math.abs(totalBearingChange);
1723
1807
  // Inline function 'kotlin.math.min' call
1724
1808
  // Inline function 'kotlin.math.max' call
1725
- var b_1 = Math.min(200.0, raw);
1726
- var clamped = Math.max(5.0, b_1);
1727
- path.setRadius_p1cueq_k$(i, clamped);
1728
- return clamped;
1809
+ var b_4 = Math.min(200.0, raw);
1810
+ var clamped_0 = Math.max(5.0, b_4);
1811
+ path.setRadius_p1cueq_k$(i, clamped_0);
1812
+ return clamped_0;
1729
1813
  }
1730
1814
  function computeBrakingLimit($this, course, currentIndex, nextIndex, corneringLimit) {
1731
1815
  var path = course.path_1;
@@ -1887,7 +1971,7 @@
1887
1971
  path.setPBrake_iza4qj_k$(i, 0.0);
1888
1972
  return Unit_instance;
1889
1973
  }
1890
- var dtSeconds = path.dt_17uzp4_k$(i) / 1000.0;
1974
+ var dtSeconds = path.dt_17uzp4_k$(i);
1891
1975
  if (dtSeconds <= 0.0) {
1892
1976
  path.setPComputedTotalPower_wm6di_k$(i, 0.0);
1893
1977
  path.setPComputedWheelPower_qplog3_k$(i, 0.0);
@@ -1982,7 +2066,7 @@
1982
2066
  this.reset_5u6xz3_k$();
1983
2067
  }
1984
2068
  if (pointIndex > this.lastIndex_1) {
1985
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2069
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex);
1986
2070
  var dtS = elapsedS - this.lastElapsedS_1;
1987
2071
  if (dtS > 0.0 && isFinite(dtS)) {
1988
2072
  this.wPrimeBalanceJ_1 = WPrimeBalanceComputer_instance.step_447nu7_k$(this.wPrimeBalanceJ_1, this.lastPowerW_1, this.criticalPowerW_1, this.wPrimeJ_1, dtS);
@@ -2071,7 +2155,7 @@
2071
2155
  this.reset_5u6xz3_k$();
2072
2156
  }
2073
2157
  if (pointIndex > this.lastIndex_1) {
2074
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2158
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex);
2075
2159
  var dtS = elapsedS - this.lastElapsedS_1;
2076
2160
  if (dtS > 0.0 && isFinite(dtS)) {
2077
2161
  var tmp = this;
@@ -2123,7 +2207,7 @@
2123
2207
  }
2124
2208
  if (pointIndex === this.lastIndex_1)
2125
2209
  return this.lastPowerW_1;
2126
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2210
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex);
2127
2211
  var dtS = elapsedS - this.lastElapsedS_1;
2128
2212
  var tmp;
2129
2213
  if (dtS > 0.0 && isFinite(dtS)) {
@@ -2227,7 +2311,7 @@
2227
2311
  this.multiplier_1 = this.smooth_uy9sy9_k$(this.multiplier_1, this.rawMultiplier_2rfnpc_k$(path, pointIndex), dx);
2228
2312
  if (isFinite(distanceM))
2229
2313
  this.lastDistanceM_1 = distanceM;
2230
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2314
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex);
2231
2315
  var dtS = elapsedS - this.lastElapsedS_1;
2232
2316
  if (dtS > 0.0 && isFinite(dtS)) {
2233
2317
  this.energyDebtJ_1 = this.energyDebtJ_1 + (this.lastDeliveredW_1 - this.lastTargetW_1) * dtS;
@@ -2369,7 +2453,7 @@
2369
2453
  if (dx <= 0.0) {
2370
2454
  copyAllFields(this, input, i, out, i);
2371
2455
  out.setTime_rfmvcd_k$(i, timeMs);
2372
- out.setElapsed_916ug_k$(i, timeMs - startTimeMs);
2456
+ out.setElapsed_916ug_k$(i, (timeMs - startTimeMs) / 1000.0);
2373
2457
  out.setDx_uk0ky4_k$(i, 0.0);
2374
2458
  out.setDt_sgarxs_k$(i, 0.0);
2375
2459
  out.setSpeed_1slan1_k$(i, speed);
@@ -2389,9 +2473,9 @@
2389
2473
  speed = speedNew;
2390
2474
  timeMs = timeMs + dt * 1000.0;
2391
2475
  out.setTime_rfmvcd_k$(i, timeMs);
2392
- out.setElapsed_916ug_k$(i, timeMs - startTimeMs);
2476
+ out.setElapsed_916ug_k$(i, (timeMs - startTimeMs) / 1000.0);
2393
2477
  out.setDx_uk0ky4_k$(i, dx);
2394
- out.setDt_sgarxs_k$(i, dt * 1000.0);
2478
+ out.setDt_sgarxs_k$(i, dt);
2395
2479
  out.setSpeed_1slan1_k$(i, speed);
2396
2480
  out.setVirtSpeedCurrent_kvg8yv_k$(i, speed);
2397
2481
  i = i + 1 | 0;
@@ -2522,140 +2606,2091 @@
2522
2606
  function WPrimeBalanceComputer_getInstance() {
2523
2607
  return WPrimeBalanceComputer_instance;
2524
2608
  }
2525
- function get_POWER_PROVIDER_KEYS() {
2526
- _init_properties_EngineJsApi_kt__9bputf();
2527
- return POWER_PROVIDER_KEYS;
2528
- }
2529
- var POWER_PROVIDER_KEYS;
2530
- function get_CYCLIST_KEYS() {
2531
- _init_properties_EngineJsApi_kt__9bputf();
2532
- return CYCLIST_KEYS;
2533
- }
2534
- var CYCLIST_KEYS;
2535
- function get_BIKE_KEYS() {
2536
- _init_properties_EngineJsApi_kt__9bputf();
2537
- return BIKE_KEYS;
2609
+ function BandedLdl() {
2538
2610
  }
2539
- var BIKE_KEYS;
2540
- function get_WIND_KEYS() {
2541
- _init_properties_EngineJsApi_kt__9bputf();
2542
- return WIND_KEYS;
2611
+ protoOf(BandedLdl).factor_n459o6_k$ = function (a0, a1, a2) {
2612
+ var n = a0.length;
2613
+ if (n === 0)
2614
+ return true;
2615
+ var l1 = new Float64Array(n);
2616
+ var l2 = new Float64Array(n);
2617
+ var d = new Float64Array(n);
2618
+ var inductionVariable = 0;
2619
+ if (inductionVariable < n)
2620
+ do {
2621
+ var i = inductionVariable;
2622
+ inductionVariable = inductionVariable + 1 | 0;
2623
+ var dm1 = i >= 1 ? d[i - 1 | 0] : 0.0;
2624
+ var dm2 = i >= 2 ? d[i - 2 | 0] : 0.0;
2625
+ l2[i] = i >= 2 ? a2[i - 2 | 0] / dm2 : 0.0;
2626
+ var tmp;
2627
+ if (i >= 1) {
2628
+ var correction = i >= 2 ? l2[i] * l1[i - 1 | 0] * dm2 : 0.0;
2629
+ tmp = (a1[i - 1 | 0] - correction) / dm1;
2630
+ } else {
2631
+ tmp = 0.0;
2632
+ }
2633
+ l1[i] = tmp;
2634
+ var pivot = a0[i];
2635
+ if (i >= 1)
2636
+ pivot = pivot - l1[i] * l1[i] * dm1;
2637
+ if (i >= 2)
2638
+ pivot = pivot - l2[i] * l2[i] * dm2;
2639
+ if (!(pivot > 0.0) || !isFinite(pivot))
2640
+ return false;
2641
+ d[i] = pivot;
2642
+ }
2643
+ while (inductionVariable < n);
2644
+ // Inline function 'kotlin.collections.copyInto' call
2645
+ var endIndex = d.length;
2646
+ // Inline function 'kotlin.js.unsafeCast' call
2647
+ // Inline function 'kotlin.js.asDynamic' call
2648
+ var tmp_0 = d;
2649
+ // Inline function 'kotlin.js.unsafeCast' call
2650
+ // Inline function 'kotlin.js.asDynamic' call
2651
+ arrayCopy(tmp_0, a0, 0, 0, endIndex);
2652
+ var inductionVariable_0 = 0;
2653
+ if (inductionVariable_0 < n)
2654
+ do {
2655
+ var i_0 = inductionVariable_0;
2656
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2657
+ if (i_0 >= 1) {
2658
+ a1[i_0 - 1 | 0] = l1[i_0];
2659
+ }
2660
+ if (i_0 >= 2) {
2661
+ a2[i_0 - 2 | 0] = l2[i_0];
2662
+ }
2663
+ }
2664
+ while (inductionVariable_0 < n);
2665
+ return true;
2666
+ };
2667
+ protoOf(BandedLdl).solveInPlace_jrw92v_k$ = function (d, l1, l2, b) {
2668
+ var n = d.length;
2669
+ if (n === 0)
2670
+ return Unit_instance;
2671
+ var inductionVariable = 0;
2672
+ if (inductionVariable < n)
2673
+ do {
2674
+ var i = inductionVariable;
2675
+ inductionVariable = inductionVariable + 1 | 0;
2676
+ var v = b[i];
2677
+ if (i >= 1)
2678
+ v = v - l1[i - 1 | 0] * b[i - 1 | 0];
2679
+ if (i >= 2)
2680
+ v = v - l2[i - 2 | 0] * b[i - 2 | 0];
2681
+ b[i] = v;
2682
+ }
2683
+ while (inductionVariable < n);
2684
+ var inductionVariable_0 = 0;
2685
+ if (inductionVariable_0 < n)
2686
+ do {
2687
+ var i_0 = inductionVariable_0;
2688
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2689
+ b[i_0] = b[i_0] / d[i_0];
2690
+ }
2691
+ while (inductionVariable_0 < n);
2692
+ var inductionVariable_1 = n - 1 | 0;
2693
+ if (0 <= inductionVariable_1)
2694
+ do {
2695
+ var i_1 = inductionVariable_1;
2696
+ inductionVariable_1 = inductionVariable_1 + -1 | 0;
2697
+ var v_0 = b[i_1];
2698
+ if ((i_1 + 1 | 0) < n)
2699
+ v_0 = v_0 - l1[i_1] * b[i_1 + 1 | 0];
2700
+ if ((i_1 + 2 | 0) < n)
2701
+ v_0 = v_0 - l2[i_1] * b[i_1 + 2 | 0];
2702
+ b[i_1] = v_0;
2703
+ }
2704
+ while (0 <= inductionVariable_1);
2705
+ };
2706
+ protoOf(BandedLdl).multiply_dwj15t_k$ = function (a0, a1, a2, x, y) {
2707
+ var n = a0.length;
2708
+ var inductionVariable = 0;
2709
+ if (inductionVariable < n)
2710
+ do {
2711
+ var i = inductionVariable;
2712
+ inductionVariable = inductionVariable + 1 | 0;
2713
+ var v = a0[i] * x[i];
2714
+ if (i >= 1)
2715
+ v = v + a1[i - 1 | 0] * x[i - 1 | 0];
2716
+ if ((i + 1 | 0) < n)
2717
+ v = v + a1[i] * x[i + 1 | 0];
2718
+ if (i >= 2)
2719
+ v = v + a2[i - 2 | 0] * x[i - 2 | 0];
2720
+ if ((i + 2 | 0) < n)
2721
+ v = v + a2[i] * x[i + 2 | 0];
2722
+ y[i] = v;
2723
+ }
2724
+ while (inductionVariable < n);
2725
+ };
2726
+ var BandedLdl_instance;
2727
+ function BandedLdl_getInstance() {
2728
+ return BandedLdl_instance;
2729
+ }
2730
+ function CornerSpan(fromIndex, untilIndex, apexIndex, kind, turnRad, direction, radiusQ20M, radiusMinM, lengthM) {
2731
+ this.fromIndex_1 = fromIndex;
2732
+ this.untilIndex_1 = untilIndex;
2733
+ this.apexIndex_1 = apexIndex;
2734
+ this.kind_1 = kind;
2735
+ this.turnRad_1 = turnRad;
2736
+ this.direction_1 = direction;
2737
+ this.radiusQ20M_1 = radiusQ20M;
2738
+ this.radiusMinM_1 = radiusMinM;
2739
+ this.lengthM_1 = lengthM;
2740
+ }
2741
+ protoOf(CornerSpan).toString = function () {
2742
+ return 'CornerSpan(fromIndex=' + this.fromIndex_1 + ', untilIndex=' + this.untilIndex_1 + ', apexIndex=' + this.apexIndex_1 + ', kind=' + this.kind_1.toString() + ', turnRad=' + this.turnRad_1 + ', direction=' + this.direction_1 + ', radiusQ20M=' + this.radiusQ20M_1 + ', radiusMinM=' + this.radiusMinM_1 + ', lengthM=' + this.lengthM_1 + ')';
2743
+ };
2744
+ protoOf(CornerSpan).hashCode = function () {
2745
+ var result = this.fromIndex_1;
2746
+ result = imul(result, 31) + this.untilIndex_1 | 0;
2747
+ result = imul(result, 31) + this.apexIndex_1 | 0;
2748
+ result = imul(result, 31) + this.kind_1.hashCode() | 0;
2749
+ result = imul(result, 31) + getNumberHashCode(this.turnRad_1) | 0;
2750
+ result = imul(result, 31) + this.direction_1 | 0;
2751
+ result = imul(result, 31) + getNumberHashCode(this.radiusQ20M_1) | 0;
2752
+ result = imul(result, 31) + getNumberHashCode(this.radiusMinM_1) | 0;
2753
+ result = imul(result, 31) + getNumberHashCode(this.lengthM_1) | 0;
2754
+ return result;
2755
+ };
2756
+ protoOf(CornerSpan).equals = function (other) {
2757
+ if (this === other)
2758
+ return true;
2759
+ if (!(other instanceof CornerSpan))
2760
+ return false;
2761
+ if (!(this.fromIndex_1 === other.fromIndex_1))
2762
+ return false;
2763
+ if (!(this.untilIndex_1 === other.untilIndex_1))
2764
+ return false;
2765
+ if (!(this.apexIndex_1 === other.apexIndex_1))
2766
+ return false;
2767
+ if (!this.kind_1.equals(other.kind_1))
2768
+ return false;
2769
+ if (!equals(this.turnRad_1, other.turnRad_1))
2770
+ return false;
2771
+ if (!(this.direction_1 === other.direction_1))
2772
+ return false;
2773
+ if (!equals(this.radiusQ20M_1, other.radiusQ20M_1))
2774
+ return false;
2775
+ if (!equals(this.radiusMinM_1, other.radiusMinM_1))
2776
+ return false;
2777
+ if (!equals(this.lengthM_1, other.lengthM_1))
2778
+ return false;
2779
+ return true;
2780
+ };
2781
+ function radiusPercentile($this, kappa, from, until, fraction) {
2782
+ var count = until - from | 0;
2783
+ if (count <= 0)
2784
+ return Infinity;
2785
+ var tmp = 0;
2786
+ var tmp_0 = new Float64Array(count);
2787
+ while (tmp < count) {
2788
+ var tmp_1 = tmp;
2789
+ tmp_0[tmp_1] = CurvatureEstimator_instance.radiusAt_umgvjz_k$(kappa[from + tmp_1 | 0]);
2790
+ tmp = tmp + 1 | 0;
2791
+ }
2792
+ var radii = tmp_0;
2793
+ sort(radii);
2794
+ var idx = coerceIn_0(numberToInt((count - 1 | 0) * fraction), 0, count - 1 | 0);
2795
+ return radii[idx];
2543
2796
  }
2544
- var WIND_KEYS;
2545
- function get_ENHANCE_OPTIONS_KEYS() {
2546
- _init_properties_EngineJsApi_kt__9bputf();
2547
- return ENHANCE_OPTIONS_KEYS;
2797
+ function CornerDetector() {
2548
2798
  }
2549
- var ENHANCE_OPTIONS_KEYS;
2550
- function parseGpxWaypoints(xml) {
2551
- _init_properties_EngineJsApi_kt__9bputf();
2552
- // Inline function 'kotlin.collections.map' call
2553
- var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
2554
- // Inline function 'kotlin.collections.mapTo' call
2555
- var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
2556
- var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
2557
- while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
2558
- var item = _iterator__ex2g4s.next_20eer_k$();
2559
- var tmp$ret$2 = waypointObj(item);
2560
- destination.add_utx5q5_k$(tmp$ret$2);
2799
+ protoOf(CornerDetector).detect_cq5dkx_k$ = function (frame, options, widthM) {
2800
+ var n = frame.get_size_woubt6_k$();
2801
+ if (n < 3)
2802
+ return emptyList();
2803
+ var enter = 1.0 / options.cornerEnterRadiusM_1;
2804
+ var exit = 1.0 / options.cornerExitRadiusM_1;
2805
+ var kappa = frame.kappa_1;
2806
+ // Inline function 'kotlin.collections.mutableListOf' call
2807
+ var raw = ArrayList_init_$Create$();
2808
+ var start = -1;
2809
+ var sign = 0;
2810
+ var inductionVariable = 0;
2811
+ if (inductionVariable < n)
2812
+ do {
2813
+ var i = inductionVariable;
2814
+ inductionVariable = inductionVariable + 1 | 0;
2815
+ var k = kappa[i];
2816
+ // Inline function 'kotlin.math.abs' call
2817
+ var a = Math.abs(k);
2818
+ var tmp;
2819
+ if (k > 0) {
2820
+ tmp = 1;
2821
+ } else if (k < 0) {
2822
+ tmp = -1;
2823
+ } else {
2824
+ tmp = 0;
2825
+ }
2826
+ var s = tmp;
2827
+ if (start < 0) {
2828
+ if (a > enter && !(s === 0)) {
2829
+ start = i;
2830
+ sign = s;
2831
+ }
2832
+ } else {
2833
+ var sameSign = s === sign || s === 0;
2834
+ if (a < exit || !sameSign) {
2835
+ // Inline function 'kotlin.intArrayOf' call
2836
+ var tmp$ret$2 = new Int32Array([start, i, sign]);
2837
+ raw.add_utx5q5_k$(tmp$ret$2);
2838
+ start = a > enter && !(s === 0) && !sameSign ? i : -1;
2839
+ if (start >= 0)
2840
+ sign = s;
2841
+ }
2842
+ }
2843
+ }
2844
+ while (inductionVariable < n);
2845
+ if (start >= 0) {
2846
+ // Inline function 'kotlin.intArrayOf' call
2847
+ var tmp$ret$3 = new Int32Array([start, n, sign]);
2848
+ raw.add_utx5q5_k$(tmp$ret$3);
2561
2849
  }
2562
- // Inline function 'kotlin.collections.toTypedArray' call
2563
- return copyToArray(destination);
2850
+ // Inline function 'kotlin.collections.mutableListOf' call
2851
+ var merged = ArrayList_init_$Create$();
2852
+ var _iterator__ex2g4s = raw.iterator_jk1svi_k$();
2853
+ $l$loop: while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
2854
+ var span = _iterator__ex2g4s.next_20eer_k$();
2855
+ var last = lastOrNull(merged);
2856
+ if (!(last == null) && last[2] === span[2]) {
2857
+ var tmp0 = span[0];
2858
+ // Inline function 'kotlin.comparisons.minOf' call
2859
+ var b = n - 1 | 0;
2860
+ var tmp$ret$5 = Math.min(tmp0, b);
2861
+ var tmp_0 = frame.s_1[tmp$ret$5];
2862
+ var tmp0_0 = last[1];
2863
+ // Inline function 'kotlin.comparisons.minOf' call
2864
+ var b_0 = n - 1 | 0;
2865
+ var tmp$ret$6 = Math.min(tmp0_0, b_0);
2866
+ var gap = tmp_0 - frame.s_1[tmp$ret$6];
2867
+ var tmp0_1 = span[0];
2868
+ // Inline function 'kotlin.comparisons.minOf' call
2869
+ var b_1 = widthM.length - 1 | 0;
2870
+ var w = widthM[Math.min(tmp0_1, b_1)];
2871
+ // Inline function 'kotlin.math.max' call
2872
+ var b_2 = 3.0 * w;
2873
+ if (gap < Math.max(15.0, b_2)) {
2874
+ last[1] = span[1];
2875
+ continue $l$loop;
2876
+ }
2877
+ }
2878
+ merged.add_utx5q5_k$(span);
2879
+ }
2880
+ var minTurn = options.minCornerTurnDeg_1 * 3.141592653589793 / 180.0;
2881
+ var hairpinTurn = options.hairpinTurnDeg_1 * 3.141592653589793 / 180.0;
2882
+ // Inline function 'kotlin.collections.mutableListOf' call
2883
+ var out = ArrayList_init_$Create$();
2884
+ var _iterator__ex2g4s_0 = merged.iterator_jk1svi_k$();
2885
+ $l$loop_2: while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
2886
+ var span_0 = _iterator__ex2g4s_0.next_20eer_k$();
2887
+ var from = span_0[0];
2888
+ // Inline function 'kotlin.comparisons.minOf' call
2889
+ var a_0 = span_0[1];
2890
+ var until = Math.min(a_0, n);
2891
+ if ((until - from | 0) < 2)
2892
+ continue $l$loop_2;
2893
+ var lengthM = frame.s_1[until - 1 | 0] - frame.s_1[from];
2894
+ if (lengthM < options.minCornerLengthM_1)
2895
+ continue $l$loop_2;
2896
+ var turn = frame.theta_1[until - 1 | 0] - frame.theta_1[from];
2897
+ // Inline function 'kotlin.math.abs' call
2898
+ if (Math.abs(turn) < minTurn)
2899
+ continue $l$loop_2;
2900
+ var apex = from;
2901
+ var peak = 0.0;
2902
+ var minRadius = 1.7976931348623157E308;
2903
+ var inductionVariable_0 = from;
2904
+ if (inductionVariable_0 < until)
2905
+ do {
2906
+ var i_0 = inductionVariable_0;
2907
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2908
+ // Inline function 'kotlin.math.abs' call
2909
+ var x = kappa[i_0];
2910
+ var a_1 = Math.abs(x);
2911
+ if (a_1 > peak) {
2912
+ peak = a_1;
2913
+ apex = i_0;
2914
+ }
2915
+ var r = CurvatureEstimator_instance.radiusAt_umgvjz_k$(kappa[i_0]);
2916
+ if (r < minRadius)
2917
+ minRadius = r;
2918
+ }
2919
+ while (inductionVariable_0 < until);
2920
+ var q20 = radiusPercentile(this, kappa, from, until, 0.2);
2921
+ var tmp_1;
2922
+ // Inline function 'kotlin.math.abs' call
2923
+ if (Math.abs(turn) >= hairpinTurn) {
2924
+ tmp_1 = CornerKind_HAIRPIN_getInstance();
2925
+ } else {
2926
+ if (q20 >= options.gentleRadiusM_1) {
2927
+ tmp_1 = CornerKind_GENTLE_getInstance();
2928
+ } else {
2929
+ tmp_1 = CornerKind_CORNER_getInstance();
2930
+ }
2931
+ }
2932
+ var kind = tmp_1;
2933
+ out.add_utx5q5_k$(new CornerSpan(from, until, apex, kind, turn, span_0[2], q20, minRadius === 1.7976931348623157E308 ? Infinity : minRadius, lengthM));
2934
+ }
2935
+ return out;
2936
+ };
2937
+ var CornerDetector_instance;
2938
+ function CornerDetector_getInstance() {
2939
+ return CornerDetector_instance;
2564
2940
  }
2565
- function parseGpx(xml) {
2566
- _init_properties_EngineJsApi_kt__9bputf();
2567
- return firstTrackAsPath(GpxParser_instance.parse$default_ez0f31_k$(xml));
2941
+ function CorridorBounds(lo, hi, halfWidthM) {
2942
+ this.lo_1 = lo;
2943
+ this.hi_1 = hi;
2944
+ this.halfWidthM_1 = halfWidthM;
2568
2945
  }
2569
- function parseGpxTracks(xml) {
2570
- _init_properties_EngineJsApi_kt__9bputf();
2571
- // Inline function 'kotlin.collections.toTypedArray' call
2572
- var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2573
- return copyToArray(this_0);
2946
+ function applyRegularityClamp($this, frame, options, lo, hi) {
2947
+ var inductionVariable = 0;
2948
+ var last = frame.get_size_woubt6_k$();
2949
+ if (inductionVariable < last)
2950
+ do {
2951
+ var i = inductionVariable;
2952
+ inductionVariable = inductionVariable + 1 | 0;
2953
+ // Inline function 'kotlin.math.abs' call
2954
+ var x = frame.kappa_1[i];
2955
+ // Inline function 'kotlin.math.max' call
2956
+ var a = Math.abs(x);
2957
+ var tmp$ret$1 = Math.max(a, 1.0E-9);
2958
+ var limit = options.regularityFactor_1 / tmp$ret$1;
2959
+ var tmp0 = lo[i];
2960
+ // Inline function 'kotlin.math.max' call
2961
+ var b = -limit;
2962
+ lo[i] = Math.max(tmp0, b);
2963
+ // Inline function 'kotlin.math.min' call
2964
+ var a_0 = hi[i];
2965
+ hi[i] = Math.min(a_0, limit);
2966
+ }
2967
+ while (inductionVariable < last);
2574
2968
  }
2575
- function parseGpxSegments(xml) {
2576
- _init_properties_EngineJsApi_kt__9bputf();
2577
- // Inline function 'kotlin.collections.toTypedArray' call
2578
- var this_0 = segmentsAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2579
- return copyToArray(this_0);
2969
+ function applySelfProximityClamp($this, frame, options, lo, hi) {
2970
+ var n = frame.get_size_woubt6_k$();
2971
+ var buckets = HashMap_init_$Create$();
2972
+ var inductionVariable = 0;
2973
+ if (inductionVariable < n)
2974
+ do {
2975
+ var i = inductionVariable;
2976
+ inductionVariable = inductionVariable + 1 | 0;
2977
+ // Inline function 'kotlin.collections.getOrPut' call
2978
+ var key = cellKey($this, bucketOf($this, frame.x_1[i]), bucketOf($this, frame.y_1[i]));
2979
+ var value = buckets.get_wei43m_k$(key);
2980
+ var tmp;
2981
+ if (value == null) {
2982
+ // Inline function 'kotlin.collections.mutableListOf' call
2983
+ var answer = ArrayList_init_$Create$();
2984
+ buckets.put_4fpzoq_k$(key, answer);
2985
+ tmp = answer;
2986
+ } else {
2987
+ tmp = value;
2988
+ }
2989
+ tmp.add_utx5q5_k$(i);
2990
+ }
2991
+ while (inductionVariable < n);
2992
+ var inductionVariable_0 = 0;
2993
+ if (inductionVariable_0 < n)
2994
+ $l$loop_1: do {
2995
+ var i_0 = inductionVariable_0;
2996
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2997
+ var bx = bucketOf($this, frame.x_1[i_0]);
2998
+ var by = bucketOf($this, frame.y_1[i_0]);
2999
+ var nearest = 1.7976931348623157E308;
3000
+ var inductionVariable_1 = -1;
3001
+ if (inductionVariable_1 <= 1)
3002
+ do {
3003
+ var dx = inductionVariable_1;
3004
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3005
+ var inductionVariable_2 = -1;
3006
+ if (inductionVariable_2 <= 1)
3007
+ $l$loop: do {
3008
+ var dy = inductionVariable_2;
3009
+ inductionVariable_2 = inductionVariable_2 + 1 | 0;
3010
+ // Inline function 'kotlin.Long.plus' call
3011
+ var tmp_0 = add(bx, fromInt(dx));
3012
+ // Inline function 'kotlin.Long.plus' call
3013
+ var tmp$ret$4 = add(by, fromInt(dy));
3014
+ var tmp0_elvis_lhs = buckets.get_wei43m_k$(cellKey($this, tmp_0, tmp$ret$4));
3015
+ var tmp_1;
3016
+ if (tmp0_elvis_lhs == null) {
3017
+ continue $l$loop;
3018
+ } else {
3019
+ tmp_1 = tmp0_elvis_lhs;
3020
+ }
3021
+ var cell = tmp_1;
3022
+ var _iterator__ex2g4s = cell.iterator_jk1svi_k$();
3023
+ $l$loop_0: while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
3024
+ var j = _iterator__ex2g4s.next_20eer_k$();
3025
+ // Inline function 'kotlin.math.abs' call
3026
+ var x = frame.s_1[j] - frame.s_1[i_0];
3027
+ var alongPath = Math.abs(x);
3028
+ var ddx = frame.x_1[j] - frame.x_1[i_0];
3029
+ var ddy = frame.y_1[j] - frame.y_1[i_0];
3030
+ // Inline function 'kotlin.math.sqrt' call
3031
+ var x_0 = ddx * ddx + ddy * ddy;
3032
+ var d = Math.sqrt(x_0);
3033
+ // Inline function 'kotlin.math.abs' call
3034
+ var x_1 = LocalFrame_instance.unwrap_i6c8al_k$(frame.theta_1[j] - frame.theta_1[i_0]);
3035
+ var headingGap = Math.abs(x_1);
3036
+ var sameRoad = alongPath <= options.selfProximityGapM_1 && headingGap < 1.5707963267948966;
3037
+ if (sameRoad)
3038
+ continue $l$loop_0;
3039
+ if (d < nearest)
3040
+ nearest = d;
3041
+ }
3042
+ }
3043
+ while (inductionVariable_2 <= 1);
3044
+ }
3045
+ while (inductionVariable_1 <= 1);
3046
+ if (nearest === 1.7976931348623157E308)
3047
+ continue $l$loop_1;
3048
+ // Inline function 'kotlin.math.max' call
3049
+ var b = nearest / 2.0 - 0.5;
3050
+ var allowed = Math.max(0.0, b);
3051
+ var tmp0 = lo[i_0];
3052
+ // Inline function 'kotlin.math.max' call
3053
+ var b_0 = -allowed;
3054
+ lo[i_0] = Math.max(tmp0, b_0);
3055
+ // Inline function 'kotlin.math.min' call
3056
+ var a = hi[i_0];
3057
+ hi[i_0] = Math.min(a, allowed);
3058
+ }
3059
+ while (inductionVariable_0 < n);
2580
3060
  }
2581
- function parseGpxTracksOnly(xml) {
2582
- _init_properties_EngineJsApi_kt__9bputf();
2583
- // Inline function 'kotlin.collections.toTypedArray' call
2584
- var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_TRACK_getInstance()));
2585
- return copyToArray(this_0);
3061
+ function bucketOf($this, v) {
3062
+ // Inline function 'kotlin.math.floor' call
3063
+ var x = v / 12.0;
3064
+ var tmp$ret$0 = Math.floor(x);
3065
+ return numberToLong(tmp$ret$0);
2586
3066
  }
2587
- function parseGpxRoutesOnly(xml) {
2588
- _init_properties_EngineJsApi_kt__9bputf();
2589
- // Inline function 'kotlin.collections.toTypedArray' call
2590
- var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_ROUTE_getInstance()));
2591
- return copyToArray(this_0);
3067
+ function cellKey($this, bx, by) {
3068
+ return bitwiseXor(shiftLeft(bx, 32), bitwiseAnd(by, new Long(-1, 0)));
2592
3069
  }
2593
- function writeGpxTracks(paths, waypoints, writeExtensions) {
2594
- var tmp;
2595
- if (waypoints === VOID) {
2596
- // Inline function 'kotlin.emptyArray' call
2597
- tmp = [];
2598
- } else {
2599
- tmp = waypoints;
2600
- }
2601
- waypoints = tmp;
2602
- writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2603
- _init_properties_EngineJsApi_kt__9bputf();
2604
- var tmp_0 = GpxWriter_instance;
2605
- var tmp_1 = toList(paths);
2606
- // Inline function 'kotlin.collections.map' call
2607
- // Inline function 'kotlin.collections.mapTo' call
2608
- var destination = ArrayList_init_$Create$_0(waypoints.length);
3070
+ function applyPins($this, frame, options, lo, hi) {
3071
+ var n = frame.get_size_woubt6_k$();
3072
+ // Inline function 'kotlin.intArrayOf' call
3073
+ var indexedObject = new Int32Array([0, 1, n - 2 | 0, n - 1 | 0]);
2609
3074
  var inductionVariable = 0;
2610
- var last = waypoints.length;
3075
+ var last = indexedObject.length;
2611
3076
  while (inductionVariable < last) {
2612
- var item = waypoints[inductionVariable];
3077
+ var i = indexedObject[inductionVariable];
2613
3078
  inductionVariable = inductionVariable + 1 | 0;
2614
- var tmp$ret$3 = toGpxWaypoint(item);
2615
- destination.add_utx5q5_k$(tmp$ret$3);
3079
+ if (0 <= i ? i < n : false) {
3080
+ lo[i] = 0.0;
3081
+ hi[i] = 0.0;
3082
+ }
2616
3083
  }
2617
- return tmp_0.write$default_koqy5u_k$(tmp_1, VOID, VOID, destination, VOID, writeExtensions);
2618
- }
2619
- function pathSize(path) {
2620
- _init_properties_EngineJsApi_kt__9bputf();
2621
- return path.size_1;
2622
- }
2623
- function pathTotalDistance(path) {
2624
- _init_properties_EngineJsApi_kt__9bputf();
2625
- return path.totalDistance_1;
2626
- }
2627
- function pathDurationMs(path) {
2628
- _init_properties_EngineJsApi_kt__9bputf();
2629
- return path.durationMs_1;
2630
- }
2631
- function pathElevationGain(path) {
2632
- _init_properties_EngineJsApi_kt__9bputf();
2633
- return path.elevationGain_1;
2634
- }
2635
- function pathElevationLoss(path) {
2636
- _init_properties_EngineJsApi_kt__9bputf();
2637
- return path.elevationLoss_1;
2638
- }
2639
- function pointAt(path, i) {
2640
- _init_properties_EngineJsApi_kt__9bputf();
2641
- return pointObj(path.latitudeDeg_i25sm6_k$(i), path.longitudeDeg_ikk1un_k$(i), path.elevation_iziwkb_k$(i), path.time_ryc845_k$(i), path.speed_npav2n_k$(i), path.pComputedPower_g6dnn4_k$(i), path.distance_5s4s77_k$(i), path.grade_c4yjz5_k$(i));
3084
+ var straightKappa = 1.0 / options.straightRadiusM_1;
3085
+ var runStart = -1;
3086
+ var inductionVariable_0 = 0;
3087
+ if (inductionVariable_0 < n)
3088
+ do {
3089
+ var i_0 = inductionVariable_0;
3090
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3091
+ // Inline function 'kotlin.math.abs' call
3092
+ var x = frame.kappa_1[i_0];
3093
+ var straight = Math.abs(x) < straightKappa;
3094
+ if (straight) {
3095
+ if (runStart < 0)
3096
+ runStart = i_0;
3097
+ } else {
3098
+ pinRunMidpoint($this, frame, options, runStart, i_0, lo, hi);
3099
+ runStart = -1;
3100
+ }
3101
+ }
3102
+ while (inductionVariable_0 < n);
3103
+ pinRunMidpoint($this, frame, options, runStart, n, lo, hi);
2642
3104
  }
2643
- function writeGpx(path, writeExtensions) {
2644
- writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2645
- _init_properties_EngineJsApi_kt__9bputf();
2646
- return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized'), writeExtensions);
3105
+ function pinRunMidpoint($this, frame, options, from, until, lo, hi) {
3106
+ if (from < 0 || (until - from | 0) < 2)
3107
+ return Unit_instance;
3108
+ if (frame.s_1[until - 1 | 0] - frame.s_1[from] < options.straightRunM_1)
3109
+ return Unit_instance;
3110
+ var mid = (from + until | 0) / 2 | 0;
3111
+ // Inline function 'kotlin.intArrayOf' call
3112
+ var indexedObject = new Int32Array([mid, mid + 1 | 0]);
3113
+ var inductionVariable = 0;
3114
+ var last = indexedObject.length;
3115
+ while (inductionVariable < last) {
3116
+ var i = indexedObject[inductionVariable];
3117
+ inductionVariable = inductionVariable + 1 | 0;
3118
+ if (0 <= i ? i < frame.get_size_woubt6_k$() : false) {
3119
+ lo[i] = 0.0;
3120
+ hi[i] = 0.0;
3121
+ }
3122
+ }
2647
3123
  }
2648
- function writeGpxAt(path, startTimeEpochMs, writeExtensions) {
2649
- writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2650
- _init_properties_EngineJsApi_kt__9bputf();
2651
- return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized', Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs))), writeExtensions);
3124
+ function Corridor() {
3125
+ this.MAX_HALF_WIDTH_M_1 = 6.0;
3126
+ this.GRID_M_1 = 12.0;
3127
+ this.PROXIMITY_CLEARANCE_M_1 = 0.5;
3128
+ this.SAME_ROAD_HEADING_RAD_1 = 1.5707963267948966;
2652
3129
  }
2653
- function enhance(path, options) {
2654
- _init_properties_EngineJsApi_kt__9bputf();
2655
- var tmp = GlobalScope_instance;
2656
- return promise(tmp, VOID, VOID, enhance$slambda_0(options, path, null));
3130
+ protoOf(Corridor).resolveWidth_feg61f_k$ = function (path, frame, options) {
3131
+ var raw = new Float64Array(frame.get_size_woubt6_k$());
3132
+ var inductionVariable = 0;
3133
+ var last = raw.length - 1 | 0;
3134
+ if (inductionVariable <= last)
3135
+ do {
3136
+ var i = inductionVariable;
3137
+ inductionVariable = inductionVariable + 1 | 0;
3138
+ var w = path.roadWidth_7zv9qq_k$(i);
3139
+ raw[i] = isNaN_0(w) || w <= 0.0 ? options.defaultRoadWidthM_1 : w;
3140
+ }
3141
+ while (inductionVariable <= last);
3142
+ return LocalFrame_instance.smooth_kce7pb_k$(raw, frame.s_1, options.widthSmoothWindowM_1);
3143
+ };
3144
+ protoOf(Corridor).build_fyfb0s_k$ = function (frame, widthM, options) {
3145
+ var n = frame.get_size_woubt6_k$();
3146
+ var lo = new Float64Array(n);
3147
+ var hi = new Float64Array(n);
3148
+ var half = new Float64Array(n);
3149
+ var inductionVariable = 0;
3150
+ if (inductionVariable < n)
3151
+ do {
3152
+ var i = inductionVariable;
3153
+ inductionVariable = inductionVariable + 1 | 0;
3154
+ var h = coerceIn(widthM[i] / 2.0 - options.edgeMarginM_1, 0.0, 6.0);
3155
+ half[i] = h;
3156
+ switch (options.corridor_1.ordinal_1) {
3157
+ case 0:
3158
+ lo[i] = -h;
3159
+ hi[i] = 0.0;
3160
+ break;
3161
+ case 1:
3162
+ lo[i] = 0.0;
3163
+ hi[i] = h;
3164
+ break;
3165
+ case 2:
3166
+ lo[i] = -h;
3167
+ hi[i] = h;
3168
+ break;
3169
+ default:
3170
+ noWhenBranchMatchedException();
3171
+ break;
3172
+ }
3173
+ }
3174
+ while (inductionVariable < n);
3175
+ applyRegularityClamp(this, frame, options, lo, hi);
3176
+ applySelfProximityClamp(this, frame, options, lo, hi);
3177
+ applyPins(this, frame, options, lo, hi);
3178
+ var inductionVariable_0 = 0;
3179
+ if (inductionVariable_0 < n)
3180
+ do {
3181
+ var i_0 = inductionVariable_0;
3182
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3183
+ if (lo[i_0] > hi[i_0]) {
3184
+ var mid = (lo[i_0] + hi[i_0]) / 2.0;
3185
+ lo[i_0] = mid;
3186
+ hi[i_0] = mid;
3187
+ }
3188
+ }
3189
+ while (inductionVariable_0 < n);
3190
+ return new CorridorBounds(lo, hi, half);
3191
+ };
3192
+ var Corridor_instance;
3193
+ function Corridor_getInstance() {
3194
+ return Corridor_instance;
2657
3195
  }
2658
- function enhanceWithCourse(path, cyclist, bike, wind, power, options) {
3196
+ function medianSigma($this, frame, halfWidthM) {
3197
+ var n = frame.get_size_woubt6_k$();
3198
+ if (n === 0)
3199
+ return 0.0;
3200
+ var values = new Float64Array(n);
3201
+ var count = 0;
3202
+ var inductionVariable = 0;
3203
+ if (inductionVariable < n)
3204
+ $l$loop: do {
3205
+ var i = inductionVariable;
3206
+ inductionVariable = inductionVariable + 1 | 0;
3207
+ var tmp0_elvis_lhs = fitSlope($this, frame, i, halfWidthM);
3208
+ var tmp;
3209
+ if (tmp0_elvis_lhs == null) {
3210
+ continue $l$loop;
3211
+ } else {
3212
+ tmp = tmp0_elvis_lhs;
3213
+ }
3214
+ var fit = tmp;
3215
+ var _unary__edvuaz = count;
3216
+ count = _unary__edvuaz + 1 | 0;
3217
+ values[_unary__edvuaz] = fit.residualSigma_1;
3218
+ }
3219
+ while (inductionVariable < n);
3220
+ if (count === 0)
3221
+ return 0.0;
3222
+ var trimmed = copyOf(values, count);
3223
+ sort(trimmed);
3224
+ return trimmed[count / 2 | 0];
3225
+ }
3226
+ function Fit(slope, residualSigma) {
3227
+ this.slope_1 = slope;
3228
+ this.residualSigma_1 = residualSigma;
3229
+ }
3230
+ function fitSlope($this, frame, i, halfWidthM) {
3231
+ var n = frame.get_size_woubt6_k$();
3232
+ var s = frame.s_1;
3233
+ var theta = frame.theta_1;
3234
+ var si = s[i];
3235
+ var ti = theta[i];
3236
+ var lo = i;
3237
+ while (lo > 0 && si - s[lo - 1 | 0] <= halfWidthM && (i - lo | 0) < 400) {
3238
+ lo = lo - 1 | 0;
3239
+ }
3240
+ var hi = i;
3241
+ while (hi < (n - 1 | 0) && s[hi + 1 | 0] - si <= halfWidthM && (hi - i | 0) < 400) {
3242
+ hi = hi + 1 | 0;
3243
+ }
3244
+ var m = (hi - lo | 0) + 1 | 0;
3245
+ if (m < 3)
3246
+ return null;
3247
+ var sumS = 0.0;
3248
+ var sumSS = 0.0;
3249
+ var sumT = 0.0;
3250
+ var sumST = 0.0;
3251
+ var inductionVariable = lo;
3252
+ var last = hi;
3253
+ if (inductionVariable <= last)
3254
+ do {
3255
+ var j = inductionVariable;
3256
+ inductionVariable = inductionVariable + 1 | 0;
3257
+ var ds = s[j] - si;
3258
+ var dt = theta[j] - ti;
3259
+ sumS = sumS + ds;
3260
+ sumSS = sumSS + ds * ds;
3261
+ sumT = sumT + dt;
3262
+ sumST = sumST + ds * dt;
3263
+ }
3264
+ while (!(j === last));
3265
+ var mD = m;
3266
+ var denominator = mD * sumSS - sumS * sumS;
3267
+ if (denominator < 1.0E-6 * mD * halfWidthM * halfWidthM)
3268
+ return null;
3269
+ var slope = (mD * sumST - sumS * sumT) / denominator;
3270
+ var intercept = (sumT - slope * sumS) / mD;
3271
+ var rss = 0.0;
3272
+ var inductionVariable_0 = lo;
3273
+ var last_0 = hi;
3274
+ if (inductionVariable_0 <= last_0)
3275
+ do {
3276
+ var j_0 = inductionVariable_0;
3277
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3278
+ var ds_0 = s[j_0] - si;
3279
+ var residual = theta[j_0] - ti - intercept - slope * ds_0;
3280
+ rss = rss + residual * residual;
3281
+ }
3282
+ while (!(j_0 === last_0));
3283
+ // Inline function 'kotlin.math.sqrt' call
3284
+ var x = rss / coerceAtLeast(mD - 2.0, 1.0);
3285
+ var sigma = Math.sqrt(x);
3286
+ return !isFinite(slope) || !isFinite(sigma) ? null : new Fit(slope, sigma);
3287
+ }
3288
+ function CurvatureEstimator() {
3289
+ this.SCALE_RESIDUAL_FACTOR_1 = 2.0;
3290
+ this.MAX_HALF_WINDOW_POINTS_1 = 400;
3291
+ this.DEGENERACY_FACTOR_1 = 1.0E-6;
3292
+ }
3293
+ protoOf(CurvatureEstimator).computeHeadings_ev7p13_k$ = function (frame) {
3294
+ var n = frame.get_size_woubt6_k$();
3295
+ var theta = frame.theta_1;
3296
+ if (n === 0)
3297
+ return Unit_instance;
3298
+ var previous = NaN;
3299
+ var inductionVariable = 0;
3300
+ if (inductionVariable < n)
3301
+ do {
3302
+ var i = inductionVariable;
3303
+ inductionVariable = inductionVariable + 1 | 0;
3304
+ var a = i > 0 ? i - 1 | 0 : 0;
3305
+ var b = i < (n - 1 | 0) ? i + 1 | 0 : n - 1 | 0;
3306
+ var dx = frame.x_1[b] - frame.x_1[a];
3307
+ var dy = frame.y_1[b] - frame.y_1[a];
3308
+ var tmp;
3309
+ if (dx === 0.0 && dy === 0.0) {
3310
+ tmp = isNaN_0(previous) ? 0.0 : previous;
3311
+ } else {
3312
+ // Inline function 'kotlin.math.atan2' call
3313
+ tmp = Math.atan2(dy, dx);
3314
+ }
3315
+ var raw = tmp;
3316
+ var tmp_0;
3317
+ if (i === 0 || isNaN_0(previous)) {
3318
+ tmp_0 = raw;
3319
+ } else {
3320
+ tmp_0 = previous + LocalFrame_instance.unwrap_i6c8al_k$(raw - previous);
3321
+ }
3322
+ theta[i] = tmp_0;
3323
+ previous = theta[i];
3324
+ }
3325
+ while (inductionVariable < n);
3326
+ };
3327
+ protoOf(CurvatureEstimator).computeCurvature_emiphc_k$ = function (frame, windowsM, sigmaThetaRad, curvatureSmoothM) {
3328
+ var n = frame.get_size_woubt6_k$();
3329
+ var kappa = frame.kappa_1;
3330
+ if (n === 0)
3331
+ return Unit_instance;
3332
+ // Inline function 'kotlin.collections.isNotEmpty' call
3333
+ // Inline function 'kotlin.collections.isEmpty' call
3334
+ // Inline function 'kotlin.require' call
3335
+ if (!!(windowsM.length === 0)) {
3336
+ var message = 'At least one curvature window is required';
3337
+ throw IllegalArgumentException_init_$Create$(toString(message));
3338
+ }
3339
+ var scales = windowsM.length;
3340
+ var slopes = new Float64Array(scales);
3341
+ var sigmas = new Float64Array(scales);
3342
+ var raw = new Float64Array(n);
3343
+ var measuredNoise = medianSigma(this, frame, windowsM[scales - 1 | 0]);
3344
+ // Inline function 'kotlin.comparisons.maxOf' call
3345
+ var threshold = 2.0 * Math.max(sigmaThetaRad, measuredNoise);
3346
+ var inductionVariable = 0;
3347
+ if (inductionVariable < n)
3348
+ do {
3349
+ var i = inductionVariable;
3350
+ inductionVariable = inductionVariable + 1 | 0;
3351
+ var inductionVariable_0 = 0;
3352
+ if (inductionVariable_0 < scales)
3353
+ do {
3354
+ var w = inductionVariable_0;
3355
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3356
+ var fit = fitSlope(this, frame, i, windowsM[w]);
3357
+ var tmp1_elvis_lhs = fit == null ? null : fit.slope_1;
3358
+ slopes[w] = tmp1_elvis_lhs == null ? NaN : tmp1_elvis_lhs;
3359
+ var tmp3_elvis_lhs = fit == null ? null : fit.residualSigma_1;
3360
+ sigmas[w] = tmp3_elvis_lhs == null ? NaN : tmp3_elvis_lhs;
3361
+ }
3362
+ while (inductionVariable_0 < scales);
3363
+ var chosen = NaN;
3364
+ var widest = NaN;
3365
+ var inductionVariable_1 = scales - 1 | 0;
3366
+ if (0 <= inductionVariable_1)
3367
+ $l$loop_0: do {
3368
+ var w_0 = inductionVariable_1;
3369
+ inductionVariable_1 = inductionVariable_1 + -1 | 0;
3370
+ if (isNaN_0(sigmas[w_0]))
3371
+ continue $l$loop_0;
3372
+ if (isNaN_0(widest))
3373
+ widest = slopes[w_0];
3374
+ if (sigmas[w_0] <= threshold) {
3375
+ chosen = slopes[w_0];
3376
+ break $l$loop_0;
3377
+ }
3378
+ }
3379
+ while (0 <= inductionVariable_1);
3380
+ var tmp;
3381
+ if (!isNaN_0(chosen)) {
3382
+ tmp = chosen;
3383
+ } else if (!isNaN_0(widest)) {
3384
+ tmp = widest;
3385
+ } else {
3386
+ tmp = 0.0;
3387
+ }
3388
+ raw[i] = tmp;
3389
+ }
3390
+ while (inductionVariable < n);
3391
+ var smoothed = LocalFrame_instance.smooth_kce7pb_k$(raw, frame.s_1, curvatureSmoothM);
3392
+ // Inline function 'kotlin.collections.copyInto' call
3393
+ var endIndex = smoothed.length;
3394
+ // Inline function 'kotlin.js.unsafeCast' call
3395
+ // Inline function 'kotlin.js.asDynamic' call
3396
+ var tmp_0 = smoothed;
3397
+ // Inline function 'kotlin.js.unsafeCast' call
3398
+ // Inline function 'kotlin.js.asDynamic' call
3399
+ arrayCopy(tmp_0, kappa, 0, 0, endIndex);
3400
+ };
3401
+ protoOf(CurvatureEstimator).radiusAt_umgvjz_k$ = function (kappa) {
3402
+ var tmp;
3403
+ // Inline function 'kotlin.math.abs' call
3404
+ if (Math.abs(kappa) < 1.0E-12) {
3405
+ tmp = Infinity;
3406
+ } else {
3407
+ // Inline function 'kotlin.math.abs' call
3408
+ tmp = 1.0 / Math.abs(kappa);
3409
+ }
3410
+ return tmp;
3411
+ };
3412
+ var CurvatureEstimator_instance;
3413
+ function CurvatureEstimator_getInstance() {
3414
+ return CurvatureEstimator_instance;
3415
+ }
3416
+ function LocalFrame() {
3417
+ this.MAX_ABS_LATITUDE_RAD_1 = 1.4835298641951802;
3418
+ this.MIN_POINTS_1 = 8;
3419
+ }
3420
+ protoOf(LocalFrame).project_n982lp_k$ = function (path, smoothWindowM) {
3421
+ var n = path.size_1;
3422
+ if (n < 8)
3423
+ return null;
3424
+ var bounds = path.boundsRad_1;
3425
+ var lat0 = (bounds.minLat_1 + bounds.maxLat_1) / 2.0;
3426
+ var lon0 = (bounds.minLon_1 + bounds.maxLon_1) / 2.0;
3427
+ if (!isFinite(lat0) || !isFinite(lon0))
3428
+ return null;
3429
+ // Inline function 'kotlin.math.abs' call
3430
+ if (Math.abs(lat0) > 1.4835298641951802)
3431
+ return null;
3432
+ if (bounds.maxLon_1 - bounds.minLon_1 > 3.141592653589793)
3433
+ lon0 = path.longitude_a9xl_k$(0);
3434
+ // Inline function 'kotlin.math.cos' call
3435
+ var k = Math.cos(lat0);
3436
+ var rawX = new Float64Array(n);
3437
+ var rawY = new Float64Array(n);
3438
+ var s = new Float64Array(n);
3439
+ var inductionVariable = 0;
3440
+ if (inductionVariable < n)
3441
+ do {
3442
+ var i = inductionVariable;
3443
+ inductionVariable = inductionVariable + 1 | 0;
3444
+ var lat = path.latitude_gb4iok_k$(i);
3445
+ var lon = path.longitude_a9xl_k$(i);
3446
+ var dist = path.distance_5s4s77_k$(i);
3447
+ if (!isFinite(lat) || !isFinite(lon) || !isFinite(dist))
3448
+ return null;
3449
+ var dLon = this.unwrap_i6c8al_k$(lon - lon0);
3450
+ rawX[i] = 6371000.0 * k * dLon;
3451
+ rawY[i] = 6371000.0 * (lat - lat0);
3452
+ s[i] = dist;
3453
+ }
3454
+ while (inductionVariable < n);
3455
+ var x = this.smooth_kce7pb_k$(rawX, s, smoothWindowM);
3456
+ var y = this.smooth_kce7pb_k$(rawY, s, smoothWindowM);
3457
+ this.arclengthOf_yiuhr5_k$(x, y, s);
3458
+ return new PlanarFrame(x, y, s, new Float64Array(n), new Float64Array(n), lat0, lon0, k);
3459
+ };
3460
+ protoOf(LocalFrame).unproject_ym27oh_k$ = function (frame, x, y) {
3461
+ var lat = frame.lat0__1 + y / 6371000.0;
3462
+ var lon = frame.lon0__1 + x / (6371000.0 * frame.k_1);
3463
+ // Inline function 'kotlin.doubleArrayOf' call
3464
+ return new Float64Array([lat, lon]);
3465
+ };
3466
+ protoOf(LocalFrame).arclengthOf_yiuhr5_k$ = function (x, y, s) {
3467
+ s[0] = 0.0;
3468
+ var inductionVariable = 1;
3469
+ var last = x.length;
3470
+ if (inductionVariable < last)
3471
+ do {
3472
+ var i = inductionVariable;
3473
+ inductionVariable = inductionVariable + 1 | 0;
3474
+ var dx = x[i] - x[i - 1 | 0];
3475
+ var dy = y[i] - y[i - 1 | 0];
3476
+ var tmp = s[i - 1 | 0];
3477
+ // Inline function 'kotlin.math.sqrt' call
3478
+ var x_0 = dx * dx + dy * dy;
3479
+ s[i] = tmp + Math.sqrt(x_0);
3480
+ }
3481
+ while (inductionVariable < last);
3482
+ };
3483
+ protoOf(LocalFrame).unwrap_i6c8al_k$ = function (a) {
3484
+ return a - 2.0 * 3.141592653589793 * round(a / (2.0 * 3.141592653589793));
3485
+ };
3486
+ protoOf(LocalFrame).smooth_kce7pb_k$ = function (v, s, windowM) {
3487
+ var n = v.length;
3488
+ if (windowM <= 0.0 || n < 3) {
3489
+ // Inline function 'kotlin.collections.copyOf' call
3490
+ // Inline function 'kotlin.js.asDynamic' call
3491
+ return v.slice();
3492
+ }
3493
+ var out = new Float64Array(n);
3494
+ var lo = 0;
3495
+ var hi = 0;
3496
+ var inductionVariable = 0;
3497
+ if (inductionVariable < n)
3498
+ do {
3499
+ var i = inductionVariable;
3500
+ inductionVariable = inductionVariable + 1 | 0;
3501
+ var c = s[i];
3502
+ while (lo < i && c - s[lo] > windowM) {
3503
+ lo = lo + 1 | 0;
3504
+ }
3505
+ if (hi < i)
3506
+ hi = i;
3507
+ while (hi < (n - 1 | 0) && s[hi + 1 | 0] - c <= windowM) {
3508
+ hi = hi + 1 | 0;
3509
+ }
3510
+ var weightSum = 0.0;
3511
+ var valueSum = 0.0;
3512
+ var inductionVariable_0 = lo;
3513
+ var last = hi;
3514
+ if (inductionVariable_0 <= last)
3515
+ $l$loop: do {
3516
+ var j = inductionVariable_0;
3517
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3518
+ // Inline function 'kotlin.math.abs' call
3519
+ var x = s[j] - c;
3520
+ var w = 1.0 - Math.abs(x) / windowM;
3521
+ if (w <= 0.0)
3522
+ continue $l$loop;
3523
+ weightSum = weightSum + w;
3524
+ valueSum = valueSum + v[j] * w;
3525
+ }
3526
+ while (!(j === last));
3527
+ out[i] = weightSum > 0.0 ? valueSum / weightSum : v[i];
3528
+ }
3529
+ while (inductionVariable < n);
3530
+ return out;
3531
+ };
3532
+ var LocalFrame_instance;
3533
+ function LocalFrame_getInstance() {
3534
+ return LocalFrame_instance;
3535
+ }
3536
+ function Companion_11() {
3537
+ }
3538
+ protoOf(Companion_11).assemble_miimn7_k$ = function (frame, center, rho, steeringLengthM, centeringLengthM) {
3539
+ var n = frame.get_size_woubt6_k$();
3540
+ var h0 = new Float64Array(n);
3541
+ var h1 = new Float64Array(n);
3542
+ var h2 = new Float64Array(n);
3543
+ var linear = new Float64Array(n);
3544
+ var constant = 0.0;
3545
+ var lambdaR = 1.0 / (steeringLengthM * steeringLengthM);
3546
+ var lambdaC = 1.0 / (centeringLengthM * centeringLengthM * centeringLengthM * centeringLengthM);
3547
+ var a = new Float64Array(3);
3548
+ var b = new Float64Array(3);
3549
+ var inductionVariable = 0;
3550
+ if (inductionVariable < n)
3551
+ $l$loop_0: do {
3552
+ var i = inductionVariable;
3553
+ inductionVariable = inductionVariable + 1 | 0;
3554
+ var hMinus = i >= 1 ? frame.s_1[i] - frame.s_1[i - 1 | 0] : 0.0;
3555
+ var hPlus = (i + 1 | 0) < n ? frame.s_1[i + 1 | 0] - frame.s_1[i] : 0.0;
3556
+ var weight = 0.5 * (hMinus + hPlus);
3557
+ h0[i] = h0[i] + 2.0 * weight * lambdaC;
3558
+ linear[i] = linear[i] - 2.0 * weight * lambdaC * center[i];
3559
+ constant = constant + weight * lambdaC * center[i] * center[i];
3560
+ if (i < 1 || (i + 1 | 0) >= n)
3561
+ continue $l$loop_0;
3562
+ var denom = hPlus * hMinus * (hPlus + hMinus);
3563
+ if (denom <= 0.0)
3564
+ continue $l$loop_0;
3565
+ a[0] = 2.0 * hPlus / denom;
3566
+ a[1] = -2.0 * (hPlus + hMinus) / denom + frame.kappa_1[i] * frame.kappa_1[i];
3567
+ a[2] = 2.0 * hMinus / denom;
3568
+ b[0] = -hPlus * hPlus / denom;
3569
+ b[1] = (hPlus * hPlus - hMinus * hMinus) / denom;
3570
+ b[2] = hMinus * hMinus / denom;
3571
+ var wRho = weight * rho[i];
3572
+ var wR = weight * lambdaR;
3573
+ var kappaI = frame.kappa_1[i];
3574
+ var inductionVariable_0 = 0;
3575
+ if (inductionVariable_0 <= 2)
3576
+ do {
3577
+ var p = inductionVariable_0;
3578
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3579
+ var row = (i - 1 | 0) + p | 0;
3580
+ linear[row] = linear[row] + 2.0 * wRho * kappaI * a[p];
3581
+ var inductionVariable_1 = p;
3582
+ if (inductionVariable_1 <= 2)
3583
+ do {
3584
+ var q = inductionVariable_1;
3585
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3586
+ var col = (i - 1 | 0) + q | 0;
3587
+ var contribution = 2.0 * (wRho * a[p] * a[q] + wR * b[p] * b[q]);
3588
+ switch (col - row | 0) {
3589
+ case 0:
3590
+ h0[row] = h0[row] + contribution;
3591
+ break;
3592
+ case 1:
3593
+ h1[row] = h1[row] + contribution;
3594
+ break;
3595
+ case 2:
3596
+ h2[row] = h2[row] + contribution;
3597
+ break;
3598
+ }
3599
+ }
3600
+ while (inductionVariable_1 <= 2);
3601
+ }
3602
+ while (inductionVariable_0 <= 2);
3603
+ constant = constant + wRho * kappaI * kappaI;
3604
+ }
3605
+ while (inductionVariable < n);
3606
+ return new OffsetEnergy(h0, h1, h2, linear, constant);
3607
+ };
3608
+ var Companion_instance_12;
3609
+ function Companion_getInstance_14() {
3610
+ return Companion_instance_12;
3611
+ }
3612
+ function OffsetEnergy(h0, h1, h2, linear, constant) {
3613
+ this.h0__1 = h0;
3614
+ this.h1__1 = h1;
3615
+ this.h2__1 = h2;
3616
+ this.linear_1 = linear;
3617
+ this.constant_1 = constant;
3618
+ }
3619
+ protoOf(OffsetEnergy).get_size_woubt6_k$ = function () {
3620
+ return this.h0__1.length;
3621
+ };
3622
+ protoOf(OffsetEnergy).value_6wg803_k$ = function (n, scratch) {
3623
+ BandedLdl_instance.multiply_dwj15t_k$(this.h0__1, this.h1__1, this.h2__1, n, scratch);
3624
+ var acc = this.constant_1;
3625
+ var inductionVariable = 0;
3626
+ var last = n.length - 1 | 0;
3627
+ if (inductionVariable <= last)
3628
+ do {
3629
+ var i = inductionVariable;
3630
+ inductionVariable = inductionVariable + 1 | 0;
3631
+ acc = acc + (0.5 * scratch[i] * n[i] + this.linear_1[i] * n[i]);
3632
+ }
3633
+ while (inductionVariable <= last);
3634
+ return acc;
3635
+ };
3636
+ protoOf(OffsetEnergy).gradient_zecmby_k$ = function (n, out) {
3637
+ BandedLdl_instance.multiply_dwj15t_k$(this.h0__1, this.h1__1, this.h2__1, n, out);
3638
+ var inductionVariable = 0;
3639
+ var last = out.length - 1 | 0;
3640
+ if (inductionVariable <= last)
3641
+ do {
3642
+ var i = inductionVariable;
3643
+ inductionVariable = inductionVariable + 1 | 0;
3644
+ out[i] = out[i] + this.linear_1[i];
3645
+ }
3646
+ while (inductionVariable <= last);
3647
+ };
3648
+ function QpResult(offset, iterations, gradientInfNorm, converged, activeConstraints) {
3649
+ this.offset_1 = offset;
3650
+ this.iterations_1 = iterations;
3651
+ this.gradientInfNorm_1 = gradientInfNorm;
3652
+ this.converged_1 = converged;
3653
+ this.activeConstraints_1 = activeConstraints;
3654
+ }
3655
+ function isFree($this, x, lo, hi, g, epsilon) {
3656
+ if (hi - lo <= 2.0 * epsilon)
3657
+ return false;
3658
+ if (x <= lo + epsilon && g > 0.0)
3659
+ return false;
3660
+ if (x >= hi - epsilon && g < 0.0)
3661
+ return false;
3662
+ return true;
3663
+ }
3664
+ function buildFreeSystem($this, energy, freeIndex, freeCount, f0, f1, f2) {
3665
+ var inductionVariable = 0;
3666
+ if (inductionVariable < freeCount)
3667
+ do {
3668
+ var p = inductionVariable;
3669
+ inductionVariable = inductionVariable + 1 | 0;
3670
+ var i = freeIndex[p];
3671
+ f0[p] = energy.h0__1[i];
3672
+ f1[p] = 0.0;
3673
+ f2[p] = 0.0;
3674
+ if ((p + 1 | 0) < freeCount) {
3675
+ var tmp0_subject = freeIndex[p + 1 | 0] - i | 0;
3676
+ if (tmp0_subject === 1) {
3677
+ f1[p] = energy.h1__1[i];
3678
+ } else if (tmp0_subject === 2) {
3679
+ f1[p] = energy.h2__1[i];
3680
+ }
3681
+ }
3682
+ if ((p + 2 | 0) < freeCount && (freeIndex[p + 2 | 0] - i | 0) === 2) {
3683
+ f2[p] = energy.h2__1[i];
3684
+ }
3685
+ }
3686
+ while (inductionVariable < freeCount);
3687
+ }
3688
+ function OffsetQp() {
3689
+ this.ARMIJO_C1__1 = 1.0E-4;
3690
+ this.MAX_BACKTRACKS_1 = 20;
3691
+ }
3692
+ protoOf(OffsetQp).solve_j37bz7_k$ = function (energy, lo, hi, seed, maxIterations, gradientTolerance, boundEpsilonM) {
3693
+ var n = energy.get_size_woubt6_k$();
3694
+ var tmp = 0;
3695
+ var tmp_0 = new Float64Array(n);
3696
+ while (tmp < n) {
3697
+ var tmp_1 = tmp;
3698
+ tmp_0[tmp_1] = coerceIn(seed[tmp_1], lo[tmp_1], hi[tmp_1]);
3699
+ tmp = tmp + 1 | 0;
3700
+ }
3701
+ var x = tmp_0;
3702
+ var g = new Float64Array(n);
3703
+ var scratch = new Float64Array(n);
3704
+ var direction = new Float64Array(n);
3705
+ var candidate = new Float64Array(n);
3706
+ energy.gradient_zecmby_k$(x, g);
3707
+ var referenceGradient = 0.0;
3708
+ var inductionVariable = 0;
3709
+ if (inductionVariable < n)
3710
+ do {
3711
+ var i = inductionVariable;
3712
+ inductionVariable = inductionVariable + 1 | 0;
3713
+ var tmp_2;
3714
+ if (isFree(this, x[i], lo[i], hi[i], g[i], boundEpsilonM)) {
3715
+ // Inline function 'kotlin.math.abs' call
3716
+ var x_0 = g[i];
3717
+ tmp_2 = Math.abs(x_0) > referenceGradient;
3718
+ } else {
3719
+ tmp_2 = false;
3720
+ }
3721
+ if (tmp_2) {
3722
+ // Inline function 'kotlin.math.abs' call
3723
+ var x_1 = g[i];
3724
+ referenceGradient = Math.abs(x_1);
3725
+ }
3726
+ }
3727
+ while (inductionVariable < n);
3728
+ if (referenceGradient <= 0.0)
3729
+ referenceGradient = 1.0;
3730
+ var iterations = 0;
3731
+ var converged = false;
3732
+ var relativeResidual = 0.0;
3733
+ var freeIndex = new Int32Array(n);
3734
+ var f0 = new Float64Array(n);
3735
+ var f1 = new Float64Array(n);
3736
+ var f2 = new Float64Array(n);
3737
+ var rhs = new Float64Array(n);
3738
+ $l$loop_3: while (iterations < maxIterations) {
3739
+ energy.gradient_zecmby_k$(x, g);
3740
+ var freeCount = 0;
3741
+ var residual = 0.0;
3742
+ var inductionVariable_0 = 0;
3743
+ if (inductionVariable_0 < n)
3744
+ do {
3745
+ var i_0 = inductionVariable_0;
3746
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3747
+ if (isFree(this, x[i_0], lo[i_0], hi[i_0], g[i_0], boundEpsilonM)) {
3748
+ var _unary__edvuaz = freeCount;
3749
+ freeCount = _unary__edvuaz + 1 | 0;
3750
+ freeIndex[_unary__edvuaz] = i_0;
3751
+ // Inline function 'kotlin.math.abs' call
3752
+ var x_2 = g[i_0];
3753
+ if (Math.abs(x_2) > residual) {
3754
+ // Inline function 'kotlin.math.abs' call
3755
+ var x_3 = g[i_0];
3756
+ residual = Math.abs(x_3);
3757
+ }
3758
+ }
3759
+ }
3760
+ while (inductionVariable_0 < n);
3761
+ relativeResidual = residual / referenceGradient;
3762
+ if (freeCount === 0 || relativeResidual <= gradientTolerance) {
3763
+ converged = true;
3764
+ break $l$loop_3;
3765
+ }
3766
+ buildFreeSystem(this, energy, freeIndex, freeCount, f0, f1, f2);
3767
+ var fa0 = copyOf(f0, freeCount);
3768
+ var fa1 = copyOf(f1, freeCount);
3769
+ var fa2 = copyOf(f2, freeCount);
3770
+ if (!BandedLdl_instance.factor_n459o6_k$(fa0, fa1, fa2)) {
3771
+ break $l$loop_3;
3772
+ }
3773
+ var inductionVariable_1 = 0;
3774
+ var last = freeCount;
3775
+ if (inductionVariable_1 < last)
3776
+ do {
3777
+ var p = inductionVariable_1;
3778
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3779
+ rhs[p] = -g[freeIndex[p]];
3780
+ }
3781
+ while (inductionVariable_1 < last);
3782
+ BandedLdl_instance.solveInPlace_jrw92v_k$(fa0, fa1, fa2, rhs);
3783
+ var inductionVariable_2 = 0;
3784
+ if (inductionVariable_2 < n)
3785
+ do {
3786
+ var i_1 = inductionVariable_2;
3787
+ inductionVariable_2 = inductionVariable_2 + 1 | 0;
3788
+ direction[i_1] = 0.0;
3789
+ }
3790
+ while (inductionVariable_2 < n);
3791
+ var inductionVariable_3 = 0;
3792
+ var last_0 = freeCount;
3793
+ if (inductionVariable_3 < last_0)
3794
+ do {
3795
+ var p_0 = inductionVariable_3;
3796
+ inductionVariable_3 = inductionVariable_3 + 1 | 0;
3797
+ direction[freeIndex[p_0]] = rhs[p_0];
3798
+ }
3799
+ while (inductionVariable_3 < last_0);
3800
+ var directionalDerivative = 0.0;
3801
+ var inductionVariable_4 = 0;
3802
+ var last_1 = freeCount;
3803
+ if (inductionVariable_4 < last_1)
3804
+ do {
3805
+ var p_1 = inductionVariable_4;
3806
+ inductionVariable_4 = inductionVariable_4 + 1 | 0;
3807
+ var i_2 = freeIndex[p_1];
3808
+ directionalDerivative = directionalDerivative + g[i_2] * direction[i_2];
3809
+ }
3810
+ while (inductionVariable_4 < last_1);
3811
+ if (directionalDerivative >= 0.0)
3812
+ break $l$loop_3;
3813
+ var current = energy.value_6wg803_k$(x, scratch);
3814
+ var step = 1.0;
3815
+ var accepted = false;
3816
+ var inductionVariable_5 = 0;
3817
+ if (inductionVariable_5 < 20)
3818
+ $l$loop_2: do {
3819
+ var attempt = inductionVariable_5;
3820
+ inductionVariable_5 = inductionVariable_5 + 1 | 0;
3821
+ var inductionVariable_6 = 0;
3822
+ if (inductionVariable_6 < n)
3823
+ do {
3824
+ var i_3 = inductionVariable_6;
3825
+ inductionVariable_6 = inductionVariable_6 + 1 | 0;
3826
+ candidate[i_3] = coerceIn(x[i_3] + step * direction[i_3], lo[i_3], hi[i_3]);
3827
+ }
3828
+ while (inductionVariable_6 < n);
3829
+ var trial = energy.value_6wg803_k$(candidate, scratch);
3830
+ if (trial <= current + 1.0E-4 * step * directionalDerivative) {
3831
+ accepted = true;
3832
+ break $l$loop_2;
3833
+ }
3834
+ step = step / 2.0;
3835
+ }
3836
+ while (inductionVariable_5 < 20);
3837
+ if (!accepted)
3838
+ break $l$loop_3;
3839
+ // Inline function 'kotlin.collections.copyInto' call
3840
+ var endIndex = candidate.length;
3841
+ // Inline function 'kotlin.js.unsafeCast' call
3842
+ // Inline function 'kotlin.js.asDynamic' call
3843
+ var tmp_3 = candidate;
3844
+ // Inline function 'kotlin.js.unsafeCast' call
3845
+ // Inline function 'kotlin.js.asDynamic' call
3846
+ arrayCopy(tmp_3, x, 0, 0, endIndex);
3847
+ iterations = iterations + 1 | 0;
3848
+ }
3849
+ var active = 0;
3850
+ var inductionVariable_7 = 0;
3851
+ if (inductionVariable_7 < n)
3852
+ do {
3853
+ var i_4 = inductionVariable_7;
3854
+ inductionVariable_7 = inductionVariable_7 + 1 | 0;
3855
+ if (x[i_4] <= lo[i_4] + boundEpsilonM || x[i_4] >= hi[i_4] - boundEpsilonM) {
3856
+ active = active + 1 | 0;
3857
+ }
3858
+ }
3859
+ while (inductionVariable_7 < n);
3860
+ return new QpResult(x, iterations, relativeResidual, converged, active);
3861
+ };
3862
+ var OffsetQp_instance;
3863
+ function OffsetQp_getInstance() {
3864
+ return OffsetQp_instance;
3865
+ }
3866
+ function Companion_12() {
3867
+ Companion_instance_13 = this;
3868
+ this.DEFAULT_1 = new CurvatureOptions();
3869
+ }
3870
+ var Companion_instance_13;
3871
+ function Companion_getInstance_15() {
3872
+ if (Companion_instance_13 == null)
3873
+ new Companion_12();
3874
+ return Companion_instance_13;
3875
+ }
3876
+ function CurvatureOptions(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) {
3877
+ Companion_getInstance_15();
3878
+ enabled = enabled === VOID ? true : enabled;
3879
+ geometrySmoothWindowM = geometrySmoothWindowM === VOID ? 3.0 : geometrySmoothWindowM;
3880
+ curvatureWindowsM = curvatureWindowsM === VOID ? listOf_0([3.0, 6.0, 12.0, 25.0]) : curvatureWindowsM;
3881
+ headingNoiseRad = headingNoiseRad === VOID ? 0.05 : headingNoiseRad;
3882
+ curvatureSmoothWindowM = curvatureSmoothWindowM === VOID ? 3.0 : curvatureSmoothWindowM;
3883
+ this.enabled_1 = enabled;
3884
+ this.geometrySmoothWindowM_1 = geometrySmoothWindowM;
3885
+ this.curvatureWindowsM_1 = curvatureWindowsM;
3886
+ this.headingNoiseRad_1 = headingNoiseRad;
3887
+ this.curvatureSmoothWindowM_1 = curvatureSmoothWindowM;
3888
+ // Inline function 'kotlin.require' call
3889
+ if (!(this.geometrySmoothWindowM_1 >= 0.0)) {
3890
+ var message = 'geometrySmoothWindowM must be >= 0';
3891
+ throw IllegalArgumentException_init_$Create$(toString(message));
3892
+ }
3893
+ // Inline function 'kotlin.collections.isNotEmpty' call
3894
+ // Inline function 'kotlin.require' call
3895
+ if (!!this.curvatureWindowsM_1.isEmpty_y1axqb_k$()) {
3896
+ var message_0 = 'at least one curvature window is required';
3897
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
3898
+ }
3899
+ var tmp0 = this.curvatureWindowsM_1;
3900
+ var tmp$ret$5;
3901
+ $l$block_0: {
3902
+ // Inline function 'kotlin.collections.all' call
3903
+ var tmp;
3904
+ if (isInterface(tmp0, Collection)) {
3905
+ tmp = tmp0.isEmpty_y1axqb_k$();
3906
+ } else {
3907
+ tmp = false;
3908
+ }
3909
+ if (tmp) {
3910
+ tmp$ret$5 = true;
3911
+ break $l$block_0;
3912
+ }
3913
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
3914
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
3915
+ var element = _iterator__ex2g4s.next_20eer_k$();
3916
+ if (!(element > 0.0)) {
3917
+ tmp$ret$5 = false;
3918
+ break $l$block_0;
3919
+ }
3920
+ }
3921
+ tmp$ret$5 = true;
3922
+ }
3923
+ // Inline function 'kotlin.require' call
3924
+ if (!tmp$ret$5) {
3925
+ var message_1 = 'curvature windows must be positive';
3926
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
3927
+ }
3928
+ var tmp0_0 = zipWithNext(this.curvatureWindowsM_1);
3929
+ var tmp$ret$9;
3930
+ $l$block_2: {
3931
+ // Inline function 'kotlin.collections.all' call
3932
+ var tmp_0;
3933
+ if (isInterface(tmp0_0, Collection)) {
3934
+ tmp_0 = tmp0_0.isEmpty_y1axqb_k$();
3935
+ } else {
3936
+ tmp_0 = false;
3937
+ }
3938
+ if (tmp_0) {
3939
+ tmp$ret$9 = true;
3940
+ break $l$block_2;
3941
+ }
3942
+ var _iterator__ex2g4s_0 = tmp0_0.iterator_jk1svi_k$();
3943
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
3944
+ var element_0 = _iterator__ex2g4s_0.next_20eer_k$();
3945
+ var a = element_0.component1_7eebsc_k$();
3946
+ var b = element_0.component2_7eebsb_k$();
3947
+ if (!(a < b)) {
3948
+ tmp$ret$9 = false;
3949
+ break $l$block_2;
3950
+ }
3951
+ }
3952
+ tmp$ret$9 = true;
3953
+ }
3954
+ // Inline function 'kotlin.require' call
3955
+ if (!tmp$ret$9) {
3956
+ var message_2 = 'curvature windows must be strictly ascending: ' + toString(this.curvatureWindowsM_1);
3957
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
3958
+ }
3959
+ // Inline function 'kotlin.require' call
3960
+ if (!(this.headingNoiseRad_1 > 0.0)) {
3961
+ var message_3 = 'headingNoiseRad must be positive';
3962
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
3963
+ }
3964
+ // Inline function 'kotlin.require' call
3965
+ if (!(this.curvatureSmoothWindowM_1 >= 0.0)) {
3966
+ var message_4 = 'curvatureSmoothWindowM must be >= 0';
3967
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
3968
+ }
3969
+ }
3970
+ protoOf(CurvatureOptions).copy_8k70ek_k$ = function (enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) {
3971
+ return new CurvatureOptions(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM);
3972
+ };
3973
+ protoOf(CurvatureOptions).copy$default_7y8gcg_k$ = function (enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM, $super) {
3974
+ enabled = enabled === VOID ? this.enabled_1 : enabled;
3975
+ geometrySmoothWindowM = geometrySmoothWindowM === VOID ? this.geometrySmoothWindowM_1 : geometrySmoothWindowM;
3976
+ curvatureWindowsM = curvatureWindowsM === VOID ? this.curvatureWindowsM_1 : curvatureWindowsM;
3977
+ headingNoiseRad = headingNoiseRad === VOID ? this.headingNoiseRad_1 : headingNoiseRad;
3978
+ curvatureSmoothWindowM = curvatureSmoothWindowM === VOID ? this.curvatureSmoothWindowM_1 : curvatureSmoothWindowM;
3979
+ return $super === VOID ? this.copy_8k70ek_k$(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) : $super.copy_8k70ek_k$.call(this, enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM);
3980
+ };
3981
+ protoOf(CurvatureOptions).toString = function () {
3982
+ return 'CurvatureOptions(enabled=' + this.enabled_1 + ', geometrySmoothWindowM=' + this.geometrySmoothWindowM_1 + ', curvatureWindowsM=' + toString(this.curvatureWindowsM_1) + ', headingNoiseRad=' + this.headingNoiseRad_1 + ', curvatureSmoothWindowM=' + this.curvatureSmoothWindowM_1 + ')';
3983
+ };
3984
+ protoOf(CurvatureOptions).hashCode = function () {
3985
+ var result = getBooleanHashCode(this.enabled_1);
3986
+ result = imul(result, 31) + getNumberHashCode(this.geometrySmoothWindowM_1) | 0;
3987
+ result = imul(result, 31) + hashCode(this.curvatureWindowsM_1) | 0;
3988
+ result = imul(result, 31) + getNumberHashCode(this.headingNoiseRad_1) | 0;
3989
+ result = imul(result, 31) + getNumberHashCode(this.curvatureSmoothWindowM_1) | 0;
3990
+ return result;
3991
+ };
3992
+ protoOf(CurvatureOptions).equals = function (other) {
3993
+ if (this === other)
3994
+ return true;
3995
+ if (!(other instanceof CurvatureOptions))
3996
+ return false;
3997
+ if (!(this.enabled_1 === other.enabled_1))
3998
+ return false;
3999
+ if (!equals(this.geometrySmoothWindowM_1, other.geometrySmoothWindowM_1))
4000
+ return false;
4001
+ if (!equals(this.curvatureWindowsM_1, other.curvatureWindowsM_1))
4002
+ return false;
4003
+ if (!equals(this.headingNoiseRad_1, other.headingNoiseRad_1))
4004
+ return false;
4005
+ if (!equals(this.curvatureSmoothWindowM_1, other.curvatureSmoothWindowM_1))
4006
+ return false;
4007
+ return true;
4008
+ };
4009
+ function PathCurvature() {
4010
+ }
4011
+ protoOf(PathCurvature).compute_s9yd16_k$ = function (path, options) {
4012
+ if (!options.enabled_1)
4013
+ return false;
4014
+ var tmp0_elvis_lhs = LocalFrame_instance.project_n982lp_k$(path, options.geometrySmoothWindowM_1);
4015
+ var tmp;
4016
+ if (tmp0_elvis_lhs == null) {
4017
+ return false;
4018
+ } else {
4019
+ tmp = tmp0_elvis_lhs;
4020
+ }
4021
+ var frame = tmp;
4022
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(frame);
4023
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(frame, toDoubleArray(options.curvatureWindowsM_1), options.headingNoiseRad_1, options.curvatureSmoothWindowM_1);
4024
+ var inductionVariable = 0;
4025
+ var last = path.size_1;
4026
+ if (inductionVariable < last)
4027
+ do {
4028
+ var i = inductionVariable;
4029
+ inductionVariable = inductionVariable + 1 | 0;
4030
+ path.setTrajectoryCurvature_yjmp8s_k$(i, frame.kappa_1[i]);
4031
+ }
4032
+ while (inductionVariable < last);
4033
+ return true;
4034
+ };
4035
+ var PathCurvature_instance;
4036
+ function PathCurvature_getInstance() {
4037
+ return PathCurvature_instance;
4038
+ }
4039
+ function PlanarFrame(x, y, s, theta, kappa, lat0, lon0, k) {
4040
+ this.x_1 = x;
4041
+ this.y_1 = y;
4042
+ this.s_1 = s;
4043
+ this.theta_1 = theta;
4044
+ this.kappa_1 = kappa;
4045
+ this.lat0__1 = lat0;
4046
+ this.lon0__1 = lon0;
4047
+ this.k_1 = k;
4048
+ }
4049
+ protoOf(PlanarFrame).get_size_woubt6_k$ = function () {
4050
+ return this.x_1.length;
4051
+ };
4052
+ function RacingLineReport(size, corners, centerlineCurvature, corridorLo, corridorHi, roadHalfWidthM, lateralOffsetM, trajectoryCurvature, newtonIterations, relativeGradient, converged, activeConstraints) {
4053
+ this.size_1 = size;
4054
+ this.corners_1 = corners;
4055
+ this.centerlineCurvature_1 = centerlineCurvature;
4056
+ this.corridorLo_1 = corridorLo;
4057
+ this.corridorHi_1 = corridorHi;
4058
+ this.roadHalfWidthM_1 = roadHalfWidthM;
4059
+ this.lateralOffsetM_1 = lateralOffsetM;
4060
+ this.trajectoryCurvature_1 = trajectoryCurvature;
4061
+ this.newtonIterations_1 = newtonIterations;
4062
+ this.relativeGradient_1 = relativeGradient;
4063
+ this.converged_1 = converged;
4064
+ this.activeConstraints_1 = activeConstraints;
4065
+ }
4066
+ protoOf(RacingLineReport).get_maxCorridorWidthM_7bycoc_k$ = function () {
4067
+ var m = 0.0;
4068
+ var inductionVariable = 0;
4069
+ var last = this.size_1;
4070
+ if (inductionVariable < last)
4071
+ do {
4072
+ var i = inductionVariable;
4073
+ inductionVariable = inductionVariable + 1 | 0;
4074
+ var w = this.corridorHi_1[i] - this.corridorLo_1[i];
4075
+ if (w > m)
4076
+ m = w;
4077
+ }
4078
+ while (inductionVariable < last);
4079
+ return m;
4080
+ };
4081
+ function project($this, path, options) {
4082
+ var tmp0_elvis_lhs = LocalFrame_instance.project_n982lp_k$(path, options.curvature_1.geometrySmoothWindowM_1);
4083
+ var tmp;
4084
+ if (tmp0_elvis_lhs == null) {
4085
+ return null;
4086
+ } else {
4087
+ tmp = tmp0_elvis_lhs;
4088
+ }
4089
+ var frame = tmp;
4090
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(frame);
4091
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(frame, toDoubleArray(options.curvature_1.curvatureWindowsM_1), options.curvature_1.headingNoiseRad_1, options.curvature_1.curvatureSmoothWindowM_1);
4092
+ return frame;
4093
+ }
4094
+ function analyzeFrame($this, path, frame, options) {
4095
+ var width = Corridor_instance.resolveWidth_feg61f_k$(path, frame, options);
4096
+ var corners = CornerDetector_instance.detect_cq5dkx_k$(frame, options, width);
4097
+ var bounds = Corridor_instance.build_fyfb0s_k$(frame, width, options);
4098
+ var tmp = 0;
4099
+ var tmp_0 = frame.get_size_woubt6_k$();
4100
+ var tmp_1 = new Float64Array(tmp_0);
4101
+ while (tmp < tmp_0) {
4102
+ var tmp_2 = tmp;
4103
+ tmp_1[tmp_2] = coerceIn(0.0, bounds.lo_1[tmp_2], bounds.hi_1[tmp_2]);
4104
+ tmp = tmp + 1 | 0;
4105
+ }
4106
+ var center = tmp_1;
4107
+ var objectiveKappa = 1.0 / options.objectiveRadiusM_1;
4108
+ var tmp_3 = 0;
4109
+ var tmp_4 = frame.get_size_woubt6_k$();
4110
+ var tmp_5 = new Float64Array(tmp_4);
4111
+ while (tmp_3 < tmp_4) {
4112
+ var tmp_6 = tmp_3;
4113
+ var tmp_7;
4114
+ // Inline function 'kotlin.math.abs' call
4115
+ var x = frame.kappa_1[tmp_6];
4116
+ if (Math.abs(x) > objectiveKappa) {
4117
+ tmp_7 = 1.0;
4118
+ } else {
4119
+ tmp_7 = 0.0;
4120
+ }
4121
+ tmp_5[tmp_6] = tmp_7;
4122
+ tmp_3 = tmp_3 + 1 | 0;
4123
+ }
4124
+ var rho = tmp_5;
4125
+ var energy = Companion_instance_12.assemble_miimn7_k$(frame, center, rho, options.steeringLengthM_1, options.centeringLengthM_1);
4126
+ var seed = center;
4127
+ var solved = OffsetQp_instance.solve_j37bz7_k$(energy, bounds.lo_1, bounds.hi_1, seed, options.maxNewtonIterations_1, options.gradientTolerance_1, options.boundEpsilonM_1);
4128
+ var trajectoryCurvature = measureOffsetCurvature($this, frame, solved.offset_1, options);
4129
+ var tmp_8 = frame.get_size_woubt6_k$();
4130
+ // Inline function 'kotlin.collections.copyOf' call
4131
+ // Inline function 'kotlin.js.asDynamic' call
4132
+ var tmp$ret$3 = frame.kappa_1.slice();
4133
+ return new RacingLineReport(tmp_8, corners, tmp$ret$3, bounds.lo_1, bounds.hi_1, bounds.halfWidthM_1, solved.offset_1, trajectoryCurvature, solved.iterations_1, solved.gradientInfNorm_1, solved.converged_1, solved.activeConstraints_1);
4134
+ }
4135
+ function measureOffsetCurvature($this, frame, offset, options) {
4136
+ var size = frame.get_size_woubt6_k$();
4137
+ var x = new Float64Array(size);
4138
+ var y = new Float64Array(size);
4139
+ var inductionVariable = 0;
4140
+ if (inductionVariable < size)
4141
+ do {
4142
+ var i = inductionVariable;
4143
+ inductionVariable = inductionVariable + 1 | 0;
4144
+ var tmp = frame.x_1[i];
4145
+ var tmp_0 = offset[i];
4146
+ // Inline function 'kotlin.math.sin' call
4147
+ var x_0 = frame.theta_1[i];
4148
+ x[i] = tmp - tmp_0 * Math.sin(x_0);
4149
+ var tmp_1 = frame.y_1[i];
4150
+ var tmp_2 = offset[i];
4151
+ // Inline function 'kotlin.math.cos' call
4152
+ var x_1 = frame.theta_1[i];
4153
+ y[i] = tmp_1 + tmp_2 * Math.cos(x_1);
4154
+ }
4155
+ while (inductionVariable < size);
4156
+ var s = new Float64Array(size);
4157
+ LocalFrame_instance.arclengthOf_yiuhr5_k$(x, y, s);
4158
+ var line = new PlanarFrame(x, y, s, new Float64Array(size), new Float64Array(size), frame.lat0__1, frame.lon0__1, frame.k_1);
4159
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(line);
4160
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(line, toDoubleArray(options.curvature_1.curvatureWindowsM_1), options.curvature_1.headingNoiseRad_1, options.curvature_1.curvatureSmoothWindowM_1);
4161
+ return line.kappa_1;
4162
+ }
4163
+ function RacingLine() {
4164
+ }
4165
+ protoOf(RacingLine).analyze_ikwae4_k$ = function (path, options) {
4166
+ var tmp0_elvis_lhs = project(this, path, options);
4167
+ var tmp;
4168
+ if (tmp0_elvis_lhs == null) {
4169
+ return null;
4170
+ } else {
4171
+ tmp = tmp0_elvis_lhs;
4172
+ }
4173
+ var frame = tmp;
4174
+ return analyzeFrame(this, path, frame, options);
4175
+ };
4176
+ protoOf(RacingLine).compute_uyx32p_k$ = function (source, options) {
4177
+ var tmp0_elvis_lhs = project(this, source, options);
4178
+ var tmp;
4179
+ if (tmp0_elvis_lhs == null) {
4180
+ return source.copy_1tks5_k$();
4181
+ } else {
4182
+ tmp = tmp0_elvis_lhs;
4183
+ }
4184
+ var frame = tmp;
4185
+ var report = analyzeFrame(this, source, frame, options);
4186
+ var out = new Path(source.size_1);
4187
+ var inductionVariable = 0;
4188
+ var last = source.size_1;
4189
+ if (inductionVariable < last)
4190
+ do {
4191
+ var i = inductionVariable;
4192
+ inductionVariable = inductionVariable + 1 | 0;
4193
+ var _iterator__ex2g4s = get_entries().iterator_jk1svi_k$();
4194
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4195
+ var field = _iterator__ex2g4s.next_20eer_k$();
4196
+ out.set_b3ze83_k$(i, field, source.get_z3le6l_k$(i, field));
4197
+ }
4198
+ }
4199
+ while (inductionVariable < last);
4200
+ var inductionVariable_0 = 0;
4201
+ var last_0 = source.size_1;
4202
+ if (inductionVariable_0 < last_0)
4203
+ do {
4204
+ var i_0 = inductionVariable_0;
4205
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
4206
+ var n = report.lateralOffsetM_1[i_0];
4207
+ // Inline function 'kotlin.math.sin' call
4208
+ var x = frame.theta_1[i_0];
4209
+ var nx = -Math.sin(x);
4210
+ // Inline function 'kotlin.math.cos' call
4211
+ var x_0 = frame.theta_1[i_0];
4212
+ var ny = Math.cos(x_0);
4213
+ var x_1 = frame.x_1[i_0] + n * nx;
4214
+ var y = frame.y_1[i_0] + n * ny;
4215
+ out.setSourceLatitude_jzh9ix_k$(i_0, source.latitude_gb4iok_k$(i_0));
4216
+ out.setSourceLongitude_xmvvyo_k$(i_0, source.longitude_a9xl_k$(i_0));
4217
+ var latLon = LocalFrame_instance.unproject_ym27oh_k$(frame, x_1, y);
4218
+ out.setLatitude_skkzf0_k$(i_0, latLon[0]);
4219
+ out.setLongitude_k0bc8l_k$(i_0, latLon[1]);
4220
+ out.setLateralOffset_k5uegq_k$(i_0, n);
4221
+ out.setTrajectoryCurvature_yjmp8s_k$(i_0, report.trajectoryCurvature_1[i_0]);
4222
+ out.setRoadWidth_g0vcte_k$(i_0, source.roadWidth_7zv9qq_k$(i_0));
4223
+ }
4224
+ while (inductionVariable_0 < last_0);
4225
+ out.computeDerivedData_uoxpeo_k$();
4226
+ PathCurvature_instance.compute_s9yd16_k$(out, options.curvature_1.copy$default_7y8gcg_k$(true));
4227
+ return out;
4228
+ };
4229
+ var RacingLine_instance;
4230
+ function RacingLine_getInstance() {
4231
+ return RacingLine_instance;
4232
+ }
4233
+ function CorridorMode$Companion$byId$lambda(it) {
4234
+ return it.get_id_kntnx8_k$();
4235
+ }
4236
+ var static_init_called_1;
4237
+ function static_init_1() {
4238
+ if (static_init_called_1)
4239
+ return Unit_instance;
4240
+ static_init_called_1 = true;
4241
+ CorridorMode_LANE_instance = new CorridorMode('LANE', 0);
4242
+ CorridorMode_LANE_LEFT_instance = new CorridorMode('LANE_LEFT', 1);
4243
+ CorridorMode_FULL_ROAD_instance = new CorridorMode('FULL_ROAD', 2);
4244
+ if (Companion_instance_14 == null) {
4245
+ Companion_instance;
4246
+ new Companion_13();
4247
+ }
4248
+ }
4249
+ var CorridorMode_LANE_instance;
4250
+ var CorridorMode_LANE_LEFT_instance;
4251
+ var CorridorMode_FULL_ROAD_instance;
4252
+ function Companion_13() {
4253
+ }
4254
+ protoOf(Companion_13).byId_8gmd94_k$ = function (name) {
4255
+ var tmp0 = get_entries_2();
4256
+ var tmp$ret$0;
4257
+ $l$block: {
4258
+ // Inline function 'kotlin.collections.firstOrNull' call
4259
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
4260
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4261
+ var element = _iterator__ex2g4s.next_20eer_k$();
4262
+ if (equals_0(element.get_id_kntnx8_k$(), name, true) || equals_0(element.name_1, name, true)) {
4263
+ tmp$ret$0 = element;
4264
+ break $l$block;
4265
+ }
4266
+ }
4267
+ tmp$ret$0 = null;
4268
+ }
4269
+ var tmp0_elvis_lhs = tmp$ret$0;
4270
+ var tmp;
4271
+ if (tmp0_elvis_lhs == null) {
4272
+ var tmp_0 = get_entries_2();
4273
+ throw IllegalArgumentException_init_$Create$("Unknown corridor '" + name + "': expected one of " + joinToString(tmp_0, ', ', VOID, VOID, VOID, VOID, CorridorMode$Companion$byId$lambda));
4274
+ } else {
4275
+ tmp = tmp0_elvis_lhs;
4276
+ }
4277
+ return tmp;
4278
+ };
4279
+ var Companion_instance_14;
4280
+ function Companion_getInstance_16() {
4281
+ return Companion_instance_14;
4282
+ }
4283
+ function values_1() {
4284
+ static_init_1();
4285
+ return [CorridorMode_LANE_getInstance(), CorridorMode_LANE_LEFT_getInstance(), CorridorMode_FULL_ROAD_getInstance()];
4286
+ }
4287
+ function get_entries_2() {
4288
+ static_init_1();
4289
+ if ($ENTRIES_1 == null)
4290
+ $ENTRIES_1 = enumEntries(values_1());
4291
+ return $ENTRIES_1;
4292
+ }
4293
+ var $ENTRIES_1;
4294
+ function CorridorMode(name, ordinal) {
4295
+ Enum.call(this, name, ordinal);
4296
+ }
4297
+ protoOf(CorridorMode).get_id_kntnx8_k$ = function () {
4298
+ var tmp;
4299
+ switch (this.ordinal_1) {
4300
+ case 0:
4301
+ tmp = 'lane';
4302
+ break;
4303
+ case 1:
4304
+ tmp = 'lane-left';
4305
+ break;
4306
+ case 2:
4307
+ tmp = 'full-road';
4308
+ break;
4309
+ default:
4310
+ noWhenBranchMatchedException();
4311
+ break;
4312
+ }
4313
+ return tmp;
4314
+ };
4315
+ var static_init_called_2;
4316
+ function static_init_2() {
4317
+ if (static_init_called_2)
4318
+ return Unit_instance;
4319
+ static_init_called_2 = true;
4320
+ CornerKind_GENTLE_instance = new CornerKind('GENTLE', 0);
4321
+ CornerKind_CORNER_instance = new CornerKind('CORNER', 1);
4322
+ CornerKind_HAIRPIN_instance = new CornerKind('HAIRPIN', 2);
4323
+ }
4324
+ var CornerKind_GENTLE_instance;
4325
+ var CornerKind_CORNER_instance;
4326
+ var CornerKind_HAIRPIN_instance;
4327
+ function CornerKind(name, ordinal) {
4328
+ Enum.call(this, name, ordinal);
4329
+ }
4330
+ function Companion_14() {
4331
+ Companion_instance_15 = this;
4332
+ this.DEFAULT_1 = new RacingLineOptions();
4333
+ }
4334
+ var Companion_instance_15;
4335
+ function Companion_getInstance_17() {
4336
+ if (Companion_instance_15 == null)
4337
+ new Companion_14();
4338
+ return Companion_instance_15;
4339
+ }
4340
+ function RacingLineOptions(enabled, defaultRoadWidthM, edgeMarginM, corridor, cornerEnterRadiusM, cornerExitRadiusM, minCornerLengthM, minCornerTurnDeg, hairpinTurnDeg, gentleRadiusM, regularityFactor, selfProximityGapM, straightRunM, straightRadiusM, widthSmoothWindowM, objectiveRadiusM, steeringLengthM, centeringLengthM, maxNewtonIterations, gradientTolerance, boundEpsilonM, curvature, simplifyToleranceCapM) {
4341
+ Companion_getInstance_17();
4342
+ enabled = enabled === VOID ? false : enabled;
4343
+ defaultRoadWidthM = defaultRoadWidthM === VOID ? 6.0 : defaultRoadWidthM;
4344
+ edgeMarginM = edgeMarginM === VOID ? 0.5 : edgeMarginM;
4345
+ corridor = corridor === VOID ? CorridorMode_LANE_getInstance() : corridor;
4346
+ cornerEnterRadiusM = cornerEnterRadiusM === VOID ? 120.0 : cornerEnterRadiusM;
4347
+ cornerExitRadiusM = cornerExitRadiusM === VOID ? 250.0 : cornerExitRadiusM;
4348
+ minCornerLengthM = minCornerLengthM === VOID ? 8.0 : minCornerLengthM;
4349
+ minCornerTurnDeg = minCornerTurnDeg === VOID ? 8.0 : minCornerTurnDeg;
4350
+ hairpinTurnDeg = hairpinTurnDeg === VOID ? 150.0 : hairpinTurnDeg;
4351
+ gentleRadiusM = gentleRadiusM === VOID ? 100.0 : gentleRadiusM;
4352
+ regularityFactor = regularityFactor === VOID ? 0.85 : regularityFactor;
4353
+ selfProximityGapM = selfProximityGapM === VOID ? 60.0 : selfProximityGapM;
4354
+ straightRunM = straightRunM === VOID ? 150.0 : straightRunM;
4355
+ straightRadiusM = straightRadiusM === VOID ? 500.0 : straightRadiusM;
4356
+ widthSmoothWindowM = widthSmoothWindowM === VOID ? 20.0 : widthSmoothWindowM;
4357
+ objectiveRadiusM = objectiveRadiusM === VOID ? 200.0 : objectiveRadiusM;
4358
+ steeringLengthM = steeringLengthM === VOID ? 20.0 : steeringLengthM;
4359
+ centeringLengthM = centeringLengthM === VOID ? 60.0 : centeringLengthM;
4360
+ maxNewtonIterations = maxNewtonIterations === VOID ? 200 : maxNewtonIterations;
4361
+ gradientTolerance = gradientTolerance === VOID ? 1.0E-8 : gradientTolerance;
4362
+ boundEpsilonM = boundEpsilonM === VOID ? 1.0E-6 : boundEpsilonM;
4363
+ curvature = curvature === VOID ? Companion_getInstance_15().DEFAULT_1 : curvature;
4364
+ simplifyToleranceCapM = simplifyToleranceCapM === VOID ? 2.0 : simplifyToleranceCapM;
4365
+ this.enabled_1 = enabled;
4366
+ this.defaultRoadWidthM_1 = defaultRoadWidthM;
4367
+ this.edgeMarginM_1 = edgeMarginM;
4368
+ this.corridor_1 = corridor;
4369
+ this.cornerEnterRadiusM_1 = cornerEnterRadiusM;
4370
+ this.cornerExitRadiusM_1 = cornerExitRadiusM;
4371
+ this.minCornerLengthM_1 = minCornerLengthM;
4372
+ this.minCornerTurnDeg_1 = minCornerTurnDeg;
4373
+ this.hairpinTurnDeg_1 = hairpinTurnDeg;
4374
+ this.gentleRadiusM_1 = gentleRadiusM;
4375
+ this.regularityFactor_1 = regularityFactor;
4376
+ this.selfProximityGapM_1 = selfProximityGapM;
4377
+ this.straightRunM_1 = straightRunM;
4378
+ this.straightRadiusM_1 = straightRadiusM;
4379
+ this.widthSmoothWindowM_1 = widthSmoothWindowM;
4380
+ this.objectiveRadiusM_1 = objectiveRadiusM;
4381
+ this.steeringLengthM_1 = steeringLengthM;
4382
+ this.centeringLengthM_1 = centeringLengthM;
4383
+ this.maxNewtonIterations_1 = maxNewtonIterations;
4384
+ this.gradientTolerance_1 = gradientTolerance;
4385
+ this.boundEpsilonM_1 = boundEpsilonM;
4386
+ this.curvature_1 = curvature;
4387
+ this.simplifyToleranceCapM_1 = simplifyToleranceCapM;
4388
+ // Inline function 'kotlin.require' call
4389
+ if (!(this.defaultRoadWidthM_1 > 0.0)) {
4390
+ var message = 'defaultRoadWidthM must be > 0';
4391
+ throw IllegalArgumentException_init_$Create$(toString(message));
4392
+ }
4393
+ // Inline function 'kotlin.require' call
4394
+ if (!(this.edgeMarginM_1 >= 0.0)) {
4395
+ var message_0 = 'edgeMarginM must be >= 0';
4396
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
4397
+ }
4398
+ // Inline function 'kotlin.require' call
4399
+ if (!(this.cornerEnterRadiusM_1 > 0.0 && this.cornerExitRadiusM_1 > 0.0)) {
4400
+ var message_1 = 'corner radii must be > 0';
4401
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
4402
+ }
4403
+ // Inline function 'kotlin.require' call
4404
+ if (!(this.cornerExitRadiusM_1 >= this.cornerEnterRadiusM_1)) {
4405
+ var message_2 = 'cornerExitRadiusM (' + this.cornerExitRadiusM_1 + ') must be >= cornerEnterRadiusM ' + ('(' + this.cornerEnterRadiusM_1 + '): a corner has to be harder to open than to keep open, or ') + 'the hysteresis runs backwards and corners flicker';
4406
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
4407
+ }
4408
+ // Inline function 'kotlin.require' call
4409
+ if (!(this.regularityFactor_1 > 0.0 && this.regularityFactor_1 < 1.0)) {
4410
+ var message_3 = 'regularityFactor must be in (0, 1) \u2014 at 1.0 the offset map folds';
4411
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
4412
+ }
4413
+ // Inline function 'kotlin.require' call
4414
+ if (!(this.selfProximityGapM_1 > 0.0)) {
4415
+ var message_4 = 'selfProximityGapM must be > 0';
4416
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
4417
+ }
4418
+ // Inline function 'kotlin.require' call
4419
+ if (!(this.widthSmoothWindowM_1 >= 0.0)) {
4420
+ var message_5 = 'widthSmoothWindowM must be >= 0';
4421
+ throw IllegalArgumentException_init_$Create$(toString(message_5));
4422
+ }
4423
+ // Inline function 'kotlin.require' call
4424
+ if (!(this.objectiveRadiusM_1 > 0.0)) {
4425
+ var message_6 = 'objectiveRadiusM must be > 0';
4426
+ throw IllegalArgumentException_init_$Create$(toString(message_6));
4427
+ }
4428
+ // Inline function 'kotlin.require' call
4429
+ if (!(this.steeringLengthM_1 > 0.0)) {
4430
+ var message_7 = 'steeringLengthM must be > 0';
4431
+ throw IllegalArgumentException_init_$Create$(toString(message_7));
4432
+ }
4433
+ // Inline function 'kotlin.require' call
4434
+ if (!(this.centeringLengthM_1 > 0.0)) {
4435
+ var message_8 = 'centeringLengthM must be > 0';
4436
+ throw IllegalArgumentException_init_$Create$(toString(message_8));
4437
+ }
4438
+ // Inline function 'kotlin.require' call
4439
+ if (!(this.maxNewtonIterations_1 > 0)) {
4440
+ var message_9 = 'maxNewtonIterations must be > 0';
4441
+ throw IllegalArgumentException_init_$Create$(toString(message_9));
4442
+ }
4443
+ // Inline function 'kotlin.require' call
4444
+ if (!(this.gradientTolerance_1 > 0.0)) {
4445
+ var message_10 = 'gradientTolerance must be > 0';
4446
+ throw IllegalArgumentException_init_$Create$(toString(message_10));
4447
+ }
4448
+ // Inline function 'kotlin.require' call
4449
+ if (!(this.boundEpsilonM_1 > 0.0)) {
4450
+ var message_11 = 'boundEpsilonM must be > 0';
4451
+ throw IllegalArgumentException_init_$Create$(toString(message_11));
4452
+ }
4453
+ }
4454
+ protoOf(RacingLineOptions).toString = function () {
4455
+ return 'RacingLineOptions(enabled=' + this.enabled_1 + ', defaultRoadWidthM=' + this.defaultRoadWidthM_1 + ', edgeMarginM=' + this.edgeMarginM_1 + ', corridor=' + this.corridor_1.toString() + ', cornerEnterRadiusM=' + this.cornerEnterRadiusM_1 + ', cornerExitRadiusM=' + this.cornerExitRadiusM_1 + ', minCornerLengthM=' + this.minCornerLengthM_1 + ', minCornerTurnDeg=' + this.minCornerTurnDeg_1 + ', hairpinTurnDeg=' + this.hairpinTurnDeg_1 + ', gentleRadiusM=' + this.gentleRadiusM_1 + ', regularityFactor=' + this.regularityFactor_1 + ', selfProximityGapM=' + this.selfProximityGapM_1 + ', straightRunM=' + this.straightRunM_1 + ', straightRadiusM=' + this.straightRadiusM_1 + ', widthSmoothWindowM=' + this.widthSmoothWindowM_1 + ', objectiveRadiusM=' + this.objectiveRadiusM_1 + ', steeringLengthM=' + this.steeringLengthM_1 + ', centeringLengthM=' + this.centeringLengthM_1 + ', maxNewtonIterations=' + this.maxNewtonIterations_1 + ', gradientTolerance=' + this.gradientTolerance_1 + ', boundEpsilonM=' + this.boundEpsilonM_1 + ', curvature=' + this.curvature_1.toString() + ', simplifyToleranceCapM=' + this.simplifyToleranceCapM_1 + ')';
4456
+ };
4457
+ protoOf(RacingLineOptions).hashCode = function () {
4458
+ var result = getBooleanHashCode(this.enabled_1);
4459
+ result = imul(result, 31) + getNumberHashCode(this.defaultRoadWidthM_1) | 0;
4460
+ result = imul(result, 31) + getNumberHashCode(this.edgeMarginM_1) | 0;
4461
+ result = imul(result, 31) + this.corridor_1.hashCode() | 0;
4462
+ result = imul(result, 31) + getNumberHashCode(this.cornerEnterRadiusM_1) | 0;
4463
+ result = imul(result, 31) + getNumberHashCode(this.cornerExitRadiusM_1) | 0;
4464
+ result = imul(result, 31) + getNumberHashCode(this.minCornerLengthM_1) | 0;
4465
+ result = imul(result, 31) + getNumberHashCode(this.minCornerTurnDeg_1) | 0;
4466
+ result = imul(result, 31) + getNumberHashCode(this.hairpinTurnDeg_1) | 0;
4467
+ result = imul(result, 31) + getNumberHashCode(this.gentleRadiusM_1) | 0;
4468
+ result = imul(result, 31) + getNumberHashCode(this.regularityFactor_1) | 0;
4469
+ result = imul(result, 31) + getNumberHashCode(this.selfProximityGapM_1) | 0;
4470
+ result = imul(result, 31) + getNumberHashCode(this.straightRunM_1) | 0;
4471
+ result = imul(result, 31) + getNumberHashCode(this.straightRadiusM_1) | 0;
4472
+ result = imul(result, 31) + getNumberHashCode(this.widthSmoothWindowM_1) | 0;
4473
+ result = imul(result, 31) + getNumberHashCode(this.objectiveRadiusM_1) | 0;
4474
+ result = imul(result, 31) + getNumberHashCode(this.steeringLengthM_1) | 0;
4475
+ result = imul(result, 31) + getNumberHashCode(this.centeringLengthM_1) | 0;
4476
+ result = imul(result, 31) + this.maxNewtonIterations_1 | 0;
4477
+ result = imul(result, 31) + getNumberHashCode(this.gradientTolerance_1) | 0;
4478
+ result = imul(result, 31) + getNumberHashCode(this.boundEpsilonM_1) | 0;
4479
+ result = imul(result, 31) + this.curvature_1.hashCode() | 0;
4480
+ result = imul(result, 31) + getNumberHashCode(this.simplifyToleranceCapM_1) | 0;
4481
+ return result;
4482
+ };
4483
+ protoOf(RacingLineOptions).equals = function (other) {
4484
+ if (this === other)
4485
+ return true;
4486
+ if (!(other instanceof RacingLineOptions))
4487
+ return false;
4488
+ if (!(this.enabled_1 === other.enabled_1))
4489
+ return false;
4490
+ if (!equals(this.defaultRoadWidthM_1, other.defaultRoadWidthM_1))
4491
+ return false;
4492
+ if (!equals(this.edgeMarginM_1, other.edgeMarginM_1))
4493
+ return false;
4494
+ if (!this.corridor_1.equals(other.corridor_1))
4495
+ return false;
4496
+ if (!equals(this.cornerEnterRadiusM_1, other.cornerEnterRadiusM_1))
4497
+ return false;
4498
+ if (!equals(this.cornerExitRadiusM_1, other.cornerExitRadiusM_1))
4499
+ return false;
4500
+ if (!equals(this.minCornerLengthM_1, other.minCornerLengthM_1))
4501
+ return false;
4502
+ if (!equals(this.minCornerTurnDeg_1, other.minCornerTurnDeg_1))
4503
+ return false;
4504
+ if (!equals(this.hairpinTurnDeg_1, other.hairpinTurnDeg_1))
4505
+ return false;
4506
+ if (!equals(this.gentleRadiusM_1, other.gentleRadiusM_1))
4507
+ return false;
4508
+ if (!equals(this.regularityFactor_1, other.regularityFactor_1))
4509
+ return false;
4510
+ if (!equals(this.selfProximityGapM_1, other.selfProximityGapM_1))
4511
+ return false;
4512
+ if (!equals(this.straightRunM_1, other.straightRunM_1))
4513
+ return false;
4514
+ if (!equals(this.straightRadiusM_1, other.straightRadiusM_1))
4515
+ return false;
4516
+ if (!equals(this.widthSmoothWindowM_1, other.widthSmoothWindowM_1))
4517
+ return false;
4518
+ if (!equals(this.objectiveRadiusM_1, other.objectiveRadiusM_1))
4519
+ return false;
4520
+ if (!equals(this.steeringLengthM_1, other.steeringLengthM_1))
4521
+ return false;
4522
+ if (!equals(this.centeringLengthM_1, other.centeringLengthM_1))
4523
+ return false;
4524
+ if (!(this.maxNewtonIterations_1 === other.maxNewtonIterations_1))
4525
+ return false;
4526
+ if (!equals(this.gradientTolerance_1, other.gradientTolerance_1))
4527
+ return false;
4528
+ if (!equals(this.boundEpsilonM_1, other.boundEpsilonM_1))
4529
+ return false;
4530
+ if (!this.curvature_1.equals(other.curvature_1))
4531
+ return false;
4532
+ if (!equals(this.simplifyToleranceCapM_1, other.simplifyToleranceCapM_1))
4533
+ return false;
4534
+ return true;
4535
+ };
4536
+ function CorridorMode_LANE_getInstance() {
4537
+ static_init_1();
4538
+ return CorridorMode_LANE_instance;
4539
+ }
4540
+ function CorridorMode_LANE_LEFT_getInstance() {
4541
+ static_init_1();
4542
+ return CorridorMode_LANE_LEFT_instance;
4543
+ }
4544
+ function CorridorMode_FULL_ROAD_getInstance() {
4545
+ static_init_1();
4546
+ return CorridorMode_FULL_ROAD_instance;
4547
+ }
4548
+ function CornerKind_GENTLE_getInstance() {
4549
+ static_init_2();
4550
+ return CornerKind_GENTLE_instance;
4551
+ }
4552
+ function CornerKind_CORNER_getInstance() {
4553
+ static_init_2();
4554
+ return CornerKind_CORNER_instance;
4555
+ }
4556
+ function CornerKind_HAIRPIN_getInstance() {
4557
+ static_init_2();
4558
+ return CornerKind_HAIRPIN_instance;
4559
+ }
4560
+ function get_POWER_PROVIDER_KEYS() {
4561
+ _init_properties_EngineJsApi_kt__9bputf();
4562
+ return POWER_PROVIDER_KEYS;
4563
+ }
4564
+ var POWER_PROVIDER_KEYS;
4565
+ function get_CYCLIST_KEYS() {
4566
+ _init_properties_EngineJsApi_kt__9bputf();
4567
+ return CYCLIST_KEYS;
4568
+ }
4569
+ var CYCLIST_KEYS;
4570
+ function get_BIKE_KEYS() {
4571
+ _init_properties_EngineJsApi_kt__9bputf();
4572
+ return BIKE_KEYS;
4573
+ }
4574
+ var BIKE_KEYS;
4575
+ function get_WIND_KEYS() {
4576
+ _init_properties_EngineJsApi_kt__9bputf();
4577
+ return WIND_KEYS;
4578
+ }
4579
+ var WIND_KEYS;
4580
+ function get_ENHANCE_OPTIONS_KEYS() {
4581
+ _init_properties_EngineJsApi_kt__9bputf();
4582
+ return ENHANCE_OPTIONS_KEYS;
4583
+ }
4584
+ var ENHANCE_OPTIONS_KEYS;
4585
+ function parseGpxWaypoints(xml) {
4586
+ _init_properties_EngineJsApi_kt__9bputf();
4587
+ // Inline function 'kotlin.collections.map' call
4588
+ var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
4589
+ // Inline function 'kotlin.collections.mapTo' call
4590
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
4591
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
4592
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4593
+ var item = _iterator__ex2g4s.next_20eer_k$();
4594
+ var tmp$ret$2 = waypointObj(item);
4595
+ destination.add_utx5q5_k$(tmp$ret$2);
4596
+ }
4597
+ // Inline function 'kotlin.collections.toTypedArray' call
4598
+ return copyToArray(destination);
4599
+ }
4600
+ function parseGpx(xml) {
4601
+ _init_properties_EngineJsApi_kt__9bputf();
4602
+ return firstTrackAsPath(GpxParser_instance.parse$default_ez0f31_k$(xml));
4603
+ }
4604
+ function parseGpxTracks(xml) {
4605
+ _init_properties_EngineJsApi_kt__9bputf();
4606
+ // Inline function 'kotlin.collections.toTypedArray' call
4607
+ var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
4608
+ return copyToArray(this_0);
4609
+ }
4610
+ function parseGpxSegments(xml) {
4611
+ _init_properties_EngineJsApi_kt__9bputf();
4612
+ // Inline function 'kotlin.collections.toTypedArray' call
4613
+ var this_0 = segmentsAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
4614
+ return copyToArray(this_0);
4615
+ }
4616
+ function parseGpxTracksOnly(xml) {
4617
+ _init_properties_EngineJsApi_kt__9bputf();
4618
+ // Inline function 'kotlin.collections.toTypedArray' call
4619
+ var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_TRACK_getInstance()));
4620
+ return copyToArray(this_0);
4621
+ }
4622
+ function parseGpxRoutesOnly(xml) {
4623
+ _init_properties_EngineJsApi_kt__9bputf();
4624
+ // Inline function 'kotlin.collections.toTypedArray' call
4625
+ var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_ROUTE_getInstance()));
4626
+ return copyToArray(this_0);
4627
+ }
4628
+ function writeGpxTracks(paths, waypoints, writeExtensions) {
4629
+ var tmp;
4630
+ if (waypoints === VOID) {
4631
+ // Inline function 'kotlin.emptyArray' call
4632
+ tmp = [];
4633
+ } else {
4634
+ tmp = waypoints;
4635
+ }
4636
+ waypoints = tmp;
4637
+ writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4638
+ _init_properties_EngineJsApi_kt__9bputf();
4639
+ var tmp_0 = GpxWriter_instance;
4640
+ var tmp_1 = toList(paths);
4641
+ // Inline function 'kotlin.collections.map' call
4642
+ // Inline function 'kotlin.collections.mapTo' call
4643
+ var destination = ArrayList_init_$Create$_0(waypoints.length);
4644
+ var inductionVariable = 0;
4645
+ var last = waypoints.length;
4646
+ while (inductionVariable < last) {
4647
+ var item = waypoints[inductionVariable];
4648
+ inductionVariable = inductionVariable + 1 | 0;
4649
+ var tmp$ret$3 = toGpxWaypoint(item);
4650
+ destination.add_utx5q5_k$(tmp$ret$3);
4651
+ }
4652
+ return tmp_0.write$default_koqy5u_k$(tmp_1, VOID, VOID, destination, VOID, writeExtensions);
4653
+ }
4654
+ function pathSize(path) {
4655
+ _init_properties_EngineJsApi_kt__9bputf();
4656
+ return path.size_1;
4657
+ }
4658
+ function pathTotalDistance(path) {
4659
+ _init_properties_EngineJsApi_kt__9bputf();
4660
+ return path.totalDistance_1;
4661
+ }
4662
+ function pathDurationMs(path) {
4663
+ _init_properties_EngineJsApi_kt__9bputf();
4664
+ return path.durationMs_1;
4665
+ }
4666
+ function pathElevationGain(path) {
4667
+ _init_properties_EngineJsApi_kt__9bputf();
4668
+ return path.elevationGain_1;
4669
+ }
4670
+ function pathElevationLoss(path) {
4671
+ _init_properties_EngineJsApi_kt__9bputf();
4672
+ return path.elevationLoss_1;
4673
+ }
4674
+ function pointAt(path, i) {
4675
+ _init_properties_EngineJsApi_kt__9bputf();
4676
+ return pointObj(path.latitudeDeg_i25sm6_k$(i), path.longitudeDeg_ikk1un_k$(i), path.elevation_iziwkb_k$(i), path.time_ryc845_k$(i), path.speed_npav2n_k$(i), path.pComputedPower_g6dnn4_k$(i), path.distance_5s4s77_k$(i), path.grade_c4yjz5_k$(i));
4677
+ }
4678
+ function writeGpx(path, writeExtensions) {
4679
+ writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4680
+ _init_properties_EngineJsApi_kt__9bputf();
4681
+ return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized'), writeExtensions);
4682
+ }
4683
+ function writeGpxAt(path, startTimeEpochMs, writeExtensions) {
4684
+ writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4685
+ _init_properties_EngineJsApi_kt__9bputf();
4686
+ return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized', Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs))), writeExtensions);
4687
+ }
4688
+ function enhance(path, options) {
4689
+ _init_properties_EngineJsApi_kt__9bputf();
4690
+ var tmp = GlobalScope_instance;
4691
+ return promise(tmp, VOID, VOID, enhance$slambda_0(options, path, null));
4692
+ }
4693
+ function enhanceWithCourse(path, cyclist, bike, wind, power, options) {
2659
4694
  _init_properties_EngineJsApi_kt__9bputf();
2660
4695
  var tmp = GlobalScope_instance;
2661
4696
  return promise(tmp, VOID, VOID, enhanceWithCourse$slambda_0(options, path, cyclist, bike, wind, power, null));
@@ -2775,6 +4810,46 @@
2775
4810
  // Inline function 'kotlin.collections.toTypedArray' call
2776
4811
  return copyToArray(destination);
2777
4812
  }
4813
+ function analyzeRacingLine(path, options) {
4814
+ options = options === VOID ? null : options;
4815
+ _init_properties_EngineJsApi_kt__9bputf();
4816
+ var racingLine = toEnhanceOptions(options).racingLine_1;
4817
+ var tmp0_elvis_lhs = RacingLine_instance.analyze_ikwae4_k$(path, racingLine);
4818
+ var tmp;
4819
+ if (tmp0_elvis_lhs == null) {
4820
+ return null;
4821
+ } else {
4822
+ tmp = tmp0_elvis_lhs;
4823
+ }
4824
+ var report = tmp;
4825
+ var o = {};
4826
+ o.size = report.size_1;
4827
+ // Inline function 'kotlin.collections.map' call
4828
+ var this_0 = report.corners_1;
4829
+ // Inline function 'kotlin.collections.mapTo' call
4830
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
4831
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
4832
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4833
+ var item = _iterator__ex2g4s.next_20eer_k$();
4834
+ var tmp$ret$2 = cornerObj(item);
4835
+ destination.add_utx5q5_k$(tmp$ret$2);
4836
+ }
4837
+ // Inline function 'kotlin.collections.toTypedArray' call
4838
+ o.corners = copyToArray(destination);
4839
+ o.centerlineCurvature = report.centerlineCurvature_1;
4840
+ o.trajectoryCurvature = report.trajectoryCurvature_1;
4841
+ o.corridorLo = report.corridorLo_1;
4842
+ o.corridorHi = report.corridorHi_1;
4843
+ o.roadHalfWidthM = report.roadHalfWidthM_1;
4844
+ o.lateralOffsetM = report.lateralOffsetM_1;
4845
+ o.maxCorridorWidthM = report.get_maxCorridorWidthM_7bycoc_k$();
4846
+ o.newtonIterations = report.newtonIterations_1;
4847
+ o.relativeGradient = report.relativeGradient_1;
4848
+ o.converged = report.converged_1;
4849
+ o.activeConstraints = report.activeConstraints_1;
4850
+ // Inline function 'kotlin.js.unsafeCast' call
4851
+ return o;
4852
+ }
2778
4853
  function waypointObj(w) {
2779
4854
  _init_properties_EngineJsApi_kt__9bputf();
2780
4855
  var o = {};
@@ -2840,11 +4915,23 @@
2840
4915
  var tmp8_elvis_lhs = _this__u8e3s4.wPrimeBalanceCriticalPower;
2841
4916
  var tmp_7 = tmp8_elvis_lhs == null ? 250.0 : tmp8_elvis_lhs;
2842
4917
  var tmp9_elvis_lhs = _this__u8e3s4.wPrimeBalanceWPrime;
2843
- return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, tmp_5, new WPrimeBalanceOptions(tmp_6, tmp_7, tmp9_elvis_lhs == null ? 20000.0 : tmp9_elvis_lhs));
4918
+ var tmp_8 = new WPrimeBalanceOptions(tmp_6, tmp_7, tmp9_elvis_lhs == null ? 20000.0 : tmp9_elvis_lhs);
4919
+ var tmp10_elvis_lhs = _this__u8e3s4.curvatureEnabled;
4920
+ var tmp_9 = new CurvatureOptions(tmp10_elvis_lhs == null ? true : tmp10_elvis_lhs);
4921
+ var tmp11_elvis_lhs = _this__u8e3s4.racingLineEnabled;
4922
+ var tmp13_enabled = tmp11_elvis_lhs == null ? false : tmp11_elvis_lhs;
4923
+ var tmp14_corridor = parseCorridor(_this__u8e3s4.racingLineCorridor);
4924
+ var tmp12_elvis_lhs = _this__u8e3s4.racingLineRoadWidthM;
4925
+ var tmp15_defaultRoadWidthM = tmp12_elvis_lhs == null ? Companion_getInstance_17().DEFAULT_1.defaultRoadWidthM_1 : tmp12_elvis_lhs;
4926
+ return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, tmp_5, tmp_8, tmp_9, new RacingLineOptions(tmp13_enabled, tmp15_defaultRoadWidthM, VOID, tmp14_corridor));
4927
+ }
4928
+ function parseCorridor(name) {
4929
+ _init_properties_EngineJsApi_kt__9bputf();
4930
+ return name == null ? Companion_getInstance_17().DEFAULT_1.corridor_1 : Companion_instance_14.byId_8gmd94_k$(name);
2844
4931
  }
2845
4932
  function defaultJsOptions() {
2846
4933
  _init_properties_EngineJsApi_kt__9bputf();
2847
- return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false));
4934
+ return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false), VOID, new CurvatureOptions(true), new RacingLineOptions(false));
2848
4935
  }
2849
4936
  function toCyclist(_this__u8e3s4) {
2850
4937
  _init_properties_EngineJsApi_kt__9bputf();
@@ -3021,6 +5108,21 @@
3021
5108
  // Inline function 'kotlin.js.unsafeCast' call
3022
5109
  return o;
3023
5110
  }
5111
+ function cornerObj(c) {
5112
+ _init_properties_EngineJsApi_kt__9bputf();
5113
+ var o = {};
5114
+ o.fromIndex = c.fromIndex_1;
5115
+ o.untilIndex = c.untilIndex_1;
5116
+ o.apexIndex = c.apexIndex_1;
5117
+ o.kind = c.kind_1.name_1;
5118
+ o.turnRad = c.turnRad_1;
5119
+ o.direction = c.direction_1;
5120
+ o.radiusQ20M = c.radiusQ20M_1;
5121
+ o.radiusMinM = c.radiusMinM_1;
5122
+ o.lengthM = c.lengthM_1;
5123
+ // Inline function 'kotlin.js.unsafeCast' call
5124
+ return o;
5125
+ }
3024
5126
  function enhance$slambda($options, $path, resultContinuation) {
3025
5127
  this.$options_1 = $options;
3026
5128
  this.$path_1 = $path;
@@ -3150,7 +5252,7 @@
3150
5252
  CYCLIST_KEYS = setOf_0(['massKg', 'cd', 'frontalAreaM2', 'maxLeanAngleDeg', 'maxBrakeG', 'maxSpeedKmH', 'roadCondition']);
3151
5253
  BIKE_KEYS = setOf_0(['crr', 'inertiaFront', 'inertiaRear', 'wheelRadiusM', 'efficiency', 'maxPedalingLeanAngleDeg']);
3152
5254
  WIND_KEYS = setOf_0(['windSpeed', 'windDirection']);
3153
- ENHANCE_OPTIONS_KEYS = setOf_0(['fixElevation', 'computeMaxSpeeds', 'virtualizeTrack', 'computeOnePointPerSecond', 'simplifyEnabled', 'simplifyToleranceM', 'simplifyZExaggeration', 'wPrimeBalanceEnabled', 'wPrimeBalanceCriticalPower', 'wPrimeBalanceWPrime']);
5255
+ ENHANCE_OPTIONS_KEYS = setOf_0(['fixElevation', 'computeMaxSpeeds', 'virtualizeTrack', 'computeOnePointPerSecond', 'simplifyEnabled', 'simplifyToleranceM', 'simplifyZExaggeration', 'wPrimeBalanceEnabled', 'wPrimeBalanceCriticalPower', 'wPrimeBalanceWPrime', 'curvatureEnabled', 'racingLineEnabled', 'racingLineCorridor', 'racingLineRoadWidthM']);
3154
5256
  }
3155
5257
  }
3156
5258
  //region block: init
@@ -3176,6 +5278,16 @@
3176
5278
  WheelBearingsPowerProvider_instance = new WheelBearingsPowerProvider();
3177
5279
  WindProviderNone_instance = new WindProviderNone();
3178
5280
  WPrimeBalanceComputer_instance = new WPrimeBalanceComputer();
5281
+ BandedLdl_instance = new BandedLdl();
5282
+ CornerDetector_instance = new CornerDetector();
5283
+ Corridor_instance = new Corridor();
5284
+ CurvatureEstimator_instance = new CurvatureEstimator();
5285
+ LocalFrame_instance = new LocalFrame();
5286
+ Companion_instance_12 = new Companion_11();
5287
+ OffsetQp_instance = new OffsetQp();
5288
+ PathCurvature_instance = new PathCurvature();
5289
+ RacingLine_instance = new RacingLine();
5290
+ Companion_instance_14 = new Companion_13();
3179
5291
  //endregion
3180
5292
  //region block: exports
3181
5293
  function $jsExportAll$(_) {
@@ -3212,6 +5324,7 @@
3212
5324
  engine.dominantHeadwindAzimuthOfTracks = dominantHeadwindAzimuthOfTracks;
3213
5325
  engine.detectClimbs = detectClimbs;
3214
5326
  engine.detectClimbsWithOptions = detectClimbsWithOptions;
5327
+ engine.analyzeRacingLine = analyzeRacingLine;
3215
5328
  }
3216
5329
  $jsExportAll$(_);
3217
5330
  kotlin_io_github_glandais_elevation.$jsExportAll$(_);