Skip to content
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

[fix] restore suport for string wkb; save binary wkb as hex wkb #2982

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@types/lodash.uniq": "^4.5.7",
"@types/styled-components": "^5.1.32",
"apache-arrow": ">=15.0.0",
"buffer": "6.0.3",
"d3-array": "^2.8.0",
"d3-shape": "^1.2.0",
"global": "^4.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/layers/src/geojson-layer/geojson-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

import {Buffer} from 'buffer';
import {Feature, Position, BBox} from 'geojson';
import normalize from '@mapbox/geojson-normalize';
import bbox from '@turf/bbox';
Expand Down
18 changes: 17 additions & 1 deletion src/utils/src/data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ export const defaultFormatter: FieldFormatter = v => (notNullorUndefined(v) ? St

export const floatFormatter = v => (isNumber(v) ? String(roundToFour(v)) : '');

/**
* Transforms a WKB in Uint8Array form into a hex WKB string.
* @param uint8Array WKB in Uint8Array form.
* @returns hex WKB string.
*/
export function uint8ArrayToHex(uint8Array: Uint8Array): string {
return Array.from(uint8Array)
.map(byte => (byte as any).toString(16).padStart(2, '0'))
.join('');
}

export const FIELD_DISPLAY_FORMAT: {
[key: string]: FieldFormatter;
} = {
Expand All @@ -301,7 +312,12 @@ export const FIELD_DISPLAY_FORMAT: {
: Array.isArray(d)
? `[${String(d)}]`
: '',
[ALL_FIELD_TYPES.geoarrow]: d => d,
[ALL_FIELD_TYPES.geoarrow]: d => {
if (d instanceof Uint8Array) {
return uint8ArrayToHex(d);
}
return d;
},
[ALL_FIELD_TYPES.object]: (value: any) => {
try {
return JSON.stringify(value);
Expand Down
21 changes: 11 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3481,6 +3481,7 @@ __metadata:
"@types/lodash.uniq": "npm:^4.5.7"
"@types/styled-components": "npm:^5.1.32"
apache-arrow: "npm:>=15.0.0"
buffer: "npm:6.0.3"
d3-array: "npm:^2.8.0"
d3-shape: "npm:^1.2.0"
global: "npm:^4.3.0"
Expand Down Expand Up @@ -12310,6 +12311,16 @@ __metadata:
languageName: node
linkType: hard

"buffer@npm:6.0.3, buffer@npm:^6.0.3":
version: 6.0.3
resolution: "buffer@npm:6.0.3"
dependencies:
base64-js: "npm:^1.3.1"
ieee754: "npm:^1.2.1"
checksum: 10c0/2a905fbbcde73cc5d8bd18d1caa23715d5f83a5935867c2329f0ac06104204ba7947be098fe1317fbd8830e26090ff8e764f08cd14fefc977bb248c3487bcbd0
languageName: node
linkType: hard

"buffer@npm:^4.3.0":
version: 4.9.2
resolution: "buffer@npm:4.9.2"
Expand All @@ -12331,16 +12342,6 @@ __metadata:
languageName: node
linkType: hard

"buffer@npm:^6.0.3":
version: 6.0.3
resolution: "buffer@npm:6.0.3"
dependencies:
base64-js: "npm:^1.3.1"
ieee754: "npm:^1.2.1"
checksum: 10c0/2a905fbbcde73cc5d8bd18d1caa23715d5f83a5935867c2329f0ac06104204ba7947be098fe1317fbd8830e26090ff8e764f08cd14fefc977bb248c3487bcbd0
languageName: node
linkType: hard

"buffer@npm:~5.2.1":
version: 5.2.1
resolution: "buffer@npm:5.2.1"
Expand Down
Loading