@loaders.gl/tiles-3d 5.0.0-beta.10 → 5.0.0-beta.11

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.
Files changed (154) hide show
  1. package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
  2. package/dist/3d-tiles/dist.dev.js +169 -581
  3. package/dist/3d-tiles/dist.min.js +16 -16
  4. package/dist/3d-tiles/index.cjs +115 -390
  5. package/dist/3d-tiles/index.cjs.map +3 -3
  6. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts +1 -2
  7. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -1
  8. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js +3 -4
  9. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  10. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts +4 -0
  11. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts.map +1 -0
  12. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js +36 -0
  13. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js.map +1 -0
  14. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -1
  15. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js +3 -4
  16. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  17. package/dist/3d-tiles/lib/classes/tile-3d-batch-table.d.ts +1 -1
  18. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts +9 -5
  19. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts.map +1 -1
  20. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js +15 -12
  21. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js.map +1 -1
  22. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +0 -1
  23. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
  24. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js +2 -4
  25. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  26. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +1 -2
  27. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
  28. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js +7 -7
  29. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  30. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -1
  31. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -2
  32. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  33. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
  34. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js +1 -2
  35. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  36. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +13 -13
  37. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  38. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  39. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js +22 -23
  40. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  41. package/dist/3d-tiles/lib/utils/version.js +1 -1
  42. package/dist/3d-tiles/types.d.ts +7 -3
  43. package/dist/3d-tiles/types.d.ts.map +1 -1
  44. package/dist/3d-tiles-archive-writer.cjs +1 -1
  45. package/dist/copc/copc-loader.d.ts.map +1 -1
  46. package/dist/copc/copc-loader.js +10 -7
  47. package/dist/copc/copc-loader.js.map +1 -1
  48. package/dist/copc/copc-writer.d.ts +5 -4
  49. package/dist/copc/copc-writer.d.ts.map +1 -1
  50. package/dist/copc/copc-writer.js +1 -1
  51. package/dist/copc/copc-writer.js.map +1 -1
  52. package/dist/copc/index.cjs +809 -124
  53. package/dist/copc/index.cjs.map +3 -3
  54. package/dist/dist.dev.js +45 -77
  55. package/dist/dist.min.js +10 -10
  56. package/dist/i3s/arcgis-webscene-loader.js +1 -1
  57. package/dist/i3s/dist.dev.js +11915 -12119
  58. package/dist/i3s/dist.min.js +25 -25
  59. package/dist/i3s/i3s-attribute-loader.js +1 -1
  60. package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
  61. package/dist/i3s/i3s-content-loader.js +1 -1
  62. package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
  63. package/dist/i3s/i3s-loader.js +1 -1
  64. package/dist/i3s/i3s-mesh-attributes.d.ts +2 -2
  65. package/dist/i3s/i3s-mesh-attributes.d.ts.map +1 -1
  66. package/dist/i3s/i3s-mesh-attributes.js +6 -11
  67. package/dist/i3s/i3s-mesh-attributes.js.map +1 -1
  68. package/dist/i3s/i3s-mesh-writer.js +2 -3
  69. package/dist/i3s/i3s-mesh-writer.js.map +1 -1
  70. package/dist/i3s/i3s-node-page-loader.js +1 -1
  71. package/dist/i3s/i3s-slpk-loader.js +1 -1
  72. package/dist/i3s/i3s-slpk-writer.js +1 -1
  73. package/dist/i3s/index.cjs +314 -442
  74. package/dist/i3s/index.cjs.map +3 -3
  75. package/dist/i3s/lib/parsers/constants.d.ts +0 -3
  76. package/dist/i3s/lib/parsers/constants.d.ts.map +1 -1
  77. package/dist/i3s/lib/parsers/constants.js +0 -8
  78. package/dist/i3s/lib/parsers/constants.js.map +1 -1
  79. package/dist/i3s/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  80. package/dist/i3s/lib/parsers/parse-i3s-tile-content.js +1 -2
  81. package/dist/i3s/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  82. package/dist/i3s/types.d.ts +0 -1
  83. package/dist/i3s/types.d.ts.map +1 -1
  84. package/dist/i3s-content-worker-node.js +11 -11
  85. package/dist/i3s-content-worker-node.js.map +4 -4
  86. package/dist/i3s-content-worker.js +485 -879
  87. package/dist/i3s-lepcc-worker-node.js +2 -2
  88. package/dist/i3s-lepcc-worker.js +2 -2
  89. package/dist/i3s-mesh-writer.cjs +87 -206
  90. package/dist/i3s-mesh-writer.cjs.map +3 -3
  91. package/dist/i3s-slpk-writer.cjs +1 -1
  92. package/dist/index.cjs +44 -41
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/point-cloud-tile-loader-types.js +1 -1
  95. package/dist/point-cloud-tile-loader.cjs +17 -28
  96. package/dist/point-cloud-tile-loader.cjs.map +1 -1
  97. package/dist/point-cloud-tile-source.cjs +16 -27
  98. package/dist/point-cloud-tile-source.cjs.map +1 -1
  99. package/dist/point-cloud-tile-source.js +2 -2
  100. package/dist/point-cloud-tile-source.js.map +1 -1
  101. package/dist/potree/dist.dev.js +985 -139
  102. package/dist/potree/dist.min.js +28 -28
  103. package/dist/potree/index.cjs +813 -140
  104. package/dist/potree/index.cjs.map +3 -3
  105. package/dist/potree/lib/potree-node-source.d.ts.map +1 -1
  106. package/dist/potree/lib/potree-node-source.js +2 -14
  107. package/dist/potree/lib/potree-node-source.js.map +1 -1
  108. package/dist/potree/parsers/parse-potree-bin.js +3 -3
  109. package/dist/potree/parsers/parse-potree-bin.js.map +1 -1
  110. package/dist/potree/potree-bin-loader.js +1 -1
  111. package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
  112. package/dist/potree/potree-loader-types.js +1 -1
  113. package/dist/potree/potree-writer.d.ts +3 -3
  114. package/dist/potree/potree-writer.d.ts.map +1 -1
  115. package/dist/potree/potree-writer.js +2 -2
  116. package/dist/potree/potree-writer.js.map +1 -1
  117. package/dist/potree/potree2-source.d.ts +1 -1
  118. package/dist/potree/potree2-source.d.ts.map +1 -1
  119. package/dist/potree/potree2-source.js +6 -3
  120. package/dist/potree/potree2-source.js.map +1 -1
  121. package/dist/potree-loader.cjs +817 -153
  122. package/dist/potree-loader.cjs.map +3 -3
  123. package/dist/tileset-3d/helpers/frame-state.d.ts +2 -1
  124. package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
  125. package/dist/tileset-3d/helpers/frame-state.js +41 -15
  126. package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
  127. package/dist/types.d.ts +15 -0
  128. package/dist/types.d.ts.map +1 -1
  129. package/package.json +13 -13
  130. package/src/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.ts +3 -4
  131. package/src/3d-tiles/lib/classes/helpers/tile-component-types.ts +39 -0
  132. package/src/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.ts +3 -4
  133. package/src/3d-tiles/lib/classes/tile-3d-feature-table.ts +38 -14
  134. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.ts +2 -5
  135. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.ts +10 -10
  136. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.ts +0 -2
  137. package/src/3d-tiles/lib/parsers/parse-3d-tile-batched-model.ts +1 -2
  138. package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +19 -19
  139. package/src/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.ts +22 -23
  140. package/src/3d-tiles/types.ts +4 -3
  141. package/src/copc/copc-loader.ts +8 -8
  142. package/src/copc/copc-writer.ts +6 -5
  143. package/src/i3s/i3s-mesh-attributes.ts +9 -17
  144. package/src/i3s/i3s-mesh-writer.ts +4 -3
  145. package/src/i3s/lib/parsers/constants.ts +0 -9
  146. package/src/i3s/lib/parsers/parse-i3s-tile-content.ts +1 -2
  147. package/src/i3s/types.ts +0 -1
  148. package/src/point-cloud-tile-source.ts +2 -2
  149. package/src/potree/lib/potree-node-source.ts +2 -15
  150. package/src/potree/parsers/parse-potree-bin.ts +3 -3
  151. package/src/potree/potree-writer.ts +6 -11
  152. package/src/potree/potree2-source.ts +6 -3
  153. package/src/tileset-3d/helpers/frame-state.ts +43 -15
  154. package/src/types.ts +15 -0
@@ -9385,6 +9385,10 @@ function validateColumnarPredicate(predicate, availableColumns) {
9385
9385
  }
9386
9386
  });
9387
9387
  }
9388
+ function isColumnarPredicateParameter(value) {
9389
+ const parameterValue = value;
9390
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && Object.hasOwn(value, "parameter") && typeof parameterValue.parameter === "string" && parameterValue.parameter.length > 0;
9391
+ }
9388
9392
  function filterColumnarRowIndices(predicate, columns, rowCount) {
9389
9393
  if (!predicate) return Array.from({ length: rowCount }, (_, index) => index);
9390
9394
  const result = [];
@@ -9461,6 +9465,13 @@ var init_columnar_predicate = __esm({
9461
9465
  });
9462
9466
 
9463
9467
  // ../core/src/loader-utils/lib/scan-utils/scan-query-metadata.ts
9468
+ function emitQueryComplete(callback, summary) {
9469
+ if (!callback) return;
9470
+ try {
9471
+ callback(summary);
9472
+ } catch {
9473
+ }
9474
+ }
9464
9475
  function createScanQueryMetadata(options) {
9465
9476
  validateScanExecutionSupport(options.queryType, options.execution);
9466
9477
  const schema = Object.freeze({
@@ -9496,6 +9507,7 @@ function createScanQueryMetadata(options) {
9496
9507
  columns: Object.freeze(columns),
9497
9508
  capabilities: queryCapabilities,
9498
9509
  queryCapabilities,
9510
+ ...options.hasDefaultRowWindow ? { hasDefaultRowWindow: true } : {},
9499
9511
  spatial: options.spatial ? Object.freeze({
9500
9512
  ...options.spatial,
9501
9513
  bounds: options.spatial.bounds ? Object.freeze({
@@ -9547,6 +9559,26 @@ var init_scan_query_metadata = __esm({
9547
9559
  });
9548
9560
 
9549
9561
  // ../core/src/loader-utils/lib/scan-utils/table-query.ts
9562
+ function planTableQuery(sourceColumnNames, options = {}) {
9563
+ validateTableQueryOptions(sourceColumnNames, options);
9564
+ const outputColumnNames = options.columns ? [...options.columns] : [...sourceColumnNames];
9565
+ const predicateColumnNames = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
9566
+ const requiredColumnNames = /* @__PURE__ */ new Set([...outputColumnNames, ...predicateColumnNames]);
9567
+ const scanColumnNames = sourceColumnNames.filter(
9568
+ (columnName) => requiredColumnNames.has(columnName)
9569
+ );
9570
+ const steps = [
9571
+ Object.freeze({ kind: "scan", columns: Object.freeze(scanColumnNames) })
9572
+ ];
9573
+ if (options.predicate) {
9574
+ steps.push(Object.freeze({ kind: "filter", predicate: options.predicate }));
9575
+ }
9576
+ steps.push(Object.freeze({ kind: "project", columns: Object.freeze(outputColumnNames) }));
9577
+ if (options.limit !== void 0) {
9578
+ steps.push(Object.freeze({ kind: "limit", limit: options.limit }));
9579
+ }
9580
+ return Object.freeze(steps);
9581
+ }
9550
9582
  function validateTableQueryOptions(sourceColumnNames, options) {
9551
9583
  const availableColumnNames = new Set(sourceColumnNames);
9552
9584
  const outputColumnNames = options.columns ?? sourceColumnNames;
@@ -9570,6 +9602,11 @@ function validateTableQueryLimit(limit) {
9570
9602
  throw new Error("Table query limit must be a non-negative safe integer.");
9571
9603
  }
9572
9604
  }
9605
+ function validateTableQueryOffset(offset) {
9606
+ if (offset !== void 0 && (!Number.isSafeInteger(offset) || offset < 0)) {
9607
+ throw new Error("Table query offset must be a non-negative safe integer.");
9608
+ }
9609
+ }
9573
9610
  var init_table_query = __esm({
9574
9611
  "../core/src/loader-utils/lib/scan-utils/table-query.ts"() {
9575
9612
  "use strict";
@@ -9577,6 +9614,177 @@ var init_table_query = __esm({
9577
9614
  }
9578
9615
  });
9579
9616
 
9617
+ // ../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts
9618
+ async function* executeTableScanBatches(readBatches, options = {}, operators = {}) {
9619
+ var _a, _b, _c, _d, _e;
9620
+ validateTableQueryLimit(options.limit);
9621
+ validateTableQueryOffset(options.offset);
9622
+ let skip = options.offset ?? 0;
9623
+ const startedAt = Date.now();
9624
+ let sourcesRead = 0;
9625
+ let batchesRead = 0;
9626
+ let rowsRead = 0;
9627
+ let rowsTested = 0;
9628
+ let rowsRetained = 0;
9629
+ let rowsReturned = 0;
9630
+ let bytesFetched = 0;
9631
+ let status = "early-terminated";
9632
+ let earlyTerminationReason;
9633
+ let executionError;
9634
+ let remaining = options.limit === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, options.limit);
9635
+ try {
9636
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
9637
+ if (remaining <= 0) {
9638
+ earlyTerminationReason = "limit";
9639
+ return;
9640
+ }
9641
+ sourcesRead = 1;
9642
+ for await (const batch of readBatches(
9643
+ options.signal,
9644
+ (byteLength) => bytesFetched += byteLength
9645
+ )) {
9646
+ if (remaining <= 0) {
9647
+ earlyTerminationReason = "limit";
9648
+ return;
9649
+ }
9650
+ (_b = options.signal) == null ? void 0 : _b.throwIfAborted();
9651
+ batchesRead++;
9652
+ const rowCount = getScanBatchRowCount(batch);
9653
+ rowsRead += rowCount;
9654
+ if (options.predicate && !operators.filter && !("shape" in batch)) {
9655
+ throw new Error("Native Arrow scans require a filter kernel for residual predicates.");
9656
+ }
9657
+ const filteredBatch = operators.filter ? await operators.filter(batch, options.predicate, options.signal) : "shape" in batch ? filterTableBatch(batch, options.predicate) : batch;
9658
+ (_c = options.signal) == null ? void 0 : _c.throwIfAborted();
9659
+ const filteredRowCount = getScanBatchRowCount(filteredBatch);
9660
+ if (options.predicate) {
9661
+ rowsTested += rowCount;
9662
+ rowsRetained += filteredRowCount;
9663
+ }
9664
+ if (skip >= filteredRowCount && (skip > 0 || options.skipEmptyBatches)) {
9665
+ skip -= filteredRowCount;
9666
+ continue;
9667
+ }
9668
+ const end = Math.min(filteredRowCount, skip + remaining);
9669
+ const window2 = skip || end < filteredRowCount ? "shape" in filteredBatch ? sliceTableBatch(filteredBatch, skip, end) : filteredBatch.slice(skip, end) : filteredBatch;
9670
+ skip = 0;
9671
+ const output = operators.project ? operators.project(window2, options.columns) : projectTableBatch(window2, options.columns);
9672
+ remaining -= getScanBatchRowCount(window2);
9673
+ rowsReturned += getScanBatchRowCount(output);
9674
+ if (remaining === 0) earlyTerminationReason = "limit";
9675
+ yield output;
9676
+ if (remaining === 0) return;
9677
+ (_d = options.signal) == null ? void 0 : _d.throwIfAborted();
9678
+ }
9679
+ status = "completed";
9680
+ } catch (error) {
9681
+ status = ((_e = options.signal) == null ? void 0 : _e.aborted) ? "cancelled" : "failed";
9682
+ executionError = error;
9683
+ throw error;
9684
+ } finally {
9685
+ if (status === "early-terminated" && !earlyTerminationReason) {
9686
+ earlyTerminationReason = "consumer-return";
9687
+ }
9688
+ emitQueryComplete(
9689
+ options.onQueryComplete,
9690
+ Object.freeze({
9691
+ status,
9692
+ sourcesPlanned: 1,
9693
+ sourcesRead,
9694
+ batchesRead,
9695
+ batchesDecoded: batchesRead,
9696
+ rowsRead,
9697
+ rowsTested: rowsTested || void 0,
9698
+ rowsRetained: rowsRetained || void 0,
9699
+ rowsReturned,
9700
+ bytesRead: bytesFetched,
9701
+ bytesFetched,
9702
+ filesOpened: sourcesRead,
9703
+ tasksOpened: sourcesRead,
9704
+ durationMilliseconds: Date.now() - startedAt,
9705
+ earlyTerminationReason,
9706
+ ...executionError === void 0 ? {} : { error: executionError }
9707
+ })
9708
+ );
9709
+ }
9710
+ }
9711
+ function getScanBatchRowCount(batch) {
9712
+ return "shape" in batch ? batch.length : batch.numRows;
9713
+ }
9714
+ function sliceTableBatch(batch, start, end) {
9715
+ const length = end - start;
9716
+ if (batch.shape === "object-row-table" || batch.shape === "array-row-table") {
9717
+ return { ...batch, data: batch.data.slice(start, end), length };
9718
+ }
9719
+ if (batch.shape === "columnar-table") {
9720
+ return {
9721
+ ...batch,
9722
+ data: Object.fromEntries(
9723
+ Object.entries(batch.data).map(([name, values]) => [
9724
+ name,
9725
+ Array.from(values).slice(start, end)
9726
+ ])
9727
+ ),
9728
+ length
9729
+ };
9730
+ }
9731
+ return { ...batch, features: batch.features.slice(start, end), length };
9732
+ }
9733
+ function projectTableBatch(batch, columns) {
9734
+ if (columns === void 0) return batch;
9735
+ if (!("shape" in batch)) {
9736
+ const indices = columns.map((column) => batch.schema.fields.findIndex((field) => field.name === column)).filter((index) => index >= 0);
9737
+ return batch.selectAt(indices);
9738
+ }
9739
+ const schema = projectTableSchema(batch, columns);
9740
+ if (batch.shape === "object-row-table") {
9741
+ return {
9742
+ ...batch,
9743
+ schema,
9744
+ data: batch.data.map((row) => Object.fromEntries(columns.map((column) => [column, row[column]])))
9745
+ };
9746
+ }
9747
+ if (batch.shape === "columnar-table") {
9748
+ return {
9749
+ ...batch,
9750
+ schema,
9751
+ data: Object.fromEntries(columns.map((column) => [column, batch.data[column]]))
9752
+ };
9753
+ }
9754
+ return batch;
9755
+ }
9756
+ function projectTableSchema(batch, columns) {
9757
+ if (!batch.schema) return void 0;
9758
+ const fieldsByName = new Map(batch.schema.fields.map((field) => [field.name, field]));
9759
+ return {
9760
+ ...batch.schema,
9761
+ fields: columns.flatMap((column) => {
9762
+ const field = fieldsByName.get(column);
9763
+ return field ? [field] : [];
9764
+ })
9765
+ };
9766
+ }
9767
+ function filterTableBatch(batch, predicate) {
9768
+ var _a;
9769
+ if (!predicate || batch.shape !== "object-row-table") return batch;
9770
+ const rows = batch.data;
9771
+ const columnNames = new Set(((_a = batch.schema) == null ? void 0 : _a.fields.map((field) => field.name)) || []);
9772
+ validateColumnarPredicate(predicate, columnNames);
9773
+ const columns = Object.fromEntries(
9774
+ [...columnNames].map((name) => [name, rows.map((row) => row[name])])
9775
+ );
9776
+ const rowIndices = filterColumnarRowIndices(predicate, columns, rows.length);
9777
+ return { ...batch, data: rowIndices.map((rowIndex) => rows[rowIndex]), length: rowIndices.length };
9778
+ }
9779
+ var init_table_scan_batch = __esm({
9780
+ "../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts"() {
9781
+ "use strict";
9782
+ init_scan_query_metadata();
9783
+ init_columnar_predicate();
9784
+ init_table_query();
9785
+ }
9786
+ });
9787
+
9580
9788
  // ../core/src/loader-utils/lib/scan-utils/point-cloud-query.ts
9581
9789
  function validatePointCloudQueryOptions(sourceColumnNames, options) {
9582
9790
  validateTableQueryOptions(sourceColumnNames, options);
@@ -9654,6 +9862,37 @@ var init_point_cloud_query = __esm({
9654
9862
  }
9655
9863
  });
9656
9864
 
9865
+ // ../core/src/loader-utils/lib/scan-utils/table-query-explain.ts
9866
+ function explainTableQuery(sourceColumnNames, options, capabilities) {
9867
+ const plan = planTableQuery(sourceColumnNames, options);
9868
+ const outputColumns = options.columns ? [...options.columns] : [...sourceColumnNames];
9869
+ const predicateColumns = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
9870
+ const requiredColumns = [...plan[0].kind === "scan" ? plan[0].columns : []];
9871
+ return Object.freeze({
9872
+ sourceColumns: Object.freeze([...sourceColumnNames]),
9873
+ outputColumns: Object.freeze(outputColumns),
9874
+ requiredColumns: Object.freeze(requiredColumns),
9875
+ predicateColumns: Object.freeze(predicateColumns),
9876
+ plan,
9877
+ capabilities: Object.freeze({ ...capabilities }),
9878
+ operators: Object.freeze({
9879
+ projection: createOperatorExplanation(options.columns !== void 0, capabilities.projection),
9880
+ predicate: createOperatorExplanation(options.predicate !== void 0, capabilities.predicate),
9881
+ limit: createOperatorExplanation(options.limit !== void 0, capabilities.limit)
9882
+ })
9883
+ });
9884
+ }
9885
+ function createOperatorExplanation(enabled, support) {
9886
+ return Object.freeze({ enabled, support });
9887
+ }
9888
+ var init_table_query_explain = __esm({
9889
+ "../core/src/loader-utils/lib/scan-utils/table-query-explain.ts"() {
9890
+ "use strict";
9891
+ init_columnar_predicate();
9892
+ init_table_query();
9893
+ }
9894
+ });
9895
+
9657
9896
  // ../core/src/loader-utils/lib/pace-batch-iterator.ts
9658
9897
  function validateBatchDeliveryRate(rate) {
9659
9898
  if (!Number.isFinite(rate) || rate < 0) {
@@ -9720,8 +9959,10 @@ var init_loader_utils = __esm({
9720
9959
  init_node_file_facade();
9721
9960
  init_data_source();
9722
9961
  init_columnar_predicate();
9962
+ init_table_scan_batch();
9723
9963
  init_scan_query_metadata();
9724
9964
  init_point_cloud_query();
9965
+ init_table_query_explain();
9725
9966
  init_pace_batch_iterator();
9726
9967
  }
9727
9968
  });
@@ -10237,7 +10478,7 @@ var init_convert_arrow_schema = __esm({
10237
10478
  });
10238
10479
 
10239
10480
  // ../core/src/lib/loader-utils/native-arrow.ts
10240
- function isNativeArrowTable(value) {
10481
+ function isArrowTable(value) {
10241
10482
  return Boolean(
10242
10483
  value && typeof value === "object" && "schema" in value && "batches" in value && Array.isArray(value.batches) && "numRows" in value && typeof value.numRows === "number" && "getChildAt" in value && typeof value.getChildAt === "function"
10243
10484
  );
@@ -10252,23 +10493,31 @@ var init_native_arrow = __esm({
10252
10493
  function snapshotArrowSchema(schema) {
10253
10494
  return deserializeArrowSchema(serializeArrowSchema(schema));
10254
10495
  }
10496
+ function snapshotArrowBatch(batch, schema) {
10497
+ const snapshot = new arrow2.RecordBatch(
10498
+ snapshotArrowSchema(schema),
10499
+ batch.data,
10500
+ new Map(batch.metadata)
10501
+ );
10502
+ if (snapshot.numRows !== batch.numRows) {
10503
+ Object.defineProperty(snapshot, "data", { value: batch.data });
10504
+ }
10505
+ return snapshot;
10506
+ }
10255
10507
  function updateArrowTableSchema(table, schema) {
10256
10508
  const snapshot = snapshotArrowSchema(schema);
10257
- const batches = table.batches.map(
10258
- (batch) => new arrow2.RecordBatch(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
10259
- );
10509
+ const batches = table.batches.map((batch) => snapshotArrowBatch(batch, snapshot));
10260
10510
  return new arrow2.Table(
10261
10511
  snapshot,
10262
10512
  batches.length ? batches : [new arrow2.RecordBatch(snapshotArrowSchema(snapshot), void 0)]
10263
10513
  );
10264
10514
  }
10265
- function updateArrowTableMetadata(table, metadata) {
10515
+ function updateNativeArrowTableMetadata(table, metadata) {
10266
10516
  const schema = new arrow2.Schema(
10267
- table.data.schema.fields,
10268
- new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
10517
+ table.schema.fields,
10518
+ new Map([...table.schema.metadata, ...Object.entries(metadata)])
10269
10519
  );
10270
- const data = updateArrowTableSchema(table.data, schema);
10271
- return { ...table, data, schema: serializeArrowSchema(data.schema) };
10520
+ return updateArrowTableSchema(table, schema);
10272
10521
  }
10273
10522
  function makeArrowMetadataBatch(schema) {
10274
10523
  return new arrow2.RecordBatch(snapshotArrowSchema(schema), void 0);
@@ -10561,7 +10810,7 @@ var init_arrow_fixed_size_list_utils = __esm({
10561
10810
  });
10562
10811
 
10563
10812
  // ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
10564
- function convertMeshToArrowTableWrapper(mesh, batchSize) {
10813
+ function convertMeshToArrowTable(mesh) {
10565
10814
  var _a;
10566
10815
  return makeMeshArrowTable(mesh.attributes, {
10567
10816
  schema: mesh.schema,
@@ -10584,22 +10833,14 @@ function makeMeshArrowTable(attributes, options = {}) {
10584
10833
  fields.push(
10585
10834
  getAttributeArrowField(options.schema, attributeName, column, attribute.componentType)
10586
10835
  );
10587
- if (attributeName === "POSITION" && ((_b = (_a = options.indices) == null ? void 0 : _a.value) == null ? void 0 : _b.length)) {
10836
+ if (attributeName === attributeNames[0] && ((_b = (_a = options.indices) == null ? void 0 : _a.value) == null ? void 0 : _b.length)) {
10588
10837
  const indicesField = indexedMeshArrowSchema.fields.find((field) => field.name === "indices");
10589
10838
  columns.indices = getIndicesVector(options.indices.value, column.length, indicesField.type);
10590
10839
  fields.push(indicesField);
10591
10840
  }
10592
10841
  }
10593
10842
  const arrowSchema = new arrow6.Schema(fields, getMeshArrowMetadata(options));
10594
- const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow6.Table(arrowSchema) : new arrow6.Table(arrowSchema, columns);
10595
- const schema = serializeArrowSchema(table.schema);
10596
- return {
10597
- shape: "arrow-table",
10598
- schema,
10599
- data: table,
10600
- topology: options.topology || "point-list",
10601
- indices: options.indices
10602
- };
10843
+ return ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow6.Table(arrowSchema) : new arrow6.Table(arrowSchema, columns);
10603
10844
  }
10604
10845
  function getAttributeArrowVector(value, size, componentType) {
10605
10846
  if (componentType === "float16") {
@@ -10726,19 +10967,11 @@ var init_convert_mesh_to_table = __esm({
10726
10967
 
10727
10968
  // ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
10728
10969
  function convertTableToMesh(table) {
10729
- if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
10730
- switch (table.shape) {
10731
- // case 'columnar-table':
10732
- // return convertColumnarTableToMesh(table);
10733
- case "arrow-table":
10734
- return convertArrowTableToMesh(table);
10735
- default:
10736
- throw new Error(table.shape);
10737
- }
10970
+ if (isArrowTable(table)) return convertArrowTableToMesh(table);
10971
+ throw new Error(table.shape);
10738
10972
  }
10739
- function convertArrowTableToMesh(table) {
10973
+ function convertArrowTableToMesh(arrowTable) {
10740
10974
  var _a, _b;
10741
- const arrowTable = isNativeArrowTable(table) ? table : table.data;
10742
10975
  const schema = serializeArrowSchema(arrowTable.schema);
10743
10976
  const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
10744
10977
  if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
@@ -10843,13 +11076,18 @@ function getAttributeTypedArray(attributeData, size) {
10843
11076
  if (!(attributeData.type instanceof arrow7.FixedSizeList)) {
10844
11077
  return attributeData.toArray();
10845
11078
  }
10846
- const values = attributeData.data[0].children[0].values;
11079
+ if (attributeData.length === 0) {
11080
+ const EmptyStorage = attributeData.type.valueType.ArrayType;
11081
+ return new EmptyStorage(0);
11082
+ }
11083
+ const values = attributeData.data.find((chunk) => chunk.length > 0).children[0].values;
10847
11084
  const TypedArrayConstructor = values.constructor;
10848
11085
  const typedArray = new TypedArrayConstructor(attributeData.length * size);
10849
11086
  let targetOffset = 0;
10850
11087
  for (const data of attributeData.data) {
10851
- const child = data.children[0];
10852
11088
  const sourceLength = data.length * size;
11089
+ if (sourceLength === 0) continue;
11090
+ const child = data.children[0];
10853
11091
  const sourceOffset = child.offset || data.offset * size;
10854
11092
  const sourceStart = sourceOffset + sourceLength <= child.values.length ? sourceOffset : 0;
10855
11093
  const source = child.values.subarray(sourceStart, sourceStart + sourceLength);
@@ -10958,11 +11196,13 @@ var init_deduce_mesh_schema = __esm({
10958
11196
  var init_schema_utils = __esm({
10959
11197
  "../core/src/schema-utils/index.ts"() {
10960
11198
  "use strict";
11199
+ init_convert_arrow_schema();
10961
11200
  init_convert_mesh_to_table();
10962
11201
  init_convert_table_to_mesh();
10963
11202
  init_deduce_mesh_schema();
10964
11203
  init_arrow_table_builder();
10965
11204
  init_arrow_metadata();
11205
+ init_native_arrow();
10966
11206
  }
10967
11207
  });
10968
11208
 
@@ -11188,7 +11428,7 @@ function formatLASMeshColors(mesh, colorFormat) {
11188
11428
  }
11189
11429
  return { ...mesh, attributes };
11190
11430
  }
11191
- var VERSION3, DEFAULT_LAS_SHAPE, LAS_LOADER_METADATA;
11431
+ var VERSION3, DEFAULT_LAS_SHAPE, LAS_LOADER_METADATA, LAS_SOURCE_METADATA;
11192
11432
  var init_las_loader_shared = __esm({
11193
11433
  "../pointclouds/src/las/las-loader-shared.ts"() {
11194
11434
  "use strict";
@@ -11217,95 +11457,499 @@ var init_las_loader_shared = __esm({
11217
11457
  }
11218
11458
  }
11219
11459
  };
11460
+ LAS_SOURCE_METADATA = {
11461
+ type: "las-source",
11462
+ fromUrl: true,
11463
+ fromBlob: true,
11464
+ testURL: (url) => /\.(?:las|laz)(?:$|[?#])/i.test(url)
11465
+ };
11466
+ }
11467
+ });
11468
+
11469
+ // ../core/src/scan/arrow-execution/project-arrow-table.ts
11470
+ function projectArrowTable(source, selections) {
11471
+ const outputNames = /* @__PURE__ */ new Set();
11472
+ const indices = [];
11473
+ const fields = selections.map((selection) => {
11474
+ const column = typeof selection === "string" ? selection : selection.column;
11475
+ const name = typeof selection === "string" ? selection : selection.as === void 0 ? column : selection.as;
11476
+ const index = source.schema.fields.findIndex((field) => field.name === column);
11477
+ if (index < 0) throw new Error(`Arrow projection column not found: ${column}`);
11478
+ if (typeof name !== "string" || typeof selection !== "string" && selection.as !== void 0 && !name.length || outputNames.has(name)) {
11479
+ throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);
11480
+ }
11481
+ outputNames.add(name);
11482
+ indices.push(index);
11483
+ return source.schema.fields[index].clone({ name });
11484
+ });
11485
+ const schema = new arrow8.Schema(fields, source.schema.metadata);
11486
+ const batches = source.batches.map(
11487
+ (batch) => new arrow8.RecordBatch(
11488
+ schema,
11489
+ arrow8.makeData({
11490
+ type: new arrow8.Struct(fields),
11491
+ length: batch.numRows,
11492
+ children: indices.map((index) => batch.data.children[index])
11493
+ }),
11494
+ batch.metadata
11495
+ )
11496
+ );
11497
+ return new arrow8.Table(schema, batches);
11498
+ }
11499
+ var arrow8;
11500
+ var init_project_arrow_table = __esm({
11501
+ "../core/src/scan/arrow-execution/project-arrow-table.ts"() {
11502
+ "use strict";
11503
+ arrow8 = __toESM(require("apache-arrow"), 1);
11504
+ }
11505
+ });
11506
+
11507
+ // ../core/src/scan/arrow-execution/filter-arrow-table.ts
11508
+ function filterArrowTable(source, predicate, options = {}) {
11509
+ validateColumnarPredicate(predicate, new Set(source.schema.fields.map((field) => field.name)));
11510
+ const columnNames = getColumnarPredicateColumns(predicate);
11511
+ return filterArrowRows(
11512
+ source,
11513
+ (batch) => {
11514
+ const columns = getPredicateColumns(new arrow9.Table(source.schema, [batch]), columnNames);
11515
+ return (rowIndex) => evaluatePredicate(predicate, columns, rowIndex) === true;
11516
+ },
11517
+ options
11518
+ );
11519
+ }
11520
+ function filterArrowRows(source, selectBatch, options = {}) {
11521
+ var _a, _b, _c;
11522
+ let remaining = options.limit ?? Infinity;
11523
+ if (remaining !== Infinity && (!Number.isSafeInteger(remaining) || remaining < 0)) {
11524
+ throw new Error("Arrow filter limit must be a non-negative safe integer.");
11525
+ }
11526
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
11527
+ const batches = [];
11528
+ for (const batch of source.batches) {
11529
+ if (remaining === 0) break;
11530
+ (_b = options.signal) == null ? void 0 : _b.throwIfAborted();
11531
+ const data = new arrow9.Table(source.schema, [batch]);
11532
+ const selectRow = selectBatch(batch);
11533
+ const indices = [];
11534
+ for (let rowIndex = 0; rowIndex < batch.numRows && indices.length < remaining; rowIndex++) {
11535
+ (_c = options.signal) == null ? void 0 : _c.throwIfAborted();
11536
+ if (selectRow(rowIndex)) indices.push(rowIndex);
11537
+ }
11538
+ remaining -= indices.length;
11539
+ if (indices.length === 0) continue;
11540
+ if (indices.length === batch.numRows) {
11541
+ batches.push(batch);
11542
+ continue;
11543
+ }
11544
+ if (indices[indices.length - 1] - indices[0] + 1 === indices.length) {
11545
+ batches.push(batch.slice(indices[0], indices[indices.length - 1] + 1));
11546
+ continue;
11547
+ }
11548
+ const gathered = (0, import_arrow.takeArrowTableRows)(data, Int32Array.from(indices));
11549
+ batches.push(
11550
+ ...gathered.batches.map(
11551
+ (output) => new arrow9.RecordBatch(source.schema, output.data, batch.metadata)
11552
+ )
11553
+ );
11554
+ }
11555
+ return new arrow9.Table(source.schema, batches);
11556
+ }
11557
+ function getPredicateColumns(sourceTable, columnNames) {
11558
+ const columns = {};
11559
+ for (const columnName of columnNames) {
11560
+ const column = sourceTable.getChild(columnName);
11561
+ if (!column) {
11562
+ throw new Error(`Arrow query column not found: ${columnName}`);
11563
+ }
11564
+ columns[columnName] = column;
11565
+ }
11566
+ return columns;
11567
+ }
11568
+ function evaluatePredicate(predicate, columns, rowIndex) {
11569
+ if (isLogicalPredicate(predicate)) {
11570
+ const values = predicate.args.map((child) => evaluatePredicate(child, columns, rowIndex));
11571
+ return predicate.op === "and" ? evaluateAnd(values) : evaluateOr(values);
11572
+ }
11573
+ if (isNotPredicate(predicate)) {
11574
+ const value2 = evaluatePredicate(predicate.args[0], columns, rowIndex);
11575
+ return value2 === null ? null : !value2;
11576
+ }
11577
+ const value = getColumnValue(columns, predicate.args[0].property, rowIndex);
11578
+ if (isNullPredicate(predicate)) {
11579
+ return value === null || value === void 0;
11580
+ }
11581
+ if (isInPredicate(predicate)) {
11582
+ return evaluateIn(value, predicate.args[1]);
11583
+ }
11584
+ return evaluateComparison(value, predicate);
11585
+ }
11586
+ function getColumnValue(columns, columnName, rowIndex) {
11587
+ const path = typeof columnName === "string" ? [columnName] : columnName;
11588
+ const column = columns[path[0]];
11589
+ if (!column) {
11590
+ throw new Error(`Arrow query could not read predicate column "${columnName}".`);
11591
+ }
11592
+ let value = column.get(rowIndex);
11593
+ for (const property of path.slice(1)) {
11594
+ if (value === null || value === void 0) return null;
11595
+ value = value[property];
11596
+ }
11597
+ return value;
11598
+ }
11599
+ function evaluateAnd(values) {
11600
+ if (values.includes(false)) {
11601
+ return false;
11602
+ }
11603
+ return values.includes(null) ? null : true;
11604
+ }
11605
+ function evaluateOr(values) {
11606
+ if (values.includes(true)) {
11607
+ return true;
11608
+ }
11609
+ return values.includes(null) ? null : false;
11610
+ }
11611
+ function evaluateIn(value, candidates) {
11612
+ if (value === null || value === void 0) {
11613
+ return null;
11614
+ }
11615
+ for (const candidate of candidates) {
11616
+ if (compareValues(value, candidate) === 0) {
11617
+ return true;
11618
+ }
11619
+ }
11620
+ return false;
11621
+ }
11622
+ function evaluateComparison(value, predicate) {
11623
+ if (value === null || value === void 0) {
11624
+ return null;
11625
+ }
11626
+ const comparison = compareValues(value, predicate.args[1]);
11627
+ switch (predicate.op) {
11628
+ case "=":
11629
+ return comparison === 0;
11630
+ case "<>":
11631
+ return comparison !== 0;
11632
+ case "<":
11633
+ return comparison < 0;
11634
+ case "<=":
11635
+ return comparison <= 0;
11636
+ case ">":
11637
+ return comparison > 0;
11638
+ case ">=":
11639
+ return comparison >= 0;
11640
+ }
11641
+ }
11642
+ function compareValues(left, right) {
11643
+ if (isColumnarPredicateParameter(right)) {
11644
+ throw new Error(
11645
+ `Arrow query parameter ":${right.parameter}" must be bound before query execution.`
11646
+ );
11647
+ }
11648
+ if (left instanceof Date && right instanceof Date) {
11649
+ return compareArrowQueryNumbers(left.getTime(), right.getTime());
11650
+ }
11651
+ if (typeof left === "number" && right instanceof Date) {
11652
+ return compareArrowQueryNumbers(left, right.getTime());
11653
+ }
11654
+ if (left instanceof Uint8Array && right instanceof Uint8Array) {
11655
+ return compareBinary(left, right);
11656
+ }
11657
+ if (typeof left === "bigint" && typeof right === "bigint") {
11658
+ return left === right ? 0 : left < right ? -1 : 1;
11659
+ }
11660
+ if (typeof left === "bigint" && typeof right === "number" || typeof left === "number" && typeof right === "bigint") {
11661
+ const numericValue = typeof left === "number" ? left : right;
11662
+ if (!Number.isFinite(numericValue))
11663
+ throw new Error("Arrow query cannot compare non-finite numbers.");
11664
+ return left < right ? -1 : left > right ? 1 : 0;
11665
+ }
11666
+ if (typeof left === "number" && typeof right === "number") {
11667
+ return compareArrowQueryNumbers(left, right);
11668
+ }
11669
+ if (typeof left === "string" && typeof right === "string") {
11670
+ return left === right ? 0 : left < right ? -1 : 1;
11671
+ }
11672
+ if (typeof left === "boolean" && typeof right === "boolean") {
11673
+ return Number(left) - Number(right);
11674
+ }
11675
+ throw new Error(
11676
+ `Arrow query cannot compare ${getArrowQueryValueType(left)} with ${getArrowQueryValueType(right)} values.`
11677
+ );
11678
+ }
11679
+ function compareArrowQueryNumbers(left, right) {
11680
+ if (!Number.isFinite(left) || !Number.isFinite(right)) {
11681
+ throw new Error("Arrow query cannot compare non-finite numbers.");
11682
+ }
11683
+ return left === right ? 0 : left < right ? -1 : 1;
11684
+ }
11685
+ function compareBinary(left, right) {
11686
+ const commonLength = Math.min(left.length, right.length);
11687
+ for (let index = 0; index < commonLength; index++) {
11688
+ if (left[index] !== right[index]) {
11689
+ return left[index] < right[index] ? -1 : 1;
11690
+ }
11691
+ }
11692
+ return left.length === right.length ? 0 : left.length < right.length ? -1 : 1;
11693
+ }
11694
+ function getArrowQueryValueType(value) {
11695
+ if (value instanceof Date) {
11696
+ return "Date";
11697
+ }
11698
+ if (value instanceof Uint8Array) {
11699
+ return "Uint8Array";
11700
+ }
11701
+ return typeof value;
11702
+ }
11703
+ function isLogicalPredicate(predicate) {
11704
+ return predicate.op === "and" || predicate.op === "or";
11705
+ }
11706
+ function isNotPredicate(predicate) {
11707
+ return predicate.op === "not";
11708
+ }
11709
+ function isNullPredicate(predicate) {
11710
+ return predicate.op === "isNull";
11711
+ }
11712
+ function isInPredicate(predicate) {
11713
+ return predicate.op === "in";
11714
+ }
11715
+ var arrow9, import_arrow;
11716
+ var init_filter_arrow_table = __esm({
11717
+ "../core/src/scan/arrow-execution/filter-arrow-table.ts"() {
11718
+ "use strict";
11719
+ arrow9 = __toESM(require("apache-arrow"), 1);
11720
+ import_arrow = require("@math.gl/arrow");
11721
+ init_loader_utils();
11722
+ }
11723
+ });
11724
+
11725
+ // ../core/src/scan/arrow-execution.ts
11726
+ var arrow_execution_exports = {};
11727
+ __export(arrow_execution_exports, {
11728
+ filterArrowTable: () => filterArrowTable,
11729
+ projectArrowTable: () => projectArrowTable
11730
+ });
11731
+ var init_arrow_execution = __esm({
11732
+ "../core/src/scan/arrow-execution.ts"() {
11733
+ "use strict";
11734
+ init_project_arrow_table();
11735
+ init_filter_arrow_table();
11736
+ }
11737
+ });
11738
+
11739
+ // ../pointclouds/src/las/las-source.ts
11740
+ var import_apache_arrow, LAS_QUERY_CAPABILITIES, LASSource;
11741
+ var init_las_source = __esm({
11742
+ "../pointclouds/src/las/las-source.ts"() {
11743
+ "use strict";
11744
+ import_apache_arrow = require("apache-arrow");
11745
+ init_loader_utils();
11746
+ init_schema_utils();
11747
+ init_las_loader();
11748
+ LAS_QUERY_CAPABILITIES = Object.freeze({
11749
+ predicate: "residual",
11750
+ projection: "pushdown+residual",
11751
+ limit: "pushdown",
11752
+ offset: "pushdown",
11753
+ cast: "unsupported",
11754
+ streaming: true,
11755
+ cancellation: true
11756
+ });
11757
+ LASSource = class extends DataSource {
11758
+ /** Creates a source without fetching or decoding point data. */
11759
+ constructor(data, options = {}, coreApi) {
11760
+ super(data, options, void 0, coreApi);
11761
+ }
11762
+ /** Discovers fields from the header and variable-length records without decoding points. */
11763
+ async getQueryMetadata(options = {}) {
11764
+ const chunks = [];
11765
+ let length = 0;
11766
+ let required = 227;
11767
+ for await (const chunk of this.readBytes(options.signal)) {
11768
+ chunks.push(chunk);
11769
+ length += chunk.byteLength;
11770
+ if (length < required) continue;
11771
+ const bytes = new Uint8Array(length);
11772
+ let offset = 0;
11773
+ for (const part of chunks) {
11774
+ bytes.set(part, offset);
11775
+ offset += part.byteLength;
11776
+ }
11777
+ const view = new DataView(bytes.buffer);
11778
+ if (view.getUint32(0, true) !== 1179861324) throw new Error("Invalid LAS header");
11779
+ required = Math.max(227, view.getUint16(94, true), view.getUint32(96, true));
11780
+ if (length < required) continue;
11781
+ const table = parseLASMetadata(bytes.buffer.slice(0, required), this.loadOptions);
11782
+ return createScanQueryMetadata({
11783
+ sourceType: "las",
11784
+ name: this.name,
11785
+ queryType: "table",
11786
+ execution: { status: "supported", method: "read" },
11787
+ schema: convertArrowToSchema(table.schema),
11788
+ capabilities: { table: LAS_QUERY_CAPABILITIES }
11789
+ });
11790
+ }
11791
+ throw new Error("Truncated LAS header");
11792
+ }
11793
+ /** Explains projection and row-window pushdown separately from residual filtering. */
11794
+ async explain(options = {}) {
11795
+ const metadata = await this.getQueryMetadata(options);
11796
+ return explainTableQuery(
11797
+ metadata.columns.map((column) => column.name),
11798
+ options,
11799
+ LAS_QUERY_CAPABILITIES
11800
+ );
11801
+ }
11802
+ /** Decodes selected columns and applies predicates before the global offset and limit. */
11803
+ async *read(options = {}) {
11804
+ const columns = options.columns === void 0 ? void 0 : [
11805
+ .../* @__PURE__ */ new Set([
11806
+ ...options.columns,
11807
+ ...options.predicate ? getColumnarPredicateColumns(options.predicate) : []
11808
+ ])
11809
+ ];
11810
+ for await (const table of executeTableScanBatches(
11811
+ (signal, onByteLength) => this.parseBatches(columns, signal, onByteLength),
11812
+ options,
11813
+ {
11814
+ async filter(batch, predicate, signal) {
11815
+ if (!predicate) return batch;
11816
+ const { filterArrowTable: filterArrowTable2 } = await Promise.resolve().then(() => (init_arrow_execution(), arrow_execution_exports));
11817
+ return filterArrowTable2(batch, predicate, { signal });
11818
+ }
11819
+ }
11820
+ )) {
11821
+ if (table.batches.length) yield* table.batches;
11822
+ else yield makeArrowMetadataBatch(table.schema);
11823
+ }
11824
+ }
11825
+ /** Pushes selected source fields into the decoder before allocating Arrow columns. */
11826
+ async *parseBatches(columns, signal, onByteLength) {
11827
+ const options = {
11828
+ ...this.loadOptions,
11829
+ signal,
11830
+ las: {
11831
+ ...this.options.las,
11832
+ shape: "arrow",
11833
+ ...columns && {
11834
+ columns: [
11835
+ ...new Set(
11836
+ columns.map(
11837
+ (column) => {
11838
+ var _a;
11839
+ return ((_a = this.options.las) == null ? void 0 : _a.extraBytes) === "typed" && column.startsWith("EXTRA_BYTES_") ? "EXTRA_BYTES" : column;
11840
+ }
11841
+ )
11842
+ )
11843
+ ]
11844
+ }
11845
+ }
11846
+ };
11847
+ const chunks = this.readBytes(signal, onByteLength);
11848
+ try {
11849
+ for await (const batch of LASLoaderWithParser.parseInBatches(chunks, options)) {
11850
+ if ("attributes" in batch) throw new Error("Expected Arrow LAS output");
11851
+ yield new import_apache_arrow.Table(batch.schema, [batch]);
11852
+ }
11853
+ } finally {
11854
+ await chunks.return();
11855
+ }
11856
+ }
11857
+ /** Reads with cancellation and closes the stream when a limit stops decoding early. */
11858
+ async *readBytes(signal, onByteLength) {
11859
+ signal == null ? void 0 : signal.throwIfAborted();
11860
+ const input = this.data instanceof Blob ? this.data : await this.fetch(this.url, { signal });
11861
+ if (input instanceof Response && !input.ok)
11862
+ throw new Error(`LAS request failed: ${input.status}`);
11863
+ const stream = input instanceof Blob ? input.stream() : input.body;
11864
+ if (!stream) {
11865
+ const bytes = new Uint8Array(await input.arrayBuffer());
11866
+ signal == null ? void 0 : signal.throwIfAborted();
11867
+ onByteLength == null ? void 0 : onByteLength(bytes.byteLength);
11868
+ yield bytes;
11869
+ return;
11870
+ }
11871
+ const reader = stream.getReader();
11872
+ const abort = () => {
11873
+ void reader.cancel().catch(() => {
11874
+ });
11875
+ };
11876
+ signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
11877
+ try {
11878
+ while (true) {
11879
+ signal == null ? void 0 : signal.throwIfAborted();
11880
+ const { done, value } = await reader.read();
11881
+ signal == null ? void 0 : signal.throwIfAborted();
11882
+ if (done) return;
11883
+ onByteLength == null ? void 0 : onByteLength(value.byteLength);
11884
+ yield value;
11885
+ }
11886
+ } finally {
11887
+ signal == null ? void 0 : signal.removeEventListener("abort", abort);
11888
+ await reader.cancel();
11889
+ reader.releaseLock();
11890
+ }
11891
+ }
11892
+ };
11220
11893
  }
11221
11894
  });
11222
11895
 
11223
11896
  // ../core/src/arrow-worker-transport.ts
11224
- function serializeArrowWorkerTable(result) {
11225
- if (!isArrowTableWrapper(result)) {
11897
+ function serializeNativeArrowWorkerResult(result, options = { copy: "all" }) {
11898
+ const batch = result instanceof arrow10.RecordBatch;
11899
+ if (!batch && !(result instanceof arrow10.Table)) {
11226
11900
  throw new Error("Workers require Arrow table output");
11227
11901
  }
11228
- const { data, shape: _shape, ...metadata } = result;
11229
11902
  return {
11230
- transport: "arrow-column-envelope",
11231
- metadata: structuredClone(metadata),
11232
- ...serializeWorkerColumns(data, { copy: "all" })
11903
+ transport: batch ? "arrow-record-batch" : "arrow-table-columns",
11904
+ columns: batch ? { data: (0, import_arrow2.dehydrateArrowRecordBatch)(result, options) } : serializeWorkerColumns(result, options)
11233
11905
  };
11234
11906
  }
11235
- function deserializeArrowWorkerTable(result) {
11236
- if (isArrowWorkerEnvelope(result)) {
11237
- return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
11907
+ function deserializeNativeArrowWorkerResult(result) {
11908
+ const payload = result;
11909
+ if ((payload == null ? void 0 : payload.transport) !== "arrow-table-columns" && (payload == null ? void 0 : payload.transport) !== "arrow-record-batch" || !hasArrowWorkerColumns(payload.columns)) {
11910
+ throw new Error("Workers require Arrow column transport");
11238
11911
  }
11239
- if (isLegacyArrowWorkerEnvelope(result)) {
11240
- const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
11241
- return { ...metadata, data: hydrateWorkerTable(result) };
11912
+ if (payload.transport === "arrow-record-batch" && !payload.columns.arrowBatchMetadata) {
11913
+ return (0, import_arrow2.hydrateArrowRecordBatch)(payload.columns.data);
11242
11914
  }
11243
- throw new Error("Workers require Arrow column transport");
11244
- }
11245
- function isArrowTableWrapper(value) {
11246
- const table = value;
11247
- return Boolean(
11248
- table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
11249
- );
11915
+ const data = hydrateWorkerTable(payload.columns);
11916
+ return payload.transport === "arrow-record-batch" ? data.batches[0] : data;
11250
11917
  }
11251
11918
  function hasArrowWorkerColumns(value) {
11252
11919
  var _a;
11253
11920
  const columns = value;
11254
11921
  return ((_a = columns == null ? void 0 : columns.data) == null ? void 0 : _a.transport) === "arrow-js" && Array.isArray(columns.data.batches);
11255
11922
  }
11256
- function isArrowWorkerEnvelope(value) {
11257
- return (value == null ? void 0 : value.transport) === "arrow-column-envelope" && hasArrowWorkerColumns(value);
11258
- }
11259
- function isLegacyArrowWorkerEnvelope(value) {
11260
- return (value == null ? void 0 : value.shape) === "arrow-table" && hasArrowWorkerColumns(value);
11261
- }
11262
11923
  function serializeWorkerColumns(table, options) {
11263
11924
  return {
11264
11925
  arrowBatchMetadata: snapshotBatchMetadata(table),
11265
- data: dehydrateWorkerTable(table, options)
11926
+ data: (0, import_arrow2.dehydrateArrowTable)(table, options)
11266
11927
  };
11267
11928
  }
11268
- function dehydrateWorkerTable(table, options) {
11269
- const payload = (0, import_arrow.dehydrateArrowTable)(table, options);
11270
- if (table.numCols === 0) {
11271
- for (const [index, batch] of table.batches.entries()) {
11272
- payload.batches[index].length = batch.numRows;
11273
- }
11274
- }
11275
- return payload;
11276
- }
11277
11929
  function snapshotBatchMetadata(table) {
11278
11930
  return table.batches.map((batch) => ({
11279
- schema: arrow8.tableToIPC(new arrow8.Table(batch.schema, [])),
11280
- metadata: Array.from(batch.metadata)
11931
+ schema: arrow10.tableToIPC(new arrow10.Table(batch.schema, []))
11281
11932
  }));
11282
11933
  }
11283
11934
  function hydrateWorkerTable(result) {
11284
11935
  const { arrowBatchMetadata, data } = result;
11285
- const table = (0, import_arrow.hydrateArrowTable)(data);
11936
+ const table = (0, import_arrow2.hydrateArrowTable)(data);
11286
11937
  const batches = table.batches.map((batch, index) => {
11287
11938
  const snapshot = arrowBatchMetadata == null ? void 0 : arrowBatchMetadata[index];
11288
- const restored = snapshot ? new arrow8.RecordBatch(
11289
- arrow8.tableFromIPC(snapshot.schema).schema,
11939
+ return snapshot ? (0, import_arrow2.createRecordBatchWithMetadata)(
11940
+ arrow10.tableFromIPC(snapshot.schema).schema,
11290
11941
  batch.data,
11291
- new Map(snapshot.metadata)
11942
+ snapshot.metadata ? new Map(snapshot.metadata) : (0, import_arrow2.getRecordBatchMetadata)(batch)
11292
11943
  ) : batch;
11293
- const rowCount = data.batches[index].length;
11294
- if (restored.numCols === 0 && restored.numRows !== rowCount) {
11295
- Object.defineProperty(restored, "data", {
11296
- value: new arrow8.Data(new arrow8.Struct([]), 0, rowCount, 0, void 0, [])
11297
- });
11298
- }
11299
- return restored;
11300
11944
  });
11301
- return new arrow8.Table(table.schema, batches);
11945
+ return new arrow10.Table(table.schema, batches);
11302
11946
  }
11303
- var arrow8, import_arrow;
11947
+ var arrow10, import_arrow2;
11304
11948
  var init_arrow_worker_transport = __esm({
11305
11949
  "../core/src/arrow-worker-transport.ts"() {
11306
11950
  "use strict";
11307
- arrow8 = __toESM(require("apache-arrow"), 1);
11308
- import_arrow = require("@math.gl/arrow");
11951
+ arrow10 = __toESM(require("apache-arrow"), 1);
11952
+ import_arrow2 = require("@math.gl/arrow");
11309
11953
  }
11310
11954
  });
11311
11955
 
@@ -11643,7 +12287,7 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
11643
12287
  lastTable = makeEmptyLASBatch(header, options);
11644
12288
  } else {
11645
12289
  for await (const table of parseLAZInBatches(pending, trackedIterator, header, options)) {
11646
- lastTable = updateArrowTableMetadata(
12290
+ lastTable = updateLASArrowMetadata(
11647
12291
  table,
11648
12292
  makeMetadataFromLasHeader({
11649
12293
  ...header,
@@ -11688,7 +12332,7 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
11688
12332
  totalRead = batch.totalRead;
11689
12333
  pending = batch.pending;
11690
12334
  absoluteOffset = batch.absoluteOffset;
11691
- lastTable = updateArrowTableMetadata(
12335
+ lastTable = updateLASArrowMetadata(
11692
12336
  parseLASArrowTableBatch(batch.arrayBuffer, batch.header, options),
11693
12337
  makeMetadataFromLasHeader({ ...header, totalRead })
11694
12338
  );
@@ -11709,11 +12353,12 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
11709
12353
  if (update) yield update;
11710
12354
  }
11711
12355
  function makeEmptyLASBatch(header, options) {
11712
- const table = parseLASArrowTableBatch(new ArrayBuffer(0), { ...header, pointsOffset: 0 }, options);
11713
- return updateArrowTableMetadata(
11714
- { ...table, loaderData: header },
11715
- makeMetadataFromLasHeader(header)
12356
+ const table = parseLASArrowTableBatch(
12357
+ new ArrayBuffer(0),
12358
+ { ...header, pointsCount: 0, pointsOffset: 0 },
12359
+ options
11716
12360
  );
12361
+ return updateLASArrowMetadata({ ...table, loaderData: header }, makeMetadataFromLasHeader(header));
11717
12362
  }
11718
12363
  function makeLASMetadataUpdate(lastTable, header, pending, absoluteOffset, totalRead) {
11719
12364
  const metadata = header.metadata;
@@ -11738,14 +12383,17 @@ function makeLASMetadataUpdate(lastTable, header, pending, absoluteOffset, total
11738
12383
  resolveLASGeoTIFFKeyDirectory(finalMetadata);
11739
12384
  const finalHeader = { ...header, totalRead, metadata: finalMetadata };
11740
12385
  if (records.length > 0) {
11741
- const data = new arrow9.Table([makeArrowMetadataBatch(lastTable.data.schema)]);
11742
- return updateArrowTableMetadata(
12386
+ const data = new arrow11.Table([makeArrowMetadataBatch(lastTable.data.schema)]);
12387
+ return updateLASArrowMetadata(
11743
12388
  { ...lastTable, data, loaderData: finalHeader },
11744
12389
  makeMetadataFromLasHeader(finalHeader)
11745
12390
  );
11746
12391
  }
11747
12392
  }
11748
12393
  }
12394
+ function updateLASArrowMetadata(table, metadata) {
12395
+ return { ...table, data: updateNativeArrowTableMetadata(table.data, metadata) };
12396
+ }
11749
12397
  async function* decodeLAZFileWithParsedVLRInBatches(initialPending, inputIterator, header, laszip, options) {
11750
12398
  var _a;
11751
12399
  if (laszip.variableChunks) {
@@ -12174,7 +12822,7 @@ function* decodeLAZFileFromCompleteBytes(bytes, header, laszip, options = {}) {
12174
12822
  const batchSize = getBatchSize(options);
12175
12823
  const outputHeader = {
12176
12824
  ...header,
12177
- metadata: parseLASMetadata(bytes, header),
12825
+ metadata: parseLASMetadata2(bytes, header),
12178
12826
  totalToRead: header.pointsCount
12179
12827
  };
12180
12828
  const state = createRawPointBatchState(
@@ -12299,7 +12947,7 @@ function parseLASHeader(arrayBuffer) {
12299
12947
  userHeaderData: versionMinor === 5 && headerSize > 393 ? new Uint8Array(arrayBuffer, 393, headerSize - 393).slice() : void 0
12300
12948
  };
12301
12949
  if (hasCompleteLASMetadata(arrayBuffer, header)) {
12302
- header.metadata = parseLASMetadata(arrayBuffer, header);
12950
+ header.metadata = parseLASMetadata2(arrayBuffer, header);
12303
12951
  }
12304
12952
  return header;
12305
12953
  }
@@ -12307,7 +12955,7 @@ function hasCompleteLASMetadata(arrayBuffer, header) {
12307
12955
  const vlrEnd = header.headerSize + header.vlrCount * 54;
12308
12956
  return arrayBuffer.byteLength >= Math.max(vlrEnd, header.pointsOffset);
12309
12957
  }
12310
- function parseLASMetadata(arrayBuffer, header) {
12958
+ function parseLASMetadata2(arrayBuffer, header) {
12311
12959
  const dataView = makeDataView(arrayBuffer);
12312
12960
  const bytes = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
12313
12961
  const version2 = header.versionAsString || "1.0";
@@ -12683,7 +13331,7 @@ function makeLASArrowTableFromAttributes(lasHeader, positions, colors, intensiti
12683
13331
  if (extraBytes) {
12684
13332
  attributes.EXTRA_BYTES = {
12685
13333
  value: extraBytes,
12686
- size: extraBytes.length / Math.max(lasHeader.pointsCount, 1)
13334
+ size: lasHeader.pointsStructSize - getLAZPointDataRecordBaseLength(lasHeader.pointsFormatId)
12687
13335
  };
12688
13336
  }
12689
13337
  if (typedExtraBytes) {
@@ -12699,7 +13347,7 @@ function makeLASArrowTableFromAttributes(lasHeader, positions, colors, intensiti
12699
13347
  }
12700
13348
  const schema = getLASSchema(lasHeader, numericAttributes);
12701
13349
  return {
12702
- ...makeMeshArrowTable(attributes, {
13350
+ data: makeMeshArrowTable(attributes, {
12703
13351
  schema,
12704
13352
  topology: "point-list",
12705
13353
  mode: 0,
@@ -14222,12 +14870,12 @@ function readUint64(dataView, byteOffset) {
14222
14870
  const high = dataView.getUint32(byteOffset + 4, true);
14223
14871
  return high * 2 ** 32 + low;
14224
14872
  }
14225
- var arrow9, DEFAULT_BATCH_SIZE, LASF_SIGNATURE, LAS_14_HEADER_LENGTH, COMPRESSED_POINT_FORMAT_MASK, POINT_FORMAT_MASK, LASZIP_USER_ID, LASZIP_RECORD_ID, VARIABLE_CHUNK_SIZE, LAZ_CHUNK_TABLE_POINTER_LENGTH, LEGACY_LAZ_FEED_BLOCK_SIZE;
14873
+ var arrow11, DEFAULT_BATCH_SIZE, LASF_SIGNATURE, LAS_14_HEADER_LENGTH, COMPRESSED_POINT_FORMAT_MASK, POINT_FORMAT_MASK, LASZIP_USER_ID, LASZIP_RECORD_ID, VARIABLE_CHUNK_SIZE, LAZ_CHUNK_TABLE_POINTER_LENGTH, LEGACY_LAZ_FEED_BLOCK_SIZE;
14226
14874
  var init_parse_las = __esm({
14227
14875
  "../pointclouds/src/las/lib/typescript/parse-las.ts"() {
14228
14876
  "use strict";
14229
14877
  init_schema_utils();
14230
- arrow9 = __toESM(require("apache-arrow"), 1);
14878
+ arrow11 = __toESM(require("apache-arrow"), 1);
14231
14879
  init_get_las_schema();
14232
14880
  init_schema_utils();
14233
14881
  init_loader_utils();
@@ -14253,6 +14901,7 @@ __export(las_loader_exports, {
14253
14901
  LASColumnLoader: () => LASColumnLoader,
14254
14902
  LASLoaderWithParser: () => LASLoaderWithParser,
14255
14903
  getLASRecordBatches: () => getLASRecordBatches,
14904
+ parseLASMetadata: () => parseLASMetadata,
14256
14905
  toPublicLASResult: () => toPublicLASResult
14257
14906
  });
14258
14907
  function parseLASTable(arrayBuffer, options) {
@@ -14263,8 +14912,8 @@ function parseLASTable(arrayBuffer, options) {
14263
14912
  function convertLASMesh(table, options) {
14264
14913
  var _a;
14265
14914
  const formattedTable = ((_a = options == null ? void 0 : options.las) == null ? void 0 : _a.colorFormat) === void 0 || options.las.colorFormat === "uint8norm" ? table : {
14266
- ...convertMeshToArrowTableWrapper(
14267
- formatLASMeshColors(convertTableToMesh(table), options.las.colorFormat)
14915
+ data: convertMeshToArrowTable(
14916
+ formatLASMeshColors(convertTableToMesh(table.data), options.las.colorFormat)
14268
14917
  ),
14269
14918
  loader: table.loader,
14270
14919
  loaderData: table.loaderData,
@@ -14274,7 +14923,7 @@ function convertLASMesh(table, options) {
14274
14923
  return formattedTable;
14275
14924
  }
14276
14925
  return {
14277
- ...convertTableToMesh(formattedTable),
14926
+ ...convertTableToMesh(formattedTable.data),
14278
14927
  loader: formattedTable.loader,
14279
14928
  loaderData: formattedTable.loaderData,
14280
14929
  progress: formattedTable.progress
@@ -14290,11 +14939,25 @@ async function* convertLASMeshBatches(tableBatches, options) {
14290
14939
  yield convertLASMesh(table, options);
14291
14940
  }
14292
14941
  }
14942
+ function serializeLASWorkerTable(result) {
14943
+ if ("attributes" in result) throw new Error("LAS workers require Arrow columns");
14944
+ return {
14945
+ columns: serializeNativeArrowWorkerResult(result.data),
14946
+ loaderData: structuredClone(result.loaderData),
14947
+ progress: result.progress
14948
+ };
14949
+ }
14293
14950
  function deserializeLASWorkerTable(result, options) {
14294
- return convertLASMesh(deserializeArrowWorkerTable(result), options);
14951
+ const payload = result;
14952
+ const table = deserializeNativeArrowWorkerResult(payload.columns);
14953
+ if (!isArrowTable(table)) throw new Error("LAS workers require an Arrow table");
14954
+ return convertLASMesh(
14955
+ { data: table, loader: "las", loaderData: payload.loaderData, progress: payload.progress },
14956
+ options
14957
+ );
14295
14958
  }
14296
14959
  function toPublicLASResult(result) {
14297
- if (!("shape" in result)) return result;
14960
+ if ("attributes" in result) return result;
14298
14961
  const header = JSON.stringify(
14299
14962
  result.loaderData,
14300
14963
  (_key, value) => typeof value === "bigint" ? value.toString() : ArrayBuffer.isView(value) ? Array.from(value) : value
@@ -14306,16 +14969,22 @@ function toPublicLASResult(result) {
14306
14969
  }
14307
14970
  return result.data;
14308
14971
  }
14309
- function getLASRecordBatches(result) {
14310
- const table = toPublicLASResult(result);
14972
+ function getLASRecordBatches(table) {
14311
14973
  return table.batches.length ? table.batches : [makeArrowMetadataBatch(table.schema)];
14312
14974
  }
14313
- var LASColumnLoader, LASLoaderWithParser;
14975
+ function parseLASMetadata(bytes, options) {
14976
+ const header = parseLASHeader(bytes);
14977
+ const empty = makeEmptyLASBatch(header, options);
14978
+ return toPublicLASResult(
14979
+ convertLASMesh(empty, { ...options, las: { ...options.las, shape: "arrow" } })
14980
+ );
14981
+ }
14982
+ var LASColumnLoader, _serializeLASWorkerResult, _serializeLASWorkerBatch, LASColumnLoaderForCaller, LASLoaderWithParser;
14314
14983
  var init_las_loader = __esm({
14315
14984
  "../pointclouds/src/las/las-loader.ts"() {
14316
14985
  "use strict";
14317
14986
  init_loader_utils();
14318
- init_schema_utils();
14987
+ init_las_source();
14319
14988
  init_schema_utils();
14320
14989
  init_las_loader_shared();
14321
14990
  init_arrow_worker_transport();
@@ -14326,8 +14995,8 @@ var init_las_loader = __esm({
14326
14995
  batchType: null,
14327
14996
  worker: true,
14328
14997
  workerInBatches: true,
14329
- serializeWorkerResult: serializeArrowWorkerTable,
14330
- serializeWorkerBatch: serializeArrowWorkerTable,
14998
+ serializeWorkerResult: serializeLASWorkerTable,
14999
+ serializeWorkerBatch: serializeLASWorkerTable,
14331
15000
  deserializeWorkerResult: deserializeLASWorkerTable,
14332
15001
  deserializeWorkerBatch: deserializeLASWorkerTable,
14333
15002
  parse: async (arrayBuffer, options) => convertLASMesh(parseLASTable(arrayBuffer, options), options),
@@ -14336,22 +15005,30 @@ var init_las_loader = __esm({
14336
15005
  yield* convertLASMeshBatches(parseLASInBatches(arrayBufferIterator, options), options);
14337
15006
  }
14338
15007
  };
15008
+ ({
15009
+ serializeWorkerResult: _serializeLASWorkerResult,
15010
+ serializeWorkerBatch: _serializeLASWorkerBatch,
15011
+ ...LASColumnLoaderForCaller
15012
+ } = LASColumnLoader);
14339
15013
  LASLoaderWithParser = {
14340
- ...LASColumnLoader,
15014
+ ...LASColumnLoaderForCaller,
15015
+ ...LAS_SOURCE_METADATA,
15016
+ /** Creates a sequential query source using the same LAS decoder. */
15017
+ createDataSourceSync: (data, options, coreApi) => new LASSource(data, options, coreApi),
14341
15018
  dataType: LAS_LOADER_METADATA.dataType,
14342
15019
  batchType: LAS_LOADER_METADATA.batchType,
14343
15020
  parse: async (input, options) => toPublicLASResult(await LASColumnLoader.parse(input, options)),
14344
15021
  parseSync: (input, options) => toPublicLASResult(LASColumnLoader.parseSync(input, options)),
14345
15022
  async *parseInBatches(input, options) {
14346
15023
  for await (const result of LASColumnLoader.parseInBatches(input, options)) {
14347
- if ("shape" in result) yield* getLASRecordBatches(result);
15024
+ if (!("attributes" in result)) yield* getLASRecordBatches(toPublicLASResult(result));
14348
15025
  else yield result;
14349
15026
  }
14350
15027
  },
14351
15028
  deserializeWorkerResult: (result, options) => toPublicLASResult(deserializeLASWorkerTable(result, options)),
14352
15029
  deserializeWorkerBatch(result, options) {
14353
15030
  const decoded = deserializeLASWorkerTable(result, options);
14354
- return "shape" in decoded ? getLASRecordBatches(decoded)[0] : decoded;
15031
+ return "attributes" in decoded ? decoded : getLASRecordBatches(toPublicLASResult(decoded))[0];
14355
15032
  }
14356
15033
  };
14357
15034
  }
@@ -14854,7 +15531,7 @@ function normalizeMesh(data) {
14854
15531
  return data;
14855
15532
  }
14856
15533
  function normalizeMeshArrowTable(data) {
14857
- return !("attributes" in data) ? data : convertMeshToArrowTableWrapper(data);
15534
+ return !("attributes" in data) ? data : convertMeshToArrowTable(data);
14858
15535
  }
14859
15536
  function mergeMeshBatches(batches) {
14860
15537
  if (batches.length === 0) {
@@ -15439,7 +16116,12 @@ var LASLoader = {
15439
16116
  ...LAS_LOADER_METADATA,
15440
16117
  worker: true,
15441
16118
  workerInBatches: true,
15442
- preload
16119
+ preload,
16120
+ ...LAS_SOURCE_METADATA,
16121
+ /** Creates a source after the parser implementation has been preloaded. */
16122
+ createDataSourceSync(_data, _options, _coreApi) {
16123
+ throw new Error("Call preload(LASLoader) before creating a source synchronously.");
16124
+ }
15443
16125
  };
15444
16126
 
15445
16127
  // dist/copc/lib/copc-reader.js
@@ -15877,7 +16559,7 @@ function normalizeCOPCProjectionDefinition(projectionData) {
15877
16559
  }
15878
16560
 
15879
16561
  // dist/copc/copc-loader.js
15880
- var VERSION4 = true ? "5.0.0-beta.10" : "latest";
16562
+ var VERSION4 = true ? "5.0.0-beta.11" : "latest";
15881
16563
  var COPC_PREFIX_CACHE_LENGTH = 65536;
15882
16564
  var COORDINATE_SYSTEM = {
15883
16565
  CARTESIAN: "cartesian",
@@ -16075,7 +16757,7 @@ var COPCTileSource = class extends DataSource {
16075
16757
  /** Extracts query-visible source-coordinate columns from one decoded COPC batch. */
16076
16758
  getCOPCScanColumns(content, columnNames, bounds) {
16077
16759
  const columns = Object.fromEntries(columnNames.map((columnName) => [columnName, []]));
16078
- const positionVector = content.data.data.getChild("POSITION");
16760
+ const positionVector = content.data.getChild("POSITION");
16079
16761
  for (let pointIndex = 0; pointIndex < content.pointCount; pointIndex++) {
16080
16762
  const offsetPosition = readArrowListValue(positionVector == null ? void 0 : positionVector.get(pointIndex));
16081
16763
  const projectedPosition = [
@@ -16491,7 +17173,10 @@ var COPCTileSource = class extends DataSource {
16491
17173
  }
16492
17174
  const input = getStandaloneArrayBuffer(compressed);
16493
17175
  const result = await parseWithWorker(LASLoader, input, workerOptions, void 0, void 0, signal);
16494
- const mesh = convertTableToMesh(deserializeArrowWorkerTable(result));
17176
+ const nativeTable = deserializeNativeArrowWorkerResult(result.columns);
17177
+ if (!("batches" in nativeTable))
17178
+ throw new Error("COPC LAS worker must return an Arrow table");
17179
+ const mesh = convertTableToMesh(nativeTable);
16495
17180
  const nativePositions = (_a = mesh.attributes.POSITION) == null ? void 0 : _a.value;
16496
17181
  const colors = ((_b = mesh.attributes.COLOR_0) == null ? void 0 : _b.value) || null;
16497
17182
  if (!(nativePositions instanceof Float64Array) || nativePositions.length !== node.pointCount * 3) {
@@ -16667,7 +17352,7 @@ var COPCTileSource = class extends DataSource {
16667
17352
  for (const attribute of (pointData == null ? void 0 : pointData.typedExtraBytes) || []) {
16668
17353
  attributes[attribute.name] = { value: attribute.value, size: attribute.size };
16669
17354
  }
16670
- return makeMeshArrowTable(attributes, { topology: "point-list", mode: 0 });
17355
+ return makeMeshArrowTable(attributes, { topology: "point-list" });
16671
17356
  }
16672
17357
  async ensureHierarchyLoaded(tileId) {
16673
17358
  await this.initialize();
@@ -16920,11 +17605,11 @@ function getCOPCScanValue(data, columnName, pointIndex, sourcePosition) {
16920
17605
  if (columnName === "Z")
16921
17606
  return sourcePosition[2];
16922
17607
  if (columnName === "Red" || columnName === "Green" || columnName === "Blue") {
16923
- const color = readArrowListValue((_a = data.data.getChild("COLOR_0")) == null ? void 0 : _a.get(pointIndex));
17608
+ const color = readArrowListValue((_a = data.getChild("COLOR_0")) == null ? void 0 : _a.get(pointIndex));
16924
17609
  return color[columnName === "Red" ? 0 : columnName === "Green" ? 1 : 2];
16925
17610
  }
16926
17611
  const decoderColumn = COPC_SCAN_COLUMN_MAP[columnName];
16927
- const value = normalizeArrowValue((_b = data.data.getChild(decoderColumn || columnName)) == null ? void 0 : _b.get(pointIndex));
17612
+ const value = normalizeArrowValue((_b = data.getChild(decoderColumn || columnName)) == null ? void 0 : _b.get(pointIndex));
16928
17613
  if (COPC_BOOLEAN_COLUMN_NAMES.has(columnName) && typeof value === "number") {
16929
17614
  return value !== 0;
16930
17615
  }
@@ -17215,7 +17900,7 @@ function createCachedCOPCRangeReader(readableFile) {
17215
17900
 
17216
17901
  // dist/copc/copc-writer.js
17217
17902
  init_loader_utils();
17218
- var VERSION5 = true ? "5.0.0-beta.10" : "latest";
17903
+ var VERSION5 = true ? "5.0.0-beta.11" : "latest";
17219
17904
  var LAS_1_4_HEADER_LENGTH3 = 375;
17220
17905
  var COPC_INFO_PAYLOAD_LENGTH = 160;
17221
17906
  var VLR_HEADER_LENGTH3 = 54;