@glandais/vcyclist-engine 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,80 +16,106 @@
16
16
  'use strict';
17
17
  //region block: imports
18
18
  var imul = Math.imul;
19
+ var sinh = Math.sinh;
19
20
  var hypot = Math.hypot;
20
21
  var VOID = kotlin_kotlin.$_$.a;
21
- var protoOf = kotlin_kotlin.$_$.j7;
22
- var getNumberHashCode = kotlin_kotlin.$_$.q6;
23
- var getBooleanHashCode = kotlin_kotlin.$_$.p6;
24
- var equals = kotlin_kotlin.$_$.n6;
25
- var initMetadataForClass = kotlin_kotlin.$_$.u6;
26
- var numberToLong = kotlin_kotlin.$_$.v5;
27
- var toNumber = kotlin_kotlin.$_$.a6;
28
- var CoroutineImpl = kotlin_kotlin.$_$.d5;
29
- var Unit_instance = kotlin_kotlin.$_$.g1;
30
- var THROW_CCE = kotlin_kotlin.$_$.ca;
31
- var MutableEntry = kotlin_kotlin.$_$.r2;
32
- var isInterface = kotlin_kotlin.$_$.c7;
33
- var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.o4;
34
- var initMetadataForLambda = kotlin_kotlin.$_$.z6;
35
- var constructCallableReference = kotlin_kotlin.$_$.k6;
36
- var emptyList = kotlin_kotlin.$_$.g3;
37
- var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.p1;
38
- var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j1;
39
- var toList = kotlin_kotlin.$_$.i4;
40
- var KtList = kotlin_kotlin.$_$.o2;
41
- var initMetadataForCoroutine = kotlin_kotlin.$_$.w6;
42
- var toString = kotlin_kotlin.$_$.m7;
43
- var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
44
- var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i1;
45
- var listOf = kotlin_kotlin.$_$.s3;
46
- var numberToInt = kotlin_kotlin.$_$.h7;
47
- var coerceIn = kotlin_kotlin.$_$.u7;
48
- var initMetadataForObject = kotlin_kotlin.$_$.a7;
49
- var toList_0 = kotlin_kotlin.$_$.h4;
50
- var collectionSizeOrDefault = kotlin_kotlin.$_$.x2;
51
- var get_indices = kotlin_kotlin.$_$.l3;
52
- var get_lastIndex = kotlin_kotlin.$_$.o3;
53
- var checkBuilderCapacity = kotlin_kotlin.$_$.v2;
54
- var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.d2;
55
- var coerceIn_0 = kotlin_kotlin.$_$.v7;
56
- var KFunctionImpl = kotlin_kotlin.$_$.a8;
57
- var initMetadataForFunctionReference = kotlin_kotlin.$_$.x6;
58
- var getStringHashCode = kotlin_kotlin.$_$.s6;
59
- var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
60
- var Semaphore = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
61
- var async = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k;
22
+ var protoOf = kotlin_kotlin.$_$.s7;
23
+ var getNumberHashCode = kotlin_kotlin.$_$.z6;
24
+ var getBooleanHashCode = kotlin_kotlin.$_$.y6;
25
+ var equals = kotlin_kotlin.$_$.w6;
26
+ var initMetadataForClass = kotlin_kotlin.$_$.d7;
27
+ var numberToLong = kotlin_kotlin.$_$.e6;
28
+ var toNumber = kotlin_kotlin.$_$.j6;
29
+ var CoroutineImpl = kotlin_kotlin.$_$.l5;
30
+ var Unit_instance = kotlin_kotlin.$_$.k1;
31
+ var THROW_CCE = kotlin_kotlin.$_$.xa;
32
+ var MutableEntry = kotlin_kotlin.$_$.w2;
33
+ var isInterface = kotlin_kotlin.$_$.l7;
34
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.w4;
35
+ var initMetadataForLambda = kotlin_kotlin.$_$.i7;
36
+ var constructCallableReference = kotlin_kotlin.$_$.t6;
37
+ var emptyList = kotlin_kotlin.$_$.l3;
38
+ var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.t1;
39
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.n1;
40
+ var toList = kotlin_kotlin.$_$.q4;
41
+ var KtList = kotlin_kotlin.$_$.t2;
42
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.f7;
43
+ var toString = kotlin_kotlin.$_$.v7;
44
+ var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.e2;
45
+ var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.m1;
46
+ var listOf = kotlin_kotlin.$_$.y3;
47
+ var numberToInt = kotlin_kotlin.$_$.q7;
48
+ var Enum = kotlin_kotlin.$_$.na;
49
+ var charSequenceLength = kotlin_kotlin.$_$.r6;
50
+ var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.d;
51
+ var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.i;
52
+ var toByte = kotlin_kotlin.$_$.t7;
53
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.h2;
54
+ var FloatCompanionObject_instance = kotlin_kotlin.$_$.d1;
55
+ var floatFromBits = kotlin_kotlin.$_$.x6;
56
+ var isNaN_0 = kotlin_kotlin.$_$.jb;
57
+ var roundToLong = kotlin_kotlin.$_$.x7;
58
+ var Long = kotlin_kotlin.$_$.sa;
59
+ var coerceIn = kotlin_kotlin.$_$.f8;
60
+ var convertToInt = kotlin_kotlin.$_$.w5;
61
+ var initMetadataForInterface = kotlin_kotlin.$_$.h7;
62
+ var coerceIn_0 = kotlin_kotlin.$_$.d8;
63
+ var initMetadataForObject = kotlin_kotlin.$_$.j7;
64
+ var toList_0 = kotlin_kotlin.$_$.p4;
65
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.c3;
66
+ var get_indices = kotlin_kotlin.$_$.r3;
67
+ var get_lastIndex = kotlin_kotlin.$_$.u3;
68
+ var checkBuilderCapacity = kotlin_kotlin.$_$.a3;
69
+ var IllegalStateException_init_$Create$_0 = kotlin_kotlin.$_$.i2;
70
+ var coerceIn_1 = kotlin_kotlin.$_$.e8;
71
+ var objectCreate = kotlin_kotlin.$_$.r7;
72
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.lb;
73
+ var KFunctionImpl = kotlin_kotlin.$_$.k8;
74
+ var initMetadataForFunctionReference = kotlin_kotlin.$_$.g7;
75
+ var getStringHashCode = kotlin_kotlin.$_$.b7;
76
+ var Companion_instance = kotlin_kotlin.$_$.i1;
77
+ var joinToString = kotlin_kotlin.$_$.s3;
78
+ var initMetadataForCompanion = kotlin_kotlin.$_$.e7;
79
+ var enumEntries = kotlin_kotlin.$_$.n5;
80
+ var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k;
81
+ var Semaphore = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
82
+ var async = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l;
62
83
  var awaitAll = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c;
63
84
  var coroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e;
64
- var Exception = kotlin_kotlin.$_$.v9;
65
- var Exception_init_$Init$ = kotlin_kotlin.$_$.x1;
66
- var captureStack = kotlin_kotlin.$_$.e6;
67
- var KtMap = kotlin_kotlin.$_$.p2;
68
- var noWhenBranchMatchedException = kotlin_kotlin.$_$.qa;
69
- var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
85
+ var Exception = kotlin_kotlin.$_$.pa;
86
+ var Exception_init_$Init$ = kotlin_kotlin.$_$.b2;
87
+ var captureStack = kotlin_kotlin.$_$.n6;
88
+ var KtMap = kotlin_kotlin.$_$.u2;
89
+ var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
70
90
  var NonCancellable_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b;
71
- var withContext = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f;
72
- var CancellationException = kotlin_kotlin.$_$.n4;
73
- var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
74
- var contentEquals = kotlin_kotlin.$_$.y2;
75
- var contentHashCode = kotlin_kotlin.$_$.z2;
76
- var objectCreate = kotlin_kotlin.$_$.i7;
77
- var round = kotlin_kotlin.$_$.p7;
78
- var initMetadataForCompanion = kotlin_kotlin.$_$.v6;
79
- var isNaN_0 = kotlin_kotlin.$_$.oa;
80
- var replace = kotlin_kotlin.$_$.z8;
91
+ var withContext = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
92
+ var CancellationException = kotlin_kotlin.$_$.v4;
93
+ var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
94
+ var contentEquals = kotlin_kotlin.$_$.d3;
95
+ var contentHashCode = kotlin_kotlin.$_$.e3;
96
+ var round = kotlin_kotlin.$_$.y7;
97
+ var replace = kotlin_kotlin.$_$.p9;
98
+ var contains = kotlin_kotlin.$_$.x8;
99
+ var IllegalStateException = kotlin_kotlin.$_$.ra;
100
+ var IllegalStateException_init_$Init$ = kotlin_kotlin.$_$.g2;
101
+ var Monotonic_instance = kotlin_kotlin.$_$.h1;
102
+ var delay = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f;
103
+ var shiftLeft = kotlin_kotlin.$_$.f6;
104
+ var multiply = kotlin_kotlin.$_$.c6;
105
+ var ValueTimeMark__elapsedNow_impl_eonqvs = kotlin_kotlin.$_$.c;
106
+ var _Duration___get_inWholeMilliseconds__impl__msfiry = kotlin_kotlin.$_$.b;
81
107
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
82
- var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l;
83
- var joinToString = kotlin_kotlin.$_$.m3;
84
- var sorted = kotlin_kotlin.$_$.c4;
85
- var IllegalStateException_init_$Create$_0 = kotlin_kotlin.$_$.c2;
86
- var setOf = kotlin_kotlin.$_$.a4;
87
- var KProperty0 = kotlin_kotlin.$_$.c8;
88
- var getPropertyCallableRef = kotlin_kotlin.$_$.r6;
89
- var isNumber = kotlin_kotlin.$_$.d7;
108
+ var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.m;
109
+ var sorted = kotlin_kotlin.$_$.k4;
110
+ var setOf = kotlin_kotlin.$_$.i4;
111
+ var KProperty0 = kotlin_kotlin.$_$.m8;
112
+ var getPropertyCallableRef = kotlin_kotlin.$_$.a7;
113
+ var isCharSequence = kotlin_kotlin.$_$.k7;
114
+ var trim = kotlin_kotlin.$_$.ia;
115
+ var toLongOrNull = kotlin_kotlin.$_$.da;
116
+ var isNumber = kotlin_kotlin.$_$.m7;
90
117
  var await_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d;
91
- var charSequenceLength = kotlin_kotlin.$_$.i6;
92
- var lazy = kotlin_kotlin.$_$.pa;
118
+ var lazy = kotlin_kotlin.$_$.kb;
93
119
  //endregion
94
120
  //region block: pre-declaration
95
121
  initMetadataForClass(SmoothingOptions, 'SmoothingOptions', SmoothingOptions);
@@ -98,8 +124,10 @@
98
124
  initMetadataForCoroutine($setElevationsCOROUTINE$, CoroutineImpl);
99
125
  initMetadataForCoroutine($getElevationsAlongCOROUTINE$, CoroutineImpl);
100
126
  initMetadataForClass(BatchCalculator, 'BatchCalculator', VOID, VOID, VOID, [4, 7]);
101
- initMetadataForClass(LatLon, 'LatLon');
102
- initMetadataForClass(LatLonElevation, 'LatLonElevation');
127
+ initMetadataForClass(TileEncoding, 'TileEncoding', VOID, Enum);
128
+ initMetadataForInterface(Coordinates, 'Coordinates');
129
+ initMetadataForClass(LatLon, 'LatLon', VOID, VOID, [Coordinates]);
130
+ initMetadataForClass(LatLonElevation, 'LatLonElevation', VOID, VOID, [Coordinates]);
103
131
  initMetadataForObject(Distance, 'Distance');
104
132
  initMetadataForObject(DouglasPeucker, 'DouglasPeucker');
105
133
  initMetadataForObject(EcefConverter, 'EcefConverter');
@@ -108,11 +136,16 @@
108
136
  initMetadataForCoroutine($elevationFromPixelCOROUTINE$, CoroutineImpl);
109
137
  initMetadataForClass(ElevationCalculator, 'ElevationCalculator', VOID, VOID, VOID, [3, 2, 1]);
110
138
  initMetadataForObject(ElevationFunctions, 'ElevationFunctions');
139
+ initMetadataForLambda(ElevationProvider$calculator$slambda, CoroutineImpl, VOID, [2]);
140
+ initMetadataForClass(ElevationProvider, 'ElevationProvider', ElevationProvider_init_$Create$, VOID, VOID, [3, 2, 6]);
111
141
  initMetadataForFunctionReference(fetchAndDecodeTile$ref, KFunctionImpl, VOID, [1]);
112
- initMetadataForClass(ElevationProvider, 'ElevationProvider', ElevationProvider, VOID, VOID, [3, 2, 6]);
142
+ initMetadataForLambda(defaultTileFetcher$slambda, CoroutineImpl, VOID, [1]);
143
+ initMetadataForLambda(defaultTileFetcher$slambda_1, CoroutineImpl, VOID, [1]);
113
144
  initMetadataForClass(ElevationProviderConfig, 'ElevationProviderConfig', ElevationProviderConfig);
114
145
  initMetadataForClass(Attribution, 'Attribution');
115
146
  initMetadataForObject(ElevationSmoother, 'ElevationSmoother');
147
+ initMetadataForCompanion(Companion);
148
+ initMetadataForClass(ElevationSource, 'ElevationSource', VOID, Enum);
116
149
  initMetadataForLambda(Flux$forEachParallel$slambda$slambda, CoroutineImpl, VOID, [1]);
117
150
  initMetadataForLambda(Flux$forEachParallel$slambda, CoroutineImpl, VOID, [1]);
118
151
  initMetadataForCoroutine($forEachParallelCOROUTINE$, CoroutineImpl);
@@ -128,24 +161,32 @@
128
161
  initMetadataForCoroutine($loadCOROUTINE$, CoroutineImpl);
129
162
  initMetadataForClass(LruCache, 'LruCache', VOID, VOID, VOID, [1, 2, 0]);
130
163
  initMetadataForClass(RawTile, 'RawTile');
131
- initMetadataForCompanion(Companion);
164
+ initMetadataForCompanion(Companion_0);
132
165
  initMetadataForClass(Tile, 'Tile');
133
166
  initMetadataForFunctionReference(fetchAndDecodeTile$ref_0, KFunctionImpl, VOID, [1]);
134
167
  initMetadataForLambda(TileManager$cache$slambda, CoroutineImpl, VOID, [1]);
135
168
  initMetadataForClass(TileManager, 'TileManager', VOID, VOID, VOID, [1, 0]);
169
+ initMetadataForClass(TileFetchException, 'TileFetchException', VOID, IllegalStateException);
170
+ initMetadataForCoroutine($awaitTurnCOROUTINE$, CoroutineImpl);
171
+ initMetadataForClass(RequestPacer, 'RequestPacer', VOID, VOID, VOID, [0]);
172
+ initMetadataForFunctionReference(fetchTileBytes$ref, KFunctionImpl, VOID, [1]);
173
+ initMetadataForLambda(pacedTileBytesFetcher$slambda, CoroutineImpl, VOID, [1]);
136
174
  initMetadataForClass(TileCoordinates, 'TileCoordinates');
137
175
  initMetadataForClass(Pixel, 'Pixel');
138
176
  initMetadataForClass(PixelFloat, 'PixelFloat');
139
177
  initMetadataForClass(TileCoordinatesFloat, 'TileCoordinatesFloat');
140
- initMetadataForCompanion(Companion_0);
178
+ initMetadataForCompanion(Companion_1);
141
179
  initMetadataForClass(Vector3D, 'Vector3D');
142
180
  initMetadataForLambda(getElevation$slambda, CoroutineImpl, VOID, [1]);
143
181
  initMetadataForLambda(getElevationsAlong$slambda, CoroutineImpl, VOID, [1]);
144
182
  initMetadataForCoroutine($fetchAndDecodeTileCOROUTINE$, CoroutineImpl);
183
+ initMetadataForCoroutine($decodeTileBytesCOROUTINE$, CoroutineImpl);
145
184
  initMetadataForCoroutine($decodeNodeCOROUTINE$, CoroutineImpl);
146
185
  initMetadataForCoroutine($decodeBrowserCOROUTINE$, CoroutineImpl);
147
- initMetadataForCoroutine($decodeWebpNodeCOROUTINE$, CoroutineImpl);
186
+ initMetadataForCoroutine($decodeBytesNodeCOROUTINE$, CoroutineImpl);
148
187
  initMetadataForCoroutine($decodeBlobCOROUTINE$, CoroutineImpl);
188
+ initMetadataForCoroutine($decodeWebpNodeCOROUTINE$, CoroutineImpl);
189
+ initMetadataForCoroutine($fetchTileBytesCOROUTINE$, CoroutineImpl);
149
190
  //endregion
150
191
  function SmoothingOptions(windowSize, enabled) {
151
192
  windowSize = windowSize === VOID ? 50.0 : windowSize;
@@ -514,6 +555,88 @@
514
555
  out.add_utx5q5_k$(b);
515
556
  return out;
516
557
  };
558
+ var static_init_called;
559
+ function static_init() {
560
+ if (static_init_called)
561
+ return Unit_instance;
562
+ static_init_called = true;
563
+ TileEncoding_TERRARIUM_instance = new TileEncoding('TERRARIUM', 0);
564
+ TileEncoding_BIL32_instance = new TileEncoding('BIL32', 1);
565
+ }
566
+ var TileEncoding_TERRARIUM_instance;
567
+ var TileEncoding_BIL32_instance;
568
+ function TileEncoding(name, ordinal) {
569
+ Enum.call(this, name, ordinal);
570
+ }
571
+ function decodeBil32Tile(bytes, tileSize, sourceUrl) {
572
+ sourceUrl = sourceUrl === VOID ? '' : sourceUrl;
573
+ var samples = imul(tileSize, tileSize);
574
+ // Inline function 'kotlin.check' call
575
+ if (!(bytes.length === imul(samples, 4))) {
576
+ // Inline function 'kotlin.text.ifEmpty' call
577
+ var tmp;
578
+ // Inline function 'kotlin.text.isEmpty' call
579
+ if (charSequenceLength(sourceUrl) === 0) {
580
+ tmp = '(no url)';
581
+ } else {
582
+ tmp = sourceUrl;
583
+ }
584
+ var tmp_0 = 'BIL32 tile ' + tmp + ' is ' + bytes.length + ' bytes, expected ' + ('' + imul(samples, 4) + ' for ' + tileSize + ' \xD7 ' + tileSize + ' float32 samples');
585
+ var tmp_1;
586
+ var tmp_2;
587
+ // Inline function 'kotlin.collections.isNotEmpty' call
588
+ // Inline function 'kotlin.collections.isEmpty' call
589
+ if (!(bytes.length === 0)) {
590
+ var tmp_3 = bytes[0];
591
+ // Inline function 'kotlin.code' call
592
+ var this_0 = _Char___init__impl__6a9atx(60);
593
+ var tmp$ret$7 = Char__toInt_impl_vasixd(this_0);
594
+ tmp_2 = tmp_3 === toByte(tmp$ret$7);
595
+ } else {
596
+ tmp_2 = false;
597
+ }
598
+ if (tmp_2) {
599
+ tmp_1 = ' \u2014 the body looks like an XML error page';
600
+ } else {
601
+ tmp_1 = '';
602
+ }
603
+ var message = tmp_0 + tmp_1;
604
+ throw IllegalStateException_init_$Create$(toString(message));
605
+ }
606
+ var rgba = new Int8Array(imul(samples, 4));
607
+ var inductionVariable = 0;
608
+ if (inductionVariable < samples)
609
+ $l$loop: do {
610
+ var i = inductionVariable;
611
+ inductionVariable = inductionVariable + 1 | 0;
612
+ var o = imul(i, 4);
613
+ var bits = bytes[o] & 255 | (bytes[o + 1 | 0] & 255) << 8 | (bytes[o + 2 | 0] & 255) << 16 | (bytes[o + 3 | 0] & 255) << 24;
614
+ // Inline function 'kotlin.fromBits' call
615
+ var value = floatFromBits(bits);
616
+ if (isNaN_0(value) || value <= -9000.0) {
617
+ rgba[o + 3 | 0] = -1;
618
+ continue $l$loop;
619
+ }
620
+ var packed = encodeTerrarium(value);
621
+ rgba[o] = toByte(packed >> 16);
622
+ rgba[o + 1 | 0] = toByte(packed >> 8);
623
+ rgba[o + 2 | 0] = toByte(packed);
624
+ rgba[o + 3 | 0] = -1;
625
+ }
626
+ while (inductionVariable < samples);
627
+ return new RawTile(tileSize, tileSize, rgba);
628
+ }
629
+ function encodeTerrarium(metres) {
630
+ return convertToInt(coerceIn(roundToLong((metres + 32768.0) * 256.0), new Long(1, 0), new Long(16777215, 0)));
631
+ }
632
+ function TileEncoding_TERRARIUM_getInstance() {
633
+ static_init();
634
+ return TileEncoding_TERRARIUM_instance;
635
+ }
636
+ function TileEncoding_BIL32_getInstance() {
637
+ static_init();
638
+ return TileEncoding_BIL32_instance;
639
+ }
517
640
  function LatLon(latitude, longitude, elevation) {
518
641
  elevation = elevation === VOID ? null : elevation;
519
642
  this.latitude_1 = latitude;
@@ -551,6 +674,8 @@
551
674
  return false;
552
675
  return true;
553
676
  };
677
+ function Coordinates() {
678
+ }
554
679
  function LatLonElevation(latitude, longitude, elevation) {
555
680
  this.latitude_1 = latitude;
556
681
  this.longitude_1 = longitude;
@@ -605,7 +730,7 @@
605
730
  var tmp_0 = Math.cos(lat1Rad);
606
731
  // Inline function 'kotlin.math.cos' call
607
732
  var a = tmp + tmp_0 * Math.cos(lat2Rad) * sinHalfLon * sinHalfLon;
608
- var ac = coerceIn(a, 0.0, 1.0);
733
+ var ac = coerceIn_0(a, 0.0, 1.0);
609
734
  // Inline function 'kotlin.math.sqrt' call
610
735
  var tmp0 = Math.sqrt(ac);
611
736
  // Inline function 'kotlin.math.sqrt' call
@@ -762,7 +887,7 @@
762
887
  var tmp = this.state_1;
763
888
  switch (tmp) {
764
889
  case 0:
765
- this.exceptionState_1 = 5;
890
+ this.exceptionState_1 = 8;
766
891
  this.exceptionState_1 = 4;
767
892
  if (this.interpolation_1) {
768
893
  this.state_1 = 2;
@@ -782,38 +907,61 @@
782
907
  }
783
908
 
784
909
  case 1:
785
- this.WHEN_RESULT1__1 = suspendResult;
910
+ this.WHEN_RESULT2__1 = suspendResult;
786
911
  this.state_1 = 3;
787
912
  continue $sm;
788
913
  case 2:
789
- this.WHEN_RESULT1__1 = suspendResult;
914
+ this.WHEN_RESULT2__1 = suspendResult;
790
915
  this.state_1 = 3;
791
916
  continue $sm;
792
917
  case 3:
793
- this.TRY_RESULT0__1 = this.WHEN_RESULT1__1;
794
- this.exceptionState_1 = 5;
795
- this.state_1 = 6;
918
+ this.TRY_RESULT1__1 = this.WHEN_RESULT2__1;
919
+ this.exceptionState_1 = 8;
920
+ this.state_1 = 5;
796
921
  continue $sm;
797
922
  case 4:
798
- this.exceptionState_1 = 5;
923
+ this.exceptionState_1 = 8;
799
924
  var tmp_0 = this.exception_1;
800
925
  if (tmp_0 instanceof Error) {
801
926
  var t = this.exception_1;
802
927
  var tmp_1 = this;
803
- throw IllegalStateException_init_$Create$('Failed to get elevation: ' + t.message, t);
928
+ throw IllegalStateException_init_$Create$_0('Failed to get elevation: ' + t.message, t);
804
929
  } else {
805
930
  throw this.exception_1;
806
931
  }
807
932
 
808
933
  case 5:
809
- throw this.exception_1;
934
+ this.exceptionState_1 = 8;
935
+ var own = this.TRY_RESULT1__1;
936
+ if (!isNaN_0(own))
937
+ return own;
938
+ var tmp0_safe_receiver = this._this__u8e3s4__1.fallback_1;
939
+ if (tmp0_safe_receiver == null) {
940
+ this.WHEN_RESULT0__1 = null;
941
+ this.state_1 = 7;
942
+ continue $sm;
943
+ } else {
944
+ this.state_1 = 6;
945
+ suspendResult = tmp0_safe_receiver(this.coords_1, this.interpolation_1, this);
946
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
947
+ return suspendResult;
948
+ }
949
+ continue $sm;
950
+ }
951
+
810
952
  case 6:
811
- this.exceptionState_1 = 5;
812
- return this.TRY_RESULT0__1;
953
+ this.WHEN_RESULT0__1 = suspendResult;
954
+ this.state_1 = 7;
955
+ continue $sm;
956
+ case 7:
957
+ var tmp1_elvis_lhs = this.WHEN_RESULT0__1;
958
+ return tmp1_elvis_lhs == null ? 0.0 : tmp1_elvis_lhs;
959
+ case 8:
960
+ throw this.exception_1;
813
961
  }
814
962
  } catch ($p) {
815
963
  var e = $p;
816
- if (this.exceptionState_1 === 5) {
964
+ if (this.exceptionState_1 === 8) {
817
965
  throw e;
818
966
  } else {
819
967
  this.state_1 = this.exceptionState_1;
@@ -936,10 +1084,12 @@
936
1084
  }
937
1085
  while (true);
938
1086
  };
939
- function ElevationCalculator(tileManager, tileSize) {
1087
+ function ElevationCalculator(tileManager, tileSize, fallback) {
940
1088
  tileSize = tileSize === VOID ? 256 : tileSize;
1089
+ fallback = fallback === VOID ? null : fallback;
941
1090
  this.tileManager_1 = tileManager;
942
1091
  this.tileSize_1 = tileSize;
1092
+ this.fallback_1 = fallback;
943
1093
  }
944
1094
  protoOf(ElevationCalculator).getElevation_e117b3_k$ = function (coords, zoomLevel, interpolation, $completion) {
945
1095
  var tmp = new $getElevationCOROUTINE$(this, coords, zoomLevel, interpolation, $completion);
@@ -988,8 +1138,20 @@
988
1138
  tileY = tileY + 1 | 0;
989
1139
  }
990
1140
  var maxTile = (1 << z) - 1 | 0;
991
- tileX = coerceIn_0(tileX, 0, maxTile);
992
- tileY = coerceIn_0(tileY, 0, maxTile);
1141
+ if (tileX < 0) {
1142
+ tileX = 0;
1143
+ x = 0;
1144
+ } else if (tileX > maxTile) {
1145
+ tileX = maxTile;
1146
+ x = tileSize - 1 | 0;
1147
+ }
1148
+ if (tileY < 0) {
1149
+ tileY = 0;
1150
+ y = 0;
1151
+ } else if (tileY > maxTile) {
1152
+ tileY = maxTile;
1153
+ y = tileSize - 1 | 0;
1154
+ }
993
1155
  return new Pixel(new TileCoordinates(tileX, tileY, z), x, y);
994
1156
  };
995
1157
  protoOf(ElevationFunctions).toTileCoordinatesFloat_fctdpc_k$ = function (coords, z) {
@@ -1020,10 +1182,10 @@
1020
1182
  var maxTile = (1 << z) - 1 | 0;
1021
1183
  // Inline function 'kotlin.math.floor' call
1022
1184
  var tmp$ret$9 = Math.floor(xFloat);
1023
- var x_0 = coerceIn_0(numberToInt(tmp$ret$9), 0, maxTile);
1185
+ var x_0 = coerceIn_1(numberToInt(tmp$ret$9), 0, maxTile);
1024
1186
  // Inline function 'kotlin.math.floor' call
1025
1187
  var tmp$ret$10 = Math.floor(yFloat);
1026
- var y = coerceIn_0(numberToInt(tmp$ret$10), 0, maxTile);
1188
+ var y = coerceIn_1(numberToInt(tmp$ret$10), 0, maxTile);
1027
1189
  return new TileCoordinatesFloat(x_0, y, xFloat, yFloat, z);
1028
1190
  };
1029
1191
  protoOf(ElevationFunctions).toTileCoordinates_jamtrs_k$ = function (coords, z) {
@@ -1035,11 +1197,11 @@
1035
1197
  // Inline function 'kotlin.math.floor' call
1036
1198
  var x = (tile.xFloat_1 - tile.x_1) * tileSize;
1037
1199
  var tmp$ret$0 = Math.floor(x);
1038
- var px = coerceIn_0(numberToInt(tmp$ret$0), 0, tileSize - 1 | 0);
1200
+ var px = coerceIn_1(numberToInt(tmp$ret$0), 0, tileSize - 1 | 0);
1039
1201
  // Inline function 'kotlin.math.floor' call
1040
1202
  var x_0 = (tile.yFloat_1 - tile.y_1) * tileSize;
1041
1203
  var tmp$ret$1 = Math.floor(x_0);
1042
- var py = coerceIn_0(numberToInt(tmp$ret$1), 0, tileSize - 1 | 0);
1204
+ var py = coerceIn_1(numberToInt(tmp$ret$1), 0, tileSize - 1 | 0);
1043
1205
  return new Pixel(new TileCoordinates(tile.x_1, tile.y_1, z), px, py);
1044
1206
  };
1045
1207
  protoOf(ElevationFunctions).toPixelFloat_ler4xt_k$ = function (coords, z, tileSize) {
@@ -1052,25 +1214,76 @@
1052
1214
  function ElevationFunctions_getInstance() {
1053
1215
  return ElevationFunctions_instance;
1054
1216
  }
1055
- function fetchAndDecodeTile$ref() {
1056
- KFunctionImpl.call(this, 1, 2, 2);
1217
+ function ElevationProvider_init_$Init$(config, fetcher, $this) {
1218
+ config = config === VOID ? new ElevationProviderConfig() : config;
1219
+ fetcher = fetcher === VOID ? defaultTileFetcher(config) : fetcher;
1220
+ ElevationProvider.call($this, config, fetcher, null);
1221
+ return $this;
1057
1222
  }
1058
- protoOf(fetchAndDecodeTile$ref).invoke_fa3hvc_k$ = function (p0, $completion) {
1059
- return fetchAndDecodeTile(p0, $completion);
1223
+ function ElevationProvider_init_$Create$(config, fetcher) {
1224
+ return ElevationProvider_init_$Init$(config, fetcher, objectCreate(protoOf(ElevationProvider)));
1225
+ }
1226
+ function ElevationProvider$calculator$slambda($f, resultContinuation) {
1227
+ this.$f_1 = $f;
1228
+ CoroutineImpl.call(this, resultContinuation);
1229
+ }
1230
+ protoOf(ElevationProvider$calculator$slambda).invoke_pvotdo_k$ = function (coords, interpolation, $completion) {
1231
+ var tmp = this.create_gsta18_k$(coords, interpolation, $completion);
1232
+ tmp.result_1 = Unit_instance;
1233
+ tmp.exception_1 = null;
1234
+ return tmp.doResume_5yljmg_k$();
1060
1235
  };
1061
- protoOf(fetchAndDecodeTile$ref).invoke_qns8j1_k$ = function (p1, $completion) {
1062
- return this.invoke_fa3hvc_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1236
+ protoOf(ElevationProvider$calculator$slambda).invoke_4tzzq6_k$ = function (p1, p2, $completion) {
1237
+ var tmp = (!(p1 == null) ? isInterface(p1, Coordinates) : false) ? p1 : THROW_CCE();
1238
+ return this.invoke_pvotdo_k$(tmp, (!(p2 == null) ? typeof p2 === 'boolean' : false) ? p2 : THROW_CCE(), $completion);
1063
1239
  };
1064
- function ElevationProvider(config, fetcher) {
1065
- config = config === VOID ? new ElevationProviderConfig() : config;
1066
- var tmp;
1067
- if (fetcher === VOID) {
1068
- tmp = fetchAndDecodeTile$ref_1();
1069
- } else {
1070
- tmp = fetcher;
1071
- }
1072
- fetcher = tmp;
1240
+ protoOf(ElevationProvider$calculator$slambda).doResume_5yljmg_k$ = function () {
1241
+ var suspendResult = this.result_1;
1242
+ $sm: do
1243
+ try {
1244
+ var tmp = this.state_1;
1245
+ switch (tmp) {
1246
+ case 0:
1247
+ this.exceptionState_1 = 2;
1248
+ this.state_1 = 1;
1249
+ suspendResult = this.$f_1.getElevation_vb6cmz_k$(this.coords_1.get_latitude_feukvp_k$(), this.coords_1.get_longitude_asb1fq_k$(), this.interpolation_1, this);
1250
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1251
+ return suspendResult;
1252
+ }
1253
+
1254
+ continue $sm;
1255
+ case 1:
1256
+ return suspendResult;
1257
+ case 2:
1258
+ throw this.exception_1;
1259
+ }
1260
+ } catch ($p) {
1261
+ var e = $p;
1262
+ if (this.exceptionState_1 === 2) {
1263
+ throw e;
1264
+ } else {
1265
+ this.state_1 = this.exceptionState_1;
1266
+ this.exception_1 = e;
1267
+ }
1268
+ }
1269
+ while (true);
1270
+ };
1271
+ protoOf(ElevationProvider$calculator$slambda).create_gsta18_k$ = function (coords, interpolation, completion) {
1272
+ var i = new ElevationProvider$calculator$slambda(this.$f_1, completion);
1273
+ i.coords_1 = coords;
1274
+ i.interpolation_1 = interpolation;
1275
+ return i;
1276
+ };
1277
+ function ElevationProvider$calculator$slambda_0($f, resultContinuation) {
1278
+ var i = new ElevationProvider$calculator$slambda($f, resultContinuation);
1279
+ return constructCallableReference(function (coords, interpolation, $completion) {
1280
+ return i.invoke_pvotdo_k$(coords, interpolation, $completion);
1281
+ }, 2);
1282
+ }
1283
+ function ElevationProvider(config, fetcher, fallback) {
1073
1284
  this.config_1 = config;
1285
+ this.fetcher_1 = fetcher;
1286
+ this.fallback_1 = fallback;
1074
1287
  var containsArg = this.config_1.zoomLevel_1;
1075
1288
  // Inline function 'kotlin.require' call
1076
1289
  if (!(0 <= containsArg ? containsArg <= 15 : false)) {
@@ -1087,10 +1300,30 @@
1087
1300
  var message_1 = 'Invalid tile size: ' + this.config_1.tileSize_1 + '. Must be a positive power of 2';
1088
1301
  throw IllegalArgumentException_init_$Create$(toString(message_1));
1089
1302
  }
1090
- this.tileManager_1 = new TileManager(this.config_1.tileUrlTemplate_1, this.config_1.cacheSize_1, fetcher);
1091
- this.calculator_1 = new ElevationCalculator(this.tileManager_1, this.config_1.tileSize_1);
1303
+ // Inline function 'kotlin.require' call
1304
+ if (!(this.config_1.maxRequestsPerSecond_1 >= 0)) {
1305
+ var message_2 = 'Invalid maxRequestsPerSecond: ' + this.config_1.maxRequestsPerSecond_1 + '. Must be 0 (no limit) or positive';
1306
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
1307
+ }
1308
+ this.tileManager_1 = new TileManager(this.config_1.tileUrlTemplate_1, this.config_1.cacheSize_1, this.fetcher_1);
1309
+ var tmp = this;
1310
+ var tmp0_safe_receiver = this.fallback_1;
1311
+ var tmp_0;
1312
+ if (tmp0_safe_receiver == null) {
1313
+ tmp_0 = null;
1314
+ } else {
1315
+ // Inline function 'kotlin.let' call
1316
+ tmp_0 = ElevationProvider$calculator$slambda_0(tmp0_safe_receiver, null);
1317
+ }
1318
+ tmp.calculator_1 = new ElevationCalculator(this.tileManager_1, this.config_1.tileSize_1, tmp_0);
1092
1319
  this.batchCalculator_1 = new BatchCalculator(this.calculator_1);
1093
1320
  }
1321
+ protoOf(ElevationProvider).withFallback_7synod_k$ = function (other) {
1322
+ return new ElevationProvider(this.config_1, this.fetcher_1, other);
1323
+ };
1324
+ protoOf(ElevationProvider).get_attribution_8rpdsm_k$ = function () {
1325
+ return this.config_1.attribution_1;
1326
+ };
1094
1327
  protoOf(ElevationProvider).getElevation_vb6cmz_k$ = function (latitude, longitude, interpolation, $completion) {
1095
1328
  return this.calculator_1.getElevation_e117b3_k$(new LatLon(latitude, longitude), this.config_1.zoomLevel_1, interpolation, $completion);
1096
1329
  };
@@ -1104,20 +1337,191 @@
1104
1337
  protoOf(ElevationProvider).getElevationsAlong_o6hmac_k$ = function (path, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion) {
1105
1338
  return this.batchCalculator_1.getElevationsAlong_4qke12_k$(path, this.config_1.zoomLevel_1, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion);
1106
1339
  };
1107
- function ElevationProviderConfig(zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution) {
1340
+ function defaultTileFetcher(config) {
1341
+ if (config.encoding_1.equals(TileEncoding_TERRARIUM_getInstance()) && config.maxRequestsPerSecond_1 === 0) {
1342
+ return fetchAndDecodeTile$ref_1();
1343
+ }
1344
+ var bytes = pacedTileBytesFetcher(config.maxRequestsPerSecond_1);
1345
+ var tmp;
1346
+ switch (config.encoding_1.ordinal_1) {
1347
+ case 0:
1348
+ tmp = defaultTileFetcher$slambda_0(bytes, null);
1349
+ break;
1350
+ case 1:
1351
+ tmp = defaultTileFetcher$slambda_2(bytes, config, null);
1352
+ break;
1353
+ default:
1354
+ noWhenBranchMatchedException();
1355
+ break;
1356
+ }
1357
+ return tmp;
1358
+ }
1359
+ function fetchAndDecodeTile$ref() {
1360
+ KFunctionImpl.call(this, 1, 2, 2);
1361
+ }
1362
+ protoOf(fetchAndDecodeTile$ref).invoke_fa3hvc_k$ = function (p0, $completion) {
1363
+ return fetchAndDecodeTile(p0, $completion);
1364
+ };
1365
+ protoOf(fetchAndDecodeTile$ref).invoke_qns8j1_k$ = function (p1, $completion) {
1366
+ return this.invoke_fa3hvc_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1367
+ };
1368
+ function defaultTileFetcher$slambda($bytes, resultContinuation) {
1369
+ this.$bytes_1 = $bytes;
1370
+ CoroutineImpl.call(this, resultContinuation);
1371
+ }
1372
+ protoOf(defaultTileFetcher$slambda).invoke_fa3hvc_k$ = function (url, $completion) {
1373
+ var tmp = this.create_99ct7z_k$(url, $completion);
1374
+ tmp.result_1 = Unit_instance;
1375
+ tmp.exception_1 = null;
1376
+ return tmp.doResume_5yljmg_k$();
1377
+ };
1378
+ protoOf(defaultTileFetcher$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
1379
+ return this.invoke_fa3hvc_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1380
+ };
1381
+ protoOf(defaultTileFetcher$slambda).doResume_5yljmg_k$ = function () {
1382
+ var suspendResult = this.result_1;
1383
+ $sm: do
1384
+ try {
1385
+ var tmp = this.state_1;
1386
+ switch (tmp) {
1387
+ case 0:
1388
+ this.exceptionState_1 = 3;
1389
+ this.state_1 = 1;
1390
+ suspendResult = this.$bytes_1(this.url_1, this);
1391
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1392
+ return suspendResult;
1393
+ }
1394
+
1395
+ continue $sm;
1396
+ case 1:
1397
+ var ARGUMENT = suspendResult;
1398
+ this.state_1 = 2;
1399
+ suspendResult = decodeTileBytes(ARGUMENT, this.url_1, this);
1400
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1401
+ return suspendResult;
1402
+ }
1403
+
1404
+ continue $sm;
1405
+ case 2:
1406
+ return suspendResult;
1407
+ case 3:
1408
+ throw this.exception_1;
1409
+ }
1410
+ } catch ($p) {
1411
+ var e = $p;
1412
+ if (this.exceptionState_1 === 3) {
1413
+ throw e;
1414
+ } else {
1415
+ this.state_1 = this.exceptionState_1;
1416
+ this.exception_1 = e;
1417
+ }
1418
+ }
1419
+ while (true);
1420
+ };
1421
+ protoOf(defaultTileFetcher$slambda).create_99ct7z_k$ = function (url, completion) {
1422
+ var i = new defaultTileFetcher$slambda(this.$bytes_1, completion);
1423
+ i.url_1 = url;
1424
+ return i;
1425
+ };
1426
+ function defaultTileFetcher$slambda_0($bytes, resultContinuation) {
1427
+ var i = new defaultTileFetcher$slambda($bytes, resultContinuation);
1428
+ return constructCallableReference(function (url, $completion) {
1429
+ return i.invoke_fa3hvc_k$(url, $completion);
1430
+ }, 1);
1431
+ }
1432
+ function defaultTileFetcher$slambda_1($bytes, $config, resultContinuation) {
1433
+ this.$bytes_1 = $bytes;
1434
+ this.$config_1 = $config;
1435
+ CoroutineImpl.call(this, resultContinuation);
1436
+ }
1437
+ protoOf(defaultTileFetcher$slambda_1).invoke_fa3hvc_k$ = function (url, $completion) {
1438
+ var tmp = this.create_99ct7z_k$(url, $completion);
1439
+ tmp.result_1 = Unit_instance;
1440
+ tmp.exception_1 = null;
1441
+ return tmp.doResume_5yljmg_k$();
1442
+ };
1443
+ protoOf(defaultTileFetcher$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
1444
+ return this.invoke_fa3hvc_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1445
+ };
1446
+ protoOf(defaultTileFetcher$slambda_1).doResume_5yljmg_k$ = function () {
1447
+ var suspendResult = this.result_1;
1448
+ $sm: do
1449
+ try {
1450
+ var tmp = this.state_1;
1451
+ switch (tmp) {
1452
+ case 0:
1453
+ this.exceptionState_1 = 2;
1454
+ this.state_1 = 1;
1455
+ suspendResult = this.$bytes_1(this.url_1, this);
1456
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1457
+ return suspendResult;
1458
+ }
1459
+
1460
+ continue $sm;
1461
+ case 1:
1462
+ var ARGUMENT = suspendResult;
1463
+ return decodeBil32Tile(ARGUMENT, this.$config_1.tileSize_1, this.url_1);
1464
+ case 2:
1465
+ throw this.exception_1;
1466
+ }
1467
+ } catch ($p) {
1468
+ var e = $p;
1469
+ if (this.exceptionState_1 === 2) {
1470
+ throw e;
1471
+ } else {
1472
+ this.state_1 = this.exceptionState_1;
1473
+ this.exception_1 = e;
1474
+ }
1475
+ }
1476
+ while (true);
1477
+ };
1478
+ protoOf(defaultTileFetcher$slambda_1).create_99ct7z_k$ = function (url, completion) {
1479
+ var i = new defaultTileFetcher$slambda_1(this.$bytes_1, this.$config_1, completion);
1480
+ i.url_1 = url;
1481
+ return i;
1482
+ };
1483
+ function defaultTileFetcher$slambda_2($bytes, $config, resultContinuation) {
1484
+ var i = new defaultTileFetcher$slambda_1($bytes, $config, resultContinuation);
1485
+ return constructCallableReference(function (url, $completion) {
1486
+ return i.invoke_fa3hvc_k$(url, $completion);
1487
+ }, 1);
1488
+ }
1489
+ function defaultTileFetcher$ref() {
1490
+ return constructCallableReference(function (p0) {
1491
+ return defaultTileFetcher(p0);
1492
+ }, 1, 0, 3, 'defaultTileFetcher');
1493
+ }
1494
+ function ElevationProviderConfig(zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond) {
1108
1495
  zoomLevel = zoomLevel === VOID ? 12 : zoomLevel;
1109
1496
  cacheSize = cacheSize === VOID ? 100 : cacheSize;
1110
1497
  tileUrlTemplate = tileUrlTemplate === VOID ? 'https://tiles.mapterhorn.com/{z}/{x}/{y}.webp' : tileUrlTemplate;
1111
1498
  tileSize = tileSize === VOID ? 512 : tileSize;
1112
1499
  attribution = attribution === VOID ? new Attribution('Mapterhorn elevation data. See mapterhorn.com/attribution/ for details.', 'https://mapterhorn.com/attribution/') : attribution;
1500
+ encoding = encoding === VOID ? TileEncoding_TERRARIUM_getInstance() : encoding;
1501
+ maxRequestsPerSecond = maxRequestsPerSecond === VOID ? 0 : maxRequestsPerSecond;
1113
1502
  this.zoomLevel_1 = zoomLevel;
1114
1503
  this.cacheSize_1 = cacheSize;
1115
1504
  this.tileUrlTemplate_1 = tileUrlTemplate;
1116
1505
  this.tileSize_1 = tileSize;
1117
1506
  this.attribution_1 = attribution;
1507
+ this.encoding_1 = encoding;
1508
+ this.maxRequestsPerSecond_1 = maxRequestsPerSecond;
1118
1509
  }
1510
+ protoOf(ElevationProviderConfig).copy_u5v3pu_k$ = function (zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond) {
1511
+ return new ElevationProviderConfig(zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond);
1512
+ };
1513
+ protoOf(ElevationProviderConfig).copy$default_ptnzjy_k$ = function (zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond, $super) {
1514
+ zoomLevel = zoomLevel === VOID ? this.zoomLevel_1 : zoomLevel;
1515
+ cacheSize = cacheSize === VOID ? this.cacheSize_1 : cacheSize;
1516
+ tileUrlTemplate = tileUrlTemplate === VOID ? this.tileUrlTemplate_1 : tileUrlTemplate;
1517
+ tileSize = tileSize === VOID ? this.tileSize_1 : tileSize;
1518
+ attribution = attribution === VOID ? this.attribution_1 : attribution;
1519
+ encoding = encoding === VOID ? this.encoding_1 : encoding;
1520
+ maxRequestsPerSecond = maxRequestsPerSecond === VOID ? this.maxRequestsPerSecond_1 : maxRequestsPerSecond;
1521
+ return $super === VOID ? this.copy_u5v3pu_k$(zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond) : $super.copy_u5v3pu_k$.call(this, zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution, encoding, maxRequestsPerSecond);
1522
+ };
1119
1523
  protoOf(ElevationProviderConfig).toString = function () {
1120
- return 'ElevationProviderConfig(zoomLevel=' + this.zoomLevel_1 + ', cacheSize=' + this.cacheSize_1 + ', tileUrlTemplate=' + this.tileUrlTemplate_1 + ', tileSize=' + this.tileSize_1 + ', attribution=' + this.attribution_1.toString() + ')';
1524
+ return 'ElevationProviderConfig(zoomLevel=' + this.zoomLevel_1 + ', cacheSize=' + this.cacheSize_1 + ', tileUrlTemplate=' + this.tileUrlTemplate_1 + ', tileSize=' + this.tileSize_1 + ', attribution=' + this.attribution_1.toString() + ', encoding=' + this.encoding_1.toString() + ', maxRequestsPerSecond=' + this.maxRequestsPerSecond_1 + ')';
1121
1525
  };
1122
1526
  protoOf(ElevationProviderConfig).hashCode = function () {
1123
1527
  var result = this.zoomLevel_1;
@@ -1125,6 +1529,8 @@
1125
1529
  result = imul(result, 31) + getStringHashCode(this.tileUrlTemplate_1) | 0;
1126
1530
  result = imul(result, 31) + this.tileSize_1 | 0;
1127
1531
  result = imul(result, 31) + this.attribution_1.hashCode() | 0;
1532
+ result = imul(result, 31) + this.encoding_1.hashCode() | 0;
1533
+ result = imul(result, 31) + this.maxRequestsPerSecond_1 | 0;
1128
1534
  return result;
1129
1535
  };
1130
1536
  protoOf(ElevationProviderConfig).equals = function (other) {
@@ -1142,6 +1548,10 @@
1142
1548
  return false;
1143
1549
  if (!this.attribution_1.equals(other.attribution_1))
1144
1550
  return false;
1551
+ if (!this.encoding_1.equals(other.encoding_1))
1552
+ return false;
1553
+ if (!(this.maxRequestsPerSecond_1 === other.maxRequestsPerSecond_1))
1554
+ return false;
1145
1555
  return true;
1146
1556
  };
1147
1557
  function Attribution(text, url) {
@@ -1292,26 +1702,198 @@
1292
1702
  function ElevationSmoother_getInstance() {
1293
1703
  return ElevationSmoother_instance;
1294
1704
  }
1295
- function Flux$forEachParallel$slambda$slambda($semaphore, $action, $item, resultContinuation) {
1296
- this.$semaphore_1 = $semaphore;
1297
- this.$action_1 = $action;
1298
- this.$item_1 = $item;
1299
- CoroutineImpl.call(this, resultContinuation);
1705
+ function ignWmsTemplate($this, layer, tileSize) {
1706
+ return 'https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=' + layer + '&STYLES=normal' + ('&CRS=EPSG:4326&BBOX={bbox}&WIDTH=' + tileSize + '&HEIGHT=' + tileSize + '&FORMAT=image%2Fx-bil%3Bbits%3D32');
1300
1707
  }
1301
- protoOf(Flux$forEachParallel$slambda$slambda).invoke_d9fzmj_k$ = function ($this$async, $completion) {
1302
- var tmp = this.create_rcuf4x_k$($this$async, $completion);
1303
- tmp.result_1 = Unit_instance;
1304
- tmp.exception_1 = null;
1305
- return tmp.doResume_5yljmg_k$();
1306
- };
1307
- protoOf(Flux$forEachParallel$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
1308
- return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1708
+ var static_init_called_0;
1709
+ function static_init_0() {
1710
+ if (static_init_called_0)
1711
+ return Unit_instance;
1712
+ static_init_called_0 = true;
1713
+ ElevationSource_MAPTERHORN_instance = new ElevationSource('MAPTERHORN', 0, 'mapterhorn');
1714
+ ElevationSource_IGN_LIDAR_HD_instance = new ElevationSource('IGN_LIDAR_HD', 1, 'ign-lidar-hd');
1715
+ if (Companion_instance_0 == null) {
1716
+ Companion_instance;
1717
+ new Companion();
1718
+ }
1719
+ }
1720
+ var ElevationSource_MAPTERHORN_instance;
1721
+ var ElevationSource_IGN_LIDAR_HD_instance;
1722
+ function Companion() {
1723
+ Companion_instance_0 = this;
1724
+ this.DEFAULT_1 = ElevationSource_MAPTERHORN_getInstance();
1725
+ this.IGN_TILE_SIZE_1 = 256;
1726
+ this.IGN_WMS_URL_1 = 'https://data.geopf.fr/wms-r/wms';
1727
+ this.IGN_LIDAR_HD_MNT_LAYER_1 = 'IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.WGS84G';
1728
+ }
1729
+ protoOf(Companion).get_ids_18j3qp_k$ = function () {
1730
+ // Inline function 'kotlin.collections.map' call
1731
+ var this_0 = get_entries();
1732
+ // Inline function 'kotlin.collections.mapTo' call
1733
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1734
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
1735
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1736
+ var item = _iterator__ex2g4s.next_20eer_k$();
1737
+ var tmp$ret$2 = item.id_1;
1738
+ destination.add_utx5q5_k$(tmp$ret$2);
1739
+ }
1740
+ return destination;
1741
+ };
1742
+ protoOf(Companion).byId_8gmd94_k$ = function (id) {
1743
+ var tmp0 = get_entries();
1744
+ var tmp$ret$0;
1745
+ $l$block: {
1746
+ // Inline function 'kotlin.collections.firstOrNull' call
1747
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
1748
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1749
+ var element = _iterator__ex2g4s.next_20eer_k$();
1750
+ if (element.id_1 === id) {
1751
+ tmp$ret$0 = element;
1752
+ break $l$block;
1753
+ }
1754
+ }
1755
+ tmp$ret$0 = null;
1756
+ }
1757
+ var tmp0_elvis_lhs = tmp$ret$0;
1758
+ var tmp;
1759
+ if (tmp0_elvis_lhs == null) {
1760
+ throw IllegalArgumentException_init_$Create$("Unknown DEM source '" + id + "' \u2014 expected one of " + joinToString(this.get_ids_18j3qp_k$()));
1761
+ } else {
1762
+ tmp = tmp0_elvis_lhs;
1763
+ }
1764
+ return tmp;
1309
1765
  };
1310
- protoOf(Flux$forEachParallel$slambda$slambda).doResume_5yljmg_k$ = function () {
1311
- var suspendResult = this.result_1;
1312
- $sm: do
1313
- try {
1314
- var tmp = this.state_1;
1766
+ var Companion_instance_0;
1767
+ function Companion_getInstance() {
1768
+ static_init_0();
1769
+ return Companion_instance_0;
1770
+ }
1771
+ function values() {
1772
+ static_init_0();
1773
+ return [ElevationSource_MAPTERHORN_getInstance(), ElevationSource_IGN_LIDAR_HD_getInstance()];
1774
+ }
1775
+ function get_entries() {
1776
+ static_init_0();
1777
+ if ($ENTRIES == null)
1778
+ $ENTRIES = enumEntries(values());
1779
+ return $ENTRIES;
1780
+ }
1781
+ var $ENTRIES;
1782
+ function ElevationSource(name, ordinal, id) {
1783
+ Enum.call(this, name, ordinal);
1784
+ this.id_1 = id;
1785
+ }
1786
+ protoOf(ElevationSource).get_fallback_j7pnit_k$ = function () {
1787
+ var tmp;
1788
+ switch (this.ordinal_1) {
1789
+ case 0:
1790
+ tmp = null;
1791
+ break;
1792
+ case 1:
1793
+ tmp = ElevationSource_MAPTERHORN_getInstance();
1794
+ break;
1795
+ default:
1796
+ noWhenBranchMatchedException();
1797
+ break;
1798
+ }
1799
+ return tmp;
1800
+ };
1801
+ protoOf(ElevationSource).get_defaultZoomLevel_a8cjy1_k$ = function () {
1802
+ var tmp;
1803
+ switch (this.ordinal_1) {
1804
+ case 0:
1805
+ tmp = (new ElevationProviderConfig()).zoomLevel_1;
1806
+ break;
1807
+ case 1:
1808
+ tmp = 15;
1809
+ break;
1810
+ default:
1811
+ noWhenBranchMatchedException();
1812
+ break;
1813
+ }
1814
+ return tmp;
1815
+ };
1816
+ protoOf(ElevationSource).config_nlp9c9_k$ = function (zoomLevel) {
1817
+ var tmp;
1818
+ switch (this.ordinal_1) {
1819
+ case 0:
1820
+ tmp = new ElevationProviderConfig(zoomLevel == null ? this.get_defaultZoomLevel_a8cjy1_k$() : zoomLevel);
1821
+ break;
1822
+ case 1:
1823
+ var tmp3_zoomLevel = zoomLevel == null ? this.get_defaultZoomLevel_a8cjy1_k$() : zoomLevel;
1824
+ var tmp5_tileUrlTemplate = ignWmsTemplate(Companion_getInstance(), 'IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.WGS84G', 256);
1825
+ var tmp6_encoding = TileEncoding_BIL32_getInstance();
1826
+ var tmp7_attribution = new Attribution('\xA9 IGN \u2014 LiDAR HD MNT, Licence Ouverte Etalab 2.0', 'https://geoservices.ign.fr/lidarhd');
1827
+ tmp = new ElevationProviderConfig(tmp3_zoomLevel, VOID, tmp5_tileUrlTemplate, 256, tmp7_attribution, tmp6_encoding, 20);
1828
+ break;
1829
+ default:
1830
+ noWhenBranchMatchedException();
1831
+ break;
1832
+ }
1833
+ return tmp;
1834
+ };
1835
+ function provider(_this__u8e3s4, zoomLevel, fetcherFor) {
1836
+ zoomLevel = zoomLevel === VOID ? null : zoomLevel;
1837
+ var tmp;
1838
+ if (fetcherFor === VOID) {
1839
+ tmp = defaultTileFetcher$ref();
1840
+ } else {
1841
+ tmp = fetcherFor;
1842
+ }
1843
+ fetcherFor = tmp;
1844
+ var config = _this__u8e3s4.config_nlp9c9_k$(zoomLevel);
1845
+ var primary = ElevationProvider_init_$Create$(config, fetcherFor(config));
1846
+ var tmp0_elvis_lhs = _this__u8e3s4.get_fallback_j7pnit_k$();
1847
+ var tmp_0;
1848
+ if (tmp0_elvis_lhs == null) {
1849
+ return primary;
1850
+ } else {
1851
+ tmp_0 = tmp0_elvis_lhs;
1852
+ }
1853
+ var next = tmp_0;
1854
+ return primary.withFallback_7synod_k$(provider(next, null, fetcherFor));
1855
+ }
1856
+ function wmsBbox4326(tc) {
1857
+ var tiles = 1 << tc.z_1;
1858
+ var west = tc.x_1 / tiles * 360.0 - 180.0;
1859
+ var east = (tc.x_1 + 1 | 0) / tiles * 360.0 - 180.0;
1860
+ return '' + tileNorthLatitude(tc.y_1 + 1 | 0, tiles) + ',' + west + ',' + tileNorthLatitude(tc.y_1, tiles) + ',' + east;
1861
+ }
1862
+ function tileNorthLatitude(y, tiles) {
1863
+ // Inline function 'kotlin.math.sinh' call
1864
+ var x = 3.141592653589793 - 2.0 * 3.141592653589793 * y / tiles;
1865
+ // Inline function 'kotlin.math.atan' call
1866
+ var x_0 = sinh(x);
1867
+ return Math.atan(x_0) * 57.29577951308232;
1868
+ }
1869
+ function ElevationSource_MAPTERHORN_getInstance() {
1870
+ static_init_0();
1871
+ return ElevationSource_MAPTERHORN_instance;
1872
+ }
1873
+ function ElevationSource_IGN_LIDAR_HD_getInstance() {
1874
+ static_init_0();
1875
+ return ElevationSource_IGN_LIDAR_HD_instance;
1876
+ }
1877
+ function Flux$forEachParallel$slambda$slambda($semaphore, $action, $item, resultContinuation) {
1878
+ this.$semaphore_1 = $semaphore;
1879
+ this.$action_1 = $action;
1880
+ this.$item_1 = $item;
1881
+ CoroutineImpl.call(this, resultContinuation);
1882
+ }
1883
+ protoOf(Flux$forEachParallel$slambda$slambda).invoke_d9fzmj_k$ = function ($this$async, $completion) {
1884
+ var tmp = this.create_rcuf4x_k$($this$async, $completion);
1885
+ tmp.result_1 = Unit_instance;
1886
+ tmp.exception_1 = null;
1887
+ return tmp.doResume_5yljmg_k$();
1888
+ };
1889
+ protoOf(Flux$forEachParallel$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
1890
+ return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1891
+ };
1892
+ protoOf(Flux$forEachParallel$slambda$slambda).doResume_5yljmg_k$ = function () {
1893
+ var suspendResult = this.result_1;
1894
+ $sm: do
1895
+ try {
1896
+ var tmp = this.state_1;
1315
1897
  switch (tmp) {
1316
1898
  case 0:
1317
1899
  this.exceptionState_1 = 6;
@@ -2006,15 +2588,15 @@
2006
2588
  function Tile_init_$Create$(raw) {
2007
2589
  return Tile_init_$Init$(raw, objectCreate(protoOf(Tile)));
2008
2590
  }
2009
- function Companion() {
2591
+ function Companion_0() {
2010
2592
  }
2011
- protoOf(Companion).decodeTerrariumElevation_vmx8i4_k$ = function (r, g, b) {
2593
+ protoOf(Companion_0).decodeTerrariumElevation_vmx8i4_k$ = function (r, g, b) {
2012
2594
  var raw = r * 256.0 + g + b / 256.0 - 32768.0;
2013
2595
  return round(raw * 100.0) / 100.0;
2014
2596
  };
2015
- var Companion_instance;
2016
- function Companion_getInstance() {
2017
- return Companion_instance;
2597
+ var Companion_instance_1;
2598
+ function Companion_getInstance_0() {
2599
+ return Companion_instance_1;
2018
2600
  }
2019
2601
  function Tile(width, height, rgba) {
2020
2602
  this.width_1 = width;
@@ -2054,13 +2636,15 @@
2054
2636
  var r = this.rgba_1[byteOffset] & 255;
2055
2637
  var g = this.rgba_1[byteOffset + 1 | 0] & 255;
2056
2638
  var b = this.rgba_1[byteOffset + 2 | 0] & 255;
2057
- var elevation = Companion_instance.decodeTerrariumElevation_vmx8i4_k$(r, g, b);
2639
+ var elevation = r === 0 && g === 0 && b === 0 ? NaN : Companion_instance_1.decodeTerrariumElevation_vmx8i4_k$(r, g, b);
2058
2640
  this.cache_1[idx] = elevation;
2059
2641
  this.decodeCount_1 = this.decodeCount_1 + 1 | 0;
2060
2642
  return elevation;
2061
2643
  };
2062
2644
  function buildUrl($this, tc) {
2063
- return replace(replace(replace($this.urlTemplate_1, '{z}', tc.z_1.toString()), '{x}', tc.x_1.toString()), '{y}', tc.y_1.toString());
2645
+ // Inline function 'kotlin.let' call
2646
+ var it = replace(replace(replace($this.urlTemplate_1, '{z}', tc.z_1.toString()), '{x}', tc.x_1.toString()), '{y}', tc.y_1.toString());
2647
+ return contains(it, '{bbox}') ? replace(it, '{bbox}', wmsBbox4326(tc)) : it;
2064
2648
  }
2065
2649
  function fetchAndDecodeTile$ref_0() {
2066
2650
  KFunctionImpl.call(this, 1, 2, 2);
@@ -2143,6 +2727,265 @@
2143
2727
  protoOf(TileManager).getTile_c22khk_k$ = function (tileCoords, $completion) {
2144
2728
  return this.cache_1.get_27lcp2_k$(tileCoords, $completion);
2145
2729
  };
2730
+ function pacedTileBytesFetcher(maxRequestsPerSecond, fetch, maxAttempts, now) {
2731
+ var tmp;
2732
+ if (fetch === VOID) {
2733
+ tmp = fetchTileBytes$ref_0();
2734
+ } else {
2735
+ tmp = fetch;
2736
+ }
2737
+ fetch = tmp;
2738
+ maxAttempts = maxAttempts === VOID ? 6 : maxAttempts;
2739
+ now = now === VOID ? monotonicMillis() : now;
2740
+ // Inline function 'kotlin.require' call
2741
+ if (!(maxRequestsPerSecond >= 0)) {
2742
+ var message = 'maxRequestsPerSecond must be >= 0, was ' + maxRequestsPerSecond;
2743
+ throw IllegalArgumentException_init_$Create$(toString(message));
2744
+ }
2745
+ // Inline function 'kotlin.require' call
2746
+ if (!(maxAttempts >= 1)) {
2747
+ var message_0 = 'maxAttempts must be >= 1, was ' + maxAttempts;
2748
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
2749
+ }
2750
+ var pacer = maxRequestsPerSecond > 0 ? new RequestPacer(maxRequestsPerSecond, now) : null;
2751
+ return pacedTileBytesFetcher$slambda_0(pacer, fetch, maxAttempts, null);
2752
+ }
2753
+ function TileFetchException(url, status, retryAfterSeconds) {
2754
+ retryAfterSeconds = retryAfterSeconds === VOID ? null : retryAfterSeconds;
2755
+ IllegalStateException_init_$Init$('Tile fetch failed for ' + url + ': HTTP ' + status, this);
2756
+ captureStack(this, TileFetchException);
2757
+ this.url_1 = url;
2758
+ this.status_1 = status;
2759
+ this.retryAfterSeconds_1 = retryAfterSeconds;
2760
+ }
2761
+ function monotonicMillis() {
2762
+ var origin = Monotonic_instance.markNow_ns2ype_k$();
2763
+ return monotonicMillis$lambda(origin);
2764
+ }
2765
+ function $awaitTurnCOROUTINE$(_this__u8e3s4, resultContinuation) {
2766
+ CoroutineImpl.call(this, resultContinuation);
2767
+ this._this__u8e3s4__1 = _this__u8e3s4;
2768
+ }
2769
+ protoOf($awaitTurnCOROUTINE$).doResume_5yljmg_k$ = function () {
2770
+ var suspendResult = this.result_1;
2771
+ $sm: do
2772
+ try {
2773
+ var tmp = this.state_1;
2774
+ switch (tmp) {
2775
+ case 0:
2776
+ this.exceptionState_1 = 4;
2777
+ this.this1__1 = this._this__u8e3s4__1.mutex_1;
2778
+ this.owner0__1 = null;
2779
+ this.state_1 = 1;
2780
+ suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner0__1, this);
2781
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2782
+ return suspendResult;
2783
+ }
2784
+
2785
+ continue $sm;
2786
+ case 1:
2787
+ var tmp$ret$0 = Unit_instance;
2788
+ l$ret$1: do {
2789
+ var tmp_0;
2790
+ try {
2791
+ var t = toNumber(this._this__u8e3s4__1.now_1());
2792
+ var b = this._this__u8e3s4__1.nextSlotMs_1;
2793
+ var slot = Math.max(t, b);
2794
+ this._this__u8e3s4__1.nextSlotMs_1 = slot + this._this__u8e3s4__1.spacingMs_1;
2795
+ tmp$ret$0 = slot - t;
2796
+ break l$ret$1;
2797
+ } catch ($p) {
2798
+ var tmp_1;
2799
+ var t_0 = $p;
2800
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
2801
+ throw t_0;
2802
+ }
2803
+ }
2804
+ while (false);
2805
+ var tmp_2 = tmp$ret$0;
2806
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
2807
+ var waitMs = tmp_2;
2808
+ if (waitMs > 0) {
2809
+ this.state_1 = 2;
2810
+ suspendResult = delay(numberToLong(Math.ceil(waitMs)), this);
2811
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2812
+ return suspendResult;
2813
+ }
2814
+ continue $sm;
2815
+ } else {
2816
+ this.state_1 = 3;
2817
+ continue $sm;
2818
+ }
2819
+
2820
+ case 2:
2821
+ this.state_1 = 3;
2822
+ continue $sm;
2823
+ case 3:
2824
+ return Unit_instance;
2825
+ case 4:
2826
+ throw this.exception_1;
2827
+ }
2828
+ } catch ($p_0) {
2829
+ var e = $p_0;
2830
+ if (this.exceptionState_1 === 4) {
2831
+ throw e;
2832
+ } else {
2833
+ this.state_1 = this.exceptionState_1;
2834
+ this.exception_1 = e;
2835
+ }
2836
+ }
2837
+ while (true);
2838
+ };
2839
+ function RequestPacer(perSecond, now) {
2840
+ this.now_1 = now;
2841
+ this.spacingMs_1 = 1000.0 / perSecond;
2842
+ this.mutex_1 = Mutex();
2843
+ this.nextSlotMs_1 = -Infinity;
2844
+ }
2845
+ protoOf(RequestPacer).awaitTurn_n6e5s4_k$ = function ($completion) {
2846
+ var tmp = new $awaitTurnCOROUTINE$(this, $completion);
2847
+ tmp.result_1 = Unit_instance;
2848
+ tmp.exception_1 = null;
2849
+ return tmp.doResume_5yljmg_k$();
2850
+ };
2851
+ function fetchTileBytes$ref() {
2852
+ KFunctionImpl.call(this, 1, 2, 4);
2853
+ }
2854
+ protoOf(fetchTileBytes$ref).invoke_vut9or_k$ = function (p0, $completion) {
2855
+ return fetchTileBytes(p0, $completion);
2856
+ };
2857
+ protoOf(fetchTileBytes$ref).invoke_qns8j1_k$ = function (p1, $completion) {
2858
+ return this.invoke_vut9or_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
2859
+ };
2860
+ function pacedTileBytesFetcher$slambda($pacer, $fetch, $maxAttempts, resultContinuation) {
2861
+ this.$pacer_1 = $pacer;
2862
+ this.$fetch_1 = $fetch;
2863
+ this.$maxAttempts_1 = $maxAttempts;
2864
+ CoroutineImpl.call(this, resultContinuation);
2865
+ }
2866
+ protoOf(pacedTileBytesFetcher$slambda).invoke_vut9or_k$ = function (url, $completion) {
2867
+ var tmp = this.create_99ct7z_k$(url, $completion);
2868
+ tmp.result_1 = Unit_instance;
2869
+ tmp.exception_1 = null;
2870
+ return tmp.doResume_5yljmg_k$();
2871
+ };
2872
+ protoOf(pacedTileBytesFetcher$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
2873
+ return this.invoke_vut9or_k$((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
2874
+ };
2875
+ protoOf(pacedTileBytesFetcher$slambda).doResume_5yljmg_k$ = function () {
2876
+ var suspendResult = this.result_1;
2877
+ $sm: do
2878
+ try {
2879
+ var tmp = this.state_1;
2880
+ switch (tmp) {
2881
+ case 0:
2882
+ this.exceptionState_1 = 9;
2883
+ this.attempt2__1 = 1;
2884
+ this.bytes0__1 = null;
2885
+ this.state_1 = 1;
2886
+ continue $sm;
2887
+ case 1:
2888
+ if (!(this.bytes0__1 == null)) {
2889
+ this.state_1 = 8;
2890
+ continue $sm;
2891
+ }
2892
+
2893
+ var tmp0_safe_receiver = this.$pacer_1;
2894
+ if (tmp0_safe_receiver == null) {
2895
+ this.WHEN_RESULT3__1 = null;
2896
+ this.state_1 = 3;
2897
+ continue $sm;
2898
+ } else {
2899
+ this.state_1 = 2;
2900
+ suspendResult = tmp0_safe_receiver.awaitTurn_n6e5s4_k$(this);
2901
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2902
+ return suspendResult;
2903
+ }
2904
+ continue $sm;
2905
+ }
2906
+
2907
+ case 2:
2908
+ var tmp_0 = this;
2909
+ tmp_0.WHEN_RESULT3__1 = Unit_instance;
2910
+ this.state_1 = 3;
2911
+ continue $sm;
2912
+ case 3:
2913
+ this.exceptionState_1 = 5;
2914
+ this.state_1 = 4;
2915
+ suspendResult = this.$fetch_1(this.url_1, this);
2916
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2917
+ return suspendResult;
2918
+ }
2919
+
2920
+ continue $sm;
2921
+ case 4:
2922
+ var tmp_1 = this;
2923
+ this.bytes0__1 = suspendResult;
2924
+ tmp_1.TRY_RESULT1__1 = Unit_instance;
2925
+ this.exceptionState_1 = 9;
2926
+ this.state_1 = 7;
2927
+ continue $sm;
2928
+ case 5:
2929
+ this.exceptionState_1 = 9;
2930
+ var tmp_2 = this.exception_1;
2931
+ if (tmp_2 instanceof TileFetchException) {
2932
+ var e = this.exception_1;
2933
+ if (!(e.status_1 === 429) && !(e.status_1 === 503) || this.attempt2__1 >= this.$maxAttempts_1)
2934
+ throw e;
2935
+ this.state_1 = 6;
2936
+ var tmp1_elvis_lhs = e.retryAfterSeconds_1;
2937
+ suspendResult = delay(multiply(tmp1_elvis_lhs == null ? shiftLeft(new Long(1, 0), this.attempt2__1 - 1 | 0) : tmp1_elvis_lhs, new Long(1000, 0)), this);
2938
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2939
+ return suspendResult;
2940
+ }
2941
+ continue $sm;
2942
+ } else {
2943
+ throw this.exception_1;
2944
+ }
2945
+
2946
+ case 6:
2947
+ var tmp_3 = this;
2948
+ var _unary__edvuaz = this.attempt2__1;
2949
+ this.attempt2__1 = _unary__edvuaz + 1 | 0;
2950
+ tmp_3.TRY_RESULT1__1 = _unary__edvuaz;
2951
+ this.state_1 = 7;
2952
+ continue $sm;
2953
+ case 7:
2954
+ this.exceptionState_1 = 9;
2955
+ this.state_1 = 1;
2956
+ continue $sm;
2957
+ case 8:
2958
+ return this.bytes0__1;
2959
+ case 9:
2960
+ throw this.exception_1;
2961
+ }
2962
+ } catch ($p) {
2963
+ var e_0 = $p;
2964
+ if (this.exceptionState_1 === 9) {
2965
+ throw e_0;
2966
+ } else {
2967
+ this.state_1 = this.exceptionState_1;
2968
+ this.exception_1 = e_0;
2969
+ }
2970
+ }
2971
+ while (true);
2972
+ };
2973
+ protoOf(pacedTileBytesFetcher$slambda).create_99ct7z_k$ = function (url, completion) {
2974
+ var i = new pacedTileBytesFetcher$slambda(this.$pacer_1, this.$fetch_1, this.$maxAttempts_1, completion);
2975
+ i.url_1 = url;
2976
+ return i;
2977
+ };
2978
+ function pacedTileBytesFetcher$slambda_0($pacer, $fetch, $maxAttempts, resultContinuation) {
2979
+ var i = new pacedTileBytesFetcher$slambda($pacer, $fetch, $maxAttempts, resultContinuation);
2980
+ return constructCallableReference(function (url, $completion) {
2981
+ return i.invoke_vut9or_k$(url, $completion);
2982
+ }, 1);
2983
+ }
2984
+ function monotonicMillis$lambda($origin) {
2985
+ return function () {
2986
+ return _Duration___get_inWholeMilliseconds__impl__msfiry(ValueTimeMark__elapsedNow_impl_eonqvs($origin));
2987
+ };
2988
+ }
2146
2989
  function TileCoordinates(x, y, z) {
2147
2990
  this.x_1 = x;
2148
2991
  this.y_1 = y;
@@ -2259,18 +3102,18 @@
2259
3102
  return false;
2260
3103
  return true;
2261
3104
  };
2262
- function Companion_0() {
2263
- Companion_instance_0 = this;
3105
+ function Companion_1() {
3106
+ Companion_instance_2 = this;
2264
3107
  this.ZERO_1 = new Vector3D(0.0, 0.0, 0.0);
2265
3108
  }
2266
- var Companion_instance_0;
2267
- function Companion_getInstance_0() {
2268
- if (Companion_instance_0 == null)
2269
- new Companion_0();
2270
- return Companion_instance_0;
3109
+ var Companion_instance_2;
3110
+ function Companion_getInstance_1() {
3111
+ if (Companion_instance_2 == null)
3112
+ new Companion_1();
3113
+ return Companion_instance_2;
2271
3114
  }
2272
3115
  function Vector3D(x, y, z) {
2273
- Companion_getInstance_0();
3116
+ Companion_getInstance_1();
2274
3117
  this.x_1 = x;
2275
3118
  this.y_1 = y;
2276
3119
  this.z_1 = z;
@@ -2303,7 +3146,7 @@
2303
3146
  return this.distanceTo_53ug7b_k$(segmentStart);
2304
3147
  var pointVector = this.minus_de4vqf_k$(segmentStart);
2305
3148
  var projection = pointVector.dot_o3y6jk_k$(segmentVector) / segmentLengthSq;
2306
- var clamped = coerceIn(projection, 0.0, 1.0);
3149
+ var clamped = coerceIn_0(projection, 0.0, 1.0);
2307
3150
  var closest = segmentStart.plus_e4szu7_k$(segmentVector.times_qz1dds_k$(clamped));
2308
3151
  return this.distanceTo_53ug7b_k$(closest);
2309
3152
  };
@@ -2356,16 +3199,42 @@
2356
3199
  else {
2357
3200
  requireOnlyKeys(configDto, 'ElevationProviderConfigDto', get_CONFIG_KEYS());
2358
3201
  }
2359
- var defaults = new ElevationProviderConfig();
2360
- var tmp2_elvis_lhs = configDto == null ? null : configDto.zoomLevel;
2361
- var tmp = tmp2_elvis_lhs == null ? defaults.zoomLevel_1 : tmp2_elvis_lhs;
2362
- var tmp4_elvis_lhs = configDto == null ? null : configDto.cacheSize;
2363
- var tmp_0 = tmp4_elvis_lhs == null ? defaults.cacheSize_1 : tmp4_elvis_lhs;
2364
- var tmp6_elvis_lhs = configDto == null ? null : configDto.tileUrlTemplate;
2365
- var tmp_1 = tmp6_elvis_lhs == null ? defaults.tileUrlTemplate_1 : tmp6_elvis_lhs;
2366
- var tmp8_elvis_lhs = configDto == null ? null : configDto.tileSize;
2367
- var cfg = new ElevationProviderConfig(tmp, tmp_0, tmp_1, tmp8_elvis_lhs == null ? defaults.tileSize_1 : tmp8_elvis_lhs, defaults.attribution_1);
2368
- return new ElevationProvider(cfg);
3202
+ var tmp2_safe_receiver = configDto == null ? null : configDto.source;
3203
+ var tmp;
3204
+ if (tmp2_safe_receiver == null) {
3205
+ tmp = null;
3206
+ } else {
3207
+ // Inline function 'kotlin.let' call
3208
+ tmp = Companion_getInstance().byId_8gmd94_k$(tmp2_safe_receiver);
3209
+ }
3210
+ var tmp3_elvis_lhs = tmp;
3211
+ var source = tmp3_elvis_lhs == null ? Companion_getInstance().DEFAULT_1 : tmp3_elvis_lhs;
3212
+ var base = source.config_nlp9c9_k$(configDto == null ? null : configDto.zoomLevel);
3213
+ var tmp6_elvis_lhs = configDto == null ? null : configDto.cacheSize;
3214
+ var tmp_0 = tmp6_elvis_lhs == null ? base.cacheSize_1 : tmp6_elvis_lhs;
3215
+ var tmp8_elvis_lhs = configDto == null ? null : configDto.tileUrlTemplate;
3216
+ var tmp_1 = tmp8_elvis_lhs == null ? base.tileUrlTemplate_1 : tmp8_elvis_lhs;
3217
+ var tmp10_elvis_lhs = configDto == null ? null : configDto.tileSize;
3218
+ var cfg = base.copy$default_ptnzjy_k$(VOID, tmp_0, tmp_1, tmp10_elvis_lhs == null ? base.tileSize_1 : tmp10_elvis_lhs);
3219
+ var primary = ElevationProvider_init_$Create$(cfg);
3220
+ var tmp11_safe_receiver = source.get_fallback_j7pnit_k$();
3221
+ var tmp_2;
3222
+ if (tmp11_safe_receiver == null) {
3223
+ tmp_2 = null;
3224
+ } else {
3225
+ // Inline function 'kotlin.let' call
3226
+ tmp_2 = primary.withFallback_7synod_k$(provider(tmp11_safe_receiver));
3227
+ }
3228
+ var tmp12_elvis_lhs = tmp_2;
3229
+ return tmp12_elvis_lhs == null ? primary : tmp12_elvis_lhs;
3230
+ }
3231
+ function elevationAttribution(provider) {
3232
+ _init_properties_ElevationJsApi_kt__1yyas4();
3233
+ var o = {};
3234
+ o.text = provider.get_attribution_8rpdsm_k$().text_1;
3235
+ o.url = provider.get_attribution_8rpdsm_k$().url_1;
3236
+ // Inline function 'kotlin.js.unsafeCast' call
3237
+ return o;
2369
3238
  }
2370
3239
  function getElevation(provider, latitude, longitude, interpolation) {
2371
3240
  _init_properties_ElevationJsApi_kt__1yyas4();
@@ -2415,7 +3284,7 @@
2415
3284
  if (!unknown.isEmpty_y1axqb_k$()) {
2416
3285
  // Inline function 'kotlin.error' call
2417
3286
  var message = 'Unknown ' + dtoName + ' key(s): ' + joinToString(unknown) + ' \u2014 expected one of ' + joinToString(sorted(allowed));
2418
- throw IllegalStateException_init_$Create$_0(toString(message));
3287
+ throw IllegalStateException_init_$Create$(toString(message));
2419
3288
  }
2420
3289
  }
2421
3290
  function toKotlin(_this__u8e3s4) {
@@ -2590,7 +3459,7 @@
2590
3459
  function _init_properties_ElevationJsApi_kt__1yyas4() {
2591
3460
  if (!properties_initialized_ElevationJsApi_kt_8pvyh6) {
2592
3461
  properties_initialized_ElevationJsApi_kt_8pvyh6 = true;
2593
- CONFIG_KEYS = setOf(['zoomLevel', 'cacheSize', 'tileUrlTemplate', 'tileSize']);
3462
+ CONFIG_KEYS = setOf(['zoomLevel', 'cacheSize', 'tileUrlTemplate', 'tileSize', 'source']);
2594
3463
  ALONG_KEYS = setOf(['step', 'minDistance', 'interpolation', 'smoothingOptions', 'filterOptions']);
2595
3464
  SMOOTHING_KEYS = setOf(['enabled', 'windowSize']);
2596
3465
  FILTER_KEYS = setOf(['enabled', 'tolerance', 'zExaggeration']);
@@ -2616,6 +3485,13 @@
2616
3485
  tmp.exception_1 = null;
2617
3486
  return tmp.doResume_5yljmg_k$();
2618
3487
  }
3488
+ function decodeTileBytes(bytes, sourceUrl, $completion) {
3489
+ sourceUrl = sourceUrl === VOID ? '' : sourceUrl;
3490
+ var tmp = new $decodeTileBytesCOROUTINE$(bytes, sourceUrl, $completion);
3491
+ tmp.result_1 = Unit_instance;
3492
+ tmp.exception_1 = null;
3493
+ return tmp.doResume_5yljmg_k$();
3494
+ }
2619
3495
  function decodeNode(url, $completion) {
2620
3496
  var tmp = new $decodeNodeCOROUTINE$(url, $completion);
2621
3497
  tmp.result_1 = Unit_instance;
@@ -2628,11 +3504,44 @@
2628
3504
  tmp.exception_1 = null;
2629
3505
  return tmp.doResume_5yljmg_k$();
2630
3506
  }
3507
+ function decodeBytesNode(bytes, sourceUrl, $completion) {
3508
+ var tmp = new $decodeBytesNodeCOROUTINE$(bytes, sourceUrl, $completion);
3509
+ tmp.result_1 = Unit_instance;
3510
+ tmp.exception_1 = null;
3511
+ return tmp.doResume_5yljmg_k$();
3512
+ }
3513
+ function decodeBlob(blob, sourceUrl, $completion) {
3514
+ var tmp = new $decodeBlobCOROUTINE$(blob, sourceUrl, $completion);
3515
+ tmp.result_1 = Unit_instance;
3516
+ tmp.exception_1 = null;
3517
+ return tmp.doResume_5yljmg_k$();
3518
+ }
3519
+ function blobOf(bytes) {
3520
+ _init_properties_TileFetcher_js_kt__7a2f1e();
3521
+ // Inline function 'kotlin.js.unsafeCast' call
3522
+ return new Blob([bytes]);
3523
+ }
2631
3524
  function fetchUrlNode(url) {
2632
3525
  _init_properties_TileFetcher_js_kt__7a2f1e();
2633
3526
  // Inline function 'kotlin.js.unsafeCast' call
2634
3527
  return globalThis.fetch(url);
2635
3528
  }
3529
+ function requireOk(_this__u8e3s4, url) {
3530
+ _init_properties_TileFetcher_js_kt__7a2f1e();
3531
+ if (_this__u8e3s4.ok)
3532
+ return Unit_instance;
3533
+ var tmp0_safe_receiver = _this__u8e3s4.headers.get('Retry-After');
3534
+ var tmp;
3535
+ if (tmp0_safe_receiver == null) {
3536
+ tmp = null;
3537
+ } else {
3538
+ // Inline function 'kotlin.text.trim' call
3539
+ tmp = toString(trim(isCharSequence(tmp0_safe_receiver) ? tmp0_safe_receiver : THROW_CCE()));
3540
+ }
3541
+ var tmp1_safe_receiver = tmp;
3542
+ var retryAfter = tmp1_safe_receiver == null ? null : toLongOrNull(tmp1_safe_receiver);
3543
+ throw new TileFetchException(url, _this__u8e3s4.status, retryAfter);
3544
+ }
2636
3545
  function responseArrayBuffer(res) {
2637
3546
  _init_properties_TileFetcher_js_kt__7a2f1e();
2638
3547
  // Inline function 'kotlin.js.unsafeCast' call
@@ -2666,8 +3575,8 @@
2666
3575
  // Inline function 'kotlin.js.unsafeCast' call
2667
3576
  return fetch(url);
2668
3577
  }
2669
- function decodeBlob(blob, sourceUrl, $completion) {
2670
- var tmp = new $decodeBlobCOROUTINE$(blob, sourceUrl, $completion);
3578
+ function fetchTileBytes(url, $completion) {
3579
+ var tmp = new $fetchTileBytesCOROUTINE$(url, $completion);
2671
3580
  tmp.result_1 = Unit_instance;
2672
3581
  tmp.exception_1 = null;
2673
3582
  return tmp.doResume_5yljmg_k$();
@@ -2693,7 +3602,7 @@
2693
3602
  function _get_nodeWebpDecoderPromise_$ref_s562t() {
2694
3603
  return constructCallableReference(function () {
2695
3604
  return get_nodeWebpDecoderPromise();
2696
- }, 0, 0, 3);
3605
+ }, 0, 0, 5);
2697
3606
  }
2698
3607
  function $fetchAndDecodeTileCOROUTINE$(url, resultContinuation) {
2699
3608
  CoroutineImpl.call(this, resultContinuation);
@@ -2747,6 +3656,59 @@
2747
3656
  }
2748
3657
  while (true);
2749
3658
  };
3659
+ function $decodeTileBytesCOROUTINE$(bytes, sourceUrl, resultContinuation) {
3660
+ CoroutineImpl.call(this, resultContinuation);
3661
+ this.bytes_1 = bytes;
3662
+ this.sourceUrl_1 = sourceUrl;
3663
+ }
3664
+ protoOf($decodeTileBytesCOROUTINE$).doResume_5yljmg_k$ = function () {
3665
+ var suspendResult = this.result_1;
3666
+ $sm: do
3667
+ try {
3668
+ var tmp = this.state_1;
3669
+ switch (tmp) {
3670
+ case 0:
3671
+ this.exceptionState_1 = 4;
3672
+ if (get_isNode()) {
3673
+ this.state_1 = 2;
3674
+ suspendResult = decodeBytesNode(this.bytes_1, this.sourceUrl_1, this);
3675
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
3676
+ return suspendResult;
3677
+ }
3678
+ continue $sm;
3679
+ } else {
3680
+ this.state_1 = 1;
3681
+ suspendResult = decodeBlob(blobOf(this.bytes_1), this.sourceUrl_1, this);
3682
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
3683
+ return suspendResult;
3684
+ }
3685
+ continue $sm;
3686
+ }
3687
+
3688
+ case 1:
3689
+ this.WHEN_RESULT0__1 = suspendResult;
3690
+ this.state_1 = 3;
3691
+ continue $sm;
3692
+ case 2:
3693
+ this.WHEN_RESULT0__1 = suspendResult;
3694
+ this.state_1 = 3;
3695
+ continue $sm;
3696
+ case 3:
3697
+ return this.WHEN_RESULT0__1;
3698
+ case 4:
3699
+ throw this.exception_1;
3700
+ }
3701
+ } catch ($p) {
3702
+ var e = $p;
3703
+ if (this.exceptionState_1 === 4) {
3704
+ throw e;
3705
+ } else {
3706
+ this.state_1 = this.exceptionState_1;
3707
+ this.exception_1 = e;
3708
+ }
3709
+ }
3710
+ while (true);
3711
+ };
2750
3712
  function $decodeNodeCOROUTINE$(url, resultContinuation) {
2751
3713
  CoroutineImpl.call(this, resultContinuation);
2752
3714
  this.url_1 = url;
@@ -2768,11 +3730,7 @@
2768
3730
  continue $sm;
2769
3731
  case 1:
2770
3732
  var res = suspendResult;
2771
- if (!res.ok) {
2772
- var message = 'Tile fetch failed for ' + this.url_1 + ': HTTP ' + res.status;
2773
- throw IllegalStateException_init_$Create$_0(toString(message));
2774
- }
2775
-
3733
+ requireOk(res, this.url_1);
2776
3734
  this.state_1 = 2;
2777
3735
  suspendResult = await_0(responseArrayBuffer(res), this);
2778
3736
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
@@ -2827,11 +3785,7 @@
2827
3785
  continue $sm;
2828
3786
  case 1:
2829
3787
  var res = suspendResult;
2830
- if (!res.ok) {
2831
- var message = 'Tile fetch failed for ' + this.url_1 + ': HTTP ' + res.status;
2832
- throw IllegalStateException_init_$Create$_0(toString(message));
2833
- }
2834
-
3788
+ requireOk(res, this.url_1);
2835
3789
  this.state_1 = 2;
2836
3790
  suspendResult = await_0(res.blob(), this);
2837
3791
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
@@ -2864,47 +3818,67 @@
2864
3818
  }
2865
3819
  while (true);
2866
3820
  };
2867
- function $decodeWebpNodeCOROUTINE$(buffer, resultContinuation) {
3821
+ function $decodeBytesNodeCOROUTINE$(bytes, sourceUrl, resultContinuation) {
2868
3822
  CoroutineImpl.call(this, resultContinuation);
2869
- this.buffer_1 = buffer;
3823
+ this.bytes_1 = bytes;
3824
+ this.sourceUrl_1 = sourceUrl;
2870
3825
  }
2871
- protoOf($decodeWebpNodeCOROUTINE$).doResume_5yljmg_k$ = function () {
3826
+ protoOf($decodeBytesNodeCOROUTINE$).doResume_5yljmg_k$ = function () {
2872
3827
  var suspendResult = this.result_1;
2873
3828
  $sm: do
2874
3829
  try {
2875
3830
  var tmp = this.state_1;
2876
3831
  switch (tmp) {
2877
3832
  case 0:
2878
- this.exceptionState_1 = 3;
3833
+ this.exceptionState_1 = 4;
3834
+ var view = this.bytes_1;
3835
+ var buffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
3836
+ this.exceptionState_1 = 2;
2879
3837
  this.state_1 = 1;
2880
- suspendResult = await_0(get_nodeWebpDecoderPromise(), this);
3838
+ suspendResult = decodeWebpNode(buffer, this);
2881
3839
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
2882
3840
  return suspendResult;
2883
3841
  }
2884
3842
 
2885
3843
  continue $sm;
2886
3844
  case 1:
2887
- var decode = suspendResult;
2888
- var resultPromise = decode(this.buffer_1);
2889
- this.state_1 = 2;
2890
- suspendResult = await_0(resultPromise, this);
2891
- if (suspendResult === get_COROUTINE_SUSPENDED()) {
2892
- return suspendResult;
2893
- }
2894
-
3845
+ this.TRY_RESULT0__1 = suspendResult;
3846
+ this.exceptionState_1 = 4;
3847
+ this.state_1 = 3;
2895
3848
  continue $sm;
2896
3849
  case 2:
2897
- return suspendResult;
3850
+ this.exceptionState_1 = 4;
3851
+ var tmp_0 = this.exception_1;
3852
+ if (tmp_0 instanceof Error) {
3853
+ var e = this.exception_1;
3854
+ var tmp_1 = this;
3855
+ var this_0 = this.sourceUrl_1;
3856
+ var tmp_2;
3857
+ if (charSequenceLength(this_0) === 0) {
3858
+ tmp_2 = '<unnamed bytes>';
3859
+ } else {
3860
+ tmp_2 = this_0;
3861
+ }
3862
+ var message = 'Cannot decode tile at ' + tmp_2 + ': ' + e.message;
3863
+ throw IllegalStateException_init_$Create$(toString(message));
3864
+ } else {
3865
+ throw this.exception_1;
3866
+ }
3867
+
2898
3868
  case 3:
3869
+ this.exceptionState_1 = 4;
3870
+ var image = this.TRY_RESULT0__1;
3871
+ return rawTileFromJsquash(image);
3872
+ case 4:
2899
3873
  throw this.exception_1;
2900
3874
  }
2901
3875
  } catch ($p) {
2902
- var e = $p;
2903
- if (this.exceptionState_1 === 3) {
2904
- throw e;
3876
+ var e_0 = $p;
3877
+ if (this.exceptionState_1 === 4) {
3878
+ throw e_0;
2905
3879
  } else {
2906
3880
  this.state_1 = this.exceptionState_1;
2907
- this.exception_1 = e;
3881
+ this.exception_1 = e_0;
2908
3882
  }
2909
3883
  }
2910
3884
  while (true);
@@ -2949,7 +3923,7 @@
2949
3923
  tmp_2 = this_0;
2950
3924
  }
2951
3925
  var message = 'Cannot decode tile at ' + tmp_2 + ': ' + e.message;
2952
- throw IllegalStateException_init_$Create$_0(toString(message));
3926
+ throw IllegalStateException_init_$Create$(toString(message));
2953
3927
  } else {
2954
3928
  throw this.exception_1;
2955
3929
  }
@@ -3004,6 +3978,114 @@
3004
3978
  }
3005
3979
  while (true);
3006
3980
  };
3981
+ function $decodeWebpNodeCOROUTINE$(buffer, resultContinuation) {
3982
+ CoroutineImpl.call(this, resultContinuation);
3983
+ this.buffer_1 = buffer;
3984
+ }
3985
+ protoOf($decodeWebpNodeCOROUTINE$).doResume_5yljmg_k$ = function () {
3986
+ var suspendResult = this.result_1;
3987
+ $sm: do
3988
+ try {
3989
+ var tmp = this.state_1;
3990
+ switch (tmp) {
3991
+ case 0:
3992
+ this.exceptionState_1 = 3;
3993
+ this.state_1 = 1;
3994
+ suspendResult = await_0(get_nodeWebpDecoderPromise(), this);
3995
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
3996
+ return suspendResult;
3997
+ }
3998
+
3999
+ continue $sm;
4000
+ case 1:
4001
+ var decode = suspendResult;
4002
+ var resultPromise = decode(this.buffer_1);
4003
+ this.state_1 = 2;
4004
+ suspendResult = await_0(resultPromise, this);
4005
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
4006
+ return suspendResult;
4007
+ }
4008
+
4009
+ continue $sm;
4010
+ case 2:
4011
+ return suspendResult;
4012
+ case 3:
4013
+ throw this.exception_1;
4014
+ }
4015
+ } catch ($p) {
4016
+ var e = $p;
4017
+ if (this.exceptionState_1 === 3) {
4018
+ throw e;
4019
+ } else {
4020
+ this.state_1 = this.exceptionState_1;
4021
+ this.exception_1 = e;
4022
+ }
4023
+ }
4024
+ while (true);
4025
+ };
4026
+ function $fetchTileBytesCOROUTINE$(url, resultContinuation) {
4027
+ CoroutineImpl.call(this, resultContinuation);
4028
+ this.url_1 = url;
4029
+ }
4030
+ protoOf($fetchTileBytesCOROUTINE$).doResume_5yljmg_k$ = function () {
4031
+ var suspendResult = this.result_1;
4032
+ $sm: do
4033
+ try {
4034
+ var tmp = this.state_1;
4035
+ switch (tmp) {
4036
+ case 0:
4037
+ this.exceptionState_1 = 5;
4038
+ if (get_isNode()) {
4039
+ this.state_1 = 2;
4040
+ suspendResult = await_0(fetchUrlNode(this.url_1), this);
4041
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
4042
+ return suspendResult;
4043
+ }
4044
+ continue $sm;
4045
+ } else {
4046
+ this.state_1 = 1;
4047
+ suspendResult = await_0(fetchUrlBrowser(this.url_1), this);
4048
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
4049
+ return suspendResult;
4050
+ }
4051
+ continue $sm;
4052
+ }
4053
+
4054
+ case 1:
4055
+ this.WHEN_RESULT0__1 = suspendResult;
4056
+ this.state_1 = 3;
4057
+ continue $sm;
4058
+ case 2:
4059
+ this.WHEN_RESULT0__1 = suspendResult;
4060
+ this.state_1 = 3;
4061
+ continue $sm;
4062
+ case 3:
4063
+ var res = this.WHEN_RESULT0__1;
4064
+ requireOk(res, this.url_1);
4065
+ this.state_1 = 4;
4066
+ suspendResult = await_0(responseArrayBuffer(res), this);
4067
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
4068
+ return suspendResult;
4069
+ }
4070
+
4071
+ continue $sm;
4072
+ case 4:
4073
+ var ab = suspendResult;
4074
+ return new Int8Array(ab);
4075
+ case 5:
4076
+ throw this.exception_1;
4077
+ }
4078
+ } catch ($p) {
4079
+ var e = $p;
4080
+ if (this.exceptionState_1 === 5) {
4081
+ throw e;
4082
+ } else {
4083
+ this.state_1 = this.exceptionState_1;
4084
+ this.exception_1 = e;
4085
+ }
4086
+ }
4087
+ while (true);
4088
+ };
3007
4089
  var properties_initialized_TileFetcher_js_kt_apmrwg;
3008
4090
  function _init_properties_TileFetcher_js_kt__7a2f1e() {
3009
4091
  if (!properties_initialized_TileFetcher_js_kt_apmrwg) {
@@ -3019,6 +4101,12 @@
3019
4101
  return i.invoke_fa3hvc_k$(p0, $completion);
3020
4102
  }, 1, 1, 2, 'fetchAndDecodeTile');
3021
4103
  }
4104
+ function fetchTileBytes$ref_0() {
4105
+ var i = new fetchTileBytes$ref();
4106
+ return constructCallableReference(function (p0, $completion) {
4107
+ return i.invoke_vut9or_k$(p0, $completion);
4108
+ }, 1, 1, 4, 'fetchTileBytes');
4109
+ }
3022
4110
  //region block: init
3023
4111
  Distance_instance = new Distance();
3024
4112
  DouglasPeucker_instance = new DouglasPeucker();
@@ -3026,7 +4114,7 @@
3026
4114
  ElevationFunctions_instance = new ElevationFunctions();
3027
4115
  ElevationSmoother_instance = new ElevationSmoother();
3028
4116
  Flux_instance = new Flux();
3029
- Companion_instance = new Companion();
4117
+ Companion_instance_1 = new Companion_0();
3030
4118
  //endregion
3031
4119
  //region block: exports
3032
4120
  function $jsExportAll$(_) {
@@ -3035,6 +4123,7 @@
3035
4123
  var glandais = github.glandais || (github.glandais = {});
3036
4124
  var elevation = glandais.elevation || (glandais.elevation = {});
3037
4125
  elevation.newElevationProvider = newElevationProvider;
4126
+ elevation.elevationAttribution = elevationAttribution;
3038
4127
  elevation.getElevation = getElevation;
3039
4128
  elevation.getElevationsAlong = getElevationsAlong;
3040
4129
  }
@@ -3044,11 +4133,11 @@
3044
4133
  _.$_$.a = Distance_instance;
3045
4134
  _.$_$.b = DouglasPeucker_instance;
3046
4135
  _.$_$.c = ElevationSmoother_instance;
3047
- _.$_$.d = ElevationProviderConfig;
3048
- _.$_$.e = ElevationProvider;
3049
- _.$_$.f = LatLonElevation;
3050
- _.$_$.g = LatLon;
3051
- _.$_$.h = Vector3D;
4136
+ _.$_$.d = Companion_getInstance;
4137
+ _.$_$.e = LatLonElevation;
4138
+ _.$_$.f = LatLon;
4139
+ _.$_$.g = Vector3D;
4140
+ _.$_$.h = provider;
3052
4141
  //endregion
3053
4142
  return _;
3054
4143
  }));