@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
@@ -5392,6 +5392,10 @@ function validateColumnarPredicate(predicate, availableColumns) {
5392
5392
  }
5393
5393
  });
5394
5394
  }
5395
+ function isColumnarPredicateParameter(value) {
5396
+ const parameterValue = value;
5397
+ 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;
5398
+ }
5395
5399
  function filterColumnarRowIndices(predicate, columns, rowCount) {
5396
5400
  if (!predicate) return Array.from({ length: rowCount }, (_, index) => index);
5397
5401
  const result = [];
@@ -5468,6 +5472,13 @@ var init_columnar_predicate = __esm({
5468
5472
  });
5469
5473
 
5470
5474
  // ../core/src/loader-utils/lib/scan-utils/scan-query-metadata.ts
5475
+ function emitQueryComplete(callback, summary) {
5476
+ if (!callback) return;
5477
+ try {
5478
+ callback(summary);
5479
+ } catch {
5480
+ }
5481
+ }
5471
5482
  function createScanQueryMetadata(options) {
5472
5483
  validateScanExecutionSupport(options.queryType, options.execution);
5473
5484
  const schema = Object.freeze({
@@ -5503,6 +5514,7 @@ function createScanQueryMetadata(options) {
5503
5514
  columns: Object.freeze(columns),
5504
5515
  capabilities: queryCapabilities,
5505
5516
  queryCapabilities,
5517
+ ...options.hasDefaultRowWindow ? { hasDefaultRowWindow: true } : {},
5506
5518
  spatial: options.spatial ? Object.freeze({
5507
5519
  ...options.spatial,
5508
5520
  bounds: options.spatial.bounds ? Object.freeze({
@@ -5554,6 +5566,26 @@ var init_scan_query_metadata = __esm({
5554
5566
  });
5555
5567
 
5556
5568
  // ../core/src/loader-utils/lib/scan-utils/table-query.ts
5569
+ function planTableQuery(sourceColumnNames, options = {}) {
5570
+ validateTableQueryOptions(sourceColumnNames, options);
5571
+ const outputColumnNames = options.columns ? [...options.columns] : [...sourceColumnNames];
5572
+ const predicateColumnNames = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
5573
+ const requiredColumnNames = /* @__PURE__ */ new Set([...outputColumnNames, ...predicateColumnNames]);
5574
+ const scanColumnNames = sourceColumnNames.filter(
5575
+ (columnName) => requiredColumnNames.has(columnName)
5576
+ );
5577
+ const steps = [
5578
+ Object.freeze({ kind: "scan", columns: Object.freeze(scanColumnNames) })
5579
+ ];
5580
+ if (options.predicate) {
5581
+ steps.push(Object.freeze({ kind: "filter", predicate: options.predicate }));
5582
+ }
5583
+ steps.push(Object.freeze({ kind: "project", columns: Object.freeze(outputColumnNames) }));
5584
+ if (options.limit !== void 0) {
5585
+ steps.push(Object.freeze({ kind: "limit", limit: options.limit }));
5586
+ }
5587
+ return Object.freeze(steps);
5588
+ }
5557
5589
  function validateTableQueryOptions(sourceColumnNames, options) {
5558
5590
  const availableColumnNames = new Set(sourceColumnNames);
5559
5591
  const outputColumnNames = options.columns ?? sourceColumnNames;
@@ -5577,6 +5609,11 @@ function validateTableQueryLimit(limit) {
5577
5609
  throw new Error("Table query limit must be a non-negative safe integer.");
5578
5610
  }
5579
5611
  }
5612
+ function validateTableQueryOffset(offset) {
5613
+ if (offset !== void 0 && (!Number.isSafeInteger(offset) || offset < 0)) {
5614
+ throw new Error("Table query offset must be a non-negative safe integer.");
5615
+ }
5616
+ }
5580
5617
  var init_table_query = __esm({
5581
5618
  "../core/src/loader-utils/lib/scan-utils/table-query.ts"() {
5582
5619
  "use strict";
@@ -5584,6 +5621,177 @@ var init_table_query = __esm({
5584
5621
  }
5585
5622
  });
5586
5623
 
5624
+ // ../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts
5625
+ async function* executeTableScanBatches(readBatches, options = {}, operators = {}) {
5626
+ var _a, _b, _c, _d, _e;
5627
+ validateTableQueryLimit(options.limit);
5628
+ validateTableQueryOffset(options.offset);
5629
+ let skip = options.offset ?? 0;
5630
+ const startedAt = Date.now();
5631
+ let sourcesRead = 0;
5632
+ let batchesRead = 0;
5633
+ let rowsRead = 0;
5634
+ let rowsTested = 0;
5635
+ let rowsRetained = 0;
5636
+ let rowsReturned = 0;
5637
+ let bytesFetched = 0;
5638
+ let status = "early-terminated";
5639
+ let earlyTerminationReason;
5640
+ let executionError;
5641
+ let remaining = options.limit === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, options.limit);
5642
+ try {
5643
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
5644
+ if (remaining <= 0) {
5645
+ earlyTerminationReason = "limit";
5646
+ return;
5647
+ }
5648
+ sourcesRead = 1;
5649
+ for await (const batch of readBatches(
5650
+ options.signal,
5651
+ (byteLength) => bytesFetched += byteLength
5652
+ )) {
5653
+ if (remaining <= 0) {
5654
+ earlyTerminationReason = "limit";
5655
+ return;
5656
+ }
5657
+ (_b = options.signal) == null ? void 0 : _b.throwIfAborted();
5658
+ batchesRead++;
5659
+ const rowCount = getScanBatchRowCount(batch);
5660
+ rowsRead += rowCount;
5661
+ if (options.predicate && !operators.filter && !("shape" in batch)) {
5662
+ throw new Error("Native Arrow scans require a filter kernel for residual predicates.");
5663
+ }
5664
+ const filteredBatch = operators.filter ? await operators.filter(batch, options.predicate, options.signal) : "shape" in batch ? filterTableBatch(batch, options.predicate) : batch;
5665
+ (_c = options.signal) == null ? void 0 : _c.throwIfAborted();
5666
+ const filteredRowCount = getScanBatchRowCount(filteredBatch);
5667
+ if (options.predicate) {
5668
+ rowsTested += rowCount;
5669
+ rowsRetained += filteredRowCount;
5670
+ }
5671
+ if (skip >= filteredRowCount && (skip > 0 || options.skipEmptyBatches)) {
5672
+ skip -= filteredRowCount;
5673
+ continue;
5674
+ }
5675
+ const end = Math.min(filteredRowCount, skip + remaining);
5676
+ const window = skip || end < filteredRowCount ? "shape" in filteredBatch ? sliceTableBatch(filteredBatch, skip, end) : filteredBatch.slice(skip, end) : filteredBatch;
5677
+ skip = 0;
5678
+ const output = operators.project ? operators.project(window, options.columns) : projectTableBatch(window, options.columns);
5679
+ remaining -= getScanBatchRowCount(window);
5680
+ rowsReturned += getScanBatchRowCount(output);
5681
+ if (remaining === 0) earlyTerminationReason = "limit";
5682
+ yield output;
5683
+ if (remaining === 0) return;
5684
+ (_d = options.signal) == null ? void 0 : _d.throwIfAborted();
5685
+ }
5686
+ status = "completed";
5687
+ } catch (error) {
5688
+ status = ((_e = options.signal) == null ? void 0 : _e.aborted) ? "cancelled" : "failed";
5689
+ executionError = error;
5690
+ throw error;
5691
+ } finally {
5692
+ if (status === "early-terminated" && !earlyTerminationReason) {
5693
+ earlyTerminationReason = "consumer-return";
5694
+ }
5695
+ emitQueryComplete(
5696
+ options.onQueryComplete,
5697
+ Object.freeze({
5698
+ status,
5699
+ sourcesPlanned: 1,
5700
+ sourcesRead,
5701
+ batchesRead,
5702
+ batchesDecoded: batchesRead,
5703
+ rowsRead,
5704
+ rowsTested: rowsTested || void 0,
5705
+ rowsRetained: rowsRetained || void 0,
5706
+ rowsReturned,
5707
+ bytesRead: bytesFetched,
5708
+ bytesFetched,
5709
+ filesOpened: sourcesRead,
5710
+ tasksOpened: sourcesRead,
5711
+ durationMilliseconds: Date.now() - startedAt,
5712
+ earlyTerminationReason,
5713
+ ...executionError === void 0 ? {} : { error: executionError }
5714
+ })
5715
+ );
5716
+ }
5717
+ }
5718
+ function getScanBatchRowCount(batch) {
5719
+ return "shape" in batch ? batch.length : batch.numRows;
5720
+ }
5721
+ function sliceTableBatch(batch, start, end) {
5722
+ const length = end - start;
5723
+ if (batch.shape === "object-row-table" || batch.shape === "array-row-table") {
5724
+ return { ...batch, data: batch.data.slice(start, end), length };
5725
+ }
5726
+ if (batch.shape === "columnar-table") {
5727
+ return {
5728
+ ...batch,
5729
+ data: Object.fromEntries(
5730
+ Object.entries(batch.data).map(([name, values]) => [
5731
+ name,
5732
+ Array.from(values).slice(start, end)
5733
+ ])
5734
+ ),
5735
+ length
5736
+ };
5737
+ }
5738
+ return { ...batch, features: batch.features.slice(start, end), length };
5739
+ }
5740
+ function projectTableBatch(batch, columns) {
5741
+ if (columns === void 0) return batch;
5742
+ if (!("shape" in batch)) {
5743
+ const indices = columns.map((column) => batch.schema.fields.findIndex((field) => field.name === column)).filter((index) => index >= 0);
5744
+ return batch.selectAt(indices);
5745
+ }
5746
+ const schema = projectTableSchema(batch, columns);
5747
+ if (batch.shape === "object-row-table") {
5748
+ return {
5749
+ ...batch,
5750
+ schema,
5751
+ data: batch.data.map((row) => Object.fromEntries(columns.map((column) => [column, row[column]])))
5752
+ };
5753
+ }
5754
+ if (batch.shape === "columnar-table") {
5755
+ return {
5756
+ ...batch,
5757
+ schema,
5758
+ data: Object.fromEntries(columns.map((column) => [column, batch.data[column]]))
5759
+ };
5760
+ }
5761
+ return batch;
5762
+ }
5763
+ function projectTableSchema(batch, columns) {
5764
+ if (!batch.schema) return void 0;
5765
+ const fieldsByName = new Map(batch.schema.fields.map((field) => [field.name, field]));
5766
+ return {
5767
+ ...batch.schema,
5768
+ fields: columns.flatMap((column) => {
5769
+ const field = fieldsByName.get(column);
5770
+ return field ? [field] : [];
5771
+ })
5772
+ };
5773
+ }
5774
+ function filterTableBatch(batch, predicate) {
5775
+ var _a;
5776
+ if (!predicate || batch.shape !== "object-row-table") return batch;
5777
+ const rows = batch.data;
5778
+ const columnNames = new Set(((_a = batch.schema) == null ? void 0 : _a.fields.map((field) => field.name)) || []);
5779
+ validateColumnarPredicate(predicate, columnNames);
5780
+ const columns = Object.fromEntries(
5781
+ [...columnNames].map((name) => [name, rows.map((row) => row[name])])
5782
+ );
5783
+ const rowIndices = filterColumnarRowIndices(predicate, columns, rows.length);
5784
+ return { ...batch, data: rowIndices.map((rowIndex) => rows[rowIndex]), length: rowIndices.length };
5785
+ }
5786
+ var init_table_scan_batch = __esm({
5787
+ "../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts"() {
5788
+ "use strict";
5789
+ init_scan_query_metadata();
5790
+ init_columnar_predicate();
5791
+ init_table_query();
5792
+ }
5793
+ });
5794
+
5587
5795
  // ../core/src/loader-utils/lib/scan-utils/point-cloud-query.ts
5588
5796
  function validatePointCloudQueryOptions(sourceColumnNames, options) {
5589
5797
  validateTableQueryOptions(sourceColumnNames, options);
@@ -5661,6 +5869,37 @@ var init_point_cloud_query = __esm({
5661
5869
  }
5662
5870
  });
5663
5871
 
5872
+ // ../core/src/loader-utils/lib/scan-utils/table-query-explain.ts
5873
+ function explainTableQuery(sourceColumnNames, options, capabilities) {
5874
+ const plan = planTableQuery(sourceColumnNames, options);
5875
+ const outputColumns = options.columns ? [...options.columns] : [...sourceColumnNames];
5876
+ const predicateColumns = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
5877
+ const requiredColumns = [...plan[0].kind === "scan" ? plan[0].columns : []];
5878
+ return Object.freeze({
5879
+ sourceColumns: Object.freeze([...sourceColumnNames]),
5880
+ outputColumns: Object.freeze(outputColumns),
5881
+ requiredColumns: Object.freeze(requiredColumns),
5882
+ predicateColumns: Object.freeze(predicateColumns),
5883
+ plan,
5884
+ capabilities: Object.freeze({ ...capabilities }),
5885
+ operators: Object.freeze({
5886
+ projection: createOperatorExplanation(options.columns !== void 0, capabilities.projection),
5887
+ predicate: createOperatorExplanation(options.predicate !== void 0, capabilities.predicate),
5888
+ limit: createOperatorExplanation(options.limit !== void 0, capabilities.limit)
5889
+ })
5890
+ });
5891
+ }
5892
+ function createOperatorExplanation(enabled, support) {
5893
+ return Object.freeze({ enabled, support });
5894
+ }
5895
+ var init_table_query_explain = __esm({
5896
+ "../core/src/loader-utils/lib/scan-utils/table-query-explain.ts"() {
5897
+ "use strict";
5898
+ init_columnar_predicate();
5899
+ init_table_query();
5900
+ }
5901
+ });
5902
+
5664
5903
  // ../core/src/loader-utils/lib/files/read-range-response.ts
5665
5904
  async function readRangeResponse(response, offset, length, signal) {
5666
5905
  var _a, _b, _c;
@@ -5778,8 +6017,10 @@ var init_loader_utils = __esm({
5778
6017
  init_file_aliases();
5779
6018
  init_data_source();
5780
6019
  init_columnar_predicate();
6020
+ init_table_scan_batch();
5781
6021
  init_scan_query_metadata();
5782
6022
  init_point_cloud_query();
6023
+ init_table_query_explain();
5783
6024
  init_read_range_response();
5784
6025
  init_pace_batch_iterator();
5785
6026
  }
@@ -6318,7 +6559,7 @@ var init_convert_arrow_schema = __esm({
6318
6559
  });
6319
6560
 
6320
6561
  // ../core/src/lib/loader-utils/native-arrow.ts
6321
- function isNativeArrowTable(value) {
6562
+ function isArrowTable(value) {
6322
6563
  return Boolean(
6323
6564
  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"
6324
6565
  );
@@ -6333,23 +6574,31 @@ var init_native_arrow = __esm({
6333
6574
  function snapshotArrowSchema(schema) {
6334
6575
  return deserializeArrowSchema(serializeArrowSchema(schema));
6335
6576
  }
6577
+ function snapshotArrowBatch(batch, schema) {
6578
+ const snapshot = new arrow2.RecordBatch(
6579
+ snapshotArrowSchema(schema),
6580
+ batch.data,
6581
+ new Map(batch.metadata)
6582
+ );
6583
+ if (snapshot.numRows !== batch.numRows) {
6584
+ Object.defineProperty(snapshot, "data", { value: batch.data });
6585
+ }
6586
+ return snapshot;
6587
+ }
6336
6588
  function updateArrowTableSchema(table, schema) {
6337
6589
  const snapshot = snapshotArrowSchema(schema);
6338
- const batches = table.batches.map(
6339
- (batch) => new arrow2.RecordBatch(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
6340
- );
6590
+ const batches = table.batches.map((batch) => snapshotArrowBatch(batch, snapshot));
6341
6591
  return new arrow2.Table(
6342
6592
  snapshot,
6343
6593
  batches.length ? batches : [new arrow2.RecordBatch(snapshotArrowSchema(snapshot), void 0)]
6344
6594
  );
6345
6595
  }
6346
- function updateArrowTableMetadata(table, metadata) {
6596
+ function updateNativeArrowTableMetadata(table, metadata) {
6347
6597
  const schema = new arrow2.Schema(
6348
- table.data.schema.fields,
6349
- new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
6598
+ table.schema.fields,
6599
+ new Map([...table.schema.metadata, ...Object.entries(metadata)])
6350
6600
  );
6351
- const data = updateArrowTableSchema(table.data, schema);
6352
- return { ...table, data, schema: serializeArrowSchema(data.schema) };
6601
+ return updateArrowTableSchema(table, schema);
6353
6602
  }
6354
6603
  function makeArrowMetadataBatch(schema) {
6355
6604
  return new arrow2.RecordBatch(snapshotArrowSchema(schema), void 0);
@@ -6642,7 +6891,7 @@ var init_arrow_fixed_size_list_utils = __esm({
6642
6891
  });
6643
6892
 
6644
6893
  // ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
6645
- function convertMeshToArrowTableWrapper(mesh, batchSize) {
6894
+ function convertMeshToArrowTable(mesh) {
6646
6895
  var _a;
6647
6896
  return makeMeshArrowTable(mesh.attributes, {
6648
6897
  schema: mesh.schema,
@@ -6665,22 +6914,14 @@ function makeMeshArrowTable(attributes, options = {}) {
6665
6914
  fields.push(
6666
6915
  getAttributeArrowField(options.schema, attributeName, column, attribute.componentType)
6667
6916
  );
6668
- if (attributeName === "POSITION" && ((_b = (_a = options.indices) == null ? void 0 : _a.value) == null ? void 0 : _b.length)) {
6917
+ if (attributeName === attributeNames[0] && ((_b = (_a = options.indices) == null ? void 0 : _a.value) == null ? void 0 : _b.length)) {
6669
6918
  const indicesField = indexedMeshArrowSchema.fields.find((field) => field.name === "indices");
6670
6919
  columns.indices = getIndicesVector(options.indices.value, column.length, indicesField.type);
6671
6920
  fields.push(indicesField);
6672
6921
  }
6673
6922
  }
6674
6923
  const arrowSchema = new arrow6.Schema(fields, getMeshArrowMetadata(options));
6675
- const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow6.Table(arrowSchema) : new arrow6.Table(arrowSchema, columns);
6676
- const schema = serializeArrowSchema(table.schema);
6677
- return {
6678
- shape: "arrow-table",
6679
- schema,
6680
- data: table,
6681
- topology: options.topology || "point-list",
6682
- indices: options.indices
6683
- };
6924
+ return ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow6.Table(arrowSchema) : new arrow6.Table(arrowSchema, columns);
6684
6925
  }
6685
6926
  function getAttributeArrowVector(value, size, componentType) {
6686
6927
  if (componentType === "float16") {
@@ -6807,19 +7048,11 @@ var init_convert_mesh_to_table = __esm({
6807
7048
 
6808
7049
  // ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
6809
7050
  function convertTableToMesh(table) {
6810
- if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
6811
- switch (table.shape) {
6812
- // case 'columnar-table':
6813
- // return convertColumnarTableToMesh(table);
6814
- case "arrow-table":
6815
- return convertArrowTableToMesh(table);
6816
- default:
6817
- throw new Error(table.shape);
6818
- }
7051
+ if (isArrowTable(table)) return convertArrowTableToMesh(table);
7052
+ throw new Error(table.shape);
6819
7053
  }
6820
- function convertArrowTableToMesh(table) {
7054
+ function convertArrowTableToMesh(arrowTable) {
6821
7055
  var _a, _b;
6822
- const arrowTable = isNativeArrowTable(table) ? table : table.data;
6823
7056
  const schema = serializeArrowSchema(arrowTable.schema);
6824
7057
  const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
6825
7058
  if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
@@ -6924,13 +7157,18 @@ function getAttributeTypedArray(attributeData, size) {
6924
7157
  if (!(attributeData.type instanceof arrow7.FixedSizeList)) {
6925
7158
  return attributeData.toArray();
6926
7159
  }
6927
- const values = attributeData.data[0].children[0].values;
7160
+ if (attributeData.length === 0) {
7161
+ const EmptyStorage = attributeData.type.valueType.ArrayType;
7162
+ return new EmptyStorage(0);
7163
+ }
7164
+ const values = attributeData.data.find((chunk) => chunk.length > 0).children[0].values;
6928
7165
  const TypedArrayConstructor = values.constructor;
6929
7166
  const typedArray = new TypedArrayConstructor(attributeData.length * size);
6930
7167
  let targetOffset = 0;
6931
7168
  for (const data of attributeData.data) {
6932
- const child = data.children[0];
6933
7169
  const sourceLength = data.length * size;
7170
+ if (sourceLength === 0) continue;
7171
+ const child = data.children[0];
6934
7172
  const sourceOffset = child.offset || data.offset * size;
6935
7173
  const sourceStart = sourceOffset + sourceLength <= child.values.length ? sourceOffset : 0;
6936
7174
  const source = child.values.subarray(sourceStart, sourceStart + sourceLength);
@@ -7039,11 +7277,13 @@ var init_deduce_mesh_schema = __esm({
7039
7277
  var init_schema_utils = __esm({
7040
7278
  "../core/src/schema-utils/index.ts"() {
7041
7279
  "use strict";
7280
+ init_convert_arrow_schema();
7042
7281
  init_convert_mesh_to_table();
7043
7282
  init_convert_table_to_mesh();
7044
7283
  init_deduce_mesh_schema();
7045
7284
  init_arrow_table_builder();
7046
7285
  init_arrow_metadata();
7286
+ init_native_arrow();
7047
7287
  }
7048
7288
  });
7049
7289
 
@@ -7242,7 +7482,7 @@ function formatLASMeshColors(mesh, colorFormat) {
7242
7482
  }
7243
7483
  return { ...mesh, attributes };
7244
7484
  }
7245
- var VERSION3, DEFAULT_LAS_SHAPE, LAS_LOADER_METADATA;
7485
+ var VERSION3, DEFAULT_LAS_SHAPE, LAS_LOADER_METADATA, LAS_SOURCE_METADATA;
7246
7486
  var init_las_loader_shared = __esm({
7247
7487
  "../pointclouds/src/las/las-loader-shared.ts"() {
7248
7488
  "use strict";
@@ -7271,95 +7511,499 @@ var init_las_loader_shared = __esm({
7271
7511
  }
7272
7512
  }
7273
7513
  };
7514
+ LAS_SOURCE_METADATA = {
7515
+ type: "las-source",
7516
+ fromUrl: true,
7517
+ fromBlob: true,
7518
+ testURL: (url) => /\.(?:las|laz)(?:$|[?#])/i.test(url)
7519
+ };
7520
+ }
7521
+ });
7522
+
7523
+ // ../core/src/scan/arrow-execution/project-arrow-table.ts
7524
+ function projectArrowTable(source, selections) {
7525
+ const outputNames = /* @__PURE__ */ new Set();
7526
+ const indices = [];
7527
+ const fields = selections.map((selection) => {
7528
+ const column = typeof selection === "string" ? selection : selection.column;
7529
+ const name = typeof selection === "string" ? selection : selection.as === void 0 ? column : selection.as;
7530
+ const index = source.schema.fields.findIndex((field) => field.name === column);
7531
+ if (index < 0) throw new Error(`Arrow projection column not found: ${column}`);
7532
+ if (typeof name !== "string" || typeof selection !== "string" && selection.as !== void 0 && !name.length || outputNames.has(name)) {
7533
+ throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);
7534
+ }
7535
+ outputNames.add(name);
7536
+ indices.push(index);
7537
+ return source.schema.fields[index].clone({ name });
7538
+ });
7539
+ const schema = new arrow8.Schema(fields, source.schema.metadata);
7540
+ const batches = source.batches.map(
7541
+ (batch) => new arrow8.RecordBatch(
7542
+ schema,
7543
+ arrow8.makeData({
7544
+ type: new arrow8.Struct(fields),
7545
+ length: batch.numRows,
7546
+ children: indices.map((index) => batch.data.children[index])
7547
+ }),
7548
+ batch.metadata
7549
+ )
7550
+ );
7551
+ return new arrow8.Table(schema, batches);
7552
+ }
7553
+ var arrow8;
7554
+ var init_project_arrow_table = __esm({
7555
+ "../core/src/scan/arrow-execution/project-arrow-table.ts"() {
7556
+ "use strict";
7557
+ arrow8 = __toESM(require("apache-arrow"), 1);
7558
+ }
7559
+ });
7560
+
7561
+ // ../core/src/scan/arrow-execution/filter-arrow-table.ts
7562
+ function filterArrowTable(source, predicate, options = {}) {
7563
+ validateColumnarPredicate(predicate, new Set(source.schema.fields.map((field) => field.name)));
7564
+ const columnNames = getColumnarPredicateColumns(predicate);
7565
+ return filterArrowRows(
7566
+ source,
7567
+ (batch) => {
7568
+ const columns = getPredicateColumns(new arrow9.Table(source.schema, [batch]), columnNames);
7569
+ return (rowIndex) => evaluatePredicate(predicate, columns, rowIndex) === true;
7570
+ },
7571
+ options
7572
+ );
7573
+ }
7574
+ function filterArrowRows(source, selectBatch, options = {}) {
7575
+ var _a, _b, _c;
7576
+ let remaining = options.limit ?? Infinity;
7577
+ if (remaining !== Infinity && (!Number.isSafeInteger(remaining) || remaining < 0)) {
7578
+ throw new Error("Arrow filter limit must be a non-negative safe integer.");
7579
+ }
7580
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
7581
+ const batches = [];
7582
+ for (const batch of source.batches) {
7583
+ if (remaining === 0) break;
7584
+ (_b = options.signal) == null ? void 0 : _b.throwIfAborted();
7585
+ const data = new arrow9.Table(source.schema, [batch]);
7586
+ const selectRow = selectBatch(batch);
7587
+ const indices = [];
7588
+ for (let rowIndex = 0; rowIndex < batch.numRows && indices.length < remaining; rowIndex++) {
7589
+ (_c = options.signal) == null ? void 0 : _c.throwIfAborted();
7590
+ if (selectRow(rowIndex)) indices.push(rowIndex);
7591
+ }
7592
+ remaining -= indices.length;
7593
+ if (indices.length === 0) continue;
7594
+ if (indices.length === batch.numRows) {
7595
+ batches.push(batch);
7596
+ continue;
7597
+ }
7598
+ if (indices[indices.length - 1] - indices[0] + 1 === indices.length) {
7599
+ batches.push(batch.slice(indices[0], indices[indices.length - 1] + 1));
7600
+ continue;
7601
+ }
7602
+ const gathered = (0, import_arrow.takeArrowTableRows)(data, Int32Array.from(indices));
7603
+ batches.push(
7604
+ ...gathered.batches.map(
7605
+ (output) => new arrow9.RecordBatch(source.schema, output.data, batch.metadata)
7606
+ )
7607
+ );
7608
+ }
7609
+ return new arrow9.Table(source.schema, batches);
7610
+ }
7611
+ function getPredicateColumns(sourceTable, columnNames) {
7612
+ const columns = {};
7613
+ for (const columnName of columnNames) {
7614
+ const column = sourceTable.getChild(columnName);
7615
+ if (!column) {
7616
+ throw new Error(`Arrow query column not found: ${columnName}`);
7617
+ }
7618
+ columns[columnName] = column;
7619
+ }
7620
+ return columns;
7621
+ }
7622
+ function evaluatePredicate(predicate, columns, rowIndex) {
7623
+ if (isLogicalPredicate(predicate)) {
7624
+ const values = predicate.args.map((child) => evaluatePredicate(child, columns, rowIndex));
7625
+ return predicate.op === "and" ? evaluateAnd(values) : evaluateOr(values);
7626
+ }
7627
+ if (isNotPredicate(predicate)) {
7628
+ const value2 = evaluatePredicate(predicate.args[0], columns, rowIndex);
7629
+ return value2 === null ? null : !value2;
7630
+ }
7631
+ const value = getColumnValue(columns, predicate.args[0].property, rowIndex);
7632
+ if (isNullPredicate(predicate)) {
7633
+ return value === null || value === void 0;
7634
+ }
7635
+ if (isInPredicate(predicate)) {
7636
+ return evaluateIn(value, predicate.args[1]);
7637
+ }
7638
+ return evaluateComparison(value, predicate);
7639
+ }
7640
+ function getColumnValue(columns, columnName, rowIndex) {
7641
+ const path = typeof columnName === "string" ? [columnName] : columnName;
7642
+ const column = columns[path[0]];
7643
+ if (!column) {
7644
+ throw new Error(`Arrow query could not read predicate column "${columnName}".`);
7645
+ }
7646
+ let value = column.get(rowIndex);
7647
+ for (const property of path.slice(1)) {
7648
+ if (value === null || value === void 0) return null;
7649
+ value = value[property];
7650
+ }
7651
+ return value;
7652
+ }
7653
+ function evaluateAnd(values) {
7654
+ if (values.includes(false)) {
7655
+ return false;
7656
+ }
7657
+ return values.includes(null) ? null : true;
7658
+ }
7659
+ function evaluateOr(values) {
7660
+ if (values.includes(true)) {
7661
+ return true;
7662
+ }
7663
+ return values.includes(null) ? null : false;
7664
+ }
7665
+ function evaluateIn(value, candidates) {
7666
+ if (value === null || value === void 0) {
7667
+ return null;
7668
+ }
7669
+ for (const candidate of candidates) {
7670
+ if (compareValues(value, candidate) === 0) {
7671
+ return true;
7672
+ }
7673
+ }
7674
+ return false;
7675
+ }
7676
+ function evaluateComparison(value, predicate) {
7677
+ if (value === null || value === void 0) {
7678
+ return null;
7679
+ }
7680
+ const comparison = compareValues(value, predicate.args[1]);
7681
+ switch (predicate.op) {
7682
+ case "=":
7683
+ return comparison === 0;
7684
+ case "<>":
7685
+ return comparison !== 0;
7686
+ case "<":
7687
+ return comparison < 0;
7688
+ case "<=":
7689
+ return comparison <= 0;
7690
+ case ">":
7691
+ return comparison > 0;
7692
+ case ">=":
7693
+ return comparison >= 0;
7694
+ }
7695
+ }
7696
+ function compareValues(left, right) {
7697
+ if (isColumnarPredicateParameter(right)) {
7698
+ throw new Error(
7699
+ `Arrow query parameter ":${right.parameter}" must be bound before query execution.`
7700
+ );
7701
+ }
7702
+ if (left instanceof Date && right instanceof Date) {
7703
+ return compareArrowQueryNumbers(left.getTime(), right.getTime());
7704
+ }
7705
+ if (typeof left === "number" && right instanceof Date) {
7706
+ return compareArrowQueryNumbers(left, right.getTime());
7707
+ }
7708
+ if (left instanceof Uint8Array && right instanceof Uint8Array) {
7709
+ return compareBinary(left, right);
7710
+ }
7711
+ if (typeof left === "bigint" && typeof right === "bigint") {
7712
+ return left === right ? 0 : left < right ? -1 : 1;
7713
+ }
7714
+ if (typeof left === "bigint" && typeof right === "number" || typeof left === "number" && typeof right === "bigint") {
7715
+ const numericValue = typeof left === "number" ? left : right;
7716
+ if (!Number.isFinite(numericValue))
7717
+ throw new Error("Arrow query cannot compare non-finite numbers.");
7718
+ return left < right ? -1 : left > right ? 1 : 0;
7719
+ }
7720
+ if (typeof left === "number" && typeof right === "number") {
7721
+ return compareArrowQueryNumbers(left, right);
7722
+ }
7723
+ if (typeof left === "string" && typeof right === "string") {
7724
+ return left === right ? 0 : left < right ? -1 : 1;
7725
+ }
7726
+ if (typeof left === "boolean" && typeof right === "boolean") {
7727
+ return Number(left) - Number(right);
7728
+ }
7729
+ throw new Error(
7730
+ `Arrow query cannot compare ${getArrowQueryValueType(left)} with ${getArrowQueryValueType(right)} values.`
7731
+ );
7732
+ }
7733
+ function compareArrowQueryNumbers(left, right) {
7734
+ if (!Number.isFinite(left) || !Number.isFinite(right)) {
7735
+ throw new Error("Arrow query cannot compare non-finite numbers.");
7736
+ }
7737
+ return left === right ? 0 : left < right ? -1 : 1;
7738
+ }
7739
+ function compareBinary(left, right) {
7740
+ const commonLength = Math.min(left.length, right.length);
7741
+ for (let index = 0; index < commonLength; index++) {
7742
+ if (left[index] !== right[index]) {
7743
+ return left[index] < right[index] ? -1 : 1;
7744
+ }
7745
+ }
7746
+ return left.length === right.length ? 0 : left.length < right.length ? -1 : 1;
7747
+ }
7748
+ function getArrowQueryValueType(value) {
7749
+ if (value instanceof Date) {
7750
+ return "Date";
7751
+ }
7752
+ if (value instanceof Uint8Array) {
7753
+ return "Uint8Array";
7754
+ }
7755
+ return typeof value;
7756
+ }
7757
+ function isLogicalPredicate(predicate) {
7758
+ return predicate.op === "and" || predicate.op === "or";
7759
+ }
7760
+ function isNotPredicate(predicate) {
7761
+ return predicate.op === "not";
7762
+ }
7763
+ function isNullPredicate(predicate) {
7764
+ return predicate.op === "isNull";
7765
+ }
7766
+ function isInPredicate(predicate) {
7767
+ return predicate.op === "in";
7768
+ }
7769
+ var arrow9, import_arrow;
7770
+ var init_filter_arrow_table = __esm({
7771
+ "../core/src/scan/arrow-execution/filter-arrow-table.ts"() {
7772
+ "use strict";
7773
+ arrow9 = __toESM(require("apache-arrow"), 1);
7774
+ import_arrow = require("@math.gl/arrow");
7775
+ init_loader_utils();
7776
+ }
7777
+ });
7778
+
7779
+ // ../core/src/scan/arrow-execution.ts
7780
+ var arrow_execution_exports = {};
7781
+ __export(arrow_execution_exports, {
7782
+ filterArrowTable: () => filterArrowTable,
7783
+ projectArrowTable: () => projectArrowTable
7784
+ });
7785
+ var init_arrow_execution = __esm({
7786
+ "../core/src/scan/arrow-execution.ts"() {
7787
+ "use strict";
7788
+ init_project_arrow_table();
7789
+ init_filter_arrow_table();
7790
+ }
7791
+ });
7792
+
7793
+ // ../pointclouds/src/las/las-source.ts
7794
+ var import_apache_arrow, LAS_QUERY_CAPABILITIES, LASSource;
7795
+ var init_las_source = __esm({
7796
+ "../pointclouds/src/las/las-source.ts"() {
7797
+ "use strict";
7798
+ import_apache_arrow = require("apache-arrow");
7799
+ init_loader_utils();
7800
+ init_schema_utils();
7801
+ init_las_loader();
7802
+ LAS_QUERY_CAPABILITIES = Object.freeze({
7803
+ predicate: "residual",
7804
+ projection: "pushdown+residual",
7805
+ limit: "pushdown",
7806
+ offset: "pushdown",
7807
+ cast: "unsupported",
7808
+ streaming: true,
7809
+ cancellation: true
7810
+ });
7811
+ LASSource = class extends DataSource {
7812
+ /** Creates a source without fetching or decoding point data. */
7813
+ constructor(data, options = {}, coreApi) {
7814
+ super(data, options, void 0, coreApi);
7815
+ }
7816
+ /** Discovers fields from the header and variable-length records without decoding points. */
7817
+ async getQueryMetadata(options = {}) {
7818
+ const chunks = [];
7819
+ let length = 0;
7820
+ let required = 227;
7821
+ for await (const chunk of this.readBytes(options.signal)) {
7822
+ chunks.push(chunk);
7823
+ length += chunk.byteLength;
7824
+ if (length < required) continue;
7825
+ const bytes = new Uint8Array(length);
7826
+ let offset = 0;
7827
+ for (const part of chunks) {
7828
+ bytes.set(part, offset);
7829
+ offset += part.byteLength;
7830
+ }
7831
+ const view = new DataView(bytes.buffer);
7832
+ if (view.getUint32(0, true) !== 1179861324) throw new Error("Invalid LAS header");
7833
+ required = Math.max(227, view.getUint16(94, true), view.getUint32(96, true));
7834
+ if (length < required) continue;
7835
+ const table = parseLASMetadata(bytes.buffer.slice(0, required), this.loadOptions);
7836
+ return createScanQueryMetadata({
7837
+ sourceType: "las",
7838
+ name: this.name,
7839
+ queryType: "table",
7840
+ execution: { status: "supported", method: "read" },
7841
+ schema: convertArrowToSchema(table.schema),
7842
+ capabilities: { table: LAS_QUERY_CAPABILITIES }
7843
+ });
7844
+ }
7845
+ throw new Error("Truncated LAS header");
7846
+ }
7847
+ /** Explains projection and row-window pushdown separately from residual filtering. */
7848
+ async explain(options = {}) {
7849
+ const metadata = await this.getQueryMetadata(options);
7850
+ return explainTableQuery(
7851
+ metadata.columns.map((column) => column.name),
7852
+ options,
7853
+ LAS_QUERY_CAPABILITIES
7854
+ );
7855
+ }
7856
+ /** Decodes selected columns and applies predicates before the global offset and limit. */
7857
+ async *read(options = {}) {
7858
+ const columns = options.columns === void 0 ? void 0 : [
7859
+ .../* @__PURE__ */ new Set([
7860
+ ...options.columns,
7861
+ ...options.predicate ? getColumnarPredicateColumns(options.predicate) : []
7862
+ ])
7863
+ ];
7864
+ for await (const table of executeTableScanBatches(
7865
+ (signal, onByteLength) => this.parseBatches(columns, signal, onByteLength),
7866
+ options,
7867
+ {
7868
+ async filter(batch, predicate, signal) {
7869
+ if (!predicate) return batch;
7870
+ const { filterArrowTable: filterArrowTable2 } = await Promise.resolve().then(() => (init_arrow_execution(), arrow_execution_exports));
7871
+ return filterArrowTable2(batch, predicate, { signal });
7872
+ }
7873
+ }
7874
+ )) {
7875
+ if (table.batches.length) yield* table.batches;
7876
+ else yield makeArrowMetadataBatch(table.schema);
7877
+ }
7878
+ }
7879
+ /** Pushes selected source fields into the decoder before allocating Arrow columns. */
7880
+ async *parseBatches(columns, signal, onByteLength) {
7881
+ const options = {
7882
+ ...this.loadOptions,
7883
+ signal,
7884
+ las: {
7885
+ ...this.options.las,
7886
+ shape: "arrow",
7887
+ ...columns && {
7888
+ columns: [
7889
+ ...new Set(
7890
+ columns.map(
7891
+ (column) => {
7892
+ var _a;
7893
+ return ((_a = this.options.las) == null ? void 0 : _a.extraBytes) === "typed" && column.startsWith("EXTRA_BYTES_") ? "EXTRA_BYTES" : column;
7894
+ }
7895
+ )
7896
+ )
7897
+ ]
7898
+ }
7899
+ }
7900
+ };
7901
+ const chunks = this.readBytes(signal, onByteLength);
7902
+ try {
7903
+ for await (const batch of LASLoaderWithParser.parseInBatches(chunks, options)) {
7904
+ if ("attributes" in batch) throw new Error("Expected Arrow LAS output");
7905
+ yield new import_apache_arrow.Table(batch.schema, [batch]);
7906
+ }
7907
+ } finally {
7908
+ await chunks.return();
7909
+ }
7910
+ }
7911
+ /** Reads with cancellation and closes the stream when a limit stops decoding early. */
7912
+ async *readBytes(signal, onByteLength) {
7913
+ signal == null ? void 0 : signal.throwIfAborted();
7914
+ const input = this.data instanceof Blob ? this.data : await this.fetch(this.url, { signal });
7915
+ if (input instanceof Response && !input.ok)
7916
+ throw new Error(`LAS request failed: ${input.status}`);
7917
+ const stream = input instanceof Blob ? input.stream() : input.body;
7918
+ if (!stream) {
7919
+ const bytes = new Uint8Array(await input.arrayBuffer());
7920
+ signal == null ? void 0 : signal.throwIfAborted();
7921
+ onByteLength == null ? void 0 : onByteLength(bytes.byteLength);
7922
+ yield bytes;
7923
+ return;
7924
+ }
7925
+ const reader = stream.getReader();
7926
+ const abort = () => {
7927
+ void reader.cancel().catch(() => {
7928
+ });
7929
+ };
7930
+ signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
7931
+ try {
7932
+ while (true) {
7933
+ signal == null ? void 0 : signal.throwIfAborted();
7934
+ const { done, value } = await reader.read();
7935
+ signal == null ? void 0 : signal.throwIfAborted();
7936
+ if (done) return;
7937
+ onByteLength == null ? void 0 : onByteLength(value.byteLength);
7938
+ yield value;
7939
+ }
7940
+ } finally {
7941
+ signal == null ? void 0 : signal.removeEventListener("abort", abort);
7942
+ await reader.cancel();
7943
+ reader.releaseLock();
7944
+ }
7945
+ }
7946
+ };
7274
7947
  }
7275
7948
  });
7276
7949
 
7277
7950
  // ../core/src/arrow-worker-transport.ts
7278
- function serializeArrowWorkerTable(result) {
7279
- if (!isArrowTableWrapper(result)) {
7951
+ function serializeNativeArrowWorkerResult(result, options = { copy: "all" }) {
7952
+ const batch = result instanceof arrow10.RecordBatch;
7953
+ if (!batch && !(result instanceof arrow10.Table)) {
7280
7954
  throw new Error("Workers require Arrow table output");
7281
7955
  }
7282
- const { data, shape: _shape, ...metadata } = result;
7283
7956
  return {
7284
- transport: "arrow-column-envelope",
7285
- metadata: structuredClone(metadata),
7286
- ...serializeWorkerColumns(data, { copy: "all" })
7957
+ transport: batch ? "arrow-record-batch" : "arrow-table-columns",
7958
+ columns: batch ? { data: (0, import_arrow2.dehydrateArrowRecordBatch)(result, options) } : serializeWorkerColumns(result, options)
7287
7959
  };
7288
7960
  }
7289
- function deserializeArrowWorkerTable(result) {
7290
- if (isArrowWorkerEnvelope(result)) {
7291
- return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
7961
+ function deserializeNativeArrowWorkerResult(result) {
7962
+ const payload = result;
7963
+ if ((payload == null ? void 0 : payload.transport) !== "arrow-table-columns" && (payload == null ? void 0 : payload.transport) !== "arrow-record-batch" || !hasArrowWorkerColumns(payload.columns)) {
7964
+ throw new Error("Workers require Arrow column transport");
7292
7965
  }
7293
- if (isLegacyArrowWorkerEnvelope(result)) {
7294
- const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
7295
- return { ...metadata, data: hydrateWorkerTable(result) };
7966
+ if (payload.transport === "arrow-record-batch" && !payload.columns.arrowBatchMetadata) {
7967
+ return (0, import_arrow2.hydrateArrowRecordBatch)(payload.columns.data);
7296
7968
  }
7297
- throw new Error("Workers require Arrow column transport");
7298
- }
7299
- function isArrowTableWrapper(value) {
7300
- const table = value;
7301
- return Boolean(
7302
- table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
7303
- );
7969
+ const data = hydrateWorkerTable(payload.columns);
7970
+ return payload.transport === "arrow-record-batch" ? data.batches[0] : data;
7304
7971
  }
7305
7972
  function hasArrowWorkerColumns(value) {
7306
7973
  var _a;
7307
7974
  const columns = value;
7308
7975
  return ((_a = columns == null ? void 0 : columns.data) == null ? void 0 : _a.transport) === "arrow-js" && Array.isArray(columns.data.batches);
7309
7976
  }
7310
- function isArrowWorkerEnvelope(value) {
7311
- return (value == null ? void 0 : value.transport) === "arrow-column-envelope" && hasArrowWorkerColumns(value);
7312
- }
7313
- function isLegacyArrowWorkerEnvelope(value) {
7314
- return (value == null ? void 0 : value.shape) === "arrow-table" && hasArrowWorkerColumns(value);
7315
- }
7316
7977
  function serializeWorkerColumns(table, options) {
7317
7978
  return {
7318
7979
  arrowBatchMetadata: snapshotBatchMetadata(table),
7319
- data: dehydrateWorkerTable(table, options)
7980
+ data: (0, import_arrow2.dehydrateArrowTable)(table, options)
7320
7981
  };
7321
7982
  }
7322
- function dehydrateWorkerTable(table, options) {
7323
- const payload = (0, import_arrow.dehydrateArrowTable)(table, options);
7324
- if (table.numCols === 0) {
7325
- for (const [index, batch] of table.batches.entries()) {
7326
- payload.batches[index].length = batch.numRows;
7327
- }
7328
- }
7329
- return payload;
7330
- }
7331
7983
  function snapshotBatchMetadata(table) {
7332
7984
  return table.batches.map((batch) => ({
7333
- schema: arrow8.tableToIPC(new arrow8.Table(batch.schema, [])),
7334
- metadata: Array.from(batch.metadata)
7985
+ schema: arrow10.tableToIPC(new arrow10.Table(batch.schema, []))
7335
7986
  }));
7336
7987
  }
7337
7988
  function hydrateWorkerTable(result) {
7338
7989
  const { arrowBatchMetadata, data } = result;
7339
- const table = (0, import_arrow.hydrateArrowTable)(data);
7990
+ const table = (0, import_arrow2.hydrateArrowTable)(data);
7340
7991
  const batches = table.batches.map((batch, index) => {
7341
7992
  const snapshot = arrowBatchMetadata == null ? void 0 : arrowBatchMetadata[index];
7342
- const restored = snapshot ? new arrow8.RecordBatch(
7343
- arrow8.tableFromIPC(snapshot.schema).schema,
7993
+ return snapshot ? (0, import_arrow2.createRecordBatchWithMetadata)(
7994
+ arrow10.tableFromIPC(snapshot.schema).schema,
7344
7995
  batch.data,
7345
- new Map(snapshot.metadata)
7996
+ snapshot.metadata ? new Map(snapshot.metadata) : (0, import_arrow2.getRecordBatchMetadata)(batch)
7346
7997
  ) : batch;
7347
- const rowCount = data.batches[index].length;
7348
- if (restored.numCols === 0 && restored.numRows !== rowCount) {
7349
- Object.defineProperty(restored, "data", {
7350
- value: new arrow8.Data(new arrow8.Struct([]), 0, rowCount, 0, void 0, [])
7351
- });
7352
- }
7353
- return restored;
7354
7998
  });
7355
- return new arrow8.Table(table.schema, batches);
7999
+ return new arrow10.Table(table.schema, batches);
7356
8000
  }
7357
- var arrow8, import_arrow;
8001
+ var arrow10, import_arrow2;
7358
8002
  var init_arrow_worker_transport = __esm({
7359
8003
  "../core/src/arrow-worker-transport.ts"() {
7360
8004
  "use strict";
7361
- arrow8 = __toESM(require("apache-arrow"), 1);
7362
- import_arrow = require("@math.gl/arrow");
8005
+ arrow10 = __toESM(require("apache-arrow"), 1);
8006
+ import_arrow2 = require("@math.gl/arrow");
7363
8007
  }
7364
8008
  });
7365
8009
 
@@ -7697,7 +8341,7 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
7697
8341
  lastTable = makeEmptyLASBatch(header, options);
7698
8342
  } else {
7699
8343
  for await (const table of parseLAZInBatches(pending, trackedIterator, header, options)) {
7700
- lastTable = updateArrowTableMetadata(
8344
+ lastTable = updateLASArrowMetadata(
7701
8345
  table,
7702
8346
  makeMetadataFromLasHeader({
7703
8347
  ...header,
@@ -7742,7 +8386,7 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
7742
8386
  totalRead = batch.totalRead;
7743
8387
  pending = batch.pending;
7744
8388
  absoluteOffset = batch.absoluteOffset;
7745
- lastTable = updateArrowTableMetadata(
8389
+ lastTable = updateLASArrowMetadata(
7746
8390
  parseLASArrowTableBatch(batch.arrayBuffer, batch.header, options),
7747
8391
  makeMetadataFromLasHeader({ ...header, totalRead })
7748
8392
  );
@@ -7763,11 +8407,12 @@ async function* parseLASInBatches(arrayBufferIterator, options = {}) {
7763
8407
  if (update) yield update;
7764
8408
  }
7765
8409
  function makeEmptyLASBatch(header, options) {
7766
- const table = parseLASArrowTableBatch(new ArrayBuffer(0), { ...header, pointsOffset: 0 }, options);
7767
- return updateArrowTableMetadata(
7768
- { ...table, loaderData: header },
7769
- makeMetadataFromLasHeader(header)
8410
+ const table = parseLASArrowTableBatch(
8411
+ new ArrayBuffer(0),
8412
+ { ...header, pointsCount: 0, pointsOffset: 0 },
8413
+ options
7770
8414
  );
8415
+ return updateLASArrowMetadata({ ...table, loaderData: header }, makeMetadataFromLasHeader(header));
7771
8416
  }
7772
8417
  function makeLASMetadataUpdate(lastTable, header, pending, absoluteOffset, totalRead) {
7773
8418
  const metadata = header.metadata;
@@ -7792,14 +8437,17 @@ function makeLASMetadataUpdate(lastTable, header, pending, absoluteOffset, total
7792
8437
  resolveLASGeoTIFFKeyDirectory(finalMetadata);
7793
8438
  const finalHeader = { ...header, totalRead, metadata: finalMetadata };
7794
8439
  if (records.length > 0) {
7795
- const data = new arrow9.Table([makeArrowMetadataBatch(lastTable.data.schema)]);
7796
- return updateArrowTableMetadata(
8440
+ const data = new arrow11.Table([makeArrowMetadataBatch(lastTable.data.schema)]);
8441
+ return updateLASArrowMetadata(
7797
8442
  { ...lastTable, data, loaderData: finalHeader },
7798
8443
  makeMetadataFromLasHeader(finalHeader)
7799
8444
  );
7800
8445
  }
7801
8446
  }
7802
8447
  }
8448
+ function updateLASArrowMetadata(table, metadata) {
8449
+ return { ...table, data: updateNativeArrowTableMetadata(table.data, metadata) };
8450
+ }
7803
8451
  async function* decodeLAZFileWithParsedVLRInBatches(initialPending, inputIterator, header, laszip, options) {
7804
8452
  var _a;
7805
8453
  if (laszip.variableChunks) {
@@ -8228,7 +8876,7 @@ function* decodeLAZFileFromCompleteBytes(bytes, header, laszip, options = {}) {
8228
8876
  const batchSize = getBatchSize(options);
8229
8877
  const outputHeader = {
8230
8878
  ...header,
8231
- metadata: parseLASMetadata(bytes, header),
8879
+ metadata: parseLASMetadata2(bytes, header),
8232
8880
  totalToRead: header.pointsCount
8233
8881
  };
8234
8882
  const state = createRawPointBatchState(
@@ -8353,7 +9001,7 @@ function parseLASHeader(arrayBuffer) {
8353
9001
  userHeaderData: versionMinor === 5 && headerSize > 393 ? new Uint8Array(arrayBuffer, 393, headerSize - 393).slice() : void 0
8354
9002
  };
8355
9003
  if (hasCompleteLASMetadata(arrayBuffer, header)) {
8356
- header.metadata = parseLASMetadata(arrayBuffer, header);
9004
+ header.metadata = parseLASMetadata2(arrayBuffer, header);
8357
9005
  }
8358
9006
  return header;
8359
9007
  }
@@ -8361,7 +9009,7 @@ function hasCompleteLASMetadata(arrayBuffer, header) {
8361
9009
  const vlrEnd = header.headerSize + header.vlrCount * 54;
8362
9010
  return arrayBuffer.byteLength >= Math.max(vlrEnd, header.pointsOffset);
8363
9011
  }
8364
- function parseLASMetadata(arrayBuffer, header) {
9012
+ function parseLASMetadata2(arrayBuffer, header) {
8365
9013
  const dataView = makeDataView(arrayBuffer);
8366
9014
  const bytes = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
8367
9015
  const version2 = header.versionAsString || "1.0";
@@ -8737,7 +9385,7 @@ function makeLASArrowTableFromAttributes(lasHeader, positions, colors, intensiti
8737
9385
  if (extraBytes) {
8738
9386
  attributes.EXTRA_BYTES = {
8739
9387
  value: extraBytes,
8740
- size: extraBytes.length / Math.max(lasHeader.pointsCount, 1)
9388
+ size: lasHeader.pointsStructSize - getLAZPointDataRecordBaseLength(lasHeader.pointsFormatId)
8741
9389
  };
8742
9390
  }
8743
9391
  if (typedExtraBytes) {
@@ -8753,7 +9401,7 @@ function makeLASArrowTableFromAttributes(lasHeader, positions, colors, intensiti
8753
9401
  }
8754
9402
  const schema = getLASSchema(lasHeader, numericAttributes);
8755
9403
  return {
8756
- ...makeMeshArrowTable(attributes, {
9404
+ data: makeMeshArrowTable(attributes, {
8757
9405
  schema,
8758
9406
  topology: "point-list",
8759
9407
  mode: 0,
@@ -10276,12 +10924,12 @@ function readUint64(dataView, byteOffset) {
10276
10924
  const high = dataView.getUint32(byteOffset + 4, true);
10277
10925
  return high * 2 ** 32 + low;
10278
10926
  }
10279
- 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;
10927
+ 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;
10280
10928
  var init_parse_las = __esm({
10281
10929
  "../pointclouds/src/las/lib/typescript/parse-las.ts"() {
10282
10930
  "use strict";
10283
10931
  init_schema_utils();
10284
- arrow9 = __toESM(require("apache-arrow"), 1);
10932
+ arrow11 = __toESM(require("apache-arrow"), 1);
10285
10933
  init_get_las_schema();
10286
10934
  init_schema_utils();
10287
10935
  init_loader_utils();
@@ -10307,6 +10955,7 @@ __export(las_loader_exports, {
10307
10955
  LASColumnLoader: () => LASColumnLoader,
10308
10956
  LASLoaderWithParser: () => LASLoaderWithParser,
10309
10957
  getLASRecordBatches: () => getLASRecordBatches,
10958
+ parseLASMetadata: () => parseLASMetadata,
10310
10959
  toPublicLASResult: () => toPublicLASResult
10311
10960
  });
10312
10961
  function parseLASTable(arrayBuffer, options) {
@@ -10317,8 +10966,8 @@ function parseLASTable(arrayBuffer, options) {
10317
10966
  function convertLASMesh(table, options) {
10318
10967
  var _a;
10319
10968
  const formattedTable = ((_a = options == null ? void 0 : options.las) == null ? void 0 : _a.colorFormat) === void 0 || options.las.colorFormat === "uint8norm" ? table : {
10320
- ...convertMeshToArrowTableWrapper(
10321
- formatLASMeshColors(convertTableToMesh(table), options.las.colorFormat)
10969
+ data: convertMeshToArrowTable(
10970
+ formatLASMeshColors(convertTableToMesh(table.data), options.las.colorFormat)
10322
10971
  ),
10323
10972
  loader: table.loader,
10324
10973
  loaderData: table.loaderData,
@@ -10328,7 +10977,7 @@ function convertLASMesh(table, options) {
10328
10977
  return formattedTable;
10329
10978
  }
10330
10979
  return {
10331
- ...convertTableToMesh(formattedTable),
10980
+ ...convertTableToMesh(formattedTable.data),
10332
10981
  loader: formattedTable.loader,
10333
10982
  loaderData: formattedTable.loaderData,
10334
10983
  progress: formattedTable.progress
@@ -10344,11 +10993,25 @@ async function* convertLASMeshBatches(tableBatches, options) {
10344
10993
  yield convertLASMesh(table, options);
10345
10994
  }
10346
10995
  }
10996
+ function serializeLASWorkerTable(result) {
10997
+ if ("attributes" in result) throw new Error("LAS workers require Arrow columns");
10998
+ return {
10999
+ columns: serializeNativeArrowWorkerResult(result.data),
11000
+ loaderData: structuredClone(result.loaderData),
11001
+ progress: result.progress
11002
+ };
11003
+ }
10347
11004
  function deserializeLASWorkerTable(result, options) {
10348
- return convertLASMesh(deserializeArrowWorkerTable(result), options);
11005
+ const payload = result;
11006
+ const table = deserializeNativeArrowWorkerResult(payload.columns);
11007
+ if (!isArrowTable(table)) throw new Error("LAS workers require an Arrow table");
11008
+ return convertLASMesh(
11009
+ { data: table, loader: "las", loaderData: payload.loaderData, progress: payload.progress },
11010
+ options
11011
+ );
10349
11012
  }
10350
11013
  function toPublicLASResult(result) {
10351
- if (!("shape" in result)) return result;
11014
+ if ("attributes" in result) return result;
10352
11015
  const header = JSON.stringify(
10353
11016
  result.loaderData,
10354
11017
  (_key, value) => typeof value === "bigint" ? value.toString() : ArrayBuffer.isView(value) ? Array.from(value) : value
@@ -10360,16 +11023,22 @@ function toPublicLASResult(result) {
10360
11023
  }
10361
11024
  return result.data;
10362
11025
  }
10363
- function getLASRecordBatches(result) {
10364
- const table = toPublicLASResult(result);
11026
+ function getLASRecordBatches(table) {
10365
11027
  return table.batches.length ? table.batches : [makeArrowMetadataBatch(table.schema)];
10366
11028
  }
10367
- var LASColumnLoader, LASLoaderWithParser;
11029
+ function parseLASMetadata(bytes, options) {
11030
+ const header = parseLASHeader(bytes);
11031
+ const empty = makeEmptyLASBatch(header, options);
11032
+ return toPublicLASResult(
11033
+ convertLASMesh(empty, { ...options, las: { ...options.las, shape: "arrow" } })
11034
+ );
11035
+ }
11036
+ var LASColumnLoader, _serializeLASWorkerResult, _serializeLASWorkerBatch, LASColumnLoaderForCaller, LASLoaderWithParser;
10368
11037
  var init_las_loader = __esm({
10369
11038
  "../pointclouds/src/las/las-loader.ts"() {
10370
11039
  "use strict";
10371
11040
  init_loader_utils();
10372
- init_schema_utils();
11041
+ init_las_source();
10373
11042
  init_schema_utils();
10374
11043
  init_las_loader_shared();
10375
11044
  init_arrow_worker_transport();
@@ -10380,8 +11049,8 @@ var init_las_loader = __esm({
10380
11049
  batchType: null,
10381
11050
  worker: true,
10382
11051
  workerInBatches: true,
10383
- serializeWorkerResult: serializeArrowWorkerTable,
10384
- serializeWorkerBatch: serializeArrowWorkerTable,
11052
+ serializeWorkerResult: serializeLASWorkerTable,
11053
+ serializeWorkerBatch: serializeLASWorkerTable,
10385
11054
  deserializeWorkerResult: deserializeLASWorkerTable,
10386
11055
  deserializeWorkerBatch: deserializeLASWorkerTable,
10387
11056
  parse: async (arrayBuffer, options) => convertLASMesh(parseLASTable(arrayBuffer, options), options),
@@ -10390,22 +11059,30 @@ var init_las_loader = __esm({
10390
11059
  yield* convertLASMeshBatches(parseLASInBatches(arrayBufferIterator, options), options);
10391
11060
  }
10392
11061
  };
11062
+ ({
11063
+ serializeWorkerResult: _serializeLASWorkerResult,
11064
+ serializeWorkerBatch: _serializeLASWorkerBatch,
11065
+ ...LASColumnLoaderForCaller
11066
+ } = LASColumnLoader);
10393
11067
  LASLoaderWithParser = {
10394
- ...LASColumnLoader,
11068
+ ...LASColumnLoaderForCaller,
11069
+ ...LAS_SOURCE_METADATA,
11070
+ /** Creates a sequential query source using the same LAS decoder. */
11071
+ createDataSourceSync: (data, options, coreApi) => new LASSource(data, options, coreApi),
10395
11072
  dataType: LAS_LOADER_METADATA.dataType,
10396
11073
  batchType: LAS_LOADER_METADATA.batchType,
10397
11074
  parse: async (input, options) => toPublicLASResult(await LASColumnLoader.parse(input, options)),
10398
11075
  parseSync: (input, options) => toPublicLASResult(LASColumnLoader.parseSync(input, options)),
10399
11076
  async *parseInBatches(input, options) {
10400
11077
  for await (const result of LASColumnLoader.parseInBatches(input, options)) {
10401
- if ("shape" in result) yield* getLASRecordBatches(result);
11078
+ if (!("attributes" in result)) yield* getLASRecordBatches(toPublicLASResult(result));
10402
11079
  else yield result;
10403
11080
  }
10404
11081
  },
10405
11082
  deserializeWorkerResult: (result, options) => toPublicLASResult(deserializeLASWorkerTable(result, options)),
10406
11083
  deserializeWorkerBatch(result, options) {
10407
11084
  const decoded = deserializeLASWorkerTable(result, options);
10408
- return "shape" in decoded ? getLASRecordBatches(decoded)[0] : decoded;
11085
+ return "attributes" in decoded ? decoded : getLASRecordBatches(toPublicLASResult(decoded))[0];
10409
11086
  }
10410
11087
  };
10411
11088
  }
@@ -10425,7 +11102,12 @@ var init_las_loader_types = __esm({
10425
11102
  ...LAS_LOADER_METADATA,
10426
11103
  worker: true,
10427
11104
  workerInBatches: true,
10428
- preload: preload2
11105
+ preload: preload2,
11106
+ ...LAS_SOURCE_METADATA,
11107
+ /** Creates a source after the parser implementation has been preloaded. */
11108
+ createDataSourceSync(_data, _options, _coreApi) {
11109
+ throw new Error("Call preload(LASLoader) before creating a source synchronously.");
11110
+ }
10429
11111
  };
10430
11112
  }
10431
11113
  });
@@ -10770,9 +11452,9 @@ function parsePotreeBin(arrayBuffer, byteOffset = 0, options) {
10770
11452
  }
10771
11453
  };
10772
11454
  const formattedMesh = formatPotreeMeshColors(mesh, resolvedOptions.colorFormat);
10773
- const table = convertMeshToArrowTableWrapper(formattedMesh);
11455
+ const table = convertMeshToArrowTable(formattedMesh);
10774
11456
  if (((_a = options == null ? void 0 : options.potree) == null ? void 0 : _a.shape) === "arrow") {
10775
- return table.data;
11457
+ return table;
10776
11458
  }
10777
11459
  return {
10778
11460
  ...convertTableToMesh(table),
@@ -11726,9 +12408,12 @@ var init_potree2_source = __esm({
11726
12408
  );
11727
12409
  this.signal.throwIfAborted();
11728
12410
  const header = this.createHeader(node);
11729
- mesh.header.boundingBox = header.boundingVolume.cartographicBounds;
11730
12411
  return {
11731
- data: convertMeshToArrowTableWrapper(mesh),
12412
+ data: makeMeshArrowTable(mesh.attributes, {
12413
+ schema: mesh.schema,
12414
+ topology: mesh.topology,
12415
+ boundingBox: header.boundingVolume.cartographicBounds
12416
+ }),
11732
12417
  pointCount: node.pointCount,
11733
12418
  coordinateSystem: "cartesian",
11734
12419
  cartographicOrigin: [0, 0, 0],
@@ -12816,7 +13501,6 @@ var init_potree_node_source = __esm({
12816
13501
  * Convert normalized node content to the Mesh Arrow table tile payload.
12817
13502
  */
12818
13503
  getPointCloudTileTable(mesh) {
12819
- var _a;
12820
13504
  const attributes = {
12821
13505
  POSITION: mesh.attributes.positions
12822
13506
  };
@@ -12826,18 +13510,7 @@ var init_potree_node_source = __esm({
12826
13510
  if (mesh.attributes.normals) {
12827
13511
  attributes.NORMAL = mesh.attributes.normals;
12828
13512
  }
12829
- return convertMeshToArrowTableWrapper({
12830
- topology: "point-list",
12831
- mode: 0,
12832
- header: {
12833
- vertexCount: ((_a = mesh.header) == null ? void 0 : _a.vertexCount) || mesh.attributes.positions.value.length / mesh.attributes.positions.size
12834
- },
12835
- schema: {
12836
- fields: [],
12837
- metadata: {}
12838
- },
12839
- attributes
12840
- });
13513
+ return makeMeshArrowTable(attributes, { topology: "point-list" });
12841
13514
  }
12842
13515
  /**
12843
13516
  * Detect whether a color buffer contains usable RGB information.
@@ -13069,7 +13742,7 @@ var init_potree_hierarchy_chunk_loader2 = __esm({
13069
13742
  "dist/potree/potree-hierarchy-chunk-loader.js"() {
13070
13743
  "use strict";
13071
13744
  init_potree_format();
13072
- VERSION7 = true ? "5.0.0-beta.10" : "latest";
13745
+ VERSION7 = true ? "5.0.0-beta.11" : "latest";
13073
13746
  PotreeHierarchyChunkLoader2 = {
13074
13747
  ...PotreeHierarchyChunkFormat,
13075
13748
  dataType: null,
@@ -13245,9 +13918,9 @@ function parsePotreeBin2(arrayBuffer, byteOffset = 0, options) {
13245
13918
  }
13246
13919
  };
13247
13920
  const formattedMesh = formatPotreeMeshColors2(mesh, resolvedOptions.colorFormat);
13248
- const table = convertMeshToArrowTableWrapper(formattedMesh);
13921
+ const table = convertMeshToArrowTable(formattedMesh);
13249
13922
  if (((_a = options == null ? void 0 : options.potree) == null ? void 0 : _a.shape) === "arrow") {
13250
- return table.data;
13923
+ return table;
13251
13924
  }
13252
13925
  return {
13253
13926
  ...convertTableToMesh(table),
@@ -13356,7 +14029,7 @@ var init_potree_bin_loader2 = __esm({
13356
14029
  "dist/potree/potree-bin-loader.js"() {
13357
14030
  "use strict";
13358
14031
  init_potree_format();
13359
- VERSION8 = true ? "5.0.0-beta.10" : "latest";
14032
+ VERSION8 = true ? "5.0.0-beta.11" : "latest";
13360
14033
  PotreeBinLoader2 = {
13361
14034
  ...PotreeBinFormat,
13362
14035
  defaultShape: "arrow",
@@ -13397,7 +14070,7 @@ init_potree_format();
13397
14070
 
13398
14071
  // dist/potree/potree-loader-types.js
13399
14072
  init_potree_format();
13400
- var VERSION6 = true ? "5.0.0-beta.10" : "latest";
14073
+ var VERSION6 = true ? "5.0.0-beta.11" : "latest";
13401
14074
  async function preload4() {
13402
14075
  const { PotreeLoaderWithParser: PotreeLoaderWithParser2 } = await Promise.resolve().then(() => (init_potree_loader(), potree_loader_exports));
13403
14076
  return PotreeLoaderWithParser2;
@@ -13437,7 +14110,7 @@ init_potree_bin_loader2();
13437
14110
 
13438
14111
  // dist/potree/potree-writer.js
13439
14112
  init_schema_utils();
13440
- var VERSION9 = true ? "5.0.0-beta.10" : "latest";
14113
+ var VERSION9 = true ? "5.0.0-beta.11" : "latest";
13441
14114
  var PotreeWriter = {
13442
14115
  name: "Potree metadata",
13443
14116
  id: "potree",
@@ -13470,7 +14143,7 @@ var WIRE_TYPES = [
13470
14143
  function getMesh(input) {
13471
14144
  var _a;
13472
14145
  if (!("attributes" in input)) {
13473
- const table = "shape" in input ? input.data : input;
14146
+ const table = input;
13474
14147
  const checkNulls = (data) => {
13475
14148
  if (data.nullCount)
13476
14149
  throw new Error("Potree writer cannot preserve null point attributes");