Skip to content

Support separated (struct) coordinates for all applicable layers #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 11, 2025
Merged
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
17 changes: 14 additions & 3 deletions src/layers/arc-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { ArcLayer } from "@deck.gl/layers";
import type { ArcLayerProps } from "@deck.gl/layers";
import * as arrow from "apache-arrow";
import * as ga from "@geoarrow/geoarrow-js";
import { assignAccessor, extractAccessorsFromProps } from "../utils/utils";
import {
assignAccessor,
convertStructToFixedSizeList,
extractAccessorsFromProps,
isGeomSeparate,
} from "../utils/utils";
import { child } from "@geoarrow/geoarrow-js";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -157,9 +162,15 @@ export class GeoArrowArcLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const sourceData = sourcePosition.data[recordBatchIdx];
let sourceData = sourcePosition.data[recordBatchIdx];
if (isGeomSeparate(sourceData)) {
sourceData = convertStructToFixedSizeList(sourceData);
}
const sourceValues = child.getPointChild(sourceData).values;
const targetData = targetPosition.data[recordBatchIdx];
let targetData = targetPosition.data[recordBatchIdx];
if (isGeomSeparate(targetData)) {
targetData = convertStructToFixedSizeList(targetData);
}
const targetValues = child.getPointChild(targetData).values;

const props: ArcLayerProps = {
Expand Down
7 changes: 6 additions & 1 deletion src/layers/column-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import type { ColumnLayerProps } from "@deck.gl/layers";
import * as arrow from "apache-arrow";
import {
assignAccessor,
convertStructToFixedSizeList,
extractAccessorsFromProps,
getGeometryVector,
isGeomSeparate,
} from "../utils/utils";
import * as ga from "@geoarrow/geoarrow-js";
import { ColorAccessor, FloatAccessor, GeoArrowPickingInfo } from "../types";
Expand Down Expand Up @@ -161,7 +163,10 @@ export class GeoArrowColumnLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const geometryData = geometryColumn.data[recordBatchIdx];
let geometryData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(geometryData)) {
geometryData = convertStructToFixedSizeList(geometryData);
}
const flatCoordsData = ga.child.getPointChild(geometryData);
const flatCoordinateArray = flatCoordsData.values;

Expand Down
7 changes: 6 additions & 1 deletion src/layers/heatmap-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import * as arrow from "apache-arrow";
import * as ga from "@geoarrow/geoarrow-js";
import {
assignAccessor,
convertStructToFixedSizeList,
extractAccessorsFromProps,
getGeometryVector,
isGeomSeparate,
} from "../utils/utils";
import { FloatAccessor } from "../types";
import { EXTENSION_NAME } from "../constants";
Expand Down Expand Up @@ -128,7 +130,10 @@ export class GeoArrowHeatmapLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const geometryData = geometryColumn.data[recordBatchIdx];
let geometryData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(geometryData)) {
geometryData = convertStructToFixedSizeList(geometryData);
}
const flatCoordsData = ga.child.getPointChild(geometryData);
const flatCoordinateArray = flatCoordsData.values;

Expand Down
12 changes: 10 additions & 2 deletions src/layers/path-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import {
assignAccessor,
extractAccessorsFromProps,
getGeometryVector,
getInterleavedLineString,
getMultiLineStringResolvedOffsets,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -172,7 +174,10 @@ export class GeoArrowPathLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const lineStringData = geometryColumn.data[recordBatchIdx];
let lineStringData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(lineStringData)) {
lineStringData = getInterleavedLineString(lineStringData);
}
const geomOffsets = lineStringData.valueOffsets;
const pointData = ga.child.getLineStringChild(lineStringData);
const nDim = pointData.type.listSize;
Expand Down Expand Up @@ -243,8 +248,11 @@ export class GeoArrowPathLayer<
recordBatchIdx++
) {
const multiLineStringData = geometryColumn.data[recordBatchIdx];
const lineStringData =
let lineStringData =
ga.child.getMultiLineStringChild(multiLineStringData);
if (isGeomSeparate(lineStringData)) {
lineStringData = getInterleavedLineString(lineStringData);
}
const pointData = ga.child.getLineStringChild(lineStringData);
const coordData = ga.child.getPointChild(pointData);

Expand Down
7 changes: 6 additions & 1 deletion src/layers/point-cloud-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import * as arrow from "apache-arrow";
import * as ga from "@geoarrow/geoarrow-js";
import {
assignAccessor,
convertStructToFixedSizeList,
extractAccessorsFromProps,
getGeometryVector,
isGeomSeparate,
} from "../utils/utils";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -156,7 +158,10 @@ export class GeoArrowPointCloudLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const geometryData = geometryColumn.data[recordBatchIdx];
let geometryData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(geometryData)) {
geometryData = convertStructToFixedSizeList(geometryData);
}
const flatCoordsData = ga.child.getPointChild(geometryData);
const flatCoordinateArray = flatCoordsData.values;

Expand Down
12 changes: 10 additions & 2 deletions src/layers/scatterplot-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import * as arrow from "apache-arrow";
import * as ga from "@geoarrow/geoarrow-js";
import {
assignAccessor,
convertStructToFixedSizeList,
extractAccessorsFromProps,
getGeometryVector,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -169,7 +171,10 @@ export class GeoArrowScatterplotLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const geometryData = geometryColumn.data[recordBatchIdx];
let geometryData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(geometryData)) {
geometryData = convertStructToFixedSizeList(geometryData);
}
const flatCoordsData = ga.child.getPointChild(geometryData);
const flatCoordinateArray = flatCoordsData.values;

Expand Down Expand Up @@ -238,7 +243,10 @@ export class GeoArrowScatterplotLayer<
recordBatchIdx++
) {
const multiPointData = geometryColumn.data[recordBatchIdx];
const pointData = ga.child.getMultiPointChild(multiPointData);
let pointData = ga.child.getMultiPointChild(multiPointData);
if (isGeomSeparate(pointData)) {
pointData = convertStructToFixedSizeList(pointData);
}
const geomOffsets = multiPointData.valueOffsets;
const flatCoordsData = ga.child.getPointChild(pointData);
const flatCoordinateArray = flatCoordsData.values;
Expand Down
40 changes: 34 additions & 6 deletions src/layers/solid-polygon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import {
assignAccessor,
extractAccessorsFromProps,
getGeometryVector,
getInterleavedPolygon,
getMultiPolygonResolvedOffsets,
getPolygonResolvedOffsets,
invertOffsets,
isGeomSeparate,
} from "../utils/utils";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -249,7 +251,12 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx < geometryColumn.data.length;
recordBatchIdx++
) {
const polygonData = geometryColumn.data[recordBatchIdx];
let polygonData = geometryColumn.data[recordBatchIdx];
// TODO: Note here that [when applicable] we do this conversion twice -
// one for triangulation (earcut) here and the other for rendering later.
if (isGeomSeparate(polygonData)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's just add a comment here, saying

TODO: Note here that we do this conversion twice - one for triangulation (earcut) and the other for rendering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

polygonData = getInterleavedPolygon(polygonData);
}
const [preparedPolygonData, arrayBuffers] = ga.worker.preparePostMessage(
polygonData,
true,
Expand Down Expand Up @@ -278,7 +285,12 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx < geometryColumn.data.length;
recordBatchIdx++
) {
const polygonData = geometryColumn.data[recordBatchIdx];
let polygonData = geometryColumn.data[recordBatchIdx];
// TODO: Note here that [when applicable] we do this conversion twice -
// one for triangulation (earcut) here and the other for rendering later.
if (isGeomSeparate(polygonData)) {
polygonData = getInterleavedPolygon(polygonData);
}
result[recordBatchIdx] = ga.algorithm.earcut(polygonData);
}

Expand All @@ -303,7 +315,12 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx++
) {
const multiPolygonData = geometryColumn.data[recordBatchIdx];
const polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
let polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
// TODO: Note here that [when applicable] we do this conversion twice -
// one for triangulation (earcut) here and the other for rendering later.
if (isGeomSeparate(polygonData)) {
polygonData = getInterleavedPolygon(polygonData);
}
const [preparedPolygonData, arrayBuffers] = ga.worker.preparePostMessage(
polygonData,
true,
Expand Down Expand Up @@ -333,7 +350,12 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx++
) {
const multiPolygonData = geometryColumn.data[recordBatchIdx];
const polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
let polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
// TODO: Note here that [when applicable] we do this conversion twice -
// one for triangulation (earcut) here and the other for rendering later.
if (isGeomSeparate(polygonData)) {
polygonData = getInterleavedPolygon(polygonData);
}
result[recordBatchIdx] = ga.algorithm.earcut(polygonData);
}

Expand Down Expand Up @@ -417,7 +439,10 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const polygonData = geometryColumn.data[recordBatchIdx];
let polygonData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(polygonData)) {
polygonData = getInterleavedPolygon(polygonData);
}
const ringData = ga.child.getPolygonChild(polygonData);
const pointData = ga.child.getLineStringChild(ringData);
const coordData = ga.child.getPointChild(pointData);
Expand Down Expand Up @@ -499,7 +524,10 @@ export class GeoArrowSolidPolygonLayer<
recordBatchIdx++
) {
const multiPolygonData = geometryColumn.data[recordBatchIdx];
const polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
let polygonData = ga.child.getMultiPolygonChild(multiPolygonData);
if (isGeomSeparate(polygonData)) {
polygonData = getInterleavedPolygon(polygonData);
}
const ringData = ga.child.getPolygonChild(polygonData);
const pointData = ga.child.getLineStringChild(ringData);
const coordData = ga.child.getPointChild(pointData);
Expand Down
7 changes: 6 additions & 1 deletion src/layers/text-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import * as arrow from "apache-arrow";
import * as ga from "@geoarrow/geoarrow-js";
import {
assignAccessor,
convertStructToFixedSizeList,
expandArrayToCoords,
extractAccessorsFromProps,
getGeometryVector,
isGeomSeparate,
} from "../utils/utils";
import {
GeoArrowExtraPickingProps,
Expand Down Expand Up @@ -207,7 +209,10 @@ export class GeoArrowTextLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const geometryData = geometryColumn.data[recordBatchIdx];
let geometryData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(geometryData)) {
geometryData = convertStructToFixedSizeList(geometryData);
}
const flatCoordsData = ga.child.getPointChild(geometryData);
const flatCoordinateArray = flatCoordsData.values;
const textData = this.props.getText.data[recordBatchIdx];
Expand Down
7 changes: 6 additions & 1 deletion src/layers/trips-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
assignAccessor,
extractAccessorsFromProps,
getGeometryVector,
getInterleavedLineString,
isGeomSeparate,
} from "../utils/utils";
import { TimestampAccessor, ColorAccessor, FloatAccessor } from "../types";
import {
Expand Down Expand Up @@ -146,7 +148,10 @@ export class GeoArrowTripsLayer<
recordBatchIdx < table.batches.length;
recordBatchIdx++
) {
const lineStringData = geometryColumn.data[recordBatchIdx];
let lineStringData = geometryColumn.data[recordBatchIdx];
if (isGeomSeparate(lineStringData)) {
lineStringData = getInterleavedLineString(lineStringData);
}
const geomOffsets = lineStringData.valueOffsets;
const pointData = ga.child.getLineStringChild(lineStringData);
const nDim = pointData.type.listSize;
Expand Down
Loading