@@ -12,6 +12,7 @@ import { PathExt, URLExt } from '@jupyterlab/coreutils';
12
12
import { Contents , ServerConnection } from '@jupyterlab/services' ;
13
13
import { VectorTile } from '@mapbox/vector-tile' ;
14
14
import * as d3Color from 'd3-color' ;
15
+ import { compressors } from 'hyparquet-compressors' ;
15
16
import Protobuf from 'pbf' ;
16
17
import shp from 'shpjs' ;
17
18
@@ -567,6 +568,26 @@ export const loadFile = async (fileInfo: {
567
568
throw new Error ( `Failed to fetch ${ filepath } ` ) ;
568
569
}
569
570
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
+
570
591
default : {
571
592
throw new Error ( `Unsupported URL handling for source type: ${ type } ` ) ;
572
593
}
@@ -633,6 +654,18 @@ export const loadFile = async (fileInfo: {
633
654
}
634
655
}
635
656
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
+
636
669
default : {
637
670
throw new Error ( `Unsupported source type: ${ type } ` ) ;
638
671
}
0 commit comments