Skip to content

Commit 49cc227

Browse files
authored
Fix setting defaultProps (#74)
* Fix setting defaultProps * bump version
1 parent eb157f1 commit 49cc227

10 files changed

+115
-99
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"examples/*"
55
],
66
"name": "@geoarrow/deck.gl-layers",
7-
"version": "0.3.0-beta.4",
7+
"version": "0.3.0-beta.5",
88
"type": "module",
99
"description": "",
1010
"source": "src/index.ts",

src/arc-layer.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ export class GeoArrowArcLayer<
132132
validatePointType(targetPosition.type);
133133
}
134134

135+
// Exclude manually-set accessors
136+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
137+
"getSourcePosition",
138+
"getTargetPosition",
139+
]);
140+
135141
const layers: ArcLayer[] = [];
136142
for (
137143
let recordBatchIdx = 0;
@@ -143,13 +149,11 @@ export class GeoArrowArcLayer<
143149
const targetData = targetPosition.data[recordBatchIdx];
144150
const targetValues = getPointChild(targetData).values;
145151

146-
// Exclude manually-set accessors
147-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
148-
"getSourcePosition",
149-
"getTargetPosition",
150-
]);
151-
152152
const props: ArcLayerProps = {
153+
// Note: because this is a composite layer and not doing the rendering
154+
// itself, we still have to pass in defaultProps as the default in this
155+
// props object
156+
...defaultProps,
153157
...otherProps,
154158

155159
// @ts-expect-error used for picking purposes

src/column-layer.ts

+20-44
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { ColumnLayerProps } from "@deck.gl/layers/typed";
1111
import * as arrow from "apache-arrow";
1212
import {
1313
assignAccessor,
14+
extractAccessorsFromProps,
1415
getGeometryVector,
1516
getPointChild,
1617
isPointVector,
@@ -133,6 +134,11 @@ export class GeoArrowColumnLayer<
133134
validateAccessors(this.props, table);
134135
}
135136

137+
// Exclude manually-set accessors
138+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
139+
"getPosition",
140+
]);
141+
136142
const layers: ColumnLayer[] = [];
137143
for (
138144
let recordBatchIdx = 0;
@@ -144,30 +150,16 @@ export class GeoArrowColumnLayer<
144150
const flatCoordinateArray = flatCoordsData.values;
145151

146152
const props: ColumnLayerProps = {
153+
// Note: because this is a composite layer and not doing the rendering
154+
// itself, we still have to pass in defaultProps as the default in this
155+
// props object
156+
...defaultProps,
157+
...otherProps,
158+
147159
// @ts-expect-error used for picking purposes
148160
recordBatchIdx,
149161

150162
id: `${this.props.id}-geoarrow-column-${recordBatchIdx}`,
151-
152-
diskResolution: this.props.diskResolution,
153-
radius: this.props.radius,
154-
angle: this.props.angle,
155-
vertices: this.props.vertices,
156-
offset: this.props.offset,
157-
coverage: this.props.coverage,
158-
elevationScale: this.props.elevationScale,
159-
filled: this.props.filled,
160-
stroked: this.props.stroked,
161-
extruded: this.props.extruded,
162-
wireframe: this.props.wireframe,
163-
flatShading: this.props.flatShading,
164-
radiusUnits: this.props.radiusUnits,
165-
lineWidthUnits: this.props.lineWidthUnits,
166-
lineWidthScale: this.props.lineWidthScale,
167-
lineWidthMinPixels: this.props.lineWidthMinPixels,
168-
lineWidthMaxPixels: this.props.lineWidthMaxPixels,
169-
material: this.props.material,
170-
171163
data: {
172164
length: geometryData.length,
173165
attributes: {
@@ -179,30 +171,14 @@ export class GeoArrowColumnLayer<
179171
},
180172
};
181173

182-
assignAccessor({
183-
props,
184-
propName: "getFillColor",
185-
propInput: this.props.getFillColor,
186-
chunkIdx: recordBatchIdx,
187-
});
188-
assignAccessor({
189-
props,
190-
propName: "getLineColor",
191-
propInput: this.props.getLineColor,
192-
chunkIdx: recordBatchIdx,
193-
});
194-
assignAccessor({
195-
props,
196-
propName: "getElevation",
197-
propInput: this.props.getElevation,
198-
chunkIdx: recordBatchIdx,
199-
});
200-
assignAccessor({
201-
props,
202-
propName: "getLineWidth",
203-
propInput: this.props.getLineWidth,
204-
chunkIdx: recordBatchIdx,
205-
});
174+
for (const [propName, propInput] of Object.entries(accessors)) {
175+
assignAccessor({
176+
props,
177+
propName,
178+
propInput,
179+
chunkIdx: recordBatchIdx,
180+
});
181+
}
206182

207183
const layer = new ColumnLayer(this.getSubLayerProps(props));
208184
layers.push(layer);

src/h3-hexagon-layer.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class GeoArrowH3HexagonLayer<
7171
validateAccessors(this.props, table);
7272
}
7373

74+
// Exclude manually-set accessors
75+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
76+
"getHexagon",
77+
]);
78+
7479
const layers: H3HexagonLayer[] = [];
7580
for (
7681
let recordBatchIdx = 0;
@@ -80,12 +85,11 @@ export class GeoArrowH3HexagonLayer<
8085
const hexData = hexagonColumn.data[recordBatchIdx];
8186
const hexValues = hexData.values;
8287

83-
// Exclude manually-set accessors
84-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
85-
"getHexagon",
86-
]);
87-
8888
const props: H3HexagonLayerProps = {
89+
// Note: because this is a composite layer and not doing the rendering
90+
// itself, we still have to pass in defaultProps as the default in this
91+
// props object
92+
...defaultProps,
8993
...otherProps,
9094

9195
// @ts-expect-error used for picking purposes

src/heatmap-layer.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ export class GeoArrowHeatmapLayer<
9696
validateAccessors(this.props, table);
9797
}
9898

99+
// Exclude manually-set accessors
100+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
101+
"getPosition",
102+
]);
103+
99104
const layers: HeatmapLayer[] = [];
100105
for (
101106
let recordBatchIdx = 0;
@@ -106,12 +111,11 @@ export class GeoArrowHeatmapLayer<
106111
const flatCoordsData = getPointChild(geometryData);
107112
const flatCoordinateArray = flatCoordsData.values;
108113

109-
// Exclude manually-set accessors
110-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
111-
"getPosition",
112-
]);
113-
114114
const props: HeatmapLayerProps = {
115+
// Note: because this is a composite layer and not doing the rendering
116+
// itself, we still have to pass in defaultProps as the default in this
117+
// props object
118+
...defaultProps,
115119
...otherProps,
116120

117121
// @ts-expect-error used for picking purposes

src/path-layer.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ export class GeoArrowPathLayer<
143143
validateAccessors(this.props, table);
144144
}
145145

146+
// Exclude manually-set accessors
147+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
148+
"getPath",
149+
]);
150+
146151
const layers: PathLayer[] = [];
147152
for (
148153
let recordBatchIdx = 0;
@@ -156,12 +161,11 @@ export class GeoArrowPathLayer<
156161
const coordData = getPointChild(pointData);
157162
const flatCoordinateArray = coordData.values;
158163

159-
// Exclude manually-set accessors
160-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
161-
"getPath",
162-
]);
163-
164164
const props: PathLayerProps = {
165+
// Note: because this is a composite layer and not doing the rendering
166+
// itself, we still have to pass in defaultProps as the default in this
167+
// props object
168+
...defaultProps,
165169
...otherProps,
166170

167171
// used for picking purposes
@@ -207,6 +211,11 @@ export class GeoArrowPathLayer<
207211
validateAccessors(this.props, table);
208212
}
209213

214+
// Exclude manually-set accessors
215+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
216+
"getPath",
217+
]);
218+
210219
const layers: PathLayer[] = [];
211220
for (
212221
let recordBatchIdx = 0;
@@ -226,12 +235,11 @@ export class GeoArrowPathLayer<
226235
const multiLineStringToCoordOffsets =
227236
getMultiLineStringResolvedOffsets(multiLineStringData);
228237

229-
// Exclude manually-set accessors
230-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
231-
"getPath",
232-
]);
233-
234238
const props: PathLayerProps = {
239+
// Note: because this is a composite layer and not doing the rendering
240+
// itself, we still have to pass in defaultProps as the default in this
241+
// props object
242+
...defaultProps,
235243
...otherProps,
236244

237245
// used for picking purposes

src/scatterplot-layer.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ export class GeoArrowScatterplotLayer<
139139
validateAccessors(this.props, table);
140140
}
141141

142+
// Exclude manually-set accessors
143+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
144+
"getPosition",
145+
]);
146+
142147
const layers: ScatterplotLayer[] = [];
143148
for (
144149
let recordBatchIdx = 0;
@@ -149,12 +154,11 @@ export class GeoArrowScatterplotLayer<
149154
const flatCoordsData = getPointChild(geometryData);
150155
const flatCoordinateArray = flatCoordsData.values;
151156

152-
// Exclude manually-set accessors
153-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
154-
"getPosition",
155-
]);
156-
157157
const props: ScatterplotLayerProps = {
158+
// Note: because this is a composite layer and not doing the rendering
159+
// itself, we still have to pass in defaultProps as the default in this
160+
// props object
161+
...defaultProps,
158162
...otherProps,
159163

160164
// @ts-expect-error used for picking purposes
@@ -200,6 +204,11 @@ export class GeoArrowScatterplotLayer<
200204
validateAccessors(this.props, table);
201205
}
202206

207+
// Exclude manually-set accessors
208+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
209+
"getPosition",
210+
]);
211+
203212
const layers: ScatterplotLayer[] = [];
204213
for (
205214
let recordBatchIdx = 0;
@@ -212,12 +221,11 @@ export class GeoArrowScatterplotLayer<
212221
const flatCoordsData = getPointChild(pointData);
213222
const flatCoordinateArray = flatCoordsData.values;
214223

215-
// Exclude manually-set accessors
216-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
217-
"getPosition",
218-
]);
219-
220224
const props: ScatterplotLayerProps = {
225+
// Note: because this is a composite layer and not doing the rendering
226+
// itself, we still have to pass in defaultProps as the default in this
227+
// props object
228+
...defaultProps,
221229
...otherProps,
222230

223231
// @ts-expect-error used for picking purposes

src/solid-polygon-layer.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ export class GeoArrowSolidPolygonLayer<
142142
validateAccessors(this.props, table);
143143
}
144144

145+
// Exclude manually-set accessors
146+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
147+
"getPolygon",
148+
]);
149+
145150
const layers: SolidPolygonLayer[] = [];
146151
for (
147152
let recordBatchIdx = 0;
@@ -163,12 +168,11 @@ export class GeoArrowSolidPolygonLayer<
163168

164169
const earcutTriangles = earcutPolygonArray(polygonData);
165170

166-
// Exclude manually-set accessors
167-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
168-
"getPolygon",
169-
]);
170-
171171
const props: SolidPolygonLayerProps = {
172+
// Note: because this is a composite layer and not doing the rendering
173+
// itself, we still have to pass in defaultProps as the default in this
174+
// props object
175+
...defaultProps,
172176
...otherProps,
173177

174178
// used for picking purposes
@@ -215,6 +219,11 @@ export class GeoArrowSolidPolygonLayer<
215219
validateAccessors(this.props, table);
216220
}
217221

222+
// Exclude manually-set accessors
223+
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
224+
"getPolygon",
225+
]);
226+
218227
const layers: SolidPolygonLayer[] = [];
219228
for (
220229
let recordBatchIdx = 0;
@@ -250,12 +259,11 @@ export class GeoArrowSolidPolygonLayer<
250259
const resolvedMultiPolygonToCoordOffsets =
251260
getMultiPolygonResolvedOffsets(multiPolygonData);
252261

253-
// Exclude manually-set accessors
254-
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
255-
"getPolygon",
256-
]);
257-
258262
const props: SolidPolygonLayerProps = {
263+
// Note: because this is a composite layer and not doing the rendering
264+
// itself, we still have to pass in defaultProps as the default in this
265+
// props object
266+
...defaultProps,
259267
...otherProps,
260268

261269
// used for picking purposes

0 commit comments

Comments
 (0)