Skip to content

Commit dd7013e

Browse files
authored
fix: H3HexagonLayer fixes (#159)
* fix: H3HexagonLayer fixes * Bump to 0.4.0-beta.3 * lock
1 parent fa12806 commit dd7013e

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/deck.gl-layers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@geoarrow/deck.gl-layers",
3-
"version": "0.4.0-beta.2",
3+
"version": "0.4.0-beta.3",
44
"type": "module",
55
"description": "",
66
"source": "src/index.ts",

packages/deck.gl-layers/src/layers/h3-hexagon-layer.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import { validateAccessors } from "../utils/validate";
2222
/** All properties supported by GeoArrowH3HexagonLayer */
2323
export type GeoArrowH3HexagonLayerProps = Omit<
2424
H3HexagonLayerProps,
25-
"data" | "getHexagon"
25+
| "data"
26+
| "getHexagon"
27+
| "getFillColor"
28+
| "getLineColor"
29+
| "getLineWidth"
30+
| "getElevation"
2631
> &
2732
_GeoArrowH3HexagonLayerProps &
2833
// Omit<GeoArrowPolygonLayerProps, "getPolygon"> &
@@ -35,7 +40,7 @@ type _GeoArrowH3HexagonLayerProps = {
3540
/**
3641
* Called for each data object to retrieve the quadkey string identifier.
3742
*/
38-
getHexagon: arrow.Data<arrow.Utf8>;
43+
getHexagon: arrow.Data<arrow.Utf8 | arrow.Uint64>;
3944

4045
/** Fill color accessor.
4146
* @default [0, 0, 0, 255]
@@ -103,10 +108,10 @@ export class GeoArrowH3HexagonLayer<
103108
}
104109

105110
renderLayers(): Layer<{}> | LayersList | null {
106-
return this._renderLayersPoint();
111+
return this._renderLayer();
107112
}
108113

109-
_renderLayersPoint(): Layer<{}> | LayersList | null {
114+
_renderLayer(): Layer<{}> | LayersList | null {
110115
const { data: batch, getHexagon: hexData } = this.props;
111116

112117
if (this.props._validate) {
@@ -117,6 +122,7 @@ export class GeoArrowH3HexagonLayer<
117122
const [accessors, otherProps] = extractAccessorsFromProps(this.props, [
118123
"getHexagon",
119124
]);
125+
const hexVector = new arrow.Vector([hexData]);
120126

121127
const props: H3HexagonLayerProps = {
122128
// Note: because this is a composite layer and not doing the rendering
@@ -130,13 +136,15 @@ export class GeoArrowH3HexagonLayer<
130136
// @ts-expect-error passed through to enable use by function accessors
131137
data: batch,
132138
length: hexData.length,
133-
attributes: {
134-
getHexagon: {
135-
value: hexData.values,
136-
// h3 cells should always be 15 characters
137-
size: 15,
138-
},
139-
},
139+
},
140+
// Unfortunately we must load back to pure JS strings
141+
getHexagon: (_, objectInfo) => {
142+
const value = hexVector.get(objectInfo.index)!;
143+
if (typeof value === "string") {
144+
return value;
145+
} else {
146+
return value.toString(16);
147+
}
140148
},
141149
};
142150

0 commit comments

Comments
 (0)