Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[fix] restore suport for string wkb; save binary wkb as hex wkb (#2982)
Igor Dykhta2c525ed8e7dd
diff --git a/src/layers/package.json b/src/layers/package.jsonindex f64f23b39..f1af1afc3 100644--- a/src/layers/package.json+++ b/src/layers/package.json@@ -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",diff --git a/src/layers/src/geojson-layer/geojson-utils.ts b/src/layers/src/geojson-layer/geojson-utils.tsindex ad7e83399..36304e48a 100644--- a/src/layers/src/geojson-layer/geojson-utils.ts+++ b/src/layers/src/geojson-layer/geojson-utils.ts@@ -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';diff --git a/src/utils/src/data-utils.ts b/src/utils/src/data-utils.tsindex cbab193ff..d7919e49a 100644--- a/src/utils/src/data-utils.ts+++ b/src/utils/src/data-utils.ts@@ -284,6 +284,17 @@ export const defaultFormatter: FieldFormatter = v => (notNullorUndefined(v) ? Stexport 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(data: Uint8Array): string {+ return Array.from(data)+ .map(byte => (byte as any).toString(16).padStart(2, '0'))+ .join('');+}+export const FIELD_DISPLAY_FORMAT: {[key: string]: FieldFormatter;} = {@@ -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);diff --git a/src/utils/src/indexed-data-container.ts b/src/utils/src/indexed-data-container.tsindex 44b9205f5..cdccefc78 100644--- a/src/utils/src/indexed-data-container.ts+++ b/src/utils/src/indexed-data-container.ts@@ -123,7 +123,7 @@ export class IndexedDataContainer implements DataContainerInterface {}mapIndex<T>(- func: ({index: number}, dc: DataContainerInterface) => T,+ func: ({index}: {index: number}, dc: DataContainerInterface) => T,options: RangeOptions = {}): T[] {const {start = 0, end = this.numRows()} = options;diff --git a/yarn.lock b/yarn.lockindex 0d12b1ba2..63ad79190 100644--- a/yarn.lock+++ b/yarn.lock@@ -3445,6 +3445,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"@@ -12282,6 +12283,16 @@ __metadata:languageName: nodelinkType: 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.2resolution: "buffer@npm:4.9.2"@@ -12303,16 +12314,6 @@ __metadata:languageName: nodelinkType: 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.1resolution: "buffer@npm:5.2.1"