File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ window.initMap = async function loadGeoParquet() {
1717
1818 try {
1919 // Read the GeoParquet file and convert to GeoJSON
20- const asyncBuffer = await asyncBufferFromUrl ( { url : parquetUrl } )
21- const geojson = await toGeoJson ( asyncBuffer )
20+ const file = await asyncBufferFromUrl ( { url : parquetUrl } )
21+ const geojson = await toGeoJson ( { file } )
2222
2323 console . log ( 'GeoJSON:' , geojson )
2424
Original file line number Diff line number Diff line change @@ -8,11 +8,12 @@ import { decodeWKB } from './wkb.js'
88 *
99 * @import { AsyncBuffer } from 'hyparquet'
1010 * @import { Feature, GeoJSON } from './geojson.js'
11- * @param {AsyncBuffer } asyncBuffer
11+ * @param {Object } options
12+ * @param {AsyncBuffer } options.file
1213 * @returns {Promise<GeoJSON> }
1314 */
14- export async function toGeoJson ( asyncBuffer ) {
15- const metadata = await parquetMetadataAsync ( asyncBuffer )
15+ export async function toGeoJson ( { file } ) {
16+ const metadata = await parquetMetadataAsync ( file )
1617 const geoMetadata = metadata . key_value_metadata ?. find ( kv => kv . key === 'geo' )
1718 if ( ! geoMetadata ) {
1819 throw new Error ( 'Invalid GeoParquet file: missing "geo" metadata' )
@@ -22,7 +23,7 @@ export async function toGeoJson(asyncBuffer) {
2223 const geoSchema = JSON . parse ( geoMetadata . value || '{}' )
2324
2425 // Read all parquet data
25- const data = await parquetQuery ( { file : asyncBuffer , utf8 : false } )
26+ const data = await parquetQuery ( { file, utf8 : false } )
2627
2728 /** @type {Feature[] } */
2829 const features = [ ]
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ import polys from '../examples/polys.json' with { type: 'json' }
66
77describe ( 'toGeoJson' , ( ) => {
88 it ( 'should parse example.parquet' , async ( ) => {
9- const asyncBuffer = await asyncBufferFromFile ( 'examples/example.parquet' )
10- const geojson = await toGeoJson ( asyncBuffer )
9+ const file = await asyncBufferFromFile ( 'examples/example.parquet' )
10+ const geojson = await toGeoJson ( { file } )
1111 expect ( geojson ) . toEqual ( example )
1212 } )
1313
1414 it ( 'should parse polys.parquet' , async ( ) => {
15- const asyncBuffer = await asyncBufferFromFile ( 'examples/polys.parquet' )
16- const geojson = await toGeoJson ( asyncBuffer )
15+ const file = await asyncBufferFromFile ( 'examples/polys.parquet' )
16+ const geojson = await toGeoJson ( { file } )
1717 expect ( geojson ) . toEqual ( polys )
1818 } )
1919} )
You can’t perform that action at this time.
0 commit comments