Skip to content

Commit c0ae426

Browse files
authored
fix: Restore DataFilterExtension functionality with vectorized accessor input (#977)
The existing code was no longer working after #912 because we're passing Arrow _`Vector`s_ into the accessor props instead of `arrow.Data` objects. This PR fixes that by selecting a specific record batch of data to pass into each layer. In geoarrow/deck.gl-layers#164 upstream, it should be easier to catch errors like this. Closes #955
1 parent 417831f commit c0ae426

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/model/base-layer.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
PickingInfo,
88
} from "@deck.gl/core";
99
import type { WidgetModel } from "@jupyter-widgets/base";
10+
import { Vector } from "apache-arrow";
1011

1112
import { BaseModel } from "./base.js";
1213
import { initializeExtension } from "./extension.js";
@@ -53,11 +54,16 @@ export abstract class BaseLayerModel extends BaseModel {
5354
.filter((extensionInstance) => extensionInstance !== null);
5455
}
5556

56-
extensionProps() {
57+
extensionProps(batchIndex?: number): Record<string, unknown> {
5758
const props: Record<string, unknown> = {};
5859
for (const layerPropertyName of this.extensionLayerPropertyNames) {
59-
if (isDefined(this[layerPropertyName as keyof this])) {
60-
props[layerPropertyName] = this[layerPropertyName as keyof this];
60+
const value = this[layerPropertyName as keyof this];
61+
if (isDefined(value)) {
62+
if (value instanceof Vector) {
63+
props[layerPropertyName] = value.data[batchIndex ?? 0];
64+
} else {
65+
props[layerPropertyName] = value;
66+
}
6167
}
6268
}
6369
// console.log("extension props", props);
@@ -71,10 +77,10 @@ export abstract class BaseLayerModel extends BaseModel {
7177
this.model.save_changes();
7278
}
7379

74-
baseLayerProps(): Omit<LayerProps, "id"> {
80+
baseLayerProps(batchIndex?: number): Omit<LayerProps, "id"> {
7581
return {
7682
extensions: this.extensionInstances(),
77-
...this.extensionProps(),
83+
...this.extensionProps(batchIndex),
7884
pickable: this.pickable,
7985
visible: this.visible,
8086
opacity: this.opacity,

src/model/layer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class ArcModel extends BaseArrowLayerModel {
156156
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
157157
layers.push(
158158
new GeoArrowArcLayer({
159-
...this.baseLayerProps(),
159+
...this.baseLayerProps(batchIdx),
160160
...this.layerProps(batchIdx),
161161
}),
162162
);
@@ -417,7 +417,7 @@ export class ColumnModel extends BaseArrowLayerModel {
417417
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
418418
layers.push(
419419
new GeoArrowColumnLayer({
420-
...this.baseLayerProps(),
420+
...this.baseLayerProps(batchIdx),
421421
...this.layerProps(batchIdx),
422422
}),
423423
);
@@ -491,7 +491,7 @@ export class HeatmapModel extends BaseArrowLayerModel {
491491
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
492492
layers.push(
493493
new GeoArrowHeatmapLayer({
494-
...this.baseLayerProps(),
494+
...this.baseLayerProps(batchIdx),
495495
...this.layerProps(batchIdx),
496496
}),
497497
);
@@ -561,7 +561,7 @@ export class PathModel extends BaseArrowLayerModel {
561561
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
562562
layers.push(
563563
new GeoArrowPathLayer({
564-
...this.baseLayerProps(),
564+
...this.baseLayerProps(batchIdx),
565565
...this.layerProps(batchIdx),
566566
}),
567567
);
@@ -610,7 +610,7 @@ export class PointCloudModel extends BaseArrowLayerModel {
610610
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
611611
layers.push(
612612
new GeoArrowPointCloudLayer({
613-
...this.baseLayerProps(),
613+
...this.baseLayerProps(batchIdx),
614614
...this.layerProps(batchIdx),
615615
}),
616616
);
@@ -715,7 +715,7 @@ export class PolygonModel extends BaseArrowLayerModel {
715715
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
716716
layers.push(
717717
new GeoArrowPolygonLayer({
718-
...this.baseLayerProps(),
718+
...this.baseLayerProps(batchIdx),
719719
...this.layerProps(batchIdx),
720720
}),
721721
);
@@ -827,7 +827,7 @@ export class ScatterplotModel extends BaseArrowLayerModel {
827827
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
828828
layers.push(
829829
new GeoArrowScatterplotLayer({
830-
...this.baseLayerProps(),
830+
...this.baseLayerProps(batchIdx),
831831
...this.layerProps(batchIdx),
832832
}),
833833
);
@@ -890,7 +890,7 @@ export class SolidPolygonModel extends BaseArrowLayerModel {
890890
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
891891
layers.push(
892892
new GeoArrowSolidPolygonLayer({
893-
...this.baseLayerProps(),
893+
...this.baseLayerProps(batchIdx),
894894
...this.layerProps(batchIdx),
895895
}),
896896
);
@@ -1159,7 +1159,7 @@ export class TextModel extends BaseArrowLayerModel {
11591159
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
11601160
layers.push(
11611161
new GeoArrowTextLayer({
1162-
...this.baseLayerProps(),
1162+
...this.baseLayerProps(batchIdx),
11631163
...this.layerProps(batchIdx),
11641164
}),
11651165
);
@@ -1242,7 +1242,7 @@ export class TripsModel extends BaseArrowLayerModel {
12421242
for (let batchIdx = 0; batchIdx < this.table.batches.length; batchIdx++) {
12431243
layers.push(
12441244
new GeoArrowTripsLayer({
1245-
...this.baseLayerProps(),
1245+
...this.baseLayerProps(batchIdx),
12461246
...this.layerProps(batchIdx),
12471247
}),
12481248
);

0 commit comments

Comments
 (0)