@@ -12,6 +12,7 @@ import { PathExt, URLExt } from '@jupyterlab/coreutils';
1212import { Contents , ServerConnection } from '@jupyterlab/services' ;
1313import { VectorTile } from '@mapbox/vector-tile' ;
1414import * as d3Color from 'd3-color' ;
15+ import { compressors } from 'hyparquet-compressors' ;
1516import Protobuf from 'pbf' ;
1617import shp from 'shpjs' ;
1718
@@ -567,6 +568,26 @@ export const loadFile = async (fileInfo: {
567568 throw new Error ( `Failed to fetch ${ filepath } ` ) ;
568569 }
569570
571+ case 'GeoParquetSource' : {
572+ const cached = await getFromIndexedDB ( filepath ) ;
573+ if ( cached ) {
574+ return cached . file ;
575+ }
576+
577+ const { asyncBufferFromUrl, toGeoJson } = await import ( 'geoparquet' ) ;
578+
579+ const file = await asyncBufferFromUrl ( { url : filepath } ) ;
580+ const geojson = await toGeoJson ( { file } ) ;
581+
582+ if ( geojson ) {
583+ await saveToIndexedDB ( filepath , geojson ) ;
584+ return geojson ;
585+ }
586+
587+ showErrorMessage ( 'Network error' , `Failed to fetch ${ filepath } ` ) ;
588+ throw new Error ( `Failed to fetch ${ filepath } ` ) ;
589+ }
590+
570591 default : {
571592 throw new Error ( `Unsupported URL handling for source type: ${ type } ` ) ;
572593 }
@@ -633,6 +654,18 @@ export const loadFile = async (fileInfo: {
633654 }
634655 }
635656
657+ case 'GeoParquetSource' : {
658+ if ( typeof file . content === 'string' ) {
659+ const { toGeoJson } = await import ( 'geoparquet' ) ;
660+
661+ const arrayBuffer = await stringToArrayBuffer ( file . content as string ) ;
662+
663+ return await toGeoJson ( { file : arrayBuffer , compressors } ) ;
664+ } else {
665+ throw new Error ( 'Invalid file format for GeoParquet content.' ) ;
666+ }
667+ }
668+
636669 default : {
637670 throw new Error ( `Unsupported source type: ${ type } ` ) ;
638671 }
0 commit comments