@loaders.gl/core 5.0.0-beta.4 → 5.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GEOARROW-README.md +1 -1
- package/README.md +1 -1
- package/SCAN-README.md +1 -1
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.js +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +3 -3
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.js +2 -2
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +6 -6
- package/dist/arrow-geometry/geometry-codecs.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-codecs.js +1 -1
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.cjs +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.js +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.js.map +1 -1
- package/dist/arrow-geometry/index.cjs +0 -11
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +0 -1
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +0 -1
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/wkb-builder.cjs +3 -3
- package/dist/arrow-geometry/wkb-builder.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-builder.d.ts +1 -1
- package/dist/arrow-geometry/wkb-builder.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-builder.js +1 -1
- package/dist/arrow-geometry/wkb-builder.js.map +1 -1
- package/dist/arrow-geometry/wkb-statistics.cjs +2 -2
- package/dist/arrow-geometry/wkb-statistics.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-statistics.js +1 -1
- package/dist/arrow-geometry/wkb-statistics.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +81 -0
- package/dist/arrow-worker-transport.cjs.map +6 -0
- package/dist/arrow-worker-transport.d.ts +9 -0
- package/dist/arrow-worker-transport.d.ts.map +1 -0
- package/dist/arrow-worker-transport.js +60 -0
- package/dist/arrow-worker-transport.js.map +1 -0
- package/dist/cluster-source.cjs +153 -584
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +546 -54
- package/dist/dist.min.js +3 -3
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-bounds.cjs +7 -7
- package/dist/geoarrow/geoarrow-bounds.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-bounds.js +3 -3
- package/dist/geoarrow/geoarrow-bounds.js.map +1 -1
- package/dist/geoarrow/geoarrow-capabilities.cjs +2 -2
- package/dist/geoarrow/geoarrow-capabilities.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-capabilities.js +1 -1
- package/dist/geoarrow/geoarrow-capabilities.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +8 -8
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-inspection.js +1 -1
- package/dist/geoarrow/geoarrow-inspection.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.js +1 -1
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.js +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs +4 -4
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -3
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs +3 -3
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js.map +1 -1
- package/dist/index.cjs +8 -11
- package/dist/index.cjs.map +3 -3
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +20 -23
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +244 -11
- package/dist/null-worker.js +239 -11
- package/dist/schema/geometry/geoarrow.d.ts +3 -6
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/worker-utils/index.cjs +19 -26
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/index.d.ts +0 -3
- package/dist/worker-utils/index.d.ts.map +1 -1
- package/dist/worker-utils/index.js +0 -3
- package/dist/worker-utils/index.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.js +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +243 -10
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +238 -10
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +1 -1
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +13 -11
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/geojson-table.ts +2 -2
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/index.ts +0 -9
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +87 -0
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-bounds.ts +3 -3
- package/src/geoarrow/geoarrow-capabilities.ts +1 -1
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +3 -3
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +1 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +2 -2
- package/src/geoarrow/lib/kernels/encode-geoarrow-box.ts +1 -1
- package/src/loader-utils/index.ts +1 -1
- package/src/schema/geometry/geoarrow.ts +8 -19
- package/src/worker-utils/index.ts +0 -16
- package/src/worker-utils/lib/worker-api/create-worker.ts +1 -1
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +1 -6
- package/src/worker-utils/lib/worker-api/task-runtime.ts +1 -1
- package/src/worker-utils/types.ts +1 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs +0 -477
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts +0 -29
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js +0 -434
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs +0 -39
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts +0 -2
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js +0 -5
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/schema-utils/arrow-transport.cjs +0 -691
- package/dist/schema-utils/arrow-transport.cjs.map +0 -6
- package/dist/schema-utils/arrow-transport.d.ts +0 -4
- package/dist/schema-utils/arrow-transport.d.ts.map +0 -1
- package/dist/schema-utils/arrow-transport.js +0 -7
- package/dist/schema-utils/arrow-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +0 -76
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +0 -182
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +0 -33
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +0 -134
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +0 -1
- package/src/arrow-geometry/arrow-geoarrow-adapter.ts +0 -568
- package/src/geoarrow/lib/arrow-geoarrow-adapter.ts +0 -12
- package/src/schema-utils/arrow-transport.ts +0 -7
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +0 -282
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +0 -247
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport {\n convertGeoArrowColumn,\n decodeGeoArrowWKB,\n encodeGeoArrowWKB\n} from '@math.gl/geospatial/geoarrow';\nimport type {DecodeGeoArrowWKBOptions} from '@math.gl/geospatial/geoarrow';\nimport {\n convertGeometryToWKB,\n convertGeometryToWKT\n} from '@loaders.gl/core/arrow-geometry/geometry-codecs';\nimport type {Geometry, Position} from '@loaders.gl/core/schema';\nimport {convertGeoArrowGeometryToGeoJSON} from '../lib/geometry-converters/convert-geoarrow-to-geojson';\nimport type {GeoArrowEncoding, GeoArrowMetadata} from '../metadata/geoarrow-metadata';\nimport {getGeometryMetadataForField} from '../metadata/geoarrow-metadata';\nimport {\n getGeoMetadata,\n type GeoMetadata,\n type GeoColumnMetadata,\n type GeoParquetGeometryType\n} from '../metadata/geoparquet-metadata';\nimport {inspectGeoArrowVector} from '../geoarrow-inspection';\nimport {\n decodeWKTGeometryCollectionVector,\n decodeWKTNativeVector,\n decodeWKTUnionVector\n} from '../lib/kernels/decode-wkt-native';\nimport {encodeGeoArrowBoxVector} from '../lib/kernels/encode-geoarrow-box';\nimport {encodeGeoArrowWKTVector} from '../lib/kernels/encode-geoarrow-wkt';\nimport {assertGeoArrowResourceLimits} from '../geoarrow-resource-limits';\nimport {\n makeArrowVectorFromGeoArrowColumn,\n makeGeoArrowColumnFromArrowVector\n} from '../lib/arrow-geoarrow-adapter';\nimport {getGeoArrowUnionGeometryKind} from '../lib/kernels/geoarrow-union';\n\ntype GeoArrowGeometryKind =\n | 'Point'\n | 'LineString'\n | 'Polygon'\n | 'MultiPoint'\n | 'MultiLineString'\n | 'MultiPolygon'\n | 'GeometryCollection';\n\ntype GeometryUnionChildValue =\n | Geometry\n | string\n | Uint8Array\n | (number | null)[]\n | number[][]\n | number[][][]\n | number[][][][]\n | null;\n\n/**\n * Options for converting geometry columns in a GeoArrow table.\n */\nexport type GeoArrowGeometryTarget = GeoArrowEncoding | 'native';\nexport type GeoArrowCoordinateLayout = 'interleaved' | 'separated';\nexport type GeoArrowDimension = 'xy' | 'xyz' | 'xym' | 'xyzm';\nexport type GeoArrowOffsetType = 'int32' | 'int64';\n\nexport type GeoArrowGeometryConvertOptions = {\n /** Optional single geometry column to convert. Defaults to all geometry columns. */\n geometryColumn?: string;\n /** Optional list of geometry columns to convert. Defaults to all geometry columns. */\n geometryColumns?: string[];\n /** Known geometry types used to select an adaptive native target for vector conversion. */\n geometryTypes?: readonly GeoParquetGeometryType[];\n /** Coordinate storage layout for native output. Defaults to interleaved. */\n coordinates?: GeoArrowCoordinateLayout;\n /** Exact coordinate dimensions for native output. */\n dimension?: GeoArrowDimension;\n /** Offset storage width for variable-length native output. Defaults to int32. */\n offsetType?: GeoArrowOffsetType;\n /** Maximum nested GeometryCollection depth. Defaults to 64. */\n maxGeometryCollectionDepth?: number;\n /** Maximum serialized bytes across one WKB or WKT input vector. */\n maxGeometryBytes?: number;\n /** Maximum coordinate vertices across one input vector. */\n maxGeometryVertices?: number;\n /** Behavior when no direct Arrow-buffer kernel exists. Defaults to the compatibility bridge. */\n fallback?: 'geojson' | 'error';\n};\n\nconst DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH = 64;\n\n/**\n * Converts one GeoArrow vector to a concrete or adaptive native encoding.\n *\n * Same-encoding conversions return the original vector so all Arrow buffers remain shared.\n *\n * @param column GeoArrow geometry vector.\n * @param sourceEncoding Source GeoArrow encoding.\n * @param targetEncoding Concrete target encoding or the adaptive `native` target.\n * @param options Conversion options and optional geometry type metadata.\n * @returns Converted GeoArrow vector.\n */\nexport function convertGeoArrowVector(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowGeometryTarget,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector {\n const maxGeometryCollectionDepth = getMaxGeometryCollectionDepth(options);\n assertGeoArrowResourceLimits(column, sourceEncoding, options);\n const resolvedTargetEncoding = resolveTargetEncoding(\n targetEncoding,\n sourceEncoding,\n options?.geometryTypes\n );\n\n if (\n sourceEncoding === resolvedTargetEncoding &&\n canReuseGeoArrowVector(column, resolvedTargetEncoding, options)\n ) {\n return column;\n }\n\n return convertGeometryColumn(column, sourceEncoding, resolvedTargetEncoding, 'geometry', {\n ...options,\n maxGeometryCollectionDepth\n });\n}\n\n/**\n * Converts one vector cell to GeoJSON, including dense-union and geometry-collection columns.\n *\n * Dense union cells need the parent vector's type-id buffer to recover the geometry kind; the\n * ordinary cell converter intentionally has no vector context and therefore cannot decode them.\n *\n * @param column GeoArrow geometry vector.\n * @param rowIndex Row index within the vector.\n * @param encoding Declared GeoArrow encoding.\n * @returns GeoJSON geometry or `null`.\n */\nexport function convertGeoArrowVectorCellToGeoJSON(\n column: arrow.Vector,\n rowIndex: number,\n encoding: GeoArrowEncoding\n): Geometry | null {\n if (encoding === 'geoarrow.geometry') {\n return convertUnionValueToGeometry(\n column.get(rowIndex),\n getDenseUnionGeometryKind(column, rowIndex)\n );\n }\n if (encoding === 'geoarrow.geometrycollection') {\n const collectionValue = column.get(rowIndex);\n if (!collectionValue) return null;\n const childGeometries: Geometry[] = [];\n const unionVector = collectionValue as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const geometry = convertUnionValueToGeometry(\n unionVector.get(memberIndex),\n getDenseUnionGeometryKind(unionVector, memberIndex)\n );\n if (geometry) childGeometries.push(geometry);\n }\n return {type: 'GeometryCollection', geometries: childGeometries};\n }\n return convertGeoArrowGeometryToGeoJSON(column.get(rowIndex), encoding);\n}\n\n/**\n * Converts one or more geometry columns in a GeoArrow Arrow table to a target GeoArrow encoding.\n * @param table GeoArrow Apache Arrow table.\n * @param targetEncoding Target GeoArrow encoding for selected geometry columns.\n * @param options Conversion options.\n * @returns A new Arrow table with converted geometry columns.\n */\nexport function convertGeoArrowGeometry(\n table: arrow.Table,\n targetEncoding: GeoArrowGeometryTarget,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Table {\n const maxGeometryCollectionDepth = getMaxGeometryCollectionDepth(options);\n const geometryColumns = getGeometryColumnsFromArrowSchema(table.schema);\n const selectedGeometryColumns = resolveGeometryColumns(geometryColumns, options);\n const geoMetadata = getGeoMetadata(table.schema.metadata || new Map());\n\n if (selectedGeometryColumns.length === 0) {\n throw new Error('GeoArrowGeometryConverter requires at least one geometry column to convert.');\n }\n\n const convertedEncodings = new Map<string, GeoArrowEncoding>();\n const conversionOptions = new Map<string, GeoArrowGeometryConvertOptions | undefined>();\n for (const geometryColumn of selectedGeometryColumns) {\n const sourceMetadata = geometryColumns[geometryColumn];\n const sourceEncoding = sourceMetadata?.encoding;\n if (!sourceEncoding) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${geometryColumn}\".`);\n }\n\n const geometryTypes =\n options?.geometryTypes ||\n geoMetadata?.columns?.[geometryColumn]?.geometry_types ||\n sourceMetadata?.geometry_types ||\n inferGeometryTypes(table, geometryColumn, sourceEncoding);\n const resolvedTargetEncoding = resolveTargetEncoding(\n targetEncoding,\n sourceEncoding,\n geometryTypes\n );\n conversionOptions.set(\n geometryColumn,\n geometryTypes && geometryTypes.length > 0\n ? {...options, geometryTypes, maxGeometryCollectionDepth}\n : {...options, maxGeometryCollectionDepth}\n );\n const sourceVector = table.getChild(geometryColumn);\n if (\n sourceEncoding !== resolvedTargetEncoding ||\n (sourceVector &&\n !canReuseGeoArrowVector(\n sourceVector,\n resolvedTargetEncoding,\n conversionOptions.get(geometryColumn)\n ))\n ) {\n convertedEncodings.set(geometryColumn, resolvedTargetEncoding);\n }\n }\n\n if (convertedEncodings.size === 0) {\n for (const geometryColumn of selectedGeometryColumns) {\n const sourceMetadata = geometryColumns[geometryColumn];\n const sourceVector = table.getChild(geometryColumn);\n if (sourceMetadata?.encoding && sourceVector) {\n assertGeoArrowResourceLimits(sourceVector, sourceMetadata.encoding, options);\n }\n }\n return table;\n }\n\n const nextSchemaMetadata = cloneMetadataMap(table.schema.metadata);\n updateGeoMetadata(nextSchemaMetadata, geoMetadata, convertedEncodings, conversionOptions);\n const sourceGeometryColumns = getGeometryColumnsFromArrowSchema(table.schema);\n const convertedColumns = new Map<string, arrow.Vector>();\n for (const [geometryColumn, convertedEncoding] of convertedEncodings) {\n const sourceVector = table.getChild(geometryColumn);\n if (!sourceVector) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${geometryColumn}\".`);\n }\n convertedColumns.set(\n geometryColumn,\n convertGeoArrowVector(\n sourceVector,\n sourceGeometryColumns[geometryColumn].encoding!,\n convertedEncoding,\n conversionOptions.get(geometryColumn)\n )\n );\n }\n const nextFields = table.schema.fields.map(field => {\n const convertedEncoding = convertedEncodings.get(field.name);\n const convertedVector = convertedColumns.get(field.name);\n return convertedEncoding && convertedVector\n ? createConvertedField(\n field,\n convertedVector.type,\n convertedEncoding,\n conversionOptions.get(field.name)?.geometryTypes,\n conversionOptions.get(field.name),\n geoMetadata?.columns?.[field.name]\n )\n : field;\n });\n const nextSchema = new arrow.Schema(nextFields, nextSchemaMetadata);\n let rowOffset = 0;\n const nextBatches = table.batches.map(batch => {\n const children = table.schema.fields.map(field => {\n const convertedVector = convertedColumns.get(field.name);\n if (!convertedVector) {\n const sourceVector = batch.getChild(field.name);\n if (!sourceVector) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${field.name}\".`);\n }\n return sourceVector.data[0];\n }\n const batchVector = convertedVector.slice(rowOffset, rowOffset + batch.numRows);\n if (batchVector.data.length !== 1) {\n throw new Error(\n `Converted GeoArrow column \"${field.name}\" does not align to record batches.`\n );\n }\n return batchVector.data[0];\n });\n rowOffset += batch.numRows;\n return new arrow.RecordBatch(\n nextSchema,\n arrow.makeData({\n type: new arrow.Struct(nextFields),\n length: batch.numRows,\n nullCount: 0,\n children\n })\n );\n });\n\n return new arrow.Table(nextSchema, nextBatches);\n}\n\n/** Inspects all record batches when WKB geometry metadata does not declare geometry types. */\nfunction inferGeometryTypes(\n table: arrow.Table,\n geometryColumn: string,\n sourceEncoding: GeoArrowEncoding\n): readonly GeoParquetGeometryType[] | undefined {\n if (sourceEncoding !== 'geoarrow.wkb' && sourceEncoding !== 'geoarrow.wkt') {\n return undefined;\n }\n const vector = table.getChild(geometryColumn);\n if (!vector) return undefined;\n const inspection = inspectGeoArrowVector(vector, sourceEncoding);\n return inspection.geometryTypes.length > 0 ? inspection.geometryTypes : undefined;\n}\n\n/**\n * Extracts GeoArrow geometry metadata from an Apache Arrow schema.\n * @param schema Apache Arrow schema.\n * @returns GeoArrow geometry columns keyed by field name.\n */\nfunction getGeometryColumnsFromArrowSchema(schema: arrow.Schema): Record<string, GeoArrowMetadata> {\n const geometryColumns: Record<string, GeoArrowMetadata> = {};\n\n for (const field of schema.fields) {\n const geometryMetadata = getGeometryMetadataForField(field.metadata || new Map());\n if (geometryMetadata) {\n geometryColumns[field.name] = geometryMetadata;\n }\n }\n\n return geometryColumns;\n}\n\n/**\n * Converts one GeoArrow geometry column to a target encoding.\n * @param column GeoArrow Arrow vector.\n * @param sourceEncoding Source encoding.\n * @param targetEncoding Target encoding.\n * @param geometryColumn Column name for error messages.\n * @returns Converted Arrow vector.\n */\nfunction convertGeometryColumn(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowEncoding,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector {\n if (targetEncoding === 'geoarrow.box') {\n return encodeGeoArrowBoxVector(column, sourceEncoding, options?.dimension);\n }\n const mathGeoArrowVector = convertGeometryColumnWithMath(\n column,\n sourceEncoding,\n targetEncoding,\n options\n );\n if (mathGeoArrowVector) return mathGeoArrowVector;\n if (targetEncoding === 'geoarrow.wkt') {\n const directWKTVector = encodeGeoArrowWKTVector(column, sourceEncoding, options?.dimension);\n if (directWKTVector) return directWKTVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && isConcreteNativeEncoding(targetEncoding)) {\n const directWKTVector = decodeWKTNativeVector(\n column,\n targetEncoding,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTVector) return directWKTVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && targetEncoding === 'geoarrow.geometry') {\n const directWKTUnionVector = decodeWKTUnionVector(\n column,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.geometryTypes,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTUnionVector) return directWKTUnionVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && targetEncoding === 'geoarrow.geometrycollection') {\n const directWKTCollectionVector = decodeWKTGeometryCollectionVector(\n column,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.geometryTypes,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTCollectionVector) return directWKTCollectionVector;\n }\n if (options?.fallback === 'error') {\n throw new Error(\n `No direct GeoArrow conversion kernel is available for ${sourceEncoding} to ${targetEncoding}.`\n );\n }\n const geometries = extractGeometries(column, sourceEncoding);\n assertGeometryCollectionDepth(geometries, options?.maxGeometryCollectionDepth);\n if (\n (targetEncoding === 'geoarrow.geometry' || targetEncoding === 'geoarrow.geometrycollection') &&\n getGeometryCollectionDepth(geometries) > 1\n ) {\n throw new Error(\n 'Native GeoArrow layouts do not support recursive GeometryCollections; keep the column as WKB or WKT.'\n );\n }\n\n const targetDimension = usesNativeGeoArrowCoordinates(targetEncoding)\n ? getTargetDimension(geometries, options?.dimension)\n : 2;\n const targetDimensionName = usesNativeGeoArrowCoordinates(targetEncoding)\n ? getTargetDimensionName(geometries, options)\n : 'xy';\n if (targetEncoding === 'geoarrow.geometry') {\n return createGeometryUnionVector(\n geometries,\n targetDimension,\n true,\n geometryColumn,\n options,\n getGeometryCollectionDepth(geometries),\n targetDimensionName\n );\n }\n if (targetEncoding === 'geoarrow.geometrycollection') {\n return createGeometryCollectionVector(\n geometries,\n targetDimension,\n geometryColumn,\n options,\n getGeometryCollectionDepth(geometries),\n targetDimensionName\n );\n }\n const targetValues = geometries.map(geometry =>\n convertGeometryValue(geometry, targetEncoding, targetDimension, geometryColumn, options)\n );\n const nativeValues =\n options?.coordinates === 'separated'\n ? targetValues.map(value =>\n separateCoordinateValues(value, targetDimension, targetDimensionName)\n )\n : targetValues;\n return arrow.vectorFromArray(\n nativeValues,\n getTargetArrowType(\n targetEncoding,\n targetDimension,\n options,\n options?.dimension || getDimensionFromGeometryTypes(options?.geometryTypes)\n )\n );\n}\n\n/** Uses math.gl for physical GeoArrow and WKB conversions without materializing geometry rows. */\nfunction convertGeometryColumnWithMath(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowEncoding,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector | null {\n const sourceIsNative = isMathGeoArrowNativeEncoding(sourceEncoding);\n const targetIsNative = isMathGeoArrowNativeEncoding(targetEncoding);\n const supportsConversion =\n (sourceEncoding === 'geoarrow.wkb' && targetIsNative) ||\n (sourceIsNative && targetEncoding === 'geoarrow.wkb') ||\n (sourceIsNative && targetIsNative);\n if (!supportsConversion) return null;\n\n const declaredDimension = getDimensionFromGeometryTypes(options?.geometryTypes);\n const sourceColumn = makeGeoArrowColumnFromArrowVector(column, {\n encoding: sourceEncoding,\n dimension:\n sourceEncoding === 'geoarrow.wkb'\n ? declaredDimension || 'xy'\n : declaredDimension || (targetEncoding === 'geoarrow.wkb' ? options?.dimension : undefined)\n });\n if (sourceEncoding === 'geoarrow.wkb') {\n try {\n const decodedColumn = decodeGeoArrowWKB(sourceColumn, {\n encoding: targetEncoding as DecodeGeoArrowWKBOptions['encoding'],\n dimension: options?.dimension || declaredDimension || 'infer',\n coordinateLayout: options?.coordinates || 'interleaved',\n offsetType: options?.offsetType || 'int32',\n traversal: {maximumDepth: options?.maxGeometryCollectionDepth}\n });\n return makeArrowVectorFromGeoArrowColumn(decodedColumn);\n } catch (error) {\n if (\n options?.maxGeometryCollectionDepth !== undefined &&\n error instanceof Error &&\n error.message.includes('nesting exceeds maximumDepth')\n ) {\n throw new Error(\n `GeometryCollection nesting exceeds maxGeometryCollectionDepth (${options.maxGeometryCollectionDepth}).`\n );\n }\n throw error;\n }\n }\n if (targetEncoding === 'geoarrow.wkb') {\n return makeArrowVectorFromGeoArrowColumn(encodeGeoArrowWKB(sourceColumn));\n }\n\n const convertedColumn = convertGeoArrowColumn(sourceColumn, {\n encoding: targetEncoding,\n dimension: options?.dimension,\n coordinateLayout: options?.coordinates || 'preserve',\n offsetType: options?.offsetType || 'preserve'\n });\n return convertedColumn === sourceColumn\n ? column\n : makeArrowVectorFromGeoArrowColumn(convertedColumn);\n}\n\n/** Returns whether math.gl models an encoding as native physical geometry buffers. */\nfunction isMathGeoArrowNativeEncoding(\n encoding: GeoArrowEncoding\n): encoding is Exclude<GeoArrowEncoding, 'geoarrow.box' | 'geoarrow.wkb' | 'geoarrow.wkt'> {\n return (\n encoding === 'geoarrow.point' ||\n encoding === 'geoarrow.linestring' ||\n encoding === 'geoarrow.polygon' ||\n encoding === 'geoarrow.multipoint' ||\n encoding === 'geoarrow.multilinestring' ||\n encoding === 'geoarrow.multipolygon' ||\n encoding === 'geoarrow.geometry' ||\n encoding === 'geoarrow.geometrycollection'\n );\n}\n\n/** Returns a validated collection-depth limit for all conversion paths. */\nfunction getMaxGeometryCollectionDepth(options?: GeoArrowGeometryConvertOptions): number {\n const maximumDepth = options?.maxGeometryCollectionDepth ?? DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH;\n if (!Number.isSafeInteger(maximumDepth) || maximumDepth < 0) {\n throw new Error('maxGeometryCollectionDepth must be a non-negative safe integer.');\n }\n return maximumDepth;\n}\n\n/** Rejects hostile or accidentally unbounded nested GeometryCollections without recursion. */\nfunction assertGeometryCollectionDepth(\n geometries: readonly (Geometry | null)[],\n maximumDepth = DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH\n): void {\n const pending: {geometry: Geometry; depth: number}[] = [];\n for (const geometry of geometries) {\n if (geometry) pending.push({geometry, depth: 0});\n }\n while (pending.length > 0) {\n const current = pending.pop()!;\n if (current.geometry.type !== 'GeometryCollection') continue;\n const depth = current.depth + 1;\n if (depth > maximumDepth) {\n throw new Error(\n `GeometryCollection nesting exceeds maxGeometryCollectionDepth (${maximumDepth}).`\n );\n }\n for (const child of current.geometry.geometries) {\n pending.push({geometry: child, depth});\n }\n }\n}\n\nfunction isConcreteNativeEncoding(\n encoding: GeoArrowEncoding\n): encoding is\n | 'geoarrow.point'\n | 'geoarrow.linestring'\n | 'geoarrow.polygon'\n | 'geoarrow.multipoint'\n | 'geoarrow.multilinestring'\n | 'geoarrow.multipolygon' {\n return (\n encoding === 'geoarrow.point' ||\n encoding === 'geoarrow.linestring' ||\n encoding === 'geoarrow.polygon' ||\n encoding === 'geoarrow.multipoint' ||\n encoding === 'geoarrow.multilinestring' ||\n encoding === 'geoarrow.multipolygon'\n );\n}\n\n/**\n * Converts one geometry value to the requested target encoding payload.\n * @param geometry Source geometry.\n * @param targetEncoding Target GeoArrow encoding.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Arrow cell value for the target encoding.\n */\nfunction convertGeometryValue(\n geometry: Geometry | null,\n targetEncoding: GeoArrowEncoding,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions\n): string | Uint8Array | (number | null)[] | number[][] | number[][][] | number[][][][] | null {\n if (!geometry) {\n return null;\n }\n\n switch (targetEncoding) {\n case 'geoarrow.wkb':\n return new Uint8Array(\n convertGeometryToWKB(geometry, getGeometryWKBOptions(geometry, options))\n );\n case 'geoarrow.wkt':\n return convertGeometryToWKT(geometry, {dimension: getGeometryDimension(geometry, options)});\n case 'geoarrow.point':\n return normalizePointCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.linestring':\n return normalizeLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.polygon':\n return normalizePolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multipoint':\n return normalizeMultiPointCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multilinestring':\n return normalizeMultiLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multipolygon':\n return normalizeMultiPolygonCoordinates(geometry, targetDimension, geometryColumn);\n default:\n throw new Error(`Unsupported GeoArrow target encoding \"${targetEncoding}\".`);\n }\n}\n\n/**\n * Extracts GeoJSON geometries from a GeoArrow column.\n * @param column GeoArrow column vector.\n * @param sourceEncoding Source GeoArrow encoding.\n * @returns Decoded geometries.\n */\nfunction extractGeometries(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding\n): (Geometry | null)[] {\n switch (sourceEncoding) {\n case 'geoarrow.geometry':\n return extractGeometryUnionColumn(column);\n case 'geoarrow.geometrycollection':\n return extractGeometryCollectionColumn(column);\n default: {\n const geometries: (Geometry | null)[] = [];\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n geometries.push(convertGeoArrowGeometryToGeoJSON(column.get(rowIndex), sourceEncoding));\n }\n return geometries;\n }\n }\n}\n\n/**\n * Extracts geometries from a `geoarrow.geometry` DenseUnion column.\n * @param column DenseUnion GeoArrow vector.\n * @returns Decoded geometries.\n */\nfunction extractGeometryUnionColumn(column: arrow.Vector): (Geometry | null)[] {\n const geometries: (Geometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const geometryKind = getDenseUnionGeometryKind(column, rowIndex);\n geometries.push(convertUnionValueToGeometry(column.get(rowIndex), geometryKind));\n }\n\n return geometries;\n}\n\n/**\n * Extracts geometries from a `geoarrow.geometrycollection` column.\n * @param column List<DenseUnion> GeoArrow vector.\n * @returns Decoded geometry collections.\n */\nfunction extractGeometryCollectionColumn(column: arrow.Vector): (Geometry | null)[] {\n const geometries: (Geometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const collectionValue = column.get(rowIndex);\n if (!collectionValue) {\n geometries.push(null);\n continue;\n }\n\n const childGeometries: Geometry[] = [];\n const unionVector = collectionValue as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const geometryKind = getDenseUnionGeometryKind(unionVector, memberIndex);\n const geometry = convertUnionValueToGeometry(unionVector.get(memberIndex), geometryKind);\n if (geometry) {\n childGeometries.push(geometry);\n }\n }\n\n geometries.push({\n type: 'GeometryCollection',\n geometries: childGeometries\n });\n }\n\n return geometries;\n}\n\n/**\n * Builds a `geoarrow.geometry` DenseUnion vector.\n * @param geometries Source geometries.\n * @param targetDimension Target coordinate dimension.\n * @param allowGeometryCollections Whether geometry collection children are allowed.\n * @param geometryColumn Column name for error messages.\n * @returns DenseUnion vector.\n */\nfunction createGeometryUnionVector(\n geometries: (Geometry | null)[],\n targetDimension: 2 | 3 | 4,\n allowGeometryCollections: boolean,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = allowGeometryCollections ? getGeometryCollectionDepth(geometries) : 0,\n targetDimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n const usedKinds = new Set<GeoArrowGeometryKind>();\n const typeIds: number[] = [];\n const valueOffsets: number[] = [];\n const childValues: Partial<Record<GeoArrowGeometryKind, GeometryUnionChildValue[]>> = {};\n\n const nullCarrierKind = getNullCarrierKind(geometries, allowGeometryCollections);\n usedKinds.add(nullCarrierKind);\n childValues[nullCarrierKind] = [];\n for (const geometryType of options?.geometryTypes || []) {\n const geometryKind = getBaseGeometryKind(geometryType);\n if (geometryKind && (allowGeometryCollections || geometryKind !== 'GeometryCollection')) {\n usedKinds.add(geometryKind);\n childValues[geometryKind] ||= [];\n }\n }\n\n for (const geometry of geometries) {\n const geometryKind = geometry?.type || nullCarrierKind;\n if (geometryKind === 'GeometryCollection' && geometryCollectionDepth === 0) {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode GeometryCollection in \"${geometryColumn}\" without a geometrycollection child.`\n );\n }\n\n const childKind = (geometryKind || nullCarrierKind) as GeoArrowGeometryKind;\n usedKinds.add(childKind);\n childValues[childKind] ||= [];\n valueOffsets.push(childValues[childKind]!.length);\n typeIds.push(getUnionTypeId(childKind, targetDimension, targetDimensionName));\n\n childValues[childKind]!.push(\n geometry ? convertGeometryToUnionChildValue(geometry, targetDimension, geometryColumn) : null\n );\n }\n\n const orderedKinds = [...usedKinds].sort(\n (leftKind, rightKind) =>\n getUnionTypeId(leftKind, targetDimension, targetDimensionName) -\n getUnionTypeId(rightKind, targetDimension, targetDimensionName)\n );\n const fields = orderedKinds.map(\n kind =>\n new arrow.Field(\n getUnionFieldName(kind, targetDimension, targetDimensionName),\n getUnionChildType(\n kind,\n targetDimension,\n options,\n geometryCollectionDepth,\n targetDimensionName\n ),\n true\n )\n );\n const children = orderedKinds.map(kind => {\n const values = childValues[kind] || [];\n return createUnionChildVector(\n kind,\n values,\n targetDimension,\n geometryColumn,\n options,\n geometryCollectionDepth,\n targetDimensionName\n ).data[0];\n });\n const unionType = new arrow.DenseUnion(\n orderedKinds.map(kind => getUnionTypeId(kind, targetDimension, targetDimensionName)),\n fields\n );\n\n return arrow.makeVector(\n arrow.makeData({\n type: unionType,\n length: geometries.length,\n nullCount: 0,\n typeIds: Int8Array.from(typeIds),\n valueOffsets: Int32Array.from(valueOffsets),\n children\n })\n );\n}\n\n/**\n * Builds a `geoarrow.geometrycollection` vector.\n * @param geometries Source geometries.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Geometry collection vector.\n */\nfunction createGeometryCollectionVector(\n geometries: (Geometry | null)[],\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = getGeometryCollectionDepth(geometries),\n targetDimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n const flattenedGeometries: (Geometry | null)[] = [];\n const valueOffsets = [0];\n const validity: boolean[] = [];\n\n for (const geometry of geometries) {\n if (!geometry) {\n validity.push(false);\n valueOffsets.push(flattenedGeometries.length);\n continue;\n }\n if (geometry.type !== 'GeometryCollection') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.geometrycollection in column \"${geometryColumn}\".`\n );\n }\n\n validity.push(true);\n flattenedGeometries.push(...geometry.geometries);\n valueOffsets.push(flattenedGeometries.length);\n }\n\n const memberUnionVector = createGeometryUnionVector(\n flattenedGeometries,\n targetDimension,\n false,\n geometryColumn,\n options,\n 0,\n targetDimensionName\n );\n const listType = createListType(\n new arrow.Field('geometries', memberUnionVector.type, true),\n options?.offsetType\n );\n\n const listData = {\n length: geometries.length,\n nullCount: validity.filter(isValid => !isValid).length,\n nullBitmap: createNullBitmap(validity),\n valueOffsets: createOffsetArray(valueOffsets, options?.offsetType),\n child: memberUnionVector.data[0]\n };\n const listDataValue =\n listType instanceof arrow.LargeList\n ? arrow.makeData({\n type: listType,\n ...listData,\n valueOffsets: BigInt64Array.from(valueOffsets, BigInt)\n })\n : arrow.makeData({\n type: listType as arrow.List,\n ...listData,\n valueOffsets: Int32Array.from(valueOffsets)\n });\n return arrow.makeVector(listDataValue as any);\n}\n\n/**\n * Converts one GeoJSON geometry to a native GeoArrow union child payload.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Union child payload.\n */\nfunction convertGeometryToUnionChildValue(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): Geometry | (number | null)[] | number[][] | number[][][] | number[][][][] | null {\n switch (geometry.type) {\n case 'Point':\n return normalizePointCoordinates(geometry, targetDimension, geometryColumn);\n case 'LineString':\n return normalizeLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'Polygon':\n return normalizePolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiPoint':\n return normalizeMultiPointCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiLineString':\n return normalizeMultiLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiPolygon':\n return normalizeMultiPolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'GeometryCollection':\n return geometry;\n }\n}\n\n/**\n * Creates a child vector for a geometry union.\n * @param geometryKind Child geometry kind.\n * @param values Child values.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Child vector.\n */\nfunction createUnionChildVector(\n geometryKind: GeoArrowGeometryKind,\n values: unknown[],\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n if (geometryKind === 'GeometryCollection') {\n return createGeometryCollectionVector(\n values as (Geometry | null)[],\n targetDimension,\n geometryColumn,\n options,\n Math.max(geometryCollectionDepth - 1, 0),\n dimensionName\n );\n }\n\n const nativeValues =\n options?.coordinates === 'separated'\n ? values.map(value => separateCoordinateValues(value, targetDimension, dimensionName))\n : values;\n return arrow.vectorFromArray(\n nativeValues,\n getUnionChildType(\n geometryKind,\n targetDimension,\n options,\n geometryCollectionDepth,\n dimensionName\n )\n );\n}\n\n/**\n * Converts a union child value back to GeoJSON geometry.\n * @param value Arrow child value.\n * @param geometryKind Geometry kind.\n * @returns GeoJSON geometry.\n */\nfunction convertUnionValueToGeometry(\n value: unknown,\n geometryKind: GeoArrowGeometryKind\n): Geometry | null {\n if (value == null) return null;\n switch (geometryKind) {\n case 'Point':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.point');\n case 'LineString':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.linestring');\n case 'Polygon':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.polygon');\n case 'MultiPoint':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multipoint');\n case 'MultiLineString':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multilinestring');\n case 'MultiPolygon':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multipolygon');\n case 'GeometryCollection': {\n const geometries: Geometry[] = [];\n const unionVector = value as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const childGeometryKind = getDenseUnionGeometryKind(unionVector, memberIndex);\n const geometry = convertUnionValueToGeometry(\n unionVector.get(memberIndex),\n childGeometryKind\n );\n if (geometry) {\n geometries.push(geometry);\n }\n }\n return {type: 'GeometryCollection', geometries};\n }\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Returns the union cell type identifier for one row.\n * @param vector DenseUnion vector or sliced nested vector.\n * @param rowIndex Row index within the vector.\n * @returns Dense union type id and value offset for the row.\n */\nfunction getDenseUnionCellInfo(\n vector: arrow.Vector,\n rowIndex: number\n): {typeId: number; valueOffset: number} {\n let remainingRowIndex = rowIndex;\n\n for (const chunk of vector.data) {\n if (remainingRowIndex < chunk.length) {\n const typeIdIndex = getUnionBufferIndex(\n chunk.typeIds.length,\n chunk.offset,\n remainingRowIndex,\n chunk.typeIds.length <= chunk.length\n );\n const valueOffsetIndex = getUnionBufferIndex(\n chunk.valueOffsets.length,\n chunk.offset,\n remainingRowIndex,\n chunk.typeIds.length <= chunk.length\n );\n return {\n typeId: chunk.typeIds[typeIdIndex],\n valueOffset: chunk.valueOffsets[valueOffsetIndex]\n };\n }\n remainingRowIndex -= chunk.length;\n }\n\n throw new Error(`DenseUnion row ${rowIndex} is out of bounds.`);\n}\n\n/** Resolves union buffer indexes for both full and already-sliced Arrow buffers. */\nfunction getUnionBufferIndex(\n bufferLength: number,\n offset: number,\n rowIndex: number,\n useLogicalIndex: boolean\n): number {\n if (useLogicalIndex) return rowIndex;\n const physicalIndex = offset + rowIndex;\n return physicalIndex < bufferLength ? physicalIndex : rowIndex;\n}\n\n/**\n * Maps a GeoArrow dense union type id to the base geometry kind.\n * @param typeId GeoArrow union type id.\n * @returns Base geometry kind.\n */\nfunction getDenseUnionGeometryKind(vector: arrow.Vector, rowIndex: number): GeoArrowGeometryKind {\n if (!(vector.type instanceof arrow.DenseUnion)) {\n throw new Error('GeoArrow geometry storage requires a DenseUnion vector.');\n }\n const {typeId} = getDenseUnionCellInfo(vector, rowIndex);\n const childIndex = vector.type.typeIds.indexOf(typeId);\n const fieldName = childIndex >= 0 ? vector.type.children[childIndex]?.name : undefined;\n const geometryKind = getGeoArrowUnionGeometryKind(fieldName, typeId);\n if (!geometryKind) {\n throw new Error(`Unsupported GeoArrow union type id \"${typeId}\".`);\n }\n return geometryKind;\n}\n\n/**\n * Selects a geometry kind that can carry null union members.\n * @param geometries Source geometries.\n * @param allowGeometryCollections Whether geometry collections are valid children.\n * @returns A geometry kind present in the table or a point fallback.\n */\nfunction getNullCarrierKind(\n geometries: (Geometry | null)[],\n allowGeometryCollections: boolean\n): GeoArrowGeometryKind {\n for (const geometry of geometries) {\n if (!geometry) {\n continue;\n }\n if (geometry.type === 'GeometryCollection' && !allowGeometryCollections) {\n continue;\n }\n return geometry.type;\n }\n\n return 'Point';\n}\n\n/** Removes a GeoParquet dimension suffix and validates a geometry union child kind. */\nfunction getBaseGeometryKind(geometryType: GeoParquetGeometryType): GeoArrowGeometryKind | null {\n const geometryKind = geometryType.replace(/ (?:ZM|Z|M)$/, '');\n switch (geometryKind) {\n case 'Point':\n case 'LineString':\n case 'Polygon':\n case 'MultiPoint':\n case 'MultiLineString':\n case 'MultiPolygon':\n case 'GeometryCollection':\n return geometryKind;\n default:\n return null;\n }\n}\n\n/** Returns the maximum nested GeometryCollection depth in a geometry sequence. */\nfunction getGeometryCollectionDepth(geometries: (Geometry | null)[]): number {\n let maximumDepth = 0;\n for (const geometry of geometries) {\n if (geometry?.type === 'GeometryCollection') {\n maximumDepth = Math.max(maximumDepth, 1 + getGeometryCollectionDepth(geometry.geometries));\n }\n }\n return maximumDepth;\n}\n\n/**\n * Returns the GeoArrow union type id for a geometry kind and coordinate dimension.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns GeoArrow union type id.\n */\nfunction getUnionTypeId(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n dimensionName = getDimensionName(targetDimension)\n): number {\n const baseTypeId = getUnionBaseTypeId(geometryKind);\n\n switch (dimensionName) {\n case 'xy':\n return baseTypeId;\n case 'xyz':\n return 10 + baseTypeId;\n case 'xym':\n return 20 + baseTypeId;\n case 'xyzm':\n return 30 + baseTypeId;\n default:\n return baseTypeId;\n }\n}\n\n/**\n * Returns the GeoArrow child field name for a dense union member.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns Arrow field name.\n */\nfunction getUnionFieldName(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n dimensionName = getDimensionName(targetDimension)\n): string {\n switch (dimensionName) {\n case 'xy':\n return geometryKind;\n case 'xyz':\n return `${geometryKind} Z`;\n case 'xym':\n return `${geometryKind} M`;\n case 'xyzm':\n return `${geometryKind} ZM`;\n default:\n return geometryKind;\n }\n}\n\n/**\n * Returns the Arrow child type for one dense union member.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns Arrow child type.\n */\nfunction getUnionChildType(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n if (geometryKind === 'GeometryCollection') {\n return buildGeometryCollectionType(\n targetDimension,\n options,\n Math.max(geometryCollectionDepth - 1, 0),\n dimensionName\n );\n }\n\n return getTargetArrowType(\n getGeometryKindEncoding(geometryKind),\n targetDimension,\n options,\n dimensionName\n );\n}\n\n/**\n * Packs Arrow validity bits into a null bitmap.\n * @param validity Row validity values.\n * @returns Arrow null bitmap.\n */\nfunction createNullBitmap(validity: boolean[]): Uint8Array {\n const nullBitmap = new Uint8Array(Math.ceil(validity.length / 8));\n\n for (let index = 0; index < validity.length; index++) {\n if (validity[index]) {\n nullBitmap[index >> 3] |= 1 << (index % 8);\n }\n }\n\n return nullBitmap;\n}\n\n/**\n * Resolves the geometry columns that should be converted.\n * @param geometryColumns Geometry columns from schema metadata.\n * @param options Conversion options.\n * @returns Geometry column names to convert.\n */\nfunction resolveGeometryColumns(\n geometryColumns: Record<string, {encoding?: GeoArrowEncoding}>,\n options?: GeoArrowGeometryConvertOptions\n): string[] {\n const availableGeometryColumns = Object.keys(geometryColumns);\n\n if (options?.geometryColumn && options?.geometryColumns?.length) {\n throw new Error('Specify only one of \"geometryColumn\" or \"geometryColumns\".');\n }\n\n if (options?.geometryColumn) {\n if (!geometryColumns[options.geometryColumn]) {\n throw new Error(\n `GeoArrowGeometryConverter could not find geometry column \"${options.geometryColumn}\".`\n );\n }\n return [options.geometryColumn];\n }\n\n if (options?.geometryColumns?.length) {\n for (const geometryColumn of options.geometryColumns) {\n if (!geometryColumns[geometryColumn]) {\n throw new Error(\n `GeoArrowGeometryConverter could not find geometry column \"${geometryColumn}\".`\n );\n }\n }\n return options.geometryColumns;\n }\n\n return availableGeometryColumns;\n}\n\n/**\n * Creates a cloned field with updated GeoArrow encoding metadata.\n * @param field Source Arrow field.\n * @param type Target Arrow type.\n * @param targetEncoding Target GeoArrow encoding.\n * @returns Converted Arrow field.\n */\nfunction createConvertedField(\n field: arrow.Field,\n type: arrow.DataType,\n targetEncoding: GeoArrowEncoding,\n geometryTypes?: readonly GeoParquetGeometryType[],\n options?: GeoArrowGeometryConvertOptions,\n sourceGeoColumnMetadata?: GeoColumnMetadata\n): arrow.Field {\n const metadata = cloneMetadataMap(field.metadata);\n metadata.set('ARROW:extension:name', targetEncoding);\n const effectiveGeometryTypes = options?.dimension\n ? getGeometryTypesForEncoding(targetEncoding, options.dimension)\n : geometryTypes && geometryTypes.length > 0\n ? geometryTypes\n : getGeometryTypesForEncoding(targetEncoding, options?.dimension);\n if (effectiveGeometryTypes.length > 0) {\n const extensionMetadata = {\n ...(getGeometryMetadataForField(metadata) || {}),\n ...getPreservedFieldMetadata(sourceGeoColumnMetadata)\n };\n extensionMetadata.encoding = targetEncoding;\n extensionMetadata.geometry_types = [...effectiveGeometryTypes];\n metadata.set('ARROW:extension:metadata', JSON.stringify(extensionMetadata));\n }\n return new arrow.Field(field.name, type, field.nullable, metadata);\n}\n\n/** Carries GeoParquet semantics into the GeoArrow field without copying its file-level encoding. */\nfunction getPreservedFieldMetadata(\n sourceGeoColumnMetadata?: GeoColumnMetadata\n): Record<string, unknown> {\n if (!sourceGeoColumnMetadata) return {};\n const preservedMetadata: Record<string, unknown> = {};\n for (const key of ['crs', 'orientation', 'bbox', 'epoch', 'edges']) {\n const value = sourceGeoColumnMetadata[key];\n if (value !== undefined && value !== null && !(key === 'edges' && value === 'planar')) {\n preservedMetadata[key] = value;\n }\n }\n for (const [key, value] of Object.entries(sourceGeoColumnMetadata)) {\n if (!(key in preservedMetadata) && !['encoding', 'geometry_types', 'crs'].includes(key)) {\n preservedMetadata[key] = value;\n }\n }\n return preservedMetadata;\n}\n\n/** Derives one concrete geometry type for explicit native dimension metadata. */\nfunction getGeometryTypesForEncoding(\n encoding: GeoArrowEncoding,\n dimension?: GeoArrowDimension\n): GeoParquetGeometryType[] {\n if (!dimension) return [];\n const geometryTypeByEncoding: Partial<Record<GeoArrowEncoding, string>> = {\n 'geoarrow.point': 'Point',\n 'geoarrow.linestring': 'LineString',\n 'geoarrow.polygon': 'Polygon',\n 'geoarrow.multipoint': 'MultiPoint',\n 'geoarrow.multilinestring': 'MultiLineString',\n 'geoarrow.multipolygon': 'MultiPolygon'\n };\n const geometryType = geometryTypeByEncoding[encoding];\n if (!geometryType) return [];\n const suffix =\n dimension === 'xy' ? '' : dimension === 'xyz' ? ' Z' : dimension === 'xym' ? ' M' : ' ZM';\n return [`${geometryType}${suffix}` as GeoParquetGeometryType];\n}\n\n/**\n * Updates schema-level GeoParquet metadata after geometry conversion.\n * @param metadata Schema metadata map to mutate.\n * @param geoMetadata Parsed GeoParquet metadata.\n * @param selectedGeometryColumns Geometry columns that were converted.\n * @param targetEncoding Target GeoArrow encoding.\n */\nfunction updateGeoMetadata(\n metadata: Map<string, string>,\n geoMetadata: GeoMetadata | null,\n convertedEncodings: Map<string, GeoArrowEncoding>,\n conversionOptions: Map<string, GeoArrowGeometryConvertOptions | undefined>\n): void {\n if (!geoMetadata) {\n return;\n }\n\n const nextGeoMetadata = JSON.parse(JSON.stringify(geoMetadata)) as GeoMetadata;\n\n for (const [geometryColumn, targetEncoding] of convertedEncodings) {\n const geometryColumnMetadata = nextGeoMetadata.columns?.[geometryColumn];\n if (!geometryColumnMetadata) continue;\n const targetGeoParquetEncoding = getGeoParquetEncoding(targetEncoding);\n if (targetGeoParquetEncoding) {\n geometryColumnMetadata.encoding = targetGeoParquetEncoding;\n }\n const requestedDimension = conversionOptions.get(geometryColumn)?.dimension;\n if (requestedDimension) {\n const geometryTypes = getGeometryTypesForEncoding(targetEncoding, requestedDimension);\n if (geometryTypes.length > 0) {\n geometryColumnMetadata.geometry_types = geometryTypes;\n }\n }\n }\n\n const remainingGeometryColumns = Object.keys(nextGeoMetadata.columns || {});\n if (\n nextGeoMetadata.primary_column &&\n !nextGeoMetadata.columns?.[nextGeoMetadata.primary_column]\n ) {\n if (remainingGeometryColumns.length > 0) {\n nextGeoMetadata.primary_column = remainingGeometryColumns[0];\n } else {\n delete nextGeoMetadata.primary_column;\n }\n }\n\n if (remainingGeometryColumns.length === 0) {\n metadata.delete('geo');\n return;\n }\n\n metadata.set('geo', JSON.stringify(nextGeoMetadata));\n}\n\n/** Maps a GeoArrow target to a representable GeoParquet encoding when one exists. */\nfunction getGeoParquetEncoding(targetEncoding: GeoArrowEncoding): string | null {\n switch (targetEncoding) {\n case 'geoarrow.wkb':\n return 'wkb';\n case 'geoarrow.wkt':\n return 'wkt';\n case 'geoarrow.geometry':\n return 'geometry';\n case 'geoarrow.point':\n return 'point';\n case 'geoarrow.linestring':\n return 'linestring';\n case 'geoarrow.polygon':\n return 'polygon';\n case 'geoarrow.multipoint':\n return 'multipoint';\n case 'geoarrow.multilinestring':\n return 'multilinestring';\n case 'geoarrow.multipolygon':\n return 'multipolygon';\n default:\n return null;\n }\n}\n\n/**\n * Returns the Arrow data type for a target GeoArrow encoding.\n * @param targetEncoding Target GeoArrow encoding.\n * @param targetDimension Target coordinate dimension.\n * @returns Arrow data type for the converted column.\n */\nfunction getTargetArrowType(\n targetEncoding: GeoArrowEncoding,\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n const coordinateType = getCoordinateType(targetDimension, options?.coordinates, dimensionName);\n const createList = (field: arrow.Field): arrow.DataType =>\n createListType(field, options?.offsetType);\n\n switch (targetEncoding) {\n case 'geoarrow.geometry':\n return buildGeometryUnionType(targetDimension, true, options, 1, dimensionName);\n case 'geoarrow.geometrycollection':\n return buildGeometryCollectionType(targetDimension, options, 0, dimensionName);\n case 'geoarrow.point':\n return coordinateType;\n case 'geoarrow.linestring':\n case 'geoarrow.multipoint':\n return createList(new arrow.Field('value', coordinateType, true));\n case 'geoarrow.polygon':\n case 'geoarrow.multilinestring':\n return createList(\n new arrow.Field('value', createList(new arrow.Field('value', coordinateType, true)), true)\n );\n case 'geoarrow.multipolygon':\n return createList(\n new arrow.Field(\n 'value',\n createList(\n new arrow.Field(\n 'value',\n createList(new arrow.Field('value', coordinateType, true)),\n true\n )\n ),\n true\n )\n );\n case 'geoarrow.box':\n return new arrow.Struct(\n getBoxFieldNames(options?.dimension || getDimensionName(targetDimension)).map(\n name => new arrow.Field(name, new arrow.Float64(), true)\n )\n );\n case 'geoarrow.wkb':\n return new arrow.Binary();\n case 'geoarrow.wkt':\n return new arrow.Utf8();\n default:\n throw new Error(`Unsupported GeoArrow target encoding \"${targetEncoding}\".`);\n }\n}\n\n/**\n * Returns true when a target encoding uses native coordinate nesting.\n * @param targetEncoding Target GeoArrow encoding.\n * @returns `true` for native point/line/polygon encodings.\n */\nfunction usesNativeGeoArrowCoordinates(targetEncoding: GeoArrowEncoding): boolean {\n return targetEncoding !== 'geoarrow.wkb' && targetEncoding !== 'geoarrow.wkt';\n}\n\n/**\n * Returns whether an explicitly requested native physical layout already matches a vector.\n *\n * Encoding names alone do not describe coordinate layout, dimensions, or offset width. Keeping\n * this check next to the identity fast path prevents an adaptive `native` request from silently\n * ignoring an explicit physical representation requirement.\n *\n * @param column GeoArrow vector to inspect.\n * @param encoding Resolved target encoding.\n * @param options Conversion options.\n * @returns Whether the vector can be reused without conversion.\n */\nfunction canReuseGeoArrowVector(\n column: arrow.Vector,\n encoding: GeoArrowEncoding,\n options?: GeoArrowGeometryConvertOptions\n): boolean {\n if (!usesNativeGeoArrowCoordinates(encoding)) {\n return true;\n }\n\n if (options?.dimension) {\n // A three-coordinate vector cannot distinguish XYZ from XYM from its physical type alone.\n return false;\n }\n if (options?.coordinates && getCoordinateLayout(column.type) !== options.coordinates) {\n return false;\n }\n if (options?.offsetType && getVectorOffsetType(column.type) !== options.offsetType) {\n return false;\n }\n return true;\n}\n\n/** Returns the coordinate layout found in a nested native GeoArrow type. */\nfunction getCoordinateLayout(type: arrow.DataType): GeoArrowCoordinateLayout | null {\n if (type instanceof arrow.FixedSizeList) return 'interleaved';\n if (type instanceof arrow.Struct) {\n const names = type.children.map(child => child.name);\n if (names[0] === 'x' && names[1] === 'y') return 'separated';\n for (const child of type.children) {\n const layout = getCoordinateLayout(child.type);\n if (layout) return layout;\n }\n return null;\n }\n if (type instanceof arrow.List || type instanceof arrow.LargeList) {\n return getCoordinateLayout(type.children[0].type);\n }\n if (type instanceof arrow.DenseUnion) {\n for (const child of type.children) {\n const layout = getCoordinateLayout(child.type);\n if (layout) return layout;\n }\n }\n return null;\n}\n\n/** Returns the first variable-length offset width found in a nested native GeoArrow type. */\nfunction getVectorOffsetType(type: arrow.DataType): GeoArrowOffsetType | null {\n if (type instanceof arrow.List) return 'int32';\n if (type instanceof arrow.LargeList) return 'int64';\n if (type instanceof arrow.Struct) {\n for (const child of type.children) {\n const offsetType = getVectorOffsetType(child.type);\n if (offsetType) return offsetType;\n }\n }\n if (type instanceof arrow.DenseUnion) {\n for (const child of type.children) {\n const offsetType = getVectorOffsetType(child.type);\n if (offsetType) return offsetType;\n }\n }\n return null;\n}\n\n/**\n * Resolves the adaptive native target for one geometry column.\n * @param targetEncoding Requested target encoding.\n * @param sourceEncoding Source encoding.\n * @param geometryTypes Trusted geometry type metadata, when available.\n * @returns Concrete GeoArrow target encoding.\n */\nfunction resolveTargetEncoding(\n targetEncoding: GeoArrowGeometryTarget,\n sourceEncoding: GeoArrowEncoding,\n geometryTypes?: readonly GeoParquetGeometryType[]\n): GeoArrowEncoding {\n if (targetEncoding !== 'native') {\n return targetEncoding;\n }\n\n if (\n sourceEncoding === 'geoarrow.geometry' ||\n sourceEncoding === 'geoarrow.geometrycollection' ||\n sourceEncoding === 'geoarrow.box'\n ) {\n return sourceEncoding;\n }\n\n if (\n sourceEncoding !== 'geoarrow.wkb' &&\n sourceEncoding !== 'geoarrow.wkt' &&\n sourceEncoding.startsWith('geoarrow.')\n ) {\n return sourceEncoding;\n }\n\n return selectNativeEncoding(geometryTypes);\n}\n\n/**\n * Selects a concrete native encoding from GeoParquet geometry type metadata.\n * @param geometryTypes Geometry type metadata.\n * @returns Concrete native encoding or dense union when metadata is incomplete.\n */\nfunction selectNativeEncoding(geometryTypes?: readonly GeoParquetGeometryType[]): GeoArrowEncoding {\n if (!geometryTypes || geometryTypes.length === 0) {\n return 'geoarrow.geometry';\n }\n\n const geometryKinds = new Set(\n geometryTypes.map(geometryType => geometryType.replace(/ (Z|M|ZM)$/, ''))\n );\n const dimensions = new Set(\n geometryTypes.map(geometryType => {\n if (geometryType.endsWith(' ZM')) return 'xyzm';\n if (geometryType.endsWith(' Z')) return 'xyz';\n if (geometryType.endsWith(' M')) return 'xym';\n return 'xy';\n })\n );\n\n if (dimensions.size > 1) {\n return 'geoarrow.geometry';\n }\n\n if (geometryKinds.has('GeometryCollection')) {\n return 'geoarrow.geometry';\n }\n\n if (geometryKinds.size === 1) {\n switch ([...geometryKinds][0]) {\n case 'Point':\n return 'geoarrow.point';\n case 'MultiPoint':\n return 'geoarrow.multipoint';\n case 'LineString':\n return 'geoarrow.linestring';\n case 'MultiLineString':\n return 'geoarrow.multilinestring';\n case 'Polygon':\n return 'geoarrow.polygon';\n case 'MultiPolygon':\n return 'geoarrow.multipolygon';\n default:\n return 'geoarrow.geometry';\n }\n }\n\n if (geometryKinds.size === 2) {\n if (geometryKinds.has('Point') && geometryKinds.has('MultiPoint')) {\n return 'geoarrow.multipoint';\n }\n if (geometryKinds.has('LineString') && geometryKinds.has('MultiLineString')) {\n return 'geoarrow.multilinestring';\n }\n if (geometryKinds.has('Polygon') && geometryKinds.has('MultiPolygon')) {\n return 'geoarrow.multipolygon';\n }\n }\n\n return 'geoarrow.geometry';\n}\n\n/**\n * Builds the Arrow type for a GeoArrow dense union geometry column.\n * @param targetDimension Coordinate dimension.\n * @param allowGeometryCollections Whether to include geometrycollection children.\n * @returns DenseUnion Arrow type.\n */\nfunction buildGeometryUnionType(\n targetDimension: 2 | 3 | 4,\n allowGeometryCollections: boolean,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = allowGeometryCollections ? 1 : 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DenseUnion {\n const geometryKinds: GeoArrowGeometryKind[] = [\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon'\n ];\n\n if (allowGeometryCollections && geometryCollectionDepth > 0) {\n geometryKinds.push('GeometryCollection');\n }\n\n return new arrow.DenseUnion(\n geometryKinds.map(geometryKind => getUnionTypeId(geometryKind, targetDimension, dimensionName)),\n geometryKinds.map(\n geometryKind =>\n new arrow.Field(\n getUnionFieldName(geometryKind, targetDimension, dimensionName),\n getUnionChildType(\n geometryKind,\n targetDimension,\n options,\n geometryCollectionDepth,\n dimensionName\n ),\n true\n )\n )\n );\n}\n\n/**\n * Builds the Arrow type for a GeoArrow geometry collection column.\n * @param targetDimension Coordinate dimension.\n * @returns List<DenseUnion> Arrow type.\n */\nfunction buildGeometryCollectionType(\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n return createListType(\n new arrow.Field(\n 'geometries',\n buildGeometryUnionType(\n targetDimension,\n geometryCollectionDepth > 0,\n options,\n geometryCollectionDepth,\n dimensionName\n ),\n true\n ),\n options?.offsetType\n );\n}\n\n/**\n * Returns the GeoArrow union base type id for a geometry kind.\n * @param geometryKind Geometry kind.\n * @returns Base union type id.\n */\nfunction getUnionBaseTypeId(geometryKind: GeoArrowGeometryKind): number {\n switch (geometryKind) {\n case 'Point':\n return 1;\n case 'LineString':\n return 2;\n case 'Polygon':\n return 3;\n case 'MultiPoint':\n return 4;\n case 'MultiLineString':\n return 5;\n case 'MultiPolygon':\n return 6;\n case 'GeometryCollection':\n return 7;\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Maps a geometry kind to its concrete GeoArrow encoding.\n * @param geometryKind Geometry kind.\n * @returns GeoArrow encoding.\n */\nfunction getGeometryKindEncoding(\n geometryKind: Exclude<GeoArrowGeometryKind, 'GeometryCollection'>\n): GeoArrowEncoding {\n switch (geometryKind) {\n case 'Point':\n return 'geoarrow.point';\n case 'LineString':\n return 'geoarrow.linestring';\n case 'Polygon':\n return 'geoarrow.polygon';\n case 'MultiPoint':\n return 'geoarrow.multipoint';\n case 'MultiLineString':\n return 'geoarrow.multilinestring';\n case 'MultiPolygon':\n return 'geoarrow.multipolygon';\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Determines the target coordinate dimension for a set of geometries.\n * @param geometries Source geometries.\n * @param dimensionName Optional exact dimension name.\n * @returns Coordinate dimension for the converted column.\n */\nfunction getTargetDimension(\n geometries: (Geometry | null)[],\n dimensionName?: GeoArrowDimension\n): 2 | 3 | 4 {\n if (dimensionName) {\n return dimensionName.length === 2 ? 2 : dimensionName.length === 3 ? 3 : 4;\n }\n let dimension = 2;\n\n for (const geometry of geometries) {\n if (!geometry) {\n continue;\n }\n dimension = Math.max(dimension, getGeometryCoordinateDimension(geometry));\n }\n\n return Math.min(Math.max(dimension, 2), 4) as 2 | 3 | 4;\n}\n\n/**\n * Gets the coordinate dimension used by a GeoJSON geometry.\n * @param geometry GeoJSON geometry.\n * @returns Number of coordinate values.\n */\nfunction getGeometryCoordinateDimension(geometry: Geometry): number {\n if ('coordinates' in geometry) {\n return getCoordinateDimension(geometry.coordinates);\n }\n\n if (geometry.geometries.length > 0) {\n return getGeometryCoordinateDimension(geometry.geometries[0]);\n }\n\n return 2;\n}\n\n/**\n * Gets the coordinate dimension used in nested coordinate arrays.\n * @param coordinates Nested coordinates.\n * @returns Number of coordinate values.\n */\nfunction getCoordinateDimension(coordinates: unknown): number {\n if (!Array.isArray(coordinates)) {\n return 2;\n }\n\n if (typeof coordinates[0] === 'number') {\n return coordinates.length;\n }\n\n if (coordinates.length === 0) {\n return 2;\n }\n\n return getCoordinateDimension(coordinates[0]);\n}\n\nfunction getDimensionName(coordinateSize: 2 | 3 | 4): GeoArrowDimension {\n return coordinateSize === 2 ? 'xy' : coordinateSize === 4 ? 'xyzm' : 'xyz';\n}\n\n/** Resolves physical coordinate width and semantic Z/M meaning for a conversion. */\nfunction getTargetDimensionName(\n geometries: (Geometry | null)[],\n options?: GeoArrowGeometryConvertOptions\n): GeoArrowDimension {\n return (\n options?.dimension ||\n getDimensionFromGeometryTypes(options?.geometryTypes) ||\n getDimensionName(getTargetDimension(geometries))\n );\n}\n\n/** Returns one semantic dimension when all declared geometry types agree. */\nfunction getDimensionFromGeometryTypes(\n geometryTypes?: readonly GeoParquetGeometryType[]\n): GeoArrowDimension | undefined {\n if (!geometryTypes || geometryTypes.length === 0) return undefined;\n const dimensions = new Set(\n geometryTypes.map(geometryType =>\n geometryType.endsWith(' ZM')\n ? 'xyzm'\n : geometryType.endsWith(' Z')\n ? 'xyz'\n : geometryType.endsWith(' M')\n ? 'xym'\n : 'xy'\n )\n );\n return dimensions.size === 1 ? ([...dimensions][0] as GeoArrowDimension) : undefined;\n}\n\nfunction getBoxFieldNames(dimension: GeoArrowDimension): string[] {\n const minimumNames =\n dimension === 'xy'\n ? ['xmin', 'ymin']\n : dimension === 'xyz'\n ? ['xmin', 'ymin', 'zmin']\n : dimension === 'xym'\n ? ['xmin', 'ymin', 'mmin']\n : ['xmin', 'ymin', 'zmin', 'mmin'];\n const maximumNames =\n dimension === 'xy'\n ? ['xmax', 'ymax']\n : dimension === 'xyz'\n ? ['xmax', 'ymax', 'zmax']\n : dimension === 'xym'\n ? ['xmax', 'ymax', 'mmax']\n : ['xmax', 'ymax', 'zmax', 'mmax'];\n return [...minimumNames, ...maximumNames];\n}\n\n/** Creates the Arrow coordinate type for the requested layout and dimension. */\nfunction getCoordinateType(\n targetDimension: 2 | 3 | 4,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n if (coordinates === 'interleaved') {\n return new arrow.FixedSizeList(\n targetDimension,\n new arrow.Field('value', new arrow.Float64(), true)\n );\n }\n\n const coordinateNames =\n dimensionName === 'xy'\n ? ['x', 'y']\n : dimensionName === 'xyz'\n ? ['x', 'y', 'z']\n : dimensionName === 'xym'\n ? ['x', 'y', 'm']\n : ['x', 'y', 'z', 'm'];\n return new arrow.Struct(\n coordinateNames.map(name => new arrow.Field(name, new arrow.Float64(), true))\n );\n}\n\n/** Creates a variable-length list type with the requested offset width. */\nfunction createListType(\n field: arrow.Field,\n offsetType: GeoArrowOffsetType = 'int32'\n): arrow.DataType {\n return offsetType === 'int64' ? new arrow.LargeList(field) : new arrow.List(field);\n}\n\n/** Creates offsets compatible with the selected Arrow list type. */\nfunction createOffsetArray(\n offsets: number[],\n offsetType: GeoArrowOffsetType = 'int32'\n): Int32Array | BigInt64Array {\n return offsetType === 'int64' ? BigInt64Array.from(offsets, BigInt) : Int32Array.from(offsets);\n}\n\n/** Recursively separates coordinate tuples, retaining the semantic measure name for XYM. */\nfunction separateCoordinateValues(\n value: unknown,\n targetDimension: 2 | 3 | 4,\n dimensionName: GeoArrowDimension\n): unknown {\n if (!Array.isArray(value)) {\n return value;\n }\n if (value.length === 0 || (typeof value[0] !== 'number' && !value.every(item => item === null))) {\n return value.map(item => separateCoordinateValues(item, targetDimension, dimensionName));\n }\n\n const names = dimensionName === 'xym' ? ['x', 'y', 'm'] : ['x', 'y', 'z', 'm'];\n return Object.fromEntries(\n names.slice(0, targetDimension).map((name, index) => [name, value[index]])\n );\n}\n\n/**\n * Clones Arrow metadata into a mutable map.\n * @param metadata Metadata to clone.\n * @returns Cloned metadata map.\n */\nfunction cloneMetadataMap(metadata?: Map<string, string>): Map<string, string> {\n return metadata ? new Map(metadata.entries()) : new Map();\n}\n\n/**\n * Returns WKB write options that preserve Z and M dimensions.\n * @param geometry Geometry being encoded.\n * @returns WKB options.\n */\nfunction getGeometryWKBOptions(\n geometry: Geometry,\n options?: GeoArrowGeometryConvertOptions\n): {hasZ?: boolean; hasM?: boolean} {\n const dimension = getGeometryDimension(geometry, options);\n return {\n hasZ: dimension === 'xyz' || dimension === 'xyzm',\n hasM: dimension === 'xym' || dimension === 'xyzm'\n };\n}\n\n/** Resolves the semantic dimension of one geometry, honoring WKT annotations and metadata. */\nfunction getGeometryDimension(\n geometry: Geometry,\n options?: GeoArrowGeometryConvertOptions\n): GeoArrowDimension {\n if (options?.dimension) return options.dimension;\n const declaredDimension = (geometry as Geometry & {__geoarrowDimension?: GeoArrowDimension})\n .__geoarrowDimension;\n if (declaredDimension) return declaredDimension;\n const geometryTypes = options?.geometryTypes || [];\n const dimensions = new Set(\n geometryTypes.map(geometryType =>\n geometryType.endsWith(' ZM')\n ? 'xyzm'\n : geometryType.endsWith(' Z')\n ? 'xyz'\n : geometryType.endsWith(' M')\n ? 'xym'\n : 'xy'\n )\n );\n if (dimensions.size === 1) return [...dimensions][0] as GeoArrowDimension;\n const coordinateDimension = getGeometryCoordinateDimension(geometry);\n return coordinateDimension === 4 ? 'xyzm' : coordinateDimension === 3 ? 'xyz' : 'xy';\n}\n\n/**\n * Normalizes a point geometry for native GeoArrow point output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded point coordinates.\n */\nfunction normalizePointCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): (number | null)[] {\n if (geometry.type !== 'Point') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.point in column \"${geometryColumn}\".`\n );\n }\n if (geometry.coordinates.length === 0) {\n return Array.from({length: targetDimension}, () => null);\n }\n return padPosition(geometry.coordinates, targetDimension);\n}\n\n/**\n * Normalizes a linestring geometry for native GeoArrow linestring output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded linestring coordinates.\n */\nfunction normalizeLineStringCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][] {\n if (geometry.type !== 'LineString') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.linestring in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(position => padPosition(position, targetDimension));\n}\n\n/**\n * Normalizes a polygon geometry for native GeoArrow polygon output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded polygon coordinates.\n */\nfunction normalizePolygonCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][] {\n if (geometry.type !== 'Polygon') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.polygon in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(ring =>\n ring.map(position => padPosition(position, targetDimension))\n );\n}\n\n/**\n * Normalizes a multipoint geometry for native GeoArrow multipoint output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multipoint coordinates.\n */\nfunction normalizeMultiPointCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][] {\n if (geometry.type === 'Point') {\n return [padPosition(geometry.coordinates, targetDimension)];\n }\n if (geometry.type !== 'MultiPoint') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multipoint in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(position => padPosition(position, targetDimension));\n}\n\n/**\n * Normalizes a multilinestring geometry for native GeoArrow multilinestring output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multilinestring coordinates.\n */\nfunction normalizeMultiLineStringCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][] {\n if (geometry.type === 'LineString') {\n return [geometry.coordinates.map(position => padPosition(position, targetDimension))];\n }\n if (geometry.type !== 'MultiLineString') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multilinestring in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(line =>\n line.map(position => padPosition(position, targetDimension))\n );\n}\n\n/**\n * Normalizes a multipolygon geometry for native GeoArrow multipolygon output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multipolygon coordinates.\n */\nfunction normalizeMultiPolygonCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][][] {\n if (geometry.type === 'Polygon') {\n return [\n geometry.coordinates.map(ring => ring.map(position => padPosition(position, targetDimension)))\n ];\n }\n if (geometry.type !== 'MultiPolygon') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multipolygon in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(polygon =>\n polygon.map(ring => ring.map(position => padPosition(position, targetDimension)))\n );\n}\n\n/**\n * Pads one coordinate tuple to the target dimension.\n * @param position Coordinate tuple.\n * @param targetDimension Target coordinate dimension.\n * @returns Padded coordinate tuple.\n */\nfunction padPosition(position: Position, targetDimension: 2 | 3 | 4): number[] {\n const paddedPosition = [...position];\n while (paddedPosition.length < targetDimension) {\n paddedPosition.push(0);\n }\n return paddedPosition.slice(0, targetDimension);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AACvB,sBAIO;AAEP,6BAGO;AAEP,yCAA+C;AAE/C,+BAA0C;AAC1C,iCAKO;AACP,iCAAoC;AACpC,+BAIO;AACP,iCAAsC;AACtC,iCAAsC;AACtC,sCAA2C;AAC3C,oCAGO;AACP,4BAA2C;AAoD3C,IAAM,wCAAwC;AAavC,SAAS,sBACd,QACA,gBACA,gBACA,SACc;AACd,QAAM,6BAA6B,8BAA8B,OAAO;AACxE,oEAA6B,QAAQ,gBAAgB,OAAO;AAC5D,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACX;AAEA,MACE,mBAAmB,0BACnB,uBAAuB,QAAQ,wBAAwB,OAAO,GAC9D;AACA,WAAO;AAAA,EACT;AAEA,SAAO,sBAAsB,QAAQ,gBAAgB,wBAAwB,YAAY;AAAA,IACvF,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAaO,SAAS,mCACd,QACA,UACA,UACiB;AACjB,MAAI,aAAa,qBAAqB;AACpC,WAAO;AAAA,MACL,OAAO,IAAI,QAAQ;AAAA,MACnB,0BAA0B,QAAQ,QAAQ;AAAA,IAC5C;AAAA,EACF;AACA,MAAI,aAAa,+BAA+B;AAC9C,UAAM,kBAAkB,OAAO,IAAI,QAAQ;AAC3C,QAAI,CAAC,gBAAiB,QAAO;AAC7B,UAAM,kBAA8B,CAAC;AACrC,UAAM,cAAc;AACpB,aAAS,cAAc,GAAG,cAAc,YAAY,QAAQ,eAAe;AACzE,YAAM,WAAW;AAAA,QACf,YAAY,IAAI,WAAW;AAAA,QAC3B,0BAA0B,aAAa,WAAW;AAA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,CAAC;AAAA,EACvB;AACA,SAAO,eAAe,MAAM,GAAG,eAAe;AAChD;",
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport {\n convertGeoArrowColumn,\n decodeGeoArrowWKB,\n encodeGeoArrowWKB\n} from '@math.gl/arrow/geoarrow-utils';\nimport type {DecodeGeoArrowWKBOptions} from '@math.gl/arrow/geoarrow-utils';\nimport {\n convertGeometryToWKB,\n convertGeometryToWKT\n} from '@loaders.gl/core/arrow-geometry/geometry-codecs';\nimport type {Geometry, Position} from '@loaders.gl/core/schema';\nimport {convertGeoArrowGeometryToGeoJSON} from '../lib/geometry-converters/convert-geoarrow-to-geojson';\nimport type {GeoArrowEncoding, GeoArrowMetadata} from '../metadata/geoarrow-metadata';\nimport {getGeometryMetadataForField} from '../metadata/geoarrow-metadata';\nimport {\n getGeoMetadata,\n type GeoMetadata,\n type GeoColumnMetadata,\n type GeoParquetGeometryType\n} from '../metadata/geoparquet-metadata';\nimport {inspectGeoArrowVector} from '../geoarrow-inspection';\nimport {\n decodeWKTGeometryCollectionVector,\n decodeWKTNativeVector,\n decodeWKTUnionVector\n} from '../lib/kernels/decode-wkt-native';\nimport {encodeGeoArrowBoxVector} from '../lib/kernels/encode-geoarrow-box';\nimport {encodeGeoArrowWKTVector} from '../lib/kernels/encode-geoarrow-wkt';\nimport {assertGeoArrowResourceLimits} from '../geoarrow-resource-limits';\nimport {\n makeArrowVectorFromGeoArrowColumn,\n makeGeoArrowColumnFromArrowVector\n} from '@math.gl/arrow/geoarrow';\nimport {getGeoArrowUnionGeometryKind} from '../lib/kernels/geoarrow-union';\n\ntype GeoArrowGeometryKind =\n | 'Point'\n | 'LineString'\n | 'Polygon'\n | 'MultiPoint'\n | 'MultiLineString'\n | 'MultiPolygon'\n | 'GeometryCollection';\n\ntype GeometryUnionChildValue =\n | Geometry\n | string\n | Uint8Array\n | (number | null)[]\n | number[][]\n | number[][][]\n | number[][][][]\n | null;\n\n/**\n * Options for converting geometry columns in a GeoArrow table.\n */\nexport type GeoArrowGeometryTarget = GeoArrowEncoding | 'native';\nexport type GeoArrowCoordinateLayout = 'interleaved' | 'separated';\nexport type GeoArrowDimension = 'xy' | 'xyz' | 'xym' | 'xyzm';\nexport type GeoArrowOffsetType = 'int32' | 'int64';\n\nexport type GeoArrowGeometryConvertOptions = {\n /** Optional single geometry column to convert. Defaults to all geometry columns. */\n geometryColumn?: string;\n /** Optional list of geometry columns to convert. Defaults to all geometry columns. */\n geometryColumns?: string[];\n /** Known geometry types used to select an adaptive native target for vector conversion. */\n geometryTypes?: readonly GeoParquetGeometryType[];\n /** Coordinate storage layout for native output. Defaults to interleaved. */\n coordinates?: GeoArrowCoordinateLayout;\n /** Exact coordinate dimensions for native output. */\n dimension?: GeoArrowDimension;\n /** Offset storage width for variable-length native output. Defaults to int32. */\n offsetType?: GeoArrowOffsetType;\n /** Maximum nested GeometryCollection depth. Defaults to 64. */\n maxGeometryCollectionDepth?: number;\n /** Maximum serialized bytes across one WKB or WKT input vector. */\n maxGeometryBytes?: number;\n /** Maximum coordinate vertices across one input vector. */\n maxGeometryVertices?: number;\n /** Behavior when no direct Arrow-buffer kernel exists. Defaults to the compatibility bridge. */\n fallback?: 'geojson' | 'error';\n};\n\nconst DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH = 64;\n\n/**\n * Converts one GeoArrow vector to a concrete or adaptive native encoding.\n *\n * Same-encoding conversions return the original vector so all Arrow buffers remain shared.\n *\n * @param column GeoArrow geometry vector.\n * @param sourceEncoding Source GeoArrow encoding.\n * @param targetEncoding Concrete target encoding or the adaptive `native` target.\n * @param options Conversion options and optional geometry type metadata.\n * @returns Converted GeoArrow vector.\n */\nexport function convertGeoArrowVector(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowGeometryTarget,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector {\n const maxGeometryCollectionDepth = getMaxGeometryCollectionDepth(options);\n assertGeoArrowResourceLimits(column, sourceEncoding, options);\n const resolvedTargetEncoding = resolveTargetEncoding(\n targetEncoding,\n sourceEncoding,\n options?.geometryTypes\n );\n\n if (\n sourceEncoding === resolvedTargetEncoding &&\n canReuseGeoArrowVector(column, resolvedTargetEncoding, options)\n ) {\n return column;\n }\n\n return convertGeometryColumn(column, sourceEncoding, resolvedTargetEncoding, 'geometry', {\n ...options,\n maxGeometryCollectionDepth\n });\n}\n\n/**\n * Converts one vector cell to GeoJSON, including dense-union and geometry-collection columns.\n *\n * Dense union cells need the parent vector's type-id buffer to recover the geometry kind; the\n * ordinary cell converter intentionally has no vector context and therefore cannot decode them.\n *\n * @param column GeoArrow geometry vector.\n * @param rowIndex Row index within the vector.\n * @param encoding Declared GeoArrow encoding.\n * @returns GeoJSON geometry or `null`.\n */\nexport function convertGeoArrowVectorCellToGeoJSON(\n column: arrow.Vector,\n rowIndex: number,\n encoding: GeoArrowEncoding\n): Geometry | null {\n if (encoding === 'geoarrow.geometry') {\n return convertUnionValueToGeometry(\n column.get(rowIndex),\n getDenseUnionGeometryKind(column, rowIndex)\n );\n }\n if (encoding === 'geoarrow.geometrycollection') {\n const collectionValue = column.get(rowIndex);\n if (!collectionValue) return null;\n const childGeometries: Geometry[] = [];\n const unionVector = collectionValue as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const geometry = convertUnionValueToGeometry(\n unionVector.get(memberIndex),\n getDenseUnionGeometryKind(unionVector, memberIndex)\n );\n if (geometry) childGeometries.push(geometry);\n }\n return {type: 'GeometryCollection', geometries: childGeometries};\n }\n return convertGeoArrowGeometryToGeoJSON(column.get(rowIndex), encoding);\n}\n\n/**\n * Converts one or more geometry columns in a GeoArrow Arrow table to a target GeoArrow encoding.\n * @param table GeoArrow Apache Arrow table.\n * @param targetEncoding Target GeoArrow encoding for selected geometry columns.\n * @param options Conversion options.\n * @returns A new Arrow table with converted geometry columns.\n */\nexport function convertGeoArrowGeometry(\n table: arrow.Table,\n targetEncoding: GeoArrowGeometryTarget,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Table {\n const maxGeometryCollectionDepth = getMaxGeometryCollectionDepth(options);\n const geometryColumns = getGeometryColumnsFromArrowSchema(table.schema);\n const selectedGeometryColumns = resolveGeometryColumns(geometryColumns, options);\n const geoMetadata = getGeoMetadata(table.schema.metadata || new Map());\n\n if (selectedGeometryColumns.length === 0) {\n throw new Error('GeoArrowGeometryConverter requires at least one geometry column to convert.');\n }\n\n const convertedEncodings = new Map<string, GeoArrowEncoding>();\n const conversionOptions = new Map<string, GeoArrowGeometryConvertOptions | undefined>();\n for (const geometryColumn of selectedGeometryColumns) {\n const sourceMetadata = geometryColumns[geometryColumn];\n const sourceEncoding = sourceMetadata?.encoding;\n if (!sourceEncoding) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${geometryColumn}\".`);\n }\n\n const geometryTypes =\n options?.geometryTypes ||\n geoMetadata?.columns?.[geometryColumn]?.geometry_types ||\n sourceMetadata?.geometry_types ||\n inferGeometryTypes(table, geometryColumn, sourceEncoding);\n const resolvedTargetEncoding = resolveTargetEncoding(\n targetEncoding,\n sourceEncoding,\n geometryTypes\n );\n conversionOptions.set(\n geometryColumn,\n geometryTypes && geometryTypes.length > 0\n ? {...options, geometryTypes, maxGeometryCollectionDepth}\n : {...options, maxGeometryCollectionDepth}\n );\n const sourceVector = table.getChild(geometryColumn);\n if (\n sourceEncoding !== resolvedTargetEncoding ||\n (sourceVector &&\n !canReuseGeoArrowVector(\n sourceVector,\n resolvedTargetEncoding,\n conversionOptions.get(geometryColumn)\n ))\n ) {\n convertedEncodings.set(geometryColumn, resolvedTargetEncoding);\n }\n }\n\n if (convertedEncodings.size === 0) {\n for (const geometryColumn of selectedGeometryColumns) {\n const sourceMetadata = geometryColumns[geometryColumn];\n const sourceVector = table.getChild(geometryColumn);\n if (sourceMetadata?.encoding && sourceVector) {\n assertGeoArrowResourceLimits(sourceVector, sourceMetadata.encoding, options);\n }\n }\n return table;\n }\n\n const nextSchemaMetadata = cloneMetadataMap(table.schema.metadata);\n updateGeoMetadata(nextSchemaMetadata, geoMetadata, convertedEncodings, conversionOptions);\n const sourceGeometryColumns = getGeometryColumnsFromArrowSchema(table.schema);\n const convertedColumns = new Map<string, arrow.Vector>();\n for (const [geometryColumn, convertedEncoding] of convertedEncodings) {\n const sourceVector = table.getChild(geometryColumn);\n if (!sourceVector) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${geometryColumn}\".`);\n }\n convertedColumns.set(\n geometryColumn,\n convertGeoArrowVector(\n sourceVector,\n sourceGeometryColumns[geometryColumn].encoding!,\n convertedEncoding,\n conversionOptions.get(geometryColumn)\n )\n );\n }\n const nextFields = table.schema.fields.map(field => {\n const convertedEncoding = convertedEncodings.get(field.name);\n const convertedVector = convertedColumns.get(field.name);\n return convertedEncoding && convertedVector\n ? createConvertedField(\n field,\n convertedVector.type,\n convertedEncoding,\n conversionOptions.get(field.name)?.geometryTypes,\n conversionOptions.get(field.name),\n geoMetadata?.columns?.[field.name]\n )\n : field;\n });\n const nextSchema = new arrow.Schema(nextFields, nextSchemaMetadata);\n let rowOffset = 0;\n const nextBatches = table.batches.map(batch => {\n const children = table.schema.fields.map(field => {\n const convertedVector = convertedColumns.get(field.name);\n if (!convertedVector) {\n const sourceVector = batch.getChild(field.name);\n if (!sourceVector) {\n throw new Error(`GeoArrowGeometryConverter could not resolve column \"${field.name}\".`);\n }\n return sourceVector.data[0];\n }\n const batchVector = convertedVector.slice(rowOffset, rowOffset + batch.numRows);\n if (batchVector.data.length !== 1) {\n throw new Error(\n `Converted GeoArrow column \"${field.name}\" does not align to record batches.`\n );\n }\n return batchVector.data[0];\n });\n rowOffset += batch.numRows;\n return new arrow.RecordBatch(\n nextSchema,\n arrow.makeData({\n type: new arrow.Struct(nextFields),\n length: batch.numRows,\n nullCount: 0,\n children\n })\n );\n });\n\n return new arrow.Table(nextSchema, nextBatches);\n}\n\n/** Inspects all record batches when WKB geometry metadata does not declare geometry types. */\nfunction inferGeometryTypes(\n table: arrow.Table,\n geometryColumn: string,\n sourceEncoding: GeoArrowEncoding\n): readonly GeoParquetGeometryType[] | undefined {\n if (sourceEncoding !== 'geoarrow.wkb' && sourceEncoding !== 'geoarrow.wkt') {\n return undefined;\n }\n const vector = table.getChild(geometryColumn);\n if (!vector) return undefined;\n const inspection = inspectGeoArrowVector(vector, sourceEncoding);\n return inspection.geometryTypes.length > 0 ? inspection.geometryTypes : undefined;\n}\n\n/**\n * Extracts GeoArrow geometry metadata from an Apache Arrow schema.\n * @param schema Apache Arrow schema.\n * @returns GeoArrow geometry columns keyed by field name.\n */\nfunction getGeometryColumnsFromArrowSchema(schema: arrow.Schema): Record<string, GeoArrowMetadata> {\n const geometryColumns: Record<string, GeoArrowMetadata> = {};\n\n for (const field of schema.fields) {\n const geometryMetadata = getGeometryMetadataForField(field.metadata || new Map());\n if (geometryMetadata) {\n geometryColumns[field.name] = geometryMetadata;\n }\n }\n\n return geometryColumns;\n}\n\n/**\n * Converts one GeoArrow geometry column to a target encoding.\n * @param column GeoArrow Arrow vector.\n * @param sourceEncoding Source encoding.\n * @param targetEncoding Target encoding.\n * @param geometryColumn Column name for error messages.\n * @returns Converted Arrow vector.\n */\nfunction convertGeometryColumn(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowEncoding,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector {\n if (targetEncoding === 'geoarrow.box') {\n return encodeGeoArrowBoxVector(column, sourceEncoding, options?.dimension);\n }\n const mathGeoArrowVector = convertGeometryColumnWithMath(\n column,\n sourceEncoding,\n targetEncoding,\n options\n );\n if (mathGeoArrowVector) return mathGeoArrowVector;\n if (targetEncoding === 'geoarrow.wkt') {\n const directWKTVector = encodeGeoArrowWKTVector(column, sourceEncoding, options?.dimension);\n if (directWKTVector) return directWKTVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && isConcreteNativeEncoding(targetEncoding)) {\n const directWKTVector = decodeWKTNativeVector(\n column,\n targetEncoding,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTVector) return directWKTVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && targetEncoding === 'geoarrow.geometry') {\n const directWKTUnionVector = decodeWKTUnionVector(\n column,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.geometryTypes,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTUnionVector) return directWKTUnionVector;\n }\n if (sourceEncoding === 'geoarrow.wkt' && targetEncoding === 'geoarrow.geometrycollection') {\n const directWKTCollectionVector = decodeWKTGeometryCollectionVector(\n column,\n options?.dimension,\n options?.coordinates,\n options?.offsetType,\n options?.geometryTypes,\n options?.maxGeometryCollectionDepth\n );\n if (directWKTCollectionVector) return directWKTCollectionVector;\n }\n if (options?.fallback === 'error') {\n throw new Error(\n `No direct GeoArrow conversion kernel is available for ${sourceEncoding} to ${targetEncoding}.`\n );\n }\n const geometries = extractGeometries(column, sourceEncoding);\n assertGeometryCollectionDepth(geometries, options?.maxGeometryCollectionDepth);\n if (\n (targetEncoding === 'geoarrow.geometry' || targetEncoding === 'geoarrow.geometrycollection') &&\n getGeometryCollectionDepth(geometries) > 1\n ) {\n throw new Error(\n 'Native GeoArrow layouts do not support recursive GeometryCollections; keep the column as WKB or WKT.'\n );\n }\n\n const targetDimension = usesNativeGeoArrowCoordinates(targetEncoding)\n ? getTargetDimension(geometries, options?.dimension)\n : 2;\n const targetDimensionName = usesNativeGeoArrowCoordinates(targetEncoding)\n ? getTargetDimensionName(geometries, options)\n : 'xy';\n if (targetEncoding === 'geoarrow.geometry') {\n return createGeometryUnionVector(\n geometries,\n targetDimension,\n true,\n geometryColumn,\n options,\n getGeometryCollectionDepth(geometries),\n targetDimensionName\n );\n }\n if (targetEncoding === 'geoarrow.geometrycollection') {\n return createGeometryCollectionVector(\n geometries,\n targetDimension,\n geometryColumn,\n options,\n getGeometryCollectionDepth(geometries),\n targetDimensionName\n );\n }\n const targetValues = geometries.map(geometry =>\n convertGeometryValue(geometry, targetEncoding, targetDimension, geometryColumn, options)\n );\n const nativeValues =\n options?.coordinates === 'separated'\n ? targetValues.map(value =>\n separateCoordinateValues(value, targetDimension, targetDimensionName)\n )\n : targetValues;\n return arrow.vectorFromArray(\n nativeValues,\n getTargetArrowType(\n targetEncoding,\n targetDimension,\n options,\n options?.dimension || getDimensionFromGeometryTypes(options?.geometryTypes)\n )\n );\n}\n\n/** Uses math.gl for physical GeoArrow and WKB conversions without materializing geometry rows. */\nfunction convertGeometryColumnWithMath(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding,\n targetEncoding: GeoArrowEncoding,\n options?: GeoArrowGeometryConvertOptions\n): arrow.Vector | null {\n const sourceIsNative = isMathGeoArrowNativeEncoding(sourceEncoding);\n const targetIsNative = isMathGeoArrowNativeEncoding(targetEncoding);\n const supportsConversion =\n (sourceEncoding === 'geoarrow.wkb' && targetIsNative) ||\n (sourceIsNative && targetEncoding === 'geoarrow.wkb') ||\n (sourceIsNative && targetIsNative);\n if (!supportsConversion) return null;\n\n const declaredDimension = getDimensionFromGeometryTypes(options?.geometryTypes);\n const sourceColumn = makeGeoArrowColumnFromArrowVector(column, {\n encoding: sourceEncoding,\n dimension:\n sourceEncoding === 'geoarrow.wkb'\n ? declaredDimension || 'xy'\n : declaredDimension || (targetEncoding === 'geoarrow.wkb' ? options?.dimension : undefined)\n });\n if (sourceEncoding === 'geoarrow.wkb') {\n try {\n const decodedColumn = decodeGeoArrowWKB(sourceColumn, {\n encoding: targetEncoding as DecodeGeoArrowWKBOptions['encoding'],\n dimension: options?.dimension || declaredDimension || 'infer',\n coordinateLayout: options?.coordinates || 'interleaved',\n offsetType: options?.offsetType || 'int32',\n traversal: {maximumDepth: options?.maxGeometryCollectionDepth}\n });\n return makeArrowVectorFromGeoArrowColumn(decodedColumn);\n } catch (error) {\n if (\n options?.maxGeometryCollectionDepth !== undefined &&\n error instanceof Error &&\n error.message.includes('nesting exceeds maximumDepth')\n ) {\n throw new Error(\n `GeometryCollection nesting exceeds maxGeometryCollectionDepth (${options.maxGeometryCollectionDepth}).`\n );\n }\n throw error;\n }\n }\n if (targetEncoding === 'geoarrow.wkb') {\n return makeArrowVectorFromGeoArrowColumn(encodeGeoArrowWKB(sourceColumn));\n }\n\n const convertedColumn = convertGeoArrowColumn(sourceColumn, {\n encoding: targetEncoding,\n dimension: options?.dimension,\n coordinateLayout: options?.coordinates || 'preserve',\n offsetType: options?.offsetType || 'preserve'\n });\n return convertedColumn === sourceColumn\n ? column\n : makeArrowVectorFromGeoArrowColumn(convertedColumn);\n}\n\n/** Returns whether math.gl models an encoding as native physical geometry buffers. */\nfunction isMathGeoArrowNativeEncoding(\n encoding: GeoArrowEncoding\n): encoding is Exclude<GeoArrowEncoding, 'geoarrow.box' | 'geoarrow.wkb' | 'geoarrow.wkt'> {\n return (\n encoding === 'geoarrow.point' ||\n encoding === 'geoarrow.linestring' ||\n encoding === 'geoarrow.polygon' ||\n encoding === 'geoarrow.multipoint' ||\n encoding === 'geoarrow.multilinestring' ||\n encoding === 'geoarrow.multipolygon' ||\n encoding === 'geoarrow.geometry' ||\n encoding === 'geoarrow.geometrycollection'\n );\n}\n\n/** Returns a validated collection-depth limit for all conversion paths. */\nfunction getMaxGeometryCollectionDepth(options?: GeoArrowGeometryConvertOptions): number {\n const maximumDepth = options?.maxGeometryCollectionDepth ?? DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH;\n if (!Number.isSafeInteger(maximumDepth) || maximumDepth < 0) {\n throw new Error('maxGeometryCollectionDepth must be a non-negative safe integer.');\n }\n return maximumDepth;\n}\n\n/** Rejects hostile or accidentally unbounded nested GeometryCollections without recursion. */\nfunction assertGeometryCollectionDepth(\n geometries: readonly (Geometry | null)[],\n maximumDepth = DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH\n): void {\n const pending: {geometry: Geometry; depth: number}[] = [];\n for (const geometry of geometries) {\n if (geometry) pending.push({geometry, depth: 0});\n }\n while (pending.length > 0) {\n const current = pending.pop()!;\n if (current.geometry.type !== 'GeometryCollection') continue;\n const depth = current.depth + 1;\n if (depth > maximumDepth) {\n throw new Error(\n `GeometryCollection nesting exceeds maxGeometryCollectionDepth (${maximumDepth}).`\n );\n }\n for (const child of current.geometry.geometries) {\n pending.push({geometry: child, depth});\n }\n }\n}\n\nfunction isConcreteNativeEncoding(\n encoding: GeoArrowEncoding\n): encoding is\n | 'geoarrow.point'\n | 'geoarrow.linestring'\n | 'geoarrow.polygon'\n | 'geoarrow.multipoint'\n | 'geoarrow.multilinestring'\n | 'geoarrow.multipolygon' {\n return (\n encoding === 'geoarrow.point' ||\n encoding === 'geoarrow.linestring' ||\n encoding === 'geoarrow.polygon' ||\n encoding === 'geoarrow.multipoint' ||\n encoding === 'geoarrow.multilinestring' ||\n encoding === 'geoarrow.multipolygon'\n );\n}\n\n/**\n * Converts one geometry value to the requested target encoding payload.\n * @param geometry Source geometry.\n * @param targetEncoding Target GeoArrow encoding.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Arrow cell value for the target encoding.\n */\nfunction convertGeometryValue(\n geometry: Geometry | null,\n targetEncoding: GeoArrowEncoding,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions\n): string | Uint8Array | (number | null)[] | number[][] | number[][][] | number[][][][] | null {\n if (!geometry) {\n return null;\n }\n\n switch (targetEncoding) {\n case 'geoarrow.wkb':\n return new Uint8Array(\n convertGeometryToWKB(geometry, getGeometryWKBOptions(geometry, options))\n );\n case 'geoarrow.wkt':\n return convertGeometryToWKT(geometry, {dimension: getGeometryDimension(geometry, options)});\n case 'geoarrow.point':\n return normalizePointCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.linestring':\n return normalizeLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.polygon':\n return normalizePolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multipoint':\n return normalizeMultiPointCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multilinestring':\n return normalizeMultiLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'geoarrow.multipolygon':\n return normalizeMultiPolygonCoordinates(geometry, targetDimension, geometryColumn);\n default:\n throw new Error(`Unsupported GeoArrow target encoding \"${targetEncoding}\".`);\n }\n}\n\n/**\n * Extracts GeoJSON geometries from a GeoArrow column.\n * @param column GeoArrow column vector.\n * @param sourceEncoding Source GeoArrow encoding.\n * @returns Decoded geometries.\n */\nfunction extractGeometries(\n column: arrow.Vector,\n sourceEncoding: GeoArrowEncoding\n): (Geometry | null)[] {\n switch (sourceEncoding) {\n case 'geoarrow.geometry':\n return extractGeometryUnionColumn(column);\n case 'geoarrow.geometrycollection':\n return extractGeometryCollectionColumn(column);\n default: {\n const geometries: (Geometry | null)[] = [];\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n geometries.push(convertGeoArrowGeometryToGeoJSON(column.get(rowIndex), sourceEncoding));\n }\n return geometries;\n }\n }\n}\n\n/**\n * Extracts geometries from a `geoarrow.geometry` DenseUnion column.\n * @param column DenseUnion GeoArrow vector.\n * @returns Decoded geometries.\n */\nfunction extractGeometryUnionColumn(column: arrow.Vector): (Geometry | null)[] {\n const geometries: (Geometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const geometryKind = getDenseUnionGeometryKind(column, rowIndex);\n geometries.push(convertUnionValueToGeometry(column.get(rowIndex), geometryKind));\n }\n\n return geometries;\n}\n\n/**\n * Extracts geometries from a `geoarrow.geometrycollection` column.\n * @param column List<DenseUnion> GeoArrow vector.\n * @returns Decoded geometry collections.\n */\nfunction extractGeometryCollectionColumn(column: arrow.Vector): (Geometry | null)[] {\n const geometries: (Geometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const collectionValue = column.get(rowIndex);\n if (!collectionValue) {\n geometries.push(null);\n continue;\n }\n\n const childGeometries: Geometry[] = [];\n const unionVector = collectionValue as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const geometryKind = getDenseUnionGeometryKind(unionVector, memberIndex);\n const geometry = convertUnionValueToGeometry(unionVector.get(memberIndex), geometryKind);\n if (geometry) {\n childGeometries.push(geometry);\n }\n }\n\n geometries.push({\n type: 'GeometryCollection',\n geometries: childGeometries\n });\n }\n\n return geometries;\n}\n\n/**\n * Builds a `geoarrow.geometry` DenseUnion vector.\n * @param geometries Source geometries.\n * @param targetDimension Target coordinate dimension.\n * @param allowGeometryCollections Whether geometry collection children are allowed.\n * @param geometryColumn Column name for error messages.\n * @returns DenseUnion vector.\n */\nfunction createGeometryUnionVector(\n geometries: (Geometry | null)[],\n targetDimension: 2 | 3 | 4,\n allowGeometryCollections: boolean,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = allowGeometryCollections ? getGeometryCollectionDepth(geometries) : 0,\n targetDimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n const usedKinds = new Set<GeoArrowGeometryKind>();\n const typeIds: number[] = [];\n const valueOffsets: number[] = [];\n const childValues: Partial<Record<GeoArrowGeometryKind, GeometryUnionChildValue[]>> = {};\n\n const nullCarrierKind = getNullCarrierKind(geometries, allowGeometryCollections);\n usedKinds.add(nullCarrierKind);\n childValues[nullCarrierKind] = [];\n for (const geometryType of options?.geometryTypes || []) {\n const geometryKind = getBaseGeometryKind(geometryType);\n if (geometryKind && (allowGeometryCollections || geometryKind !== 'GeometryCollection')) {\n usedKinds.add(geometryKind);\n childValues[geometryKind] ||= [];\n }\n }\n\n for (const geometry of geometries) {\n const geometryKind = geometry?.type || nullCarrierKind;\n if (geometryKind === 'GeometryCollection' && geometryCollectionDepth === 0) {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode GeometryCollection in \"${geometryColumn}\" without a geometrycollection child.`\n );\n }\n\n const childKind = (geometryKind || nullCarrierKind) as GeoArrowGeometryKind;\n usedKinds.add(childKind);\n childValues[childKind] ||= [];\n valueOffsets.push(childValues[childKind]!.length);\n typeIds.push(getUnionTypeId(childKind, targetDimension, targetDimensionName));\n\n childValues[childKind]!.push(\n geometry ? convertGeometryToUnionChildValue(geometry, targetDimension, geometryColumn) : null\n );\n }\n\n const orderedKinds = [...usedKinds].sort(\n (leftKind, rightKind) =>\n getUnionTypeId(leftKind, targetDimension, targetDimensionName) -\n getUnionTypeId(rightKind, targetDimension, targetDimensionName)\n );\n const fields = orderedKinds.map(\n kind =>\n new arrow.Field(\n getUnionFieldName(kind, targetDimension, targetDimensionName),\n getUnionChildType(\n kind,\n targetDimension,\n options,\n geometryCollectionDepth,\n targetDimensionName\n ),\n true\n )\n );\n const children = orderedKinds.map(kind => {\n const values = childValues[kind] || [];\n return createUnionChildVector(\n kind,\n values,\n targetDimension,\n geometryColumn,\n options,\n geometryCollectionDepth,\n targetDimensionName\n ).data[0];\n });\n const unionType = new arrow.DenseUnion(\n orderedKinds.map(kind => getUnionTypeId(kind, targetDimension, targetDimensionName)),\n fields\n );\n\n return arrow.makeVector(\n arrow.makeData({\n type: unionType,\n length: geometries.length,\n nullCount: 0,\n typeIds: Int8Array.from(typeIds),\n valueOffsets: Int32Array.from(valueOffsets),\n children\n })\n );\n}\n\n/**\n * Builds a `geoarrow.geometrycollection` vector.\n * @param geometries Source geometries.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Geometry collection vector.\n */\nfunction createGeometryCollectionVector(\n geometries: (Geometry | null)[],\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = getGeometryCollectionDepth(geometries),\n targetDimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n const flattenedGeometries: (Geometry | null)[] = [];\n const valueOffsets = [0];\n const validity: boolean[] = [];\n\n for (const geometry of geometries) {\n if (!geometry) {\n validity.push(false);\n valueOffsets.push(flattenedGeometries.length);\n continue;\n }\n if (geometry.type !== 'GeometryCollection') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.geometrycollection in column \"${geometryColumn}\".`\n );\n }\n\n validity.push(true);\n flattenedGeometries.push(...geometry.geometries);\n valueOffsets.push(flattenedGeometries.length);\n }\n\n const memberUnionVector = createGeometryUnionVector(\n flattenedGeometries,\n targetDimension,\n false,\n geometryColumn,\n options,\n 0,\n targetDimensionName\n );\n const listType = createListType(\n new arrow.Field('geometries', memberUnionVector.type, true),\n options?.offsetType\n );\n\n const listData = {\n length: geometries.length,\n nullCount: validity.filter(isValid => !isValid).length,\n nullBitmap: createNullBitmap(validity),\n valueOffsets: createOffsetArray(valueOffsets, options?.offsetType),\n child: memberUnionVector.data[0]\n };\n const listDataValue =\n listType instanceof arrow.LargeList\n ? arrow.makeData({\n type: listType,\n ...listData,\n valueOffsets: BigInt64Array.from(valueOffsets, BigInt)\n })\n : arrow.makeData({\n type: listType as arrow.List,\n ...listData,\n valueOffsets: Int32Array.from(valueOffsets)\n });\n return arrow.makeVector(listDataValue as any);\n}\n\n/**\n * Converts one GeoJSON geometry to a native GeoArrow union child payload.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Union child payload.\n */\nfunction convertGeometryToUnionChildValue(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): Geometry | (number | null)[] | number[][] | number[][][] | number[][][][] | null {\n switch (geometry.type) {\n case 'Point':\n return normalizePointCoordinates(geometry, targetDimension, geometryColumn);\n case 'LineString':\n return normalizeLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'Polygon':\n return normalizePolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiPoint':\n return normalizeMultiPointCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiLineString':\n return normalizeMultiLineStringCoordinates(geometry, targetDimension, geometryColumn);\n case 'MultiPolygon':\n return normalizeMultiPolygonCoordinates(geometry, targetDimension, geometryColumn);\n case 'GeometryCollection':\n return geometry;\n }\n}\n\n/**\n * Creates a child vector for a geometry union.\n * @param geometryKind Child geometry kind.\n * @param values Child values.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Child vector.\n */\nfunction createUnionChildVector(\n geometryKind: GeoArrowGeometryKind,\n values: unknown[],\n targetDimension: 2 | 3 | 4,\n geometryColumn: string,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.Vector {\n if (geometryKind === 'GeometryCollection') {\n return createGeometryCollectionVector(\n values as (Geometry | null)[],\n targetDimension,\n geometryColumn,\n options,\n Math.max(geometryCollectionDepth - 1, 0),\n dimensionName\n );\n }\n\n const nativeValues =\n options?.coordinates === 'separated'\n ? values.map(value => separateCoordinateValues(value, targetDimension, dimensionName))\n : values;\n return arrow.vectorFromArray(\n nativeValues,\n getUnionChildType(\n geometryKind,\n targetDimension,\n options,\n geometryCollectionDepth,\n dimensionName\n )\n );\n}\n\n/**\n * Converts a union child value back to GeoJSON geometry.\n * @param value Arrow child value.\n * @param geometryKind Geometry kind.\n * @returns GeoJSON geometry.\n */\nfunction convertUnionValueToGeometry(\n value: unknown,\n geometryKind: GeoArrowGeometryKind\n): Geometry | null {\n if (value == null) return null;\n switch (geometryKind) {\n case 'Point':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.point');\n case 'LineString':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.linestring');\n case 'Polygon':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.polygon');\n case 'MultiPoint':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multipoint');\n case 'MultiLineString':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multilinestring');\n case 'MultiPolygon':\n return convertGeoArrowGeometryToGeoJSON(value, 'geoarrow.multipolygon');\n case 'GeometryCollection': {\n const geometries: Geometry[] = [];\n const unionVector = value as arrow.Vector;\n for (let memberIndex = 0; memberIndex < unionVector.length; memberIndex++) {\n const childGeometryKind = getDenseUnionGeometryKind(unionVector, memberIndex);\n const geometry = convertUnionValueToGeometry(\n unionVector.get(memberIndex),\n childGeometryKind\n );\n if (geometry) {\n geometries.push(geometry);\n }\n }\n return {type: 'GeometryCollection', geometries};\n }\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Returns the union cell type identifier for one row.\n * @param vector DenseUnion vector or sliced nested vector.\n * @param rowIndex Row index within the vector.\n * @returns Dense union type id and value offset for the row.\n */\nfunction getDenseUnionCellInfo(\n vector: arrow.Vector,\n rowIndex: number\n): {typeId: number; valueOffset: number} {\n let remainingRowIndex = rowIndex;\n\n for (const chunk of vector.data) {\n if (remainingRowIndex < chunk.length) {\n const typeIdIndex = getUnionBufferIndex(\n chunk.typeIds.length,\n chunk.offset,\n remainingRowIndex,\n chunk.typeIds.length <= chunk.length\n );\n const valueOffsetIndex = getUnionBufferIndex(\n chunk.valueOffsets.length,\n chunk.offset,\n remainingRowIndex,\n chunk.typeIds.length <= chunk.length\n );\n return {\n typeId: chunk.typeIds[typeIdIndex],\n valueOffset: chunk.valueOffsets[valueOffsetIndex]\n };\n }\n remainingRowIndex -= chunk.length;\n }\n\n throw new Error(`DenseUnion row ${rowIndex} is out of bounds.`);\n}\n\n/** Resolves union buffer indexes for both full and already-sliced Arrow buffers. */\nfunction getUnionBufferIndex(\n bufferLength: number,\n offset: number,\n rowIndex: number,\n useLogicalIndex: boolean\n): number {\n if (useLogicalIndex) return rowIndex;\n const physicalIndex = offset + rowIndex;\n return physicalIndex < bufferLength ? physicalIndex : rowIndex;\n}\n\n/**\n * Maps a GeoArrow dense union type id to the base geometry kind.\n * @param typeId GeoArrow union type id.\n * @returns Base geometry kind.\n */\nfunction getDenseUnionGeometryKind(vector: arrow.Vector, rowIndex: number): GeoArrowGeometryKind {\n if (!(vector.type instanceof arrow.DenseUnion)) {\n throw new Error('GeoArrow geometry storage requires a DenseUnion vector.');\n }\n const {typeId} = getDenseUnionCellInfo(vector, rowIndex);\n const childIndex = vector.type.typeIds.indexOf(typeId);\n const fieldName = childIndex >= 0 ? vector.type.children[childIndex]?.name : undefined;\n const geometryKind = getGeoArrowUnionGeometryKind(fieldName, typeId);\n if (!geometryKind) {\n throw new Error(`Unsupported GeoArrow union type id \"${typeId}\".`);\n }\n return geometryKind;\n}\n\n/**\n * Selects a geometry kind that can carry null union members.\n * @param geometries Source geometries.\n * @param allowGeometryCollections Whether geometry collections are valid children.\n * @returns A geometry kind present in the table or a point fallback.\n */\nfunction getNullCarrierKind(\n geometries: (Geometry | null)[],\n allowGeometryCollections: boolean\n): GeoArrowGeometryKind {\n for (const geometry of geometries) {\n if (!geometry) {\n continue;\n }\n if (geometry.type === 'GeometryCollection' && !allowGeometryCollections) {\n continue;\n }\n return geometry.type;\n }\n\n return 'Point';\n}\n\n/** Removes a GeoParquet dimension suffix and validates a geometry union child kind. */\nfunction getBaseGeometryKind(geometryType: GeoParquetGeometryType): GeoArrowGeometryKind | null {\n const geometryKind = geometryType.replace(/ (?:ZM|Z|M)$/, '');\n switch (geometryKind) {\n case 'Point':\n case 'LineString':\n case 'Polygon':\n case 'MultiPoint':\n case 'MultiLineString':\n case 'MultiPolygon':\n case 'GeometryCollection':\n return geometryKind;\n default:\n return null;\n }\n}\n\n/** Returns the maximum nested GeometryCollection depth in a geometry sequence. */\nfunction getGeometryCollectionDepth(geometries: (Geometry | null)[]): number {\n let maximumDepth = 0;\n for (const geometry of geometries) {\n if (geometry?.type === 'GeometryCollection') {\n maximumDepth = Math.max(maximumDepth, 1 + getGeometryCollectionDepth(geometry.geometries));\n }\n }\n return maximumDepth;\n}\n\n/**\n * Returns the GeoArrow union type id for a geometry kind and coordinate dimension.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns GeoArrow union type id.\n */\nfunction getUnionTypeId(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n dimensionName = getDimensionName(targetDimension)\n): number {\n const baseTypeId = getUnionBaseTypeId(geometryKind);\n\n switch (dimensionName) {\n case 'xy':\n return baseTypeId;\n case 'xyz':\n return 10 + baseTypeId;\n case 'xym':\n return 20 + baseTypeId;\n case 'xyzm':\n return 30 + baseTypeId;\n default:\n return baseTypeId;\n }\n}\n\n/**\n * Returns the GeoArrow child field name for a dense union member.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns Arrow field name.\n */\nfunction getUnionFieldName(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n dimensionName = getDimensionName(targetDimension)\n): string {\n switch (dimensionName) {\n case 'xy':\n return geometryKind;\n case 'xyz':\n return `${geometryKind} Z`;\n case 'xym':\n return `${geometryKind} M`;\n case 'xyzm':\n return `${geometryKind} ZM`;\n default:\n return geometryKind;\n }\n}\n\n/**\n * Returns the Arrow child type for one dense union member.\n * @param geometryKind Geometry kind.\n * @param targetDimension Coordinate dimension.\n * @returns Arrow child type.\n */\nfunction getUnionChildType(\n geometryKind: GeoArrowGeometryKind,\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n if (geometryKind === 'GeometryCollection') {\n return buildGeometryCollectionType(\n targetDimension,\n options,\n Math.max(geometryCollectionDepth - 1, 0),\n dimensionName\n );\n }\n\n return getTargetArrowType(\n getGeometryKindEncoding(geometryKind),\n targetDimension,\n options,\n dimensionName\n );\n}\n\n/**\n * Packs Arrow validity bits into a null bitmap.\n * @param validity Row validity values.\n * @returns Arrow null bitmap.\n */\nfunction createNullBitmap(validity: boolean[]): Uint8Array {\n const nullBitmap = new Uint8Array(Math.ceil(validity.length / 8));\n\n for (let index = 0; index < validity.length; index++) {\n if (validity[index]) {\n nullBitmap[index >> 3] |= 1 << (index % 8);\n }\n }\n\n return nullBitmap;\n}\n\n/**\n * Resolves the geometry columns that should be converted.\n * @param geometryColumns Geometry columns from schema metadata.\n * @param options Conversion options.\n * @returns Geometry column names to convert.\n */\nfunction resolveGeometryColumns(\n geometryColumns: Record<string, {encoding?: GeoArrowEncoding}>,\n options?: GeoArrowGeometryConvertOptions\n): string[] {\n const availableGeometryColumns = Object.keys(geometryColumns);\n\n if (options?.geometryColumn && options?.geometryColumns?.length) {\n throw new Error('Specify only one of \"geometryColumn\" or \"geometryColumns\".');\n }\n\n if (options?.geometryColumn) {\n if (!geometryColumns[options.geometryColumn]) {\n throw new Error(\n `GeoArrowGeometryConverter could not find geometry column \"${options.geometryColumn}\".`\n );\n }\n return [options.geometryColumn];\n }\n\n if (options?.geometryColumns?.length) {\n for (const geometryColumn of options.geometryColumns) {\n if (!geometryColumns[geometryColumn]) {\n throw new Error(\n `GeoArrowGeometryConverter could not find geometry column \"${geometryColumn}\".`\n );\n }\n }\n return options.geometryColumns;\n }\n\n return availableGeometryColumns;\n}\n\n/**\n * Creates a cloned field with updated GeoArrow encoding metadata.\n * @param field Source Arrow field.\n * @param type Target Arrow type.\n * @param targetEncoding Target GeoArrow encoding.\n * @returns Converted Arrow field.\n */\nfunction createConvertedField(\n field: arrow.Field,\n type: arrow.DataType,\n targetEncoding: GeoArrowEncoding,\n geometryTypes?: readonly GeoParquetGeometryType[],\n options?: GeoArrowGeometryConvertOptions,\n sourceGeoColumnMetadata?: GeoColumnMetadata\n): arrow.Field {\n const metadata = cloneMetadataMap(field.metadata);\n metadata.set('ARROW:extension:name', targetEncoding);\n const effectiveGeometryTypes = options?.dimension\n ? getGeometryTypesForEncoding(targetEncoding, options.dimension)\n : geometryTypes && geometryTypes.length > 0\n ? geometryTypes\n : getGeometryTypesForEncoding(targetEncoding, options?.dimension);\n if (effectiveGeometryTypes.length > 0) {\n const extensionMetadata = {\n ...(getGeometryMetadataForField(metadata) || {}),\n ...getPreservedFieldMetadata(sourceGeoColumnMetadata)\n };\n extensionMetadata.encoding = targetEncoding;\n extensionMetadata.geometry_types = [...effectiveGeometryTypes];\n metadata.set('ARROW:extension:metadata', JSON.stringify(extensionMetadata));\n }\n return new arrow.Field(field.name, type, field.nullable, metadata);\n}\n\n/** Carries GeoParquet semantics into the GeoArrow field without copying its file-level encoding. */\nfunction getPreservedFieldMetadata(\n sourceGeoColumnMetadata?: GeoColumnMetadata\n): Record<string, unknown> {\n if (!sourceGeoColumnMetadata) return {};\n const preservedMetadata: Record<string, unknown> = {};\n for (const key of ['crs', 'orientation', 'bbox', 'epoch', 'edges']) {\n const value = sourceGeoColumnMetadata[key];\n if (value !== undefined && value !== null && !(key === 'edges' && value === 'planar')) {\n preservedMetadata[key] = value;\n }\n }\n for (const [key, value] of Object.entries(sourceGeoColumnMetadata)) {\n if (!(key in preservedMetadata) && !['encoding', 'geometry_types', 'crs'].includes(key)) {\n preservedMetadata[key] = value;\n }\n }\n return preservedMetadata;\n}\n\n/** Derives one concrete geometry type for explicit native dimension metadata. */\nfunction getGeometryTypesForEncoding(\n encoding: GeoArrowEncoding,\n dimension?: GeoArrowDimension\n): GeoParquetGeometryType[] {\n if (!dimension) return [];\n const geometryTypeByEncoding: Partial<Record<GeoArrowEncoding, string>> = {\n 'geoarrow.point': 'Point',\n 'geoarrow.linestring': 'LineString',\n 'geoarrow.polygon': 'Polygon',\n 'geoarrow.multipoint': 'MultiPoint',\n 'geoarrow.multilinestring': 'MultiLineString',\n 'geoarrow.multipolygon': 'MultiPolygon'\n };\n const geometryType = geometryTypeByEncoding[encoding];\n if (!geometryType) return [];\n const suffix =\n dimension === 'xy' ? '' : dimension === 'xyz' ? ' Z' : dimension === 'xym' ? ' M' : ' ZM';\n return [`${geometryType}${suffix}` as GeoParquetGeometryType];\n}\n\n/**\n * Updates schema-level GeoParquet metadata after geometry conversion.\n * @param metadata Schema metadata map to mutate.\n * @param geoMetadata Parsed GeoParquet metadata.\n * @param selectedGeometryColumns Geometry columns that were converted.\n * @param targetEncoding Target GeoArrow encoding.\n */\nfunction updateGeoMetadata(\n metadata: Map<string, string>,\n geoMetadata: GeoMetadata | null,\n convertedEncodings: Map<string, GeoArrowEncoding>,\n conversionOptions: Map<string, GeoArrowGeometryConvertOptions | undefined>\n): void {\n if (!geoMetadata) {\n return;\n }\n\n const nextGeoMetadata = JSON.parse(JSON.stringify(geoMetadata)) as GeoMetadata;\n\n for (const [geometryColumn, targetEncoding] of convertedEncodings) {\n const geometryColumnMetadata = nextGeoMetadata.columns?.[geometryColumn];\n if (!geometryColumnMetadata) continue;\n const targetGeoParquetEncoding = getGeoParquetEncoding(targetEncoding);\n if (targetGeoParquetEncoding) {\n geometryColumnMetadata.encoding = targetGeoParquetEncoding;\n }\n const requestedDimension = conversionOptions.get(geometryColumn)?.dimension;\n if (requestedDimension) {\n const geometryTypes = getGeometryTypesForEncoding(targetEncoding, requestedDimension);\n if (geometryTypes.length > 0) {\n geometryColumnMetadata.geometry_types = geometryTypes;\n }\n }\n }\n\n const remainingGeometryColumns = Object.keys(nextGeoMetadata.columns || {});\n if (\n nextGeoMetadata.primary_column &&\n !nextGeoMetadata.columns?.[nextGeoMetadata.primary_column]\n ) {\n if (remainingGeometryColumns.length > 0) {\n nextGeoMetadata.primary_column = remainingGeometryColumns[0];\n } else {\n delete nextGeoMetadata.primary_column;\n }\n }\n\n if (remainingGeometryColumns.length === 0) {\n metadata.delete('geo');\n return;\n }\n\n metadata.set('geo', JSON.stringify(nextGeoMetadata));\n}\n\n/** Maps a GeoArrow target to a representable GeoParquet encoding when one exists. */\nfunction getGeoParquetEncoding(targetEncoding: GeoArrowEncoding): string | null {\n switch (targetEncoding) {\n case 'geoarrow.wkb':\n return 'wkb';\n case 'geoarrow.wkt':\n return 'wkt';\n case 'geoarrow.geometry':\n return 'geometry';\n case 'geoarrow.point':\n return 'point';\n case 'geoarrow.linestring':\n return 'linestring';\n case 'geoarrow.polygon':\n return 'polygon';\n case 'geoarrow.multipoint':\n return 'multipoint';\n case 'geoarrow.multilinestring':\n return 'multilinestring';\n case 'geoarrow.multipolygon':\n return 'multipolygon';\n default:\n return null;\n }\n}\n\n/**\n * Returns the Arrow data type for a target GeoArrow encoding.\n * @param targetEncoding Target GeoArrow encoding.\n * @param targetDimension Target coordinate dimension.\n * @returns Arrow data type for the converted column.\n */\nfunction getTargetArrowType(\n targetEncoding: GeoArrowEncoding,\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n const coordinateType = getCoordinateType(targetDimension, options?.coordinates, dimensionName);\n const createList = (field: arrow.Field): arrow.DataType =>\n createListType(field, options?.offsetType);\n\n switch (targetEncoding) {\n case 'geoarrow.geometry':\n return buildGeometryUnionType(targetDimension, true, options, 1, dimensionName);\n case 'geoarrow.geometrycollection':\n return buildGeometryCollectionType(targetDimension, options, 0, dimensionName);\n case 'geoarrow.point':\n return coordinateType;\n case 'geoarrow.linestring':\n case 'geoarrow.multipoint':\n return createList(new arrow.Field('value', coordinateType, true));\n case 'geoarrow.polygon':\n case 'geoarrow.multilinestring':\n return createList(\n new arrow.Field('value', createList(new arrow.Field('value', coordinateType, true)), true)\n );\n case 'geoarrow.multipolygon':\n return createList(\n new arrow.Field(\n 'value',\n createList(\n new arrow.Field(\n 'value',\n createList(new arrow.Field('value', coordinateType, true)),\n true\n )\n ),\n true\n )\n );\n case 'geoarrow.box':\n return new arrow.Struct(\n getBoxFieldNames(options?.dimension || getDimensionName(targetDimension)).map(\n name => new arrow.Field(name, new arrow.Float64(), true)\n )\n );\n case 'geoarrow.wkb':\n return new arrow.Binary();\n case 'geoarrow.wkt':\n return new arrow.Utf8();\n default:\n throw new Error(`Unsupported GeoArrow target encoding \"${targetEncoding}\".`);\n }\n}\n\n/**\n * Returns true when a target encoding uses native coordinate nesting.\n * @param targetEncoding Target GeoArrow encoding.\n * @returns `true` for native point/line/polygon encodings.\n */\nfunction usesNativeGeoArrowCoordinates(targetEncoding: GeoArrowEncoding): boolean {\n return targetEncoding !== 'geoarrow.wkb' && targetEncoding !== 'geoarrow.wkt';\n}\n\n/**\n * Returns whether an explicitly requested native physical layout already matches a vector.\n *\n * Encoding names alone do not describe coordinate layout, dimensions, or offset width. Keeping\n * this check next to the identity fast path prevents an adaptive `native` request from silently\n * ignoring an explicit physical representation requirement.\n *\n * @param column GeoArrow vector to inspect.\n * @param encoding Resolved target encoding.\n * @param options Conversion options.\n * @returns Whether the vector can be reused without conversion.\n */\nfunction canReuseGeoArrowVector(\n column: arrow.Vector,\n encoding: GeoArrowEncoding,\n options?: GeoArrowGeometryConvertOptions\n): boolean {\n if (!usesNativeGeoArrowCoordinates(encoding)) {\n return true;\n }\n\n if (options?.dimension) {\n // A three-coordinate vector cannot distinguish XYZ from XYM from its physical type alone.\n return false;\n }\n if (options?.coordinates && getCoordinateLayout(column.type) !== options.coordinates) {\n return false;\n }\n if (options?.offsetType && getVectorOffsetType(column.type) !== options.offsetType) {\n return false;\n }\n return true;\n}\n\n/** Returns the coordinate layout found in a nested native GeoArrow type. */\nfunction getCoordinateLayout(type: arrow.DataType): GeoArrowCoordinateLayout | null {\n if (type instanceof arrow.FixedSizeList) return 'interleaved';\n if (type instanceof arrow.Struct) {\n const names = type.children.map(child => child.name);\n if (names[0] === 'x' && names[1] === 'y') return 'separated';\n for (const child of type.children) {\n const layout = getCoordinateLayout(child.type);\n if (layout) return layout;\n }\n return null;\n }\n if (type instanceof arrow.List || type instanceof arrow.LargeList) {\n return getCoordinateLayout(type.children[0].type);\n }\n if (type instanceof arrow.DenseUnion) {\n for (const child of type.children) {\n const layout = getCoordinateLayout(child.type);\n if (layout) return layout;\n }\n }\n return null;\n}\n\n/** Returns the first variable-length offset width found in a nested native GeoArrow type. */\nfunction getVectorOffsetType(type: arrow.DataType): GeoArrowOffsetType | null {\n if (type instanceof arrow.List) return 'int32';\n if (type instanceof arrow.LargeList) return 'int64';\n if (type instanceof arrow.Struct) {\n for (const child of type.children) {\n const offsetType = getVectorOffsetType(child.type);\n if (offsetType) return offsetType;\n }\n }\n if (type instanceof arrow.DenseUnion) {\n for (const child of type.children) {\n const offsetType = getVectorOffsetType(child.type);\n if (offsetType) return offsetType;\n }\n }\n return null;\n}\n\n/**\n * Resolves the adaptive native target for one geometry column.\n * @param targetEncoding Requested target encoding.\n * @param sourceEncoding Source encoding.\n * @param geometryTypes Trusted geometry type metadata, when available.\n * @returns Concrete GeoArrow target encoding.\n */\nfunction resolveTargetEncoding(\n targetEncoding: GeoArrowGeometryTarget,\n sourceEncoding: GeoArrowEncoding,\n geometryTypes?: readonly GeoParquetGeometryType[]\n): GeoArrowEncoding {\n if (targetEncoding !== 'native') {\n return targetEncoding;\n }\n\n if (\n sourceEncoding === 'geoarrow.geometry' ||\n sourceEncoding === 'geoarrow.geometrycollection' ||\n sourceEncoding === 'geoarrow.box'\n ) {\n return sourceEncoding;\n }\n\n if (\n sourceEncoding !== 'geoarrow.wkb' &&\n sourceEncoding !== 'geoarrow.wkt' &&\n sourceEncoding.startsWith('geoarrow.')\n ) {\n return sourceEncoding;\n }\n\n return selectNativeEncoding(geometryTypes);\n}\n\n/**\n * Selects a concrete native encoding from GeoParquet geometry type metadata.\n * @param geometryTypes Geometry type metadata.\n * @returns Concrete native encoding or dense union when metadata is incomplete.\n */\nfunction selectNativeEncoding(geometryTypes?: readonly GeoParquetGeometryType[]): GeoArrowEncoding {\n if (!geometryTypes || geometryTypes.length === 0) {\n return 'geoarrow.geometry';\n }\n\n const geometryKinds = new Set(\n geometryTypes.map(geometryType => geometryType.replace(/ (Z|M|ZM)$/, ''))\n );\n const dimensions = new Set(\n geometryTypes.map(geometryType => {\n if (geometryType.endsWith(' ZM')) return 'xyzm';\n if (geometryType.endsWith(' Z')) return 'xyz';\n if (geometryType.endsWith(' M')) return 'xym';\n return 'xy';\n })\n );\n\n if (dimensions.size > 1) {\n return 'geoarrow.geometry';\n }\n\n if (geometryKinds.has('GeometryCollection')) {\n return 'geoarrow.geometry';\n }\n\n if (geometryKinds.size === 1) {\n switch ([...geometryKinds][0]) {\n case 'Point':\n return 'geoarrow.point';\n case 'MultiPoint':\n return 'geoarrow.multipoint';\n case 'LineString':\n return 'geoarrow.linestring';\n case 'MultiLineString':\n return 'geoarrow.multilinestring';\n case 'Polygon':\n return 'geoarrow.polygon';\n case 'MultiPolygon':\n return 'geoarrow.multipolygon';\n default:\n return 'geoarrow.geometry';\n }\n }\n\n if (geometryKinds.size === 2) {\n if (geometryKinds.has('Point') && geometryKinds.has('MultiPoint')) {\n return 'geoarrow.multipoint';\n }\n if (geometryKinds.has('LineString') && geometryKinds.has('MultiLineString')) {\n return 'geoarrow.multilinestring';\n }\n if (geometryKinds.has('Polygon') && geometryKinds.has('MultiPolygon')) {\n return 'geoarrow.multipolygon';\n }\n }\n\n return 'geoarrow.geometry';\n}\n\n/**\n * Builds the Arrow type for a GeoArrow dense union geometry column.\n * @param targetDimension Coordinate dimension.\n * @param allowGeometryCollections Whether to include geometrycollection children.\n * @returns DenseUnion Arrow type.\n */\nfunction buildGeometryUnionType(\n targetDimension: 2 | 3 | 4,\n allowGeometryCollections: boolean,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = allowGeometryCollections ? 1 : 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DenseUnion {\n const geometryKinds: GeoArrowGeometryKind[] = [\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon'\n ];\n\n if (allowGeometryCollections && geometryCollectionDepth > 0) {\n geometryKinds.push('GeometryCollection');\n }\n\n return new arrow.DenseUnion(\n geometryKinds.map(geometryKind => getUnionTypeId(geometryKind, targetDimension, dimensionName)),\n geometryKinds.map(\n geometryKind =>\n new arrow.Field(\n getUnionFieldName(geometryKind, targetDimension, dimensionName),\n getUnionChildType(\n geometryKind,\n targetDimension,\n options,\n geometryCollectionDepth,\n dimensionName\n ),\n true\n )\n )\n );\n}\n\n/**\n * Builds the Arrow type for a GeoArrow geometry collection column.\n * @param targetDimension Coordinate dimension.\n * @returns List<DenseUnion> Arrow type.\n */\nfunction buildGeometryCollectionType(\n targetDimension: 2 | 3 | 4,\n options?: GeoArrowGeometryConvertOptions,\n geometryCollectionDepth = 0,\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n return createListType(\n new arrow.Field(\n 'geometries',\n buildGeometryUnionType(\n targetDimension,\n geometryCollectionDepth > 0,\n options,\n geometryCollectionDepth,\n dimensionName\n ),\n true\n ),\n options?.offsetType\n );\n}\n\n/**\n * Returns the GeoArrow union base type id for a geometry kind.\n * @param geometryKind Geometry kind.\n * @returns Base union type id.\n */\nfunction getUnionBaseTypeId(geometryKind: GeoArrowGeometryKind): number {\n switch (geometryKind) {\n case 'Point':\n return 1;\n case 'LineString':\n return 2;\n case 'Polygon':\n return 3;\n case 'MultiPoint':\n return 4;\n case 'MultiLineString':\n return 5;\n case 'MultiPolygon':\n return 6;\n case 'GeometryCollection':\n return 7;\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Maps a geometry kind to its concrete GeoArrow encoding.\n * @param geometryKind Geometry kind.\n * @returns GeoArrow encoding.\n */\nfunction getGeometryKindEncoding(\n geometryKind: Exclude<GeoArrowGeometryKind, 'GeometryCollection'>\n): GeoArrowEncoding {\n switch (geometryKind) {\n case 'Point':\n return 'geoarrow.point';\n case 'LineString':\n return 'geoarrow.linestring';\n case 'Polygon':\n return 'geoarrow.polygon';\n case 'MultiPoint':\n return 'geoarrow.multipoint';\n case 'MultiLineString':\n return 'geoarrow.multilinestring';\n case 'MultiPolygon':\n return 'geoarrow.multipolygon';\n default:\n throw new Error(`Unsupported geometry kind \"${geometryKind}\".`);\n }\n}\n\n/**\n * Determines the target coordinate dimension for a set of geometries.\n * @param geometries Source geometries.\n * @param dimensionName Optional exact dimension name.\n * @returns Coordinate dimension for the converted column.\n */\nfunction getTargetDimension(\n geometries: (Geometry | null)[],\n dimensionName?: GeoArrowDimension\n): 2 | 3 | 4 {\n if (dimensionName) {\n return dimensionName.length === 2 ? 2 : dimensionName.length === 3 ? 3 : 4;\n }\n let dimension = 2;\n\n for (const geometry of geometries) {\n if (!geometry) {\n continue;\n }\n dimension = Math.max(dimension, getGeometryCoordinateDimension(geometry));\n }\n\n return Math.min(Math.max(dimension, 2), 4) as 2 | 3 | 4;\n}\n\n/**\n * Gets the coordinate dimension used by a GeoJSON geometry.\n * @param geometry GeoJSON geometry.\n * @returns Number of coordinate values.\n */\nfunction getGeometryCoordinateDimension(geometry: Geometry): number {\n if ('coordinates' in geometry) {\n return getCoordinateDimension(geometry.coordinates);\n }\n\n if (geometry.geometries.length > 0) {\n return getGeometryCoordinateDimension(geometry.geometries[0]);\n }\n\n return 2;\n}\n\n/**\n * Gets the coordinate dimension used in nested coordinate arrays.\n * @param coordinates Nested coordinates.\n * @returns Number of coordinate values.\n */\nfunction getCoordinateDimension(coordinates: unknown): number {\n if (!Array.isArray(coordinates)) {\n return 2;\n }\n\n if (typeof coordinates[0] === 'number') {\n return coordinates.length;\n }\n\n if (coordinates.length === 0) {\n return 2;\n }\n\n return getCoordinateDimension(coordinates[0]);\n}\n\nfunction getDimensionName(coordinateSize: 2 | 3 | 4): GeoArrowDimension {\n return coordinateSize === 2 ? 'xy' : coordinateSize === 4 ? 'xyzm' : 'xyz';\n}\n\n/** Resolves physical coordinate width and semantic Z/M meaning for a conversion. */\nfunction getTargetDimensionName(\n geometries: (Geometry | null)[],\n options?: GeoArrowGeometryConvertOptions\n): GeoArrowDimension {\n return (\n options?.dimension ||\n getDimensionFromGeometryTypes(options?.geometryTypes) ||\n getDimensionName(getTargetDimension(geometries))\n );\n}\n\n/** Returns one semantic dimension when all declared geometry types agree. */\nfunction getDimensionFromGeometryTypes(\n geometryTypes?: readonly GeoParquetGeometryType[]\n): GeoArrowDimension | undefined {\n if (!geometryTypes || geometryTypes.length === 0) return undefined;\n const dimensions = new Set(\n geometryTypes.map(geometryType =>\n geometryType.endsWith(' ZM')\n ? 'xyzm'\n : geometryType.endsWith(' Z')\n ? 'xyz'\n : geometryType.endsWith(' M')\n ? 'xym'\n : 'xy'\n )\n );\n return dimensions.size === 1 ? ([...dimensions][0] as GeoArrowDimension) : undefined;\n}\n\nfunction getBoxFieldNames(dimension: GeoArrowDimension): string[] {\n const minimumNames =\n dimension === 'xy'\n ? ['xmin', 'ymin']\n : dimension === 'xyz'\n ? ['xmin', 'ymin', 'zmin']\n : dimension === 'xym'\n ? ['xmin', 'ymin', 'mmin']\n : ['xmin', 'ymin', 'zmin', 'mmin'];\n const maximumNames =\n dimension === 'xy'\n ? ['xmax', 'ymax']\n : dimension === 'xyz'\n ? ['xmax', 'ymax', 'zmax']\n : dimension === 'xym'\n ? ['xmax', 'ymax', 'mmax']\n : ['xmax', 'ymax', 'zmax', 'mmax'];\n return [...minimumNames, ...maximumNames];\n}\n\n/** Creates the Arrow coordinate type for the requested layout and dimension. */\nfunction getCoordinateType(\n targetDimension: 2 | 3 | 4,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n dimensionName: GeoArrowDimension = getDimensionName(targetDimension)\n): arrow.DataType {\n if (coordinates === 'interleaved') {\n return new arrow.FixedSizeList(\n targetDimension,\n new arrow.Field('value', new arrow.Float64(), true)\n );\n }\n\n const coordinateNames =\n dimensionName === 'xy'\n ? ['x', 'y']\n : dimensionName === 'xyz'\n ? ['x', 'y', 'z']\n : dimensionName === 'xym'\n ? ['x', 'y', 'm']\n : ['x', 'y', 'z', 'm'];\n return new arrow.Struct(\n coordinateNames.map(name => new arrow.Field(name, new arrow.Float64(), true))\n );\n}\n\n/** Creates a variable-length list type with the requested offset width. */\nfunction createListType(\n field: arrow.Field,\n offsetType: GeoArrowOffsetType = 'int32'\n): arrow.DataType {\n return offsetType === 'int64' ? new arrow.LargeList(field) : new arrow.List(field);\n}\n\n/** Creates offsets compatible with the selected Arrow list type. */\nfunction createOffsetArray(\n offsets: number[],\n offsetType: GeoArrowOffsetType = 'int32'\n): Int32Array | BigInt64Array {\n return offsetType === 'int64' ? BigInt64Array.from(offsets, BigInt) : Int32Array.from(offsets);\n}\n\n/** Recursively separates coordinate tuples, retaining the semantic measure name for XYM. */\nfunction separateCoordinateValues(\n value: unknown,\n targetDimension: 2 | 3 | 4,\n dimensionName: GeoArrowDimension\n): unknown {\n if (!Array.isArray(value)) {\n return value;\n }\n if (value.length === 0 || (typeof value[0] !== 'number' && !value.every(item => item === null))) {\n return value.map(item => separateCoordinateValues(item, targetDimension, dimensionName));\n }\n\n const names = dimensionName === 'xym' ? ['x', 'y', 'm'] : ['x', 'y', 'z', 'm'];\n return Object.fromEntries(\n names.slice(0, targetDimension).map((name, index) => [name, value[index]])\n );\n}\n\n/**\n * Clones Arrow metadata into a mutable map.\n * @param metadata Metadata to clone.\n * @returns Cloned metadata map.\n */\nfunction cloneMetadataMap(metadata?: Map<string, string>): Map<string, string> {\n return metadata ? new Map(metadata.entries()) : new Map();\n}\n\n/**\n * Returns WKB write options that preserve Z and M dimensions.\n * @param geometry Geometry being encoded.\n * @returns WKB options.\n */\nfunction getGeometryWKBOptions(\n geometry: Geometry,\n options?: GeoArrowGeometryConvertOptions\n): {hasZ?: boolean; hasM?: boolean} {\n const dimension = getGeometryDimension(geometry, options);\n return {\n hasZ: dimension === 'xyz' || dimension === 'xyzm',\n hasM: dimension === 'xym' || dimension === 'xyzm'\n };\n}\n\n/** Resolves the semantic dimension of one geometry, honoring WKT annotations and metadata. */\nfunction getGeometryDimension(\n geometry: Geometry,\n options?: GeoArrowGeometryConvertOptions\n): GeoArrowDimension {\n if (options?.dimension) return options.dimension;\n const declaredDimension = (geometry as Geometry & {__geoarrowDimension?: GeoArrowDimension})\n .__geoarrowDimension;\n if (declaredDimension) return declaredDimension;\n const geometryTypes = options?.geometryTypes || [];\n const dimensions = new Set(\n geometryTypes.map(geometryType =>\n geometryType.endsWith(' ZM')\n ? 'xyzm'\n : geometryType.endsWith(' Z')\n ? 'xyz'\n : geometryType.endsWith(' M')\n ? 'xym'\n : 'xy'\n )\n );\n if (dimensions.size === 1) return [...dimensions][0] as GeoArrowDimension;\n const coordinateDimension = getGeometryCoordinateDimension(geometry);\n return coordinateDimension === 4 ? 'xyzm' : coordinateDimension === 3 ? 'xyz' : 'xy';\n}\n\n/**\n * Normalizes a point geometry for native GeoArrow point output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded point coordinates.\n */\nfunction normalizePointCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): (number | null)[] {\n if (geometry.type !== 'Point') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.point in column \"${geometryColumn}\".`\n );\n }\n if (geometry.coordinates.length === 0) {\n return Array.from({length: targetDimension}, () => null);\n }\n return padPosition(geometry.coordinates, targetDimension);\n}\n\n/**\n * Normalizes a linestring geometry for native GeoArrow linestring output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded linestring coordinates.\n */\nfunction normalizeLineStringCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][] {\n if (geometry.type !== 'LineString') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.linestring in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(position => padPosition(position, targetDimension));\n}\n\n/**\n * Normalizes a polygon geometry for native GeoArrow polygon output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded polygon coordinates.\n */\nfunction normalizePolygonCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][] {\n if (geometry.type !== 'Polygon') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.polygon in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(ring =>\n ring.map(position => padPosition(position, targetDimension))\n );\n}\n\n/**\n * Normalizes a multipoint geometry for native GeoArrow multipoint output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multipoint coordinates.\n */\nfunction normalizeMultiPointCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][] {\n if (geometry.type === 'Point') {\n return [padPosition(geometry.coordinates, targetDimension)];\n }\n if (geometry.type !== 'MultiPoint') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multipoint in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(position => padPosition(position, targetDimension));\n}\n\n/**\n * Normalizes a multilinestring geometry for native GeoArrow multilinestring output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multilinestring coordinates.\n */\nfunction normalizeMultiLineStringCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][] {\n if (geometry.type === 'LineString') {\n return [geometry.coordinates.map(position => padPosition(position, targetDimension))];\n }\n if (geometry.type !== 'MultiLineString') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multilinestring in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(line =>\n line.map(position => padPosition(position, targetDimension))\n );\n}\n\n/**\n * Normalizes a multipolygon geometry for native GeoArrow multipolygon output.\n * @param geometry Source geometry.\n * @param targetDimension Target coordinate dimension.\n * @param geometryColumn Column name for error messages.\n * @returns Padded multipolygon coordinates.\n */\nfunction normalizeMultiPolygonCoordinates(\n geometry: Geometry,\n targetDimension: 2 | 3 | 4,\n geometryColumn: string\n): number[][][][] {\n if (geometry.type === 'Polygon') {\n return [\n geometry.coordinates.map(ring => ring.map(position => padPosition(position, targetDimension)))\n ];\n }\n if (geometry.type !== 'MultiPolygon') {\n throw new Error(\n `GeoArrowGeometryConverter cannot encode ${geometry.type} as geoarrow.multipolygon in column \"${geometryColumn}\".`\n );\n }\n return geometry.coordinates.map(polygon =>\n polygon.map(ring => ring.map(position => padPosition(position, targetDimension)))\n );\n}\n\n/**\n * Pads one coordinate tuple to the target dimension.\n * @param position Coordinate tuple.\n * @param targetDimension Target coordinate dimension.\n * @returns Padded coordinate tuple.\n */\nfunction padPosition(position: Position, targetDimension: 2 | 3 | 4): number[] {\n const paddedPosition = [...position];\n while (paddedPosition.length < targetDimension) {\n paddedPosition.push(0);\n }\n return paddedPosition.slice(0, targetDimension);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AACvB,4BAIO;AAEP,6BAGO;AAEP,yCAA+C;AAE/C,+BAA0C;AAC1C,iCAKO;AACP,iCAAoC;AACpC,+BAIO;AACP,iCAAsC;AACtC,iCAAsC;AACtC,sCAA2C;AAC3C,sBAGO;AACP,4BAA2C;AAoD3C,IAAM,wCAAwC;AAavC,SAAS,sBACd,QACA,gBACA,gBACA,SACc;AACd,QAAM,6BAA6B,8BAA8B,OAAO;AACxE,oEAA6B,QAAQ,gBAAgB,OAAO;AAC5D,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACX;AAEA,MACE,mBAAmB,0BACnB,uBAAuB,QAAQ,wBAAwB,OAAO,GAC9D;AACA,WAAO;AAAA,EACT;AAEA,SAAO,sBAAsB,QAAQ,gBAAgB,wBAAwB,YAAY;AAAA,IACvF,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAaO,SAAS,mCACd,QACA,UACA,UACiB;AACjB,MAAI,aAAa,qBAAqB;AACpC,WAAO;AAAA,M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SAAS,SAAS,gBAAgB;AACpC,UAAM,IAAI;AAAA,MACR,2CAA2C,SAAS,IAAI,wCAAwC,cAAc;AAAA,IAChH;AAAA,EACF;AACA,SAAO,SAAS,YAAY;AAAA,IAAI,aAC9B,QAAQ,IAAI,UAAQ,KAAK,IAAI,cAAY,YAAY,UAAU,eAAe,CAAC,CAAC;AAAA,EAClF;AACF;AAQA,SAAS,YAAY,UAAoB,iBAAsC;AAC7E,QAAM,iBAAiB,CAAC,GAAG,QAAQ;AACnC,SAAO,eAAe,SAAS,iBAAiB;AAC9C,mBAAe,KAAK,CAAC;AAAA,EACvB;AACA,SAAO,eAAe,MAAM,GAAG,eAAe;AAChD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import * as arrow from 'apache-arrow';
|
|
5
|
-
import { convertGeoArrowColumn, decodeGeoArrowWKB, encodeGeoArrowWKB } from '@math.gl/
|
|
5
|
+
import { convertGeoArrowColumn, decodeGeoArrowWKB, encodeGeoArrowWKB } from '@math.gl/arrow/geoarrow-utils';
|
|
6
6
|
import { convertGeometryToWKB, convertGeometryToWKT } from '@loaders.gl/core/arrow-geometry/geometry-codecs';
|
|
7
7
|
import { convertGeoArrowGeometryToGeoJSON } from "../lib/geometry-converters/convert-geoarrow-to-geojson.js";
|
|
8
8
|
import { getGeometryMetadataForField } from "../metadata/geoarrow-metadata.js";
|
|
@@ -12,7 +12,7 @@ import { decodeWKTGeometryCollectionVector, decodeWKTNativeVector, decodeWKTUnio
|
|
|
12
12
|
import { encodeGeoArrowBoxVector } from "../lib/kernels/encode-geoarrow-box.js";
|
|
13
13
|
import { encodeGeoArrowWKTVector } from "../lib/kernels/encode-geoarrow-wkt.js";
|
|
14
14
|
import { assertGeoArrowResourceLimits } from "../geoarrow-resource-limits.js";
|
|
15
|
-
import { makeArrowVectorFromGeoArrowColumn, makeGeoArrowColumnFromArrowVector } from
|
|
15
|
+
import { makeArrowVectorFromGeoArrowColumn, makeGeoArrowColumnFromArrowVector } from '@math.gl/arrow/geoarrow';
|
|
16
16
|
import { getGeoArrowUnionGeometryKind } from "../lib/kernels/geoarrow-union.js";
|
|
17
17
|
const DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH = 64;
|
|
18
18
|
/**
|