LercWorker-ANBWKSUG.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import {
  2. A
  3. } from "./chunk-RYY6632W.js";
  4. import "./chunk-DW42UVIT.js";
  5. import "./chunk-TJNOJH33.js";
  6. import "./chunk-YAEIHDJH.js";
  7. import "./chunk-OSHI574D.js";
  8. import "./chunk-YXWMMD76.js";
  9. import "./chunk-S5KM4IGW.js";
  10. // node_modules/@arcgis/core/layers/support/LercWorker.js
  11. var t = {};
  12. t.defaultNoDataValue = A(-1 / 0), t.decode = function(s2, r2) {
  13. var o2 = (r2 = r2 || {}).encodedMaskData || null === r2.encodedMaskData, f2 = l(s2, r2.inputOffset || 0, o2), u = null != r2.noDataValue ? A(r2.noDataValue) : t.defaultNoDataValue, m = i(f2, r2.pixelType || Float32Array, r2.encodedMaskData, u, r2.returnMask), d = { width: f2.width, height: f2.height, pixelData: m.resultPixels, minValue: f2.pixels.minValue, maxValue: f2.pixels.maxValue, noDataValue: u };
  14. return m.resultMask && (d.maskData = m.resultMask), r2.returnEncodedMask && f2.mask && (d.encodedMaskData = f2.mask.bitset ? f2.mask.bitset : null), r2.returnFileInfo && (d.fileInfo = n(f2, u), r2.computeUsedBitDepths && (d.fileInfo.bitDepths = a(f2))), d;
  15. };
  16. var i = function(e, t2, i2, n2, a2) {
  17. var l2, r2, o2 = 0, f2 = e.pixels.numBlocksX, u = e.pixels.numBlocksY, m = Math.floor(e.width / f2), d = Math.floor(e.height / u), c = 2 * e.maxZError;
  18. i2 = i2 || (e.mask ? e.mask.bitset : null), l2 = new t2(e.width * e.height), a2 && i2 && (r2 = new Uint8Array(e.width * e.height));
  19. for (var g, h, k = new Float32Array(m * d), x = 0; x <= u; x++) {
  20. var p = x !== u ? d : e.height % u;
  21. if (0 !== p)
  22. for (var w = 0; w <= f2; w++) {
  23. var y = w !== f2 ? m : e.width % f2;
  24. if (0 !== y) {
  25. var V, B, v, U, D = x * e.width * d + w * m, M = e.width - y, b = e.pixels.blocks[o2];
  26. if (b.encoding < 2 ? (0 === b.encoding ? V = b.rawData : (s(b.stuffedData, b.bitsPerPixel, b.numValidPixels, b.offset, c, k, e.pixels.maxValue), V = k), B = 0) : v = 2 === b.encoding ? 0 : b.offset, i2)
  27. for (h = 0; h < p; h++) {
  28. for (7 & D && (U = i2[D >> 3], U <<= 7 & D), g = 0; g < y; g++)
  29. 7 & D || (U = i2[D >> 3]), 128 & U ? (r2 && (r2[D] = 1), l2[D++] = b.encoding < 2 ? V[B++] : v) : (r2 && (r2[D] = 0), l2[D++] = n2), U <<= 1;
  30. D += M;
  31. }
  32. else if (b.encoding < 2)
  33. for (h = 0; h < p; h++) {
  34. for (g = 0; g < y; g++)
  35. l2[D++] = V[B++];
  36. D += M;
  37. }
  38. else
  39. for (h = 0; h < p; h++)
  40. if (l2.fill)
  41. l2.fill(v, D, D + y), D += y + M;
  42. else {
  43. for (g = 0; g < y; g++)
  44. l2[D++] = v;
  45. D += M;
  46. }
  47. if (1 === b.encoding && B !== b.numValidPixels)
  48. throw "Block and Mask do not match";
  49. o2++;
  50. }
  51. }
  52. }
  53. return { resultPixels: l2, resultMask: r2 };
  54. };
  55. var n = function(e, t2) {
  56. return { fileIdentifierString: e.fileIdentifierString, fileVersion: e.fileVersion, imageType: e.imageType, height: e.height, width: e.width, maxZError: e.maxZError, eofOffset: e.eofOffset, mask: e.mask ? { numBlocksX: e.mask.numBlocksX, numBlocksY: e.mask.numBlocksY, numBytes: e.mask.numBytes, maxValue: e.mask.maxValue } : null, pixels: { numBlocksX: e.pixels.numBlocksX, numBlocksY: e.pixels.numBlocksY, numBytes: e.pixels.numBytes, maxValue: e.pixels.maxValue, minValue: e.pixels.minValue, noDataValue: t2 } };
  57. };
  58. var a = function(e) {
  59. for (var t2 = e.pixels.numBlocksX * e.pixels.numBlocksY, i2 = {}, n2 = 0; n2 < t2; n2++) {
  60. var a2 = e.pixels.blocks[n2];
  61. 0 === a2.encoding ? i2.float32 = true : 1 === a2.encoding ? i2[a2.bitsPerPixel] = true : i2[0] = true;
  62. }
  63. return Object.keys(i2);
  64. };
  65. var l = function(e, t2, i2) {
  66. var n2 = {}, a2 = new Uint8Array(e, t2, 10);
  67. if (n2.fileIdentifierString = String.fromCharCode.apply(null, a2), "CntZImage" != n2.fileIdentifierString.trim())
  68. throw "Unexpected file identifier string: " + n2.fileIdentifierString;
  69. t2 += 10;
  70. var l2 = new DataView(e, t2, 24);
  71. if (n2.fileVersion = l2.getInt32(0, true), n2.imageType = l2.getInt32(4, true), n2.height = l2.getUint32(8, true), n2.width = l2.getUint32(12, true), n2.maxZError = l2.getFloat64(16, true), t2 += 24, !i2) {
  72. if (l2 = new DataView(e, t2, 16), n2.mask = {}, n2.mask.numBlocksY = l2.getUint32(0, true), n2.mask.numBlocksX = l2.getUint32(4, true), n2.mask.numBytes = l2.getUint32(8, true), n2.mask.maxValue = l2.getFloat32(12, true), t2 += 16, n2.mask.numBytes > 0) {
  73. var s2 = new Uint8Array(Math.ceil(n2.width * n2.height / 8)), r2 = (l2 = new DataView(e, t2, n2.mask.numBytes)).getInt16(0, true), o2 = 2, f2 = 0;
  74. do {
  75. if (r2 > 0)
  76. for (; r2--; )
  77. s2[f2++] = l2.getUint8(o2++);
  78. else {
  79. var u = l2.getUint8(o2++);
  80. for (r2 = -r2; r2--; )
  81. s2[f2++] = u;
  82. }
  83. r2 = l2.getInt16(o2, true), o2 += 2;
  84. } while (o2 < n2.mask.numBytes);
  85. if (-32768 !== r2 || f2 < s2.length)
  86. throw "Unexpected end of mask RLE encoding";
  87. n2.mask.bitset = s2, t2 += n2.mask.numBytes;
  88. } else if (0 == (n2.mask.numBytes | n2.mask.numBlocksY | n2.mask.maxValue)) {
  89. s2 = new Uint8Array(Math.ceil(n2.width * n2.height / 8));
  90. n2.mask.bitset = s2;
  91. }
  92. }
  93. l2 = new DataView(e, t2, 16), n2.pixels = {}, n2.pixels.numBlocksY = l2.getUint32(0, true), n2.pixels.numBlocksX = l2.getUint32(4, true), n2.pixels.numBytes = l2.getUint32(8, true), n2.pixels.maxValue = l2.getFloat32(12, true), t2 += 16;
  94. var m = n2.pixels.numBlocksX, d = n2.pixels.numBlocksY, c = m + (n2.width % m > 0 ? 1 : 0), g = d + (n2.height % d > 0 ? 1 : 0);
  95. n2.pixels.blocks = new Array(c * g);
  96. for (var h = 1e9, k = 0, x = 0; x < g; x++)
  97. for (var p = 0; p < c; p++) {
  98. var w = 0, y = e.byteLength - t2;
  99. l2 = new DataView(e, t2, Math.min(10, y));
  100. var V = {};
  101. n2.pixels.blocks[k++] = V;
  102. var B = l2.getUint8(0);
  103. if (w++, V.encoding = 63 & B, V.encoding > 3)
  104. throw "Invalid block encoding (" + V.encoding + ")";
  105. if (2 !== V.encoding) {
  106. if (0 !== B && 2 !== B) {
  107. if (B >>= 6, V.offsetType = B, 2 === B)
  108. V.offset = l2.getInt8(1), w++;
  109. else if (1 === B)
  110. V.offset = l2.getInt16(1, true), w += 2;
  111. else {
  112. if (0 !== B)
  113. throw "Invalid block offset type";
  114. V.offset = l2.getFloat32(1, true), w += 4;
  115. }
  116. if (h = Math.min(V.offset, h), 1 === V.encoding)
  117. if (B = l2.getUint8(w), w++, V.bitsPerPixel = 63 & B, B >>= 6, V.numValidPixelsType = B, 2 === B)
  118. V.numValidPixels = l2.getUint8(w), w++;
  119. else if (1 === B)
  120. V.numValidPixels = l2.getUint16(w, true), w += 2;
  121. else {
  122. if (0 !== B)
  123. throw "Invalid valid pixel count type";
  124. V.numValidPixels = l2.getUint32(w, true), w += 4;
  125. }
  126. }
  127. var v;
  128. if (t2 += w, 3 != V.encoding) {
  129. if (0 === V.encoding) {
  130. var U = (n2.pixels.numBytes - 1) / 4;
  131. if (U !== Math.floor(U))
  132. throw "uncompressed block has invalid length";
  133. v = new ArrayBuffer(4 * U), new Uint8Array(v).set(new Uint8Array(e, t2, 4 * U));
  134. for (var D = new Float32Array(v), M = 0; M < D.length; M++)
  135. h = Math.min(h, D[M]);
  136. V.rawData = D, t2 += 4 * U;
  137. } else if (1 === V.encoding) {
  138. var b = Math.ceil(V.numValidPixels * V.bitsPerPixel / 8), I = Math.ceil(b / 4);
  139. v = new ArrayBuffer(4 * I), new Uint8Array(v).set(new Uint8Array(e, t2, b)), V.stuffedData = new Uint32Array(v), t2 += b;
  140. }
  141. }
  142. } else
  143. t2++, h = Math.min(h, 0);
  144. }
  145. return n2.pixels.minValue = h, n2.eofOffset = t2, n2;
  146. };
  147. var s = function(e, t2, i2, n2, a2, l2, s2) {
  148. var r2, o2, f2, u = (1 << t2) - 1, m = 0, d = 0, c = Math.ceil((s2 - n2) / a2), g = 4 * e.length - Math.ceil(t2 * i2 / 8);
  149. for (e[e.length - 1] <<= 8 * g, r2 = 0; r2 < i2; r2++) {
  150. if (0 === d && (f2 = e[m++], d = 32), d >= t2)
  151. o2 = f2 >>> d - t2 & u, d -= t2;
  152. else {
  153. var h = t2 - d;
  154. o2 = (f2 & u) << h & u, o2 += (f2 = e[m++]) >>> (d = 32 - h);
  155. }
  156. l2[r2] = o2 < c ? n2 + o2 * a2 : s2;
  157. }
  158. return l2;
  159. };
  160. var r = t.decode;
  161. var o = class {
  162. _decode(e) {
  163. const t2 = r(e.buffer, e.options);
  164. return Promise.resolve({ result: t2, transferList: [t2.pixelData.buffer] });
  165. }
  166. };
  167. function f() {
  168. return new o();
  169. }
  170. export {
  171. f as default
  172. };
  173. //# sourceMappingURL=LercWorker-ANBWKSUG.js.map