Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/deck.gl-geoarrow/src/layers/path-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
getGeometryData,
getInterleavedLineString,
getMultiLineStringResolvedOffsets,
getValueOffsets,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
Expand Down Expand Up @@ -170,7 +171,7 @@ export class GeoArrowPathLayer<
if (isGeomSeparate(lineStringData)) {
lineStringData = getInterleavedLineString(lineStringData);
}
const geomOffsets = lineStringData.valueOffsets;
const geomOffsets = getValueOffsets(lineStringData);
const pointData = ga.child.getLineStringChild(lineStringData);
const nDim = pointData.type.listSize;
const coordData = ga.child.getPointChild(pointData);
Expand Down Expand Up @@ -230,8 +231,8 @@ export class GeoArrowPathLayer<
const pointData = ga.child.getLineStringChild(lineStringData);
const coordData = ga.child.getPointChild(pointData);

const geomOffsets = multiLineStringData.valueOffsets;
const ringOffsets = lineStringData.valueOffsets;
const geomOffsets = getValueOffsets(multiLineStringData);
const ringOffsets = getValueOffsets(lineStringData);

const nDim = pointData.type.listSize;
const flatCoordinateArray = coordData.values;
Expand Down
4 changes: 2 additions & 2 deletions packages/deck.gl-geoarrow/src/layers/polygon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
GeoArrowPickingInfo,
} from "../types";
import type { GeoArrowExtraPickingProps } from "../utils/picking";
import { getGeometryData } from "../utils/utils";
import { getGeometryData, getValueOffsets } from "../utils/utils";
import { GeoArrowPathLayer } from "./path-layer";
import { GeoArrowSolidPolygonLayer } from "./solid-polygon-layer";

Expand Down Expand Up @@ -78,7 +78,7 @@ export function getMultiPolygonExterior(
);
}

const geomOffsets: Int32Array = input.valueOffsets;
const geomOffsets: Int32Array = getValueOffsets(input);
const polygonData = ga.child.getMultiPolygonChild(input);
const polygonOffsets: Int32Array = polygonData.valueOffsets;
const lineStringData = ga.child.getPolygonChild(polygonData);
Expand Down
3 changes: 2 additions & 1 deletion packages/deck.gl-geoarrow/src/layers/scatterplot-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
convertStructToFixedSizeList,
extractAccessorsFromProps,
getGeometryData,
getValueOffsets,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
Expand Down Expand Up @@ -219,7 +220,7 @@ export class GeoArrowScatterplotLayer<
if (isGeomSeparate(pointData)) {
pointData = convertStructToFixedSizeList(pointData);
}
const geomOffsets = multiPointData.valueOffsets;
const geomOffsets = getValueOffsets(multiPointData);
const flatCoordsData = ga.child.getPointChild(pointData);
const flatCoordinateArray = flatCoordsData.values;

Expand Down
3 changes: 2 additions & 1 deletion packages/deck.gl-geoarrow/src/layers/solid-polygon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getInterleavedPolygon,
getMultiPolygonResolvedOffsets,
getPolygonResolvedOffsets,
getValueOffsets,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
Expand Down Expand Up @@ -553,7 +554,7 @@ export class GeoArrowSolidPolygonLayer<

const nDim = pointData.type.listSize;

const geomOffsets = multiPolygonData.valueOffsets;
const geomOffsets = getValueOffsets(multiPolygonData);
const flatCoordinateArray = coordData.values;

if (!this.state.triangles) {
Expand Down
3 changes: 2 additions & 1 deletion packages/deck.gl-geoarrow/src/layers/text-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
expandArrayToCoords,
extractAccessorsFromProps,
getGeometryData,
getValueOffsets,
isGeomSeparate,
} from "../utils/utils";
import { validateAccessors } from "../utils/validate";
Expand Down Expand Up @@ -206,7 +207,7 @@ export class GeoArrowTextLayer<

// console.log(textData);
const textValues = textData.values;
const characterOffsets = textData.valueOffsets;
const characterOffsets = getValueOffsets(textData);

const props: TextLayerProps = {
// Note: because this is a composite layer and not doing the rendering
Expand Down
3 changes: 2 additions & 1 deletion packages/deck.gl-geoarrow/src/layers/trips-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
extractAccessorsFromProps,
getGeometryData,
getInterleavedLineString,
getValueOffsets,
isGeomSeparate,
} from "../utils/utils";
import { validateAccessors } from "../utils/validate";
Expand Down Expand Up @@ -137,7 +138,7 @@ export class GeoArrowTripsLayer<
if (isGeomSeparate(lineStringData)) {
lineStringData = getInterleavedLineString(lineStringData);
}
const geomOffsets = lineStringData.valueOffsets;
const geomOffsets = getValueOffsets(lineStringData);
const pointData = ga.child.getLineStringChild(lineStringData);
const nDim = pointData.type.listSize;
const coordData = ga.child.getPointChild(pointData);
Expand Down
26 changes: 23 additions & 3 deletions packages/deck.gl-geoarrow/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ export function convertStructToFixedSizeList(
throw new Error(`Unsupported coordinate data type: ${coords.type}`);
}

/**
* Get the logical offsets buffer for a list- or Utf8-typed Data.
*
* Per the Arrow Columnar Format spec, IPC producers pad each buffer to a
* 64-byte boundary; `apache-arrow` JS exposes the offsets buffer at its
* on-wire byte length, so `data.valueOffsets.length` can exceed
* `data.length + 1` and the trailing entries are padding zeros that must not
* be read.
*
* Returns a zero-copy `subarray` view over the `data.length + 1` logical
* offsets — safe to iterate, index, and pass to `startIndices` /
* `invertOffsets` / `expandArrayToCoords`.
*/
export function getValueOffsets(data: {
readonly valueOffsets: Int32Array;
readonly length: number;
}): Int32Array {
return data.valueOffsets.subarray(0, data.length + 1);
}

/**
* Get LineString Data with interleaved coordinates
* from the given LineString Data with separated (struct) coordinates.
Expand Down Expand Up @@ -370,7 +390,7 @@ export function getListNestingLevels(data: arrow.Data): number {
export function getMultiLineStringResolvedOffsets(
data: ga.data.MultiLineStringData,
): Int32Array {
const geomOffsets = data.valueOffsets;
const geomOffsets = getValueOffsets(data);
const lineStringData = ga.child.getMultiLineStringChild(data);
const ringOffsets = lineStringData.valueOffsets;

Expand All @@ -387,7 +407,7 @@ export function getMultiLineStringResolvedOffsets(
export function getPolygonResolvedOffsets(
data: ga.data.PolygonData,
): Int32Array {
const geomOffsets = data.valueOffsets;
const geomOffsets = getValueOffsets(data);
const ringData = ga.child.getPolygonChild(data);
const ringOffsets = ringData.valueOffsets;

Expand All @@ -407,7 +427,7 @@ export function getMultiPolygonResolvedOffsets(
const polygonData = ga.child.getMultiPolygonChild(data);
const ringData = ga.child.getPolygonChild(polygonData);

const geomOffsets = data.valueOffsets;
const geomOffsets = getValueOffsets(data);
const polygonOffsets = polygonData.valueOffsets;
const ringOffsets = ringData.valueOffsets;

Expand Down