File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
src/layers/src/geojson-layer Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,28 @@ export function fieldIsGeoArrow(geoField?: ProtoDatasetField | null): boolean {
5555
5656export function parseGeoJsonRawFeature ( rawFeature : unknown ) : Feature | null {
5757 const properties = null ; // help ensure that properties is present on the returned geojson feature
58+ // Support WKB geometry provided as binary (e.g., from Parquet/GeoParquet)
59+ if ( rawFeature instanceof Uint8Array || rawFeature instanceof ArrayBuffer ) {
60+ try {
61+ const binaryInput =
62+ rawFeature instanceof ArrayBuffer
63+ ? rawFeature
64+ : ( rawFeature as Uint8Array ) . buffer . slice (
65+ ( rawFeature as Uint8Array ) . byteOffset ,
66+ ( rawFeature as Uint8Array ) . byteOffset + ( rawFeature as Uint8Array ) . byteLength
67+ ) ;
68+ const binaryGeo = parseSync ( binaryInput as ArrayBuffer , WKBLoader ) ;
69+ // @ts -expect-error loaders.gl binary type to GeoJSON geometry
70+ const parsedGeo = binaryToGeometry ( binaryGeo ) ;
71+ const normalized = normalize ( parsedGeo ) ;
72+ if ( ! normalized || ! Array . isArray ( normalized . features ) ) {
73+ return null ;
74+ }
75+ return { properties, ...normalized . features [ 0 ] } ;
76+ } catch ( e ) {
77+ return null ;
78+ }
79+ }
5880 if ( typeof rawFeature === 'object' ) {
5981 // Support GeoJson feature as object
6082 // probably need to normalize it as well
You can’t perform that action at this time.
0 commit comments