@luma.gl/graph 10.0.0-alpha.10 → 10.0.0-alpha.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.
- package/dist/arrow/cpu/arrow-coordinate-projection.cjs +30 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.d.ts +5 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.js +9 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.js.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.cjs +31 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts +2 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.js +5 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.js.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.cjs +99 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts +9 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.js +100 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +10 -371
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +9 -28
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +5 -381
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +11 -11
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +2 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +3 -3
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -1
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +2 -2
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +1 -1
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -1
- package/dist/arrow/index.cjs +17 -2
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +3 -0
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +3 -0
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/internal.cjs.map +2 -2
- package/dist/dist.dev.js +533 -108
- package/dist/dist.min.js +70 -70
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/simulation/index.cjs.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.cjs +32 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts +4 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.js +39 -1
- package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph.cjs +19 -7
- package/dist/gpu-core/gpu-command-graph.d.ts +11 -4
- package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph.js +24 -7
- package/dist/gpu-core/gpu-command-graph.js.map +1 -1
- package/dist/gpu-core/gpu-cpu-execution.cjs +279 -0
- package/dist/gpu-core/gpu-cpu-execution.d.ts +22 -0
- package/dist/gpu-core/gpu-cpu-execution.d.ts.map +1 -0
- package/dist/gpu-core/gpu-cpu-execution.js +294 -0
- package/dist/gpu-core/gpu-cpu-execution.js.map +1 -0
- package/dist/gpu-core/gpu-cpu-operation.cjs +54 -0
- package/dist/gpu-core/gpu-cpu-operation.d.ts +40 -0
- package/dist/gpu-core/gpu-cpu-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-cpu-operation.js +35 -0
- package/dist/gpu-core/gpu-cpu-operation.js.map +1 -0
- package/dist/gpu-core/gpu-expression-operation.cjs +2 -2
- package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
- package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-operation.js +1 -1
- package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.cjs +1 -1
- package/dist/gpu-core/gpu-expression-plan.d.ts +3 -2
- package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.js +2 -1
- package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
- package/dist/gpu-core/gpu-graph.d.ts +2 -2
- package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-operation.d.ts +4 -4
- package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-operation.js.map +1 -1
- package/dist/gpu-core/gpu-render-operation.cjs +39 -0
- package/dist/gpu-core/gpu-render-operation.d.ts +21 -0
- package/dist/gpu-core/gpu-render-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-render-operation.js +22 -0
- package/dist/gpu-core/gpu-render-operation.js.map +1 -0
- package/dist/gpu-core/gpu-texture-plan.d.ts +3 -2
- package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-data/cpu-data.cjs +60 -0
- package/dist/gpu-data/cpu-data.d.ts +28 -0
- package/dist/gpu-data/cpu-data.d.ts.map +1 -0
- package/dist/gpu-data/cpu-data.js +41 -0
- package/dist/gpu-data/cpu-data.js.map +1 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
- package/dist/gpu-data/cpu-vector.cjs +42 -0
- package/dist/gpu-data/cpu-vector.d.ts +17 -0
- package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
- package/dist/gpu-data/cpu-vector.js +21 -0
- package/dist/gpu-data/cpu-vector.js.map +1 -0
- package/dist/gpu-data/index.cjs +13 -2
- package/dist/gpu-data/index.cjs.map +3 -3
- package/dist/gpu-data/index.d.ts +3 -0
- package/dist/gpu-data/index.d.ts.map +1 -1
- package/dist/gpu-data/index.js +3 -0
- package/dist/gpu-data/index.js.map +1 -1
- package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
- package/dist/gpu-graph/index.cjs +3 -0
- package/dist/gpu-graph/index.cjs.map +3 -3
- package/dist/gpu-graph/index.d.ts +2 -0
- package/dist/gpu-graph/index.d.ts.map +1 -1
- package/dist/gpu-graph/index.js +1 -0
- package/dist/gpu-graph/index.js.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
- package/dist/gpu-physics/index.cjs.map +1 -1
- package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
- package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
- package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
- package/dist/gpu-project/coordinate-projection-graph.js +40 -0
- package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
- package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
- package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
- package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
- package/dist/gpu-project/cpu-geoarrow.js +103 -0
- package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
- package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
- package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
- package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
- package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
- package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
- package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
- package/dist/gpu-project/cpu-projection-operation.js +37 -0
- package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
- package/dist/gpu-project/geoarrow.cjs +36 -0
- package/dist/gpu-project/geoarrow.cjs.map +6 -0
- package/dist/gpu-project/geoarrow.d.ts +3 -0
- package/dist/gpu-project/geoarrow.d.ts.map +1 -0
- package/dist/gpu-project/geoarrow.js +7 -0
- package/dist/gpu-project/geoarrow.js.map +1 -0
- package/dist/gpu-project/graph.cjs +27 -0
- package/dist/gpu-project/graph.cjs.map +6 -0
- package/dist/gpu-project/graph.d.ts +2 -0
- package/dist/gpu-project/graph.d.ts.map +1 -0
- package/dist/gpu-project/graph.js +6 -0
- package/dist/gpu-project/graph.js.map +1 -0
- package/dist/gpu-project/index.cjs +3 -0
- package/dist/gpu-project/index.cjs.map +3 -3
- package/dist/gpu-project/index.d.ts +1 -0
- package/dist/gpu-project/index.d.ts.map +1 -1
- package/dist/gpu-project/index.js +1 -0
- package/dist/gpu-project/index.js.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +24 -2
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +2 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +29 -2
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
- package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
- package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
- package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +17 -6
- package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
- package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
- package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
- package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
- package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
- package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
- package/src/arrow/index.ts +11 -0
- package/src/gpu-core/compiled-gpu-graph.ts +55 -1
- package/src/gpu-core/gpu-command-graph.ts +27 -7
- package/src/gpu-core/gpu-cpu-execution.ts +345 -0
- package/src/gpu-core/gpu-cpu-operation.ts +65 -0
- package/src/gpu-core/gpu-expression-operation.ts +1 -1
- package/src/gpu-core/gpu-expression-plan.ts +5 -3
- package/src/gpu-core/gpu-graph.ts +3 -3
- package/src/gpu-core/gpu-operation.ts +9 -7
- package/src/gpu-core/gpu-render-operation.ts +42 -0
- package/src/gpu-core/gpu-texture-plan.ts +3 -2
- package/src/gpu-core/index.ts +10 -0
- package/src/gpu-data/cpu-data.ts +62 -0
- package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
- package/src/gpu-data/cpu-vector.ts +31 -0
- package/src/gpu-data/index.ts +5 -0
- package/src/gpu-graph/index.ts +8 -0
- package/src/gpu-project/coordinate-projection-graph.ts +59 -0
- package/src/gpu-project/cpu-geoarrow.ts +135 -0
- package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
- package/src/gpu-project/cpu-projection-operation.ts +49 -0
- package/src/gpu-project/geoarrow.ts +11 -0
- package/src/gpu-project/graph.ts +10 -0
- package/src/gpu-project/index.ts +2 -0
- package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +39 -2
- package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
- package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
- package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
- package/src/index.ts +8 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var coordinate_projection_graph_exports = {};
|
|
19
|
+
__export(coordinate_projection_graph_exports, {
|
|
20
|
+
CoordinateProjectionGraph: () => CoordinateProjectionGraph
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(coordinate_projection_graph_exports);
|
|
23
|
+
var import_core = require("@luma.gl/core");
|
|
24
|
+
var import_gpu_simple_graph = require("../gpu-simple-graph/gpu-simple-graph.cjs");
|
|
25
|
+
var import_gpu_graph = require("../gpu-core/gpu-graph.cjs");
|
|
26
|
+
var import_gpu_graph_value = require("../gpu-core/gpu-graph-value.cjs");
|
|
27
|
+
var import_cpu_projection_operation = require("./cpu-projection-operation.cjs");
|
|
28
|
+
class CoordinateProjectionGraph {
|
|
29
|
+
graph;
|
|
30
|
+
format;
|
|
31
|
+
constructor(device, props) {
|
|
32
|
+
this.format = props.format;
|
|
33
|
+
const graph = device.type === "webgpu" ? new import_gpu_graph.GPUGraph() : new import_gpu_simple_graph.GPUSimpleGraph();
|
|
34
|
+
graph.addInput("source", import_gpu_graph_value.gpuGraph.vector(props.format));
|
|
35
|
+
graph.add(new import_cpu_projection_operation.CPUProjectionOperation({
|
|
36
|
+
id: "project-coordinates",
|
|
37
|
+
input: "source",
|
|
38
|
+
output: "positions",
|
|
39
|
+
format: props.format,
|
|
40
|
+
projection: props.projection
|
|
41
|
+
}));
|
|
42
|
+
this.graph = graph.compile(device, { outputs: ["positions"] });
|
|
43
|
+
}
|
|
44
|
+
/** Borrow input storage and preserve row/chunk boundaries; each result owns independent storage. */
|
|
45
|
+
async run(source) {
|
|
46
|
+
(0, import_core.assert)(source.format === this.format);
|
|
47
|
+
(0, import_core.assert)(source.data.every((chunk) => !chunk.nullBitmap && !chunk.valueOffsets));
|
|
48
|
+
const { positions } = await this.graph.run({ inputs: { source } });
|
|
49
|
+
return { positions, destroy: () => positions.destroy() };
|
|
50
|
+
}
|
|
51
|
+
/** Destroy the compiled pipeline. Previously returned results remain caller-owned. */
|
|
52
|
+
destroy() {
|
|
53
|
+
this.graph.destroy();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
CoordinateProjectionGraph
|
|
59
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Device } from '@luma.gl/core';
|
|
2
|
+
import { CPUVector, GPUVector } from '@luma.gl/graph/gpu-data';
|
|
3
|
+
import { type CPUProjectionOperationProps } from "./cpu-projection-operation.js";
|
|
4
|
+
export type CoordinateProjectionGraphProps = {
|
|
5
|
+
format: 'float32x2' | 'float32x3';
|
|
6
|
+
projection: CPUProjectionOperationProps['projection'];
|
|
7
|
+
};
|
|
8
|
+
export type ProjectedCoordinateResult = {
|
|
9
|
+
positions: GPUVector;
|
|
10
|
+
/** Release this invocation's GPU result after downstream consumers finish. */
|
|
11
|
+
destroy(): void;
|
|
12
|
+
};
|
|
13
|
+
/** Reusable layer-facing point-coordinate pipeline. Projection loading remains caller-owned. */
|
|
14
|
+
export declare class CoordinateProjectionGraph {
|
|
15
|
+
private readonly graph;
|
|
16
|
+
readonly format: CoordinateProjectionGraphProps['format'];
|
|
17
|
+
constructor(device: Device, props: CoordinateProjectionGraphProps);
|
|
18
|
+
/** Borrow input storage and preserve row/chunk boundaries; each result owns independent storage. */
|
|
19
|
+
run(source: CPUVector | GPUVector): Promise<ProjectedCoordinateResult>;
|
|
20
|
+
/** Destroy the compiled pipeline. Previously returned results remain caller-owned. */
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=coordinate-projection-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinate-projection-graph.d.ts","sourceRoot":"","sources":["../../src/gpu-project/coordinate-projection-graph.ts"],"names":[],"mappings":"AAKA,OAAO,EAAS,KAAK,MAAM,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAM7D,OAAO,EAAyB,KAAK,2BAA2B,EAAC,sCAAmC;AAEpG,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC;IAClC,UAAU,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;CACvD,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,SAAS,CAAC;IACrB,8EAA8E;IAC9E,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC;AAEF,gGAAgG;AAChG,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsD;IAC5E,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,CAAC;gBAE9C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;IAgBjE,oGAAoG;IAC9F,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAQ5E,sFAAsF;IACtF,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
import { assert } from '@luma.gl/core';
|
|
6
|
+
import { GPUSimpleGraph } from "../gpu-simple-graph/gpu-simple-graph.js";
|
|
7
|
+
import { GPUGraph } from "../gpu-core/gpu-graph.js";
|
|
8
|
+
import { gpuGraph } from "../gpu-core/gpu-graph-value.js";
|
|
9
|
+
import { CPUProjectionOperation } from "./cpu-projection-operation.js";
|
|
10
|
+
/** Reusable layer-facing point-coordinate pipeline. Projection loading remains caller-owned. */
|
|
11
|
+
export class CoordinateProjectionGraph {
|
|
12
|
+
graph;
|
|
13
|
+
format;
|
|
14
|
+
constructor(device, props) {
|
|
15
|
+
this.format = props.format;
|
|
16
|
+
const graph = device.type === 'webgpu' ? new GPUGraph() : new GPUSimpleGraph();
|
|
17
|
+
graph.addInput('source', gpuGraph.vector(props.format));
|
|
18
|
+
graph.add(new CPUProjectionOperation({
|
|
19
|
+
id: 'project-coordinates',
|
|
20
|
+
input: 'source',
|
|
21
|
+
output: 'positions',
|
|
22
|
+
format: props.format,
|
|
23
|
+
projection: props.projection
|
|
24
|
+
}));
|
|
25
|
+
this.graph = graph.compile(device, { outputs: ['positions'] });
|
|
26
|
+
}
|
|
27
|
+
/** Borrow input storage and preserve row/chunk boundaries; each result owns independent storage. */
|
|
28
|
+
async run(source) {
|
|
29
|
+
assert(source.format === this.format);
|
|
30
|
+
// Point layers must handle null filtering before this numeric projection boundary.
|
|
31
|
+
assert(source.data.every(chunk => !chunk.nullBitmap && !chunk.valueOffsets));
|
|
32
|
+
const { positions } = await this.graph.run({ inputs: { source } });
|
|
33
|
+
return { positions, destroy: () => positions.destroy() };
|
|
34
|
+
}
|
|
35
|
+
/** Destroy the compiled pipeline. Previously returned results remain caller-owned. */
|
|
36
|
+
destroy() {
|
|
37
|
+
this.graph.destroy();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=coordinate-projection-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinate-projection-graph.js","sourceRoot":"","sources":["../../src/gpu-project/coordinate-projection-graph.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAC5D,4FAA4F;AAE5F,OAAO,EAAC,MAAM,EAAc,MAAM,eAAe,CAAC;AAElD,OAAO,EAAC,cAAc,EAAC,gDAA6C;AACpE,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAG/C,OAAO,EAAC,QAAQ,EAAC,uCAAoC;AACrD,OAAO,EAAC,sBAAsB,EAAmC,sCAAmC;AAYpG,gGAAgG;AAChG,MAAM,OAAO,yBAAyB;IACnB,KAAK,CAAsD;IACnE,MAAM,CAA2C;IAE1D,YAAY,MAAc,EAAE,KAAqC;QAC/D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC;QAC/E,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACxD,KAAK,CAAC,GAAG,CACP,IAAI,sBAAsB,CAAC;YACzB,EAAE,EAAE,qBAAqB;YACzB,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC,CACH,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAC,CAAC,CAAC;IAC/D,CAAC;IAED,oGAAoG;IACpG,KAAK,CAAC,GAAG,CAAC,MAA6B;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,mFAAmF;QACnF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7E,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,EAAC,MAAM,EAAC,EAAC,CAAC,CAAC;QAC7D,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAC,CAAC;IACzD,CAAC;IAED,sFAAsF;IACtF,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var cpu_geoarrow_exports = {};
|
|
19
|
+
__export(cpu_geoarrow_exports, {
|
|
20
|
+
makeCPUVectorFromGeoArrowColumn: () => makeCPUVectorFromGeoArrowColumn,
|
|
21
|
+
makeGeoArrowColumnFromCPUVector: () => makeGeoArrowColumnFromCPUVector
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cpu_geoarrow_exports);
|
|
24
|
+
var import_core = require("@luma.gl/core");
|
|
25
|
+
var import_gpu_data = require("@luma.gl/graph/gpu-data");
|
|
26
|
+
function makeGeoArrowColumnFromCPUVector(vector, options = {}) {
|
|
27
|
+
const info = (0, import_gpu_data.getGPUVectorFormatInfo)(vector.format);
|
|
28
|
+
(0, import_core.assert)(info.signedDataType === "float32" && info.components >= 2 && !info.fixedSizeList);
|
|
29
|
+
const variable = info.vertexList || info.valueList;
|
|
30
|
+
const encoding = options.encoding ?? (variable ? "geoarrow.linestring" : "geoarrow.point");
|
|
31
|
+
(0, import_core.assert)(variable === (encoding !== "geoarrow.point"));
|
|
32
|
+
const dimension = options.dimension ?? (info.components === 2 ? "xy" : info.components === 3 ? "xyz" : "xyzm");
|
|
33
|
+
(0, import_core.assert)((dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3) === info.components);
|
|
34
|
+
const chunks = vector.data.map((chunk) => {
|
|
35
|
+
const packed = chunk.byteStride === info.byteLength && chunk.byteOffset % 4 === 0;
|
|
36
|
+
const count = variable ? chunk.valueLength : chunk.length;
|
|
37
|
+
let values;
|
|
38
|
+
if (packed)
|
|
39
|
+
values = new Float32Array(chunk.buffer, chunk.byteOffset, count * info.components);
|
|
40
|
+
else {
|
|
41
|
+
values = new Float32Array(count * info.components);
|
|
42
|
+
const bytes = new Uint8Array(values.buffer);
|
|
43
|
+
for (let index = 0; index < count; index++)
|
|
44
|
+
bytes.set(new Uint8Array(chunk.buffer, chunk.byteOffset + index * chunk.byteStride, info.byteLength), index * info.byteLength);
|
|
45
|
+
}
|
|
46
|
+
const coordinates = {
|
|
47
|
+
kind: "fixed-size-list",
|
|
48
|
+
length: count,
|
|
49
|
+
size: info.components,
|
|
50
|
+
child: {
|
|
51
|
+
kind: "primitive",
|
|
52
|
+
length: count * info.components,
|
|
53
|
+
values
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const validity = chunk.nullBitmap ? { values: chunk.nullBitmap } : void 0;
|
|
57
|
+
if (!variable)
|
|
58
|
+
return { ...coordinates, validity };
|
|
59
|
+
(0, import_core.assert)(chunk.valueOffsets);
|
|
60
|
+
const rings = {
|
|
61
|
+
kind: "list",
|
|
62
|
+
length: chunk.length,
|
|
63
|
+
offsets: chunk.valueOffsets,
|
|
64
|
+
child: coordinates,
|
|
65
|
+
validity
|
|
66
|
+
};
|
|
67
|
+
return encoding === "geoarrow.polygon" ? {
|
|
68
|
+
kind: "list",
|
|
69
|
+
length: chunk.length,
|
|
70
|
+
offsets: Int32Array.from({ length: chunk.length + 1 }, (_, index) => index),
|
|
71
|
+
child: rings,
|
|
72
|
+
validity
|
|
73
|
+
} : rings;
|
|
74
|
+
});
|
|
75
|
+
return { encoding, dimension, coordinateLayout: "interleaved", chunks };
|
|
76
|
+
}
|
|
77
|
+
function makeCPUVectorFromGeoArrowColumn(column) {
|
|
78
|
+
(0, import_core.assert)(column.coordinateLayout === "interleaved" && ["geoarrow.point", "geoarrow.linestring", "geoarrow.multipoint"].includes(column.encoding));
|
|
79
|
+
const components = column.dimension === "xy" ? 2 : column.dimension === "xyzm" ? 4 : 3;
|
|
80
|
+
const variable = column.encoding !== "geoarrow.point";
|
|
81
|
+
const element = `float32x${components}`;
|
|
82
|
+
const format = variable ? `vertex-list<${element}>` : element;
|
|
83
|
+
const data = column.chunks.map((chunk) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
(0, import_core.assert)(!((_a = chunk.validity) == null ? void 0 : _a.bitOffset));
|
|
86
|
+
const coordinates = variable && chunk.kind === "list" ? chunk.child : chunk;
|
|
87
|
+
(0, import_core.assert)(coordinates.kind === "fixed-size-list" && coordinates.size === components && !coordinates.offset && (!variable || !coordinates.validity));
|
|
88
|
+
const primitive = coordinates.child;
|
|
89
|
+
(0, import_core.assert)(primitive.kind === "primitive" && primitive.values instanceof Float32Array && !primitive.validity && (!primitive.stride || primitive.stride === 1));
|
|
90
|
+
const offset = primitive.offset ?? 0;
|
|
91
|
+
const values = primitive.values.subarray(offset, offset + coordinates.length * components);
|
|
92
|
+
let valueOffsets;
|
|
93
|
+
if (variable) {
|
|
94
|
+
(0, import_core.assert)(chunk.kind === "list" && chunk.offsets instanceof Int32Array && !chunk.offset && !chunk.offsetBase);
|
|
95
|
+
valueOffsets = chunk.offsets;
|
|
96
|
+
}
|
|
97
|
+
return new import_gpu_data.CPUData({
|
|
98
|
+
buffer: values,
|
|
99
|
+
format,
|
|
100
|
+
length: chunk.length,
|
|
101
|
+
valueLength: variable ? coordinates.length : void 0,
|
|
102
|
+
valueOffsets,
|
|
103
|
+
nullBitmap: (_b = chunk.validity) == null ? void 0 : _b.values
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return new import_gpu_data.CPUVector({ format, data });
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
makeCPUVectorFromGeoArrowColumn,
|
|
111
|
+
makeGeoArrowColumnFromCPUVector
|
|
112
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CPUVector } from '@luma.gl/graph/gpu-data';
|
|
2
|
+
import type { GeoArrowColumn, GeoArrowDimension } from '@math.gl/arrow/geoarrow-utils';
|
|
3
|
+
/** Borrow CPU coordinate chunks as native GeoArrow points or single-level coordinate lists. */
|
|
4
|
+
export declare function makeGeoArrowColumnFromCPUVector(vector: CPUVector, options?: {
|
|
5
|
+
encoding?: 'geoarrow.point' | 'geoarrow.linestring' | 'geoarrow.multipoint' | 'geoarrow.polygon';
|
|
6
|
+
dimension?: GeoArrowDimension;
|
|
7
|
+
}): GeoArrowColumn;
|
|
8
|
+
/** Borrow packed Float32 GeoArrow points/lines/multipoints as CPU chunks. Nested polygons stay GeoArrow. */
|
|
9
|
+
export declare function makeCPUVectorFromGeoArrowColumn(column: GeoArrowColumn): CPUVector;
|
|
10
|
+
//# sourceMappingURL=cpu-geoarrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cpu-geoarrow.d.ts","sourceRoot":"","sources":["../../src/gpu-project/cpu-geoarrow.ts"],"names":[],"mappings":"AAMA,OAAO,EAAU,SAAS,EAAyB,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAGlB,MAAM,+BAA+B,CAAC;AAEvC,+FAA+F;AAC/F,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE;IACP,QAAQ,CAAC,EACL,gBAAgB,GAChB,qBAAqB,GACrB,qBAAqB,GACrB,kBAAkB,CAAC;IACvB,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC1B,GACL,cAAc,CA2DhB;AAED,4GAA4G;AAC5G,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CA+CjF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
import { assert } from '@luma.gl/core';
|
|
6
|
+
import { CPUData, CPUVector, getGPUVectorFormatInfo } from '@luma.gl/graph/gpu-data';
|
|
7
|
+
/** Borrow CPU coordinate chunks as native GeoArrow points or single-level coordinate lists. */
|
|
8
|
+
export function makeGeoArrowColumnFromCPUVector(vector, options = {}) {
|
|
9
|
+
const info = getGPUVectorFormatInfo(vector.format);
|
|
10
|
+
assert(info.signedDataType === 'float32' && info.components >= 2 && !info.fixedSizeList);
|
|
11
|
+
const variable = info.vertexList || info.valueList;
|
|
12
|
+
const encoding = options.encoding ?? (variable ? 'geoarrow.linestring' : 'geoarrow.point');
|
|
13
|
+
assert(variable === (encoding !== 'geoarrow.point'));
|
|
14
|
+
const dimension = options.dimension ?? (info.components === 2 ? 'xy' : info.components === 3 ? 'xyz' : 'xyzm');
|
|
15
|
+
assert((dimension === 'xy' ? 2 : dimension === 'xyzm' ? 4 : 3) === info.components);
|
|
16
|
+
const chunks = vector.data.map(chunk => {
|
|
17
|
+
// GeoArrow primitive scalar stride cannot express padding between coordinate tuples.
|
|
18
|
+
const packed = chunk.byteStride === info.byteLength && chunk.byteOffset % 4 === 0;
|
|
19
|
+
const count = variable ? chunk.valueLength : chunk.length;
|
|
20
|
+
let values;
|
|
21
|
+
if (packed)
|
|
22
|
+
values = new Float32Array(chunk.buffer, chunk.byteOffset, count * info.components);
|
|
23
|
+
else {
|
|
24
|
+
values = new Float32Array(count * info.components);
|
|
25
|
+
const bytes = new Uint8Array(values.buffer);
|
|
26
|
+
for (let index = 0; index < count; index++)
|
|
27
|
+
bytes.set(new Uint8Array(chunk.buffer, chunk.byteOffset + index * chunk.byteStride, info.byteLength), index * info.byteLength);
|
|
28
|
+
}
|
|
29
|
+
const coordinates = {
|
|
30
|
+
kind: 'fixed-size-list',
|
|
31
|
+
length: count,
|
|
32
|
+
size: info.components,
|
|
33
|
+
child: {
|
|
34
|
+
kind: 'primitive',
|
|
35
|
+
length: count * info.components,
|
|
36
|
+
values
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const validity = chunk.nullBitmap ? { values: chunk.nullBitmap } : undefined;
|
|
40
|
+
if (!variable)
|
|
41
|
+
return { ...coordinates, validity };
|
|
42
|
+
assert(chunk.valueOffsets);
|
|
43
|
+
const rings = {
|
|
44
|
+
kind: 'list',
|
|
45
|
+
length: chunk.length,
|
|
46
|
+
offsets: chunk.valueOffsets,
|
|
47
|
+
child: coordinates,
|
|
48
|
+
validity
|
|
49
|
+
};
|
|
50
|
+
return encoding === 'geoarrow.polygon'
|
|
51
|
+
? {
|
|
52
|
+
kind: 'list',
|
|
53
|
+
length: chunk.length,
|
|
54
|
+
offsets: Int32Array.from({ length: chunk.length + 1 }, (_, index) => index),
|
|
55
|
+
child: rings,
|
|
56
|
+
validity
|
|
57
|
+
}
|
|
58
|
+
: rings;
|
|
59
|
+
});
|
|
60
|
+
return { encoding, dimension, coordinateLayout: 'interleaved', chunks };
|
|
61
|
+
}
|
|
62
|
+
/** Borrow packed Float32 GeoArrow points/lines/multipoints as CPU chunks. Nested polygons stay GeoArrow. */
|
|
63
|
+
export function makeCPUVectorFromGeoArrowColumn(column) {
|
|
64
|
+
assert(column.coordinateLayout === 'interleaved' &&
|
|
65
|
+
['geoarrow.point', 'geoarrow.linestring', 'geoarrow.multipoint'].includes(column.encoding));
|
|
66
|
+
const components = column.dimension === 'xy' ? 2 : column.dimension === 'xyzm' ? 4 : 3;
|
|
67
|
+
const variable = column.encoding !== 'geoarrow.point';
|
|
68
|
+
const element = `float32x${components}`;
|
|
69
|
+
const format = variable ? `vertex-list<${element}>` : element;
|
|
70
|
+
const data = column.chunks.map(chunk => {
|
|
71
|
+
assert(!chunk.validity?.bitOffset);
|
|
72
|
+
const coordinates = variable && chunk.kind === 'list' ? chunk.child : chunk;
|
|
73
|
+
assert(coordinates.kind === 'fixed-size-list' &&
|
|
74
|
+
coordinates.size === components &&
|
|
75
|
+
!coordinates.offset &&
|
|
76
|
+
(!variable || !coordinates.validity));
|
|
77
|
+
const primitive = coordinates.child;
|
|
78
|
+
assert(primitive.kind === 'primitive' &&
|
|
79
|
+
primitive.values instanceof Float32Array &&
|
|
80
|
+
!primitive.validity &&
|
|
81
|
+
(!primitive.stride || primitive.stride === 1));
|
|
82
|
+
const offset = primitive.offset ?? 0;
|
|
83
|
+
const values = primitive.values.subarray(offset, offset + coordinates.length * components);
|
|
84
|
+
let valueOffsets;
|
|
85
|
+
if (variable) {
|
|
86
|
+
assert(chunk.kind === 'list' &&
|
|
87
|
+
chunk.offsets instanceof Int32Array &&
|
|
88
|
+
!chunk.offset &&
|
|
89
|
+
!chunk.offsetBase);
|
|
90
|
+
valueOffsets = chunk.offsets;
|
|
91
|
+
}
|
|
92
|
+
return new CPUData({
|
|
93
|
+
buffer: values,
|
|
94
|
+
format,
|
|
95
|
+
length: chunk.length,
|
|
96
|
+
valueLength: variable ? coordinates.length : undefined,
|
|
97
|
+
valueOffsets,
|
|
98
|
+
nullBitmap: chunk.validity?.values
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return new CPUVector({ format, data });
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=cpu-geoarrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cpu-geoarrow.js","sourceRoot":"","sources":["../../src/gpu-project/cpu-geoarrow.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAC5D,4FAA4F;AAE5F,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAQnF,+FAA+F;AAC/F,MAAM,UAAU,+BAA+B,CAC7C,MAAiB,EACjB,UAOI,EAAE;IAEN,MAAM,IAAI,GAAG,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC;IACnD,MAAM,QAAQ,GAAG,O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nPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var cpu_geometry_pipelines_exports = {};
|
|
19
|
+
__export(cpu_geometry_pipelines_exports, {
|
|
20
|
+
projectCPUVector: () => projectCPUVector,
|
|
21
|
+
tessellateCPUVectorPolygons: () => tessellateCPUVectorPolygons,
|
|
22
|
+
tessellateGeoArrowColumnToCPUVectors: () => tessellateGeoArrowColumnToCPUVectors
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cpu_geometry_pipelines_exports);
|
|
25
|
+
var import_core = require("@luma.gl/core");
|
|
26
|
+
var import_gpu_data = require("@luma.gl/graph/gpu-data");
|
|
27
|
+
var import_geoarrow_utils = require("@math.gl/arrow/geoarrow-utils");
|
|
28
|
+
var import_cpu_geoarrow = require("./cpu-geoarrow.cjs");
|
|
29
|
+
async function projectCPUVector(vector, projection) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const { name, format } = vector;
|
|
32
|
+
vector = (0, import_cpu_geoarrow.makeCPUVectorFromGeoArrowColumn)((0, import_cpu_geoarrow.makeGeoArrowColumnFromCPUVector)(vector));
|
|
33
|
+
const info = (0, import_gpu_data.getGPUVectorFormatInfo)(vector.format);
|
|
34
|
+
(0, import_core.assert)(info.signedDataType === "float32" && (info.components === 2 || info.components === 3) && !info.fixedSizeList);
|
|
35
|
+
const data = [];
|
|
36
|
+
for (const chunk of vector.data) {
|
|
37
|
+
const variable = info.vertexList || info.valueList;
|
|
38
|
+
const count = variable ? chunk.valueLength : chunk.length;
|
|
39
|
+
const values = new Float32Array(count * info.components);
|
|
40
|
+
const bytes = new Uint8Array(values.buffer);
|
|
41
|
+
for (let index = 0; index < count; index++)
|
|
42
|
+
bytes.set(new Uint8Array(chunk.buffer, chunk.byteOffset + index * chunk.byteStride, info.byteLength), index * info.byteLength);
|
|
43
|
+
if (variable)
|
|
44
|
+
(0, import_core.assert)(chunk.valueOffsets);
|
|
45
|
+
let row = 0;
|
|
46
|
+
while (row < chunk.length) {
|
|
47
|
+
if (chunk.nullBitmap && !(chunk.nullBitmap[row >> 3] & 1 << (row & 7))) {
|
|
48
|
+
row++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const firstRow = row++;
|
|
52
|
+
while (row < chunk.length && (!chunk.nullBitmap || chunk.nullBitmap[row >> 3] & 1 << (row & 7)))
|
|
53
|
+
row++;
|
|
54
|
+
const start = variable ? chunk.valueOffsets[firstRow] : firstRow;
|
|
55
|
+
const end = variable ? chunk.valueOffsets[row] : row;
|
|
56
|
+
if (end > start)
|
|
57
|
+
values.set(await projection.projectFlat(values.slice(start * info.components, end * info.components), info.components), start * info.components);
|
|
58
|
+
}
|
|
59
|
+
data.push(new import_gpu_data.CPUData({
|
|
60
|
+
buffer: values,
|
|
61
|
+
format,
|
|
62
|
+
length: chunk.length,
|
|
63
|
+
valueLength: chunk.valueLength,
|
|
64
|
+
valueOffsets: (_a = chunk.valueOffsets) == null ? void 0 : _a.slice(),
|
|
65
|
+
nullBitmap: (_b = chunk.nullBitmap) == null ? void 0 : _b.slice()
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return new import_gpu_data.CPUVector({ name, format, data });
|
|
69
|
+
}
|
|
70
|
+
function tessellateCPUVectorPolygons(vector) {
|
|
71
|
+
return tessellateGeoArrowColumnToCPUVectors((0, import_cpu_geoarrow.makeGeoArrowColumnFromCPUVector)(vector, { encoding: "geoarrow.polygon" }));
|
|
72
|
+
}
|
|
73
|
+
function tessellateGeoArrowColumnToCPUVectors(column, options = {}) {
|
|
74
|
+
const positions = [];
|
|
75
|
+
const indices = [];
|
|
76
|
+
const rowIndices = [];
|
|
77
|
+
let rowOffset = options.sourceRowOffset ?? 0;
|
|
78
|
+
for (const rings of column.chunks) {
|
|
79
|
+
const mesh = (0, import_geoarrow_utils.tessellateGeoArrowPolygons)({ ...column, chunks: [rings] }, { ...options, positionSize: 4, sourceRowOffset: rowOffset });
|
|
80
|
+
const vertexOffsets = new Int32Array(rings.length + 1);
|
|
81
|
+
const indexOffsets = new Int32Array(rings.length + 1);
|
|
82
|
+
for (const source of mesh.sourceRowIndices)
|
|
83
|
+
vertexOffsets[source - rowOffset + 1]++;
|
|
84
|
+
for (const index of mesh.indices)
|
|
85
|
+
indexOffsets[mesh.sourceRowIndices[index] - rowOffset + 1]++;
|
|
86
|
+
for (let row = 1; row <= rings.length; row++) {
|
|
87
|
+
vertexOffsets[row] += vertexOffsets[row - 1];
|
|
88
|
+
indexOffsets[row] += indexOffsets[row - 1];
|
|
89
|
+
}
|
|
90
|
+
let nullBitmap;
|
|
91
|
+
if (rings.validity) {
|
|
92
|
+
nullBitmap = new Uint8Array(Math.ceil(rings.length / 8));
|
|
93
|
+
for (let row = 0; row < rings.length; row++) {
|
|
94
|
+
const bit = row + (rings.validity.bitOffset ?? 0);
|
|
95
|
+
if (rings.validity.values[bit >> 3] & 1 << (bit & 7))
|
|
96
|
+
nullBitmap[row >> 3] |= 1 << (row & 7);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const common = { length: rings.length, nullBitmap };
|
|
100
|
+
positions.push(new import_gpu_data.CPUData({
|
|
101
|
+
...common,
|
|
102
|
+
format: "vertex-list<float32x4>",
|
|
103
|
+
buffer: mesh.positions,
|
|
104
|
+
valueLength: mesh.vertexCount,
|
|
105
|
+
valueOffsets: vertexOffsets
|
|
106
|
+
}));
|
|
107
|
+
indices.push(new import_gpu_data.CPUData({
|
|
108
|
+
...common,
|
|
109
|
+
format: "vertex-list<uint32>",
|
|
110
|
+
buffer: Uint32Array.from(mesh.indices),
|
|
111
|
+
valueLength: mesh.indices.length,
|
|
112
|
+
valueOffsets: indexOffsets
|
|
113
|
+
}));
|
|
114
|
+
rowIndices.push(new import_gpu_data.CPUData({
|
|
115
|
+
...common,
|
|
116
|
+
format: "vertex-list<uint32>",
|
|
117
|
+
buffer: mesh.sourceRowIndices,
|
|
118
|
+
valueLength: mesh.vertexCount,
|
|
119
|
+
valueOffsets: vertexOffsets
|
|
120
|
+
}));
|
|
121
|
+
rowOffset += rings.length;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
positions: new import_gpu_data.CPUVector({ format: "vertex-list<float32x4>", data: positions }),
|
|
125
|
+
indices: new import_gpu_data.CPUVector({ format: "vertex-list<uint32>", data: indices }),
|
|
126
|
+
rowIndices: new import_gpu_data.CPUVector({ format: "vertex-list<uint32>", data: rowIndices })
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
projectCPUVector,
|
|
132
|
+
tessellateCPUVectorPolygons,
|
|
133
|
+
tessellateGeoArrowColumnToCPUVectors
|
|
134
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CPUVector } from '@luma.gl/graph/gpu-data';
|
|
2
|
+
import type { Projection } from '@math.gl/geospatial/projection/types';
|
|
3
|
+
import { type GeoArrowColumn, type TessellateGeoArrowPolygonsOptions } from '@math.gl/arrow/geoarrow-utils';
|
|
4
|
+
/** Project Float32 coordinates while retaining single-level row topology and null rows. */
|
|
5
|
+
export declare function projectCPUVector(vector: CPUVector, projection: Pick<Projection, 'projectFlat'>): Promise<CPUVector>;
|
|
6
|
+
/** Tessellate one simple polygon ring per list row, preserving source chunks and row identities. */
|
|
7
|
+
export declare function tessellateCPUVectorPolygons(vector: CPUVector): {
|
|
8
|
+
positions: CPUVector<'vertex-list<float32x4>'>;
|
|
9
|
+
indices: CPUVector<'vertex-list<uint32>'>;
|
|
10
|
+
rowIndices: CPUVector<'vertex-list<uint32>'>;
|
|
11
|
+
};
|
|
12
|
+
/** Full native GeoArrow polygon tessellation, including holes, multipolygons and mixed columns. */
|
|
13
|
+
export declare function tessellateGeoArrowColumnToCPUVectors(column: GeoArrowColumn, options?: TessellateGeoArrowPolygonsOptions): {
|
|
14
|
+
positions: CPUVector<'vertex-list<float32x4>'>;
|
|
15
|
+
indices: CPUVector<'vertex-list<uint32>'>;
|
|
16
|
+
rowIndices: CPUVector<'vertex-list<uint32>'>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=cpu-geometry-pipelines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cpu-geometry-pipelines.d.ts","sourceRoot":"","sources":["../../src/gpu-project/cpu-geometry-pipelines.ts"],"names":[],"mappings":"AAMA,OAAO,EAAU,SAAS,EAAyB,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iCAAiC,EACvC,MAAM,+BAA+B,CAAC;AAGvC,2FAA2F;AAC3F,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,GAC1C,OAAO,CAAC,SAAS,CAAC,CAwDpB;AAED,oGAAoG;AACpG,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,GAAG;IAC9D,SAAS,EAAE,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC1C,UAAU,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;CAC9C,CAIA;AAED,mGAAmG;AACnG,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,iCAAsC,GAC9C;IACD,SAAS,EAAE,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC1C,UAAU,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;CAC9C,CA8DA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
import { assert } from '@luma.gl/core';
|
|
6
|
+
import { CPUData, CPUVector, getGPUVectorFormatInfo } from '@luma.gl/graph/gpu-data';
|
|
7
|
+
import { tessellateGeoArrowPolygons } from '@math.gl/arrow/geoarrow-utils';
|
|
8
|
+
import { makeGeoArrowColumnFromCPUVector, makeCPUVectorFromGeoArrowColumn } from "./cpu-geoarrow.js";
|
|
9
|
+
/** Project Float32 coordinates while retaining single-level row topology and null rows. */
|
|
10
|
+
export async function projectCPUVector(vector, projection) {
|
|
11
|
+
const { name, format } = vector;
|
|
12
|
+
vector = makeCPUVectorFromGeoArrowColumn(makeGeoArrowColumnFromCPUVector(vector));
|
|
13
|
+
const info = getGPUVectorFormatInfo(vector.format);
|
|
14
|
+
assert(info.signedDataType === 'float32' &&
|
|
15
|
+
(info.components === 2 || info.components === 3) &&
|
|
16
|
+
!info.fixedSizeList);
|
|
17
|
+
const data = [];
|
|
18
|
+
for (const chunk of vector.data) {
|
|
19
|
+
const variable = info.vertexList || info.valueList;
|
|
20
|
+
const count = variable ? chunk.valueLength : chunk.length;
|
|
21
|
+
const values = new Float32Array(count * info.components);
|
|
22
|
+
const bytes = new Uint8Array(values.buffer);
|
|
23
|
+
for (let index = 0; index < count; index++)
|
|
24
|
+
bytes.set(new Uint8Array(chunk.buffer, chunk.byteOffset + index * chunk.byteStride, info.byteLength), index * info.byteLength);
|
|
25
|
+
if (variable)
|
|
26
|
+
assert(chunk.valueOffsets);
|
|
27
|
+
let row = 0;
|
|
28
|
+
while (row < chunk.length) {
|
|
29
|
+
if (chunk.nullBitmap && !(chunk.nullBitmap[row >> 3] & (1 << (row & 7)))) {
|
|
30
|
+
row++;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const firstRow = row++;
|
|
34
|
+
while (row < chunk.length &&
|
|
35
|
+
(!chunk.nullBitmap || chunk.nullBitmap[row >> 3] & (1 << (row & 7))))
|
|
36
|
+
row++;
|
|
37
|
+
const start = variable ? chunk.valueOffsets[firstRow] : firstRow;
|
|
38
|
+
const end = variable ? chunk.valueOffsets[row] : row;
|
|
39
|
+
if (end > start)
|
|
40
|
+
values.set(await projection.projectFlat(values.slice(start * info.components, end * info.components), info.components), start * info.components);
|
|
41
|
+
}
|
|
42
|
+
data.push(new CPUData({
|
|
43
|
+
buffer: values,
|
|
44
|
+
format,
|
|
45
|
+
length: chunk.length,
|
|
46
|
+
valueLength: chunk.valueLength,
|
|
47
|
+
valueOffsets: chunk.valueOffsets?.slice(),
|
|
48
|
+
nullBitmap: chunk.nullBitmap?.slice()
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
return new CPUVector({ name, format, data });
|
|
52
|
+
}
|
|
53
|
+
/** Tessellate one simple polygon ring per list row, preserving source chunks and row identities. */
|
|
54
|
+
export function tessellateCPUVectorPolygons(vector) {
|
|
55
|
+
return tessellateGeoArrowColumnToCPUVectors(makeGeoArrowColumnFromCPUVector(vector, { encoding: 'geoarrow.polygon' }));
|
|
56
|
+
}
|
|
57
|
+
/** Full native GeoArrow polygon tessellation, including holes, multipolygons and mixed columns. */
|
|
58
|
+
export function tessellateGeoArrowColumnToCPUVectors(column, options = {}) {
|
|
59
|
+
const positions = [];
|
|
60
|
+
const indices = [];
|
|
61
|
+
const rowIndices = [];
|
|
62
|
+
let rowOffset = options.sourceRowOffset ?? 0;
|
|
63
|
+
for (const rings of column.chunks) {
|
|
64
|
+
const mesh = tessellateGeoArrowPolygons({ ...column, chunks: [rings] }, { ...options, positionSize: 4, sourceRowOffset: rowOffset });
|
|
65
|
+
const vertexOffsets = new Int32Array(rings.length + 1);
|
|
66
|
+
const indexOffsets = new Int32Array(rings.length + 1);
|
|
67
|
+
for (const source of mesh.sourceRowIndices)
|
|
68
|
+
vertexOffsets[source - rowOffset + 1]++;
|
|
69
|
+
for (const index of mesh.indices)
|
|
70
|
+
indexOffsets[mesh.sourceRowIndices[index] - rowOffset + 1]++;
|
|
71
|
+
for (let row = 1; row <= rings.length; row++) {
|
|
72
|
+
vertexOffsets[row] += vertexOffsets[row - 1];
|
|
73
|
+
indexOffsets[row] += indexOffsets[row - 1];
|
|
74
|
+
}
|
|
75
|
+
let nullBitmap;
|
|
76
|
+
if (rings.validity) {
|
|
77
|
+
nullBitmap = new Uint8Array(Math.ceil(rings.length / 8));
|
|
78
|
+
for (let row = 0; row < rings.length; row++) {
|
|
79
|
+
const bit = row + (rings.validity.bitOffset ?? 0);
|
|
80
|
+
if (rings.validity.values[bit >> 3] & (1 << (bit & 7)))
|
|
81
|
+
nullBitmap[row >> 3] |= 1 << (row & 7);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const common = { length: rings.length, nullBitmap };
|
|
85
|
+
positions.push(new CPUData({
|
|
86
|
+
...common,
|
|
87
|
+
format: 'vertex-list<float32x4>',
|
|
88
|
+
buffer: mesh.positions,
|
|
89
|
+
valueLength: mesh.vertexCount,
|
|
90
|
+
valueOffsets: vertexOffsets
|
|
91
|
+
}));
|
|
92
|
+
indices.push(new CPUData({
|
|
93
|
+
...common,
|
|
94
|
+
format: 'vertex-list<uint32>',
|
|
95
|
+
buffer: Uint32Array.from(mesh.indices),
|
|
96
|
+
valueLength: mesh.indices.length,
|
|
97
|
+
valueOffsets: indexOffsets
|
|
98
|
+
}));
|
|
99
|
+
rowIndices.push(new CPUData({
|
|
100
|
+
...common,
|
|
101
|
+
format: 'vertex-list<uint32>',
|
|
102
|
+
buffer: mesh.sourceRowIndices,
|
|
103
|
+
valueLength: mesh.vertexCount,
|
|
104
|
+
valueOffsets: vertexOffsets
|
|
105
|
+
}));
|
|
106
|
+
rowOffset += rings.length;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
positions: new CPUVector({ format: 'vertex-list<float32x4>', data: positions }),
|
|
110
|
+
indices: new CPUVector({ format: 'vertex-list<uint32>', data: indices }),
|
|
111
|
+
rowIndices: new CPUVector({ format: 'vertex-list<uint32>', data: rowIndices })
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=cpu-geometry-pipelines.js.map
|