@loaders.gl/core 5.0.0-rc.2 → 5.0.1
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/dist/api.cjs +4129 -0
- package/dist/api.cjs.map +6 -0
- package/dist/api.d.ts +34 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +50 -0
- package/dist/api.js.map +1 -0
- package/dist/arrow-geometry/geometry-codecs.cjs +51 -50
- package/dist/arrow-geometry/geometry-codecs.cjs.map +3 -3
- package/dist/arrow-geometry/geometry-codecs.d.ts +1 -1
- package/dist/arrow-geometry/geometry-codecs.d.ts.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.js +27 -60
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/index.cjs +5 -2
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +1 -0
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +1 -0
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.cjs +100 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.cjs.map +7 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.d.ts +15 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.d.ts.map +1 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.js +87 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.js.map +1 -0
- package/dist/arrow-geometry/triangulate-wkb.cjs +33 -118
- package/dist/arrow-geometry/triangulate-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/triangulate-wkb.d.ts.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb.js +39 -142
- package/dist/arrow-geometry/triangulate-wkb.js.map +1 -1
- package/dist/constants/index.cjs +2 -2
- package/dist/constants/index.d.ts +4 -4
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +2 -2
- package/dist/constants/index.js.map +1 -1
- package/dist/dist.dev.js +460 -541
- package/dist/dist.min.js +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +15 -0
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +19 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +6 -27
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.d.ts.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js +9 -24
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/index.cjs +1 -1
- package/dist/geoarrow/index.cjs.map +1 -1
- package/dist/geoarrow/index.d.ts +2 -2
- package/dist/geoarrow/index.d.ts.map +1 -1
- package/dist/geoarrow/index.js +1 -1
- package/dist/geoarrow/index.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -5
- 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.d.ts +2 -24
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +6 -28
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs +21 -227
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts +2 -3
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js +24 -265
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js.map +1 -1
- package/dist/index.cjs +67 -4114
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -46
- package/dist/index.js.map +1 -1
- package/dist/lib/api/encode-table.d.ts +4 -4
- package/dist/lib/api/encode-table.d.ts.map +1 -1
- package/dist/lib/api/encode-table.js +21 -3
- package/dist/lib/api/encode-table.js.map +1 -1
- package/dist/lib/api/encode.d.ts +6 -6
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +46 -7
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/loader-utils/index.cjs +96 -239
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader-metadata.cjs +85 -0
- package/dist/loader-utils/json-loader-metadata.cjs.map +6 -0
- package/dist/loader-utils/json-loader-metadata.d.ts +51 -0
- package/dist/loader-utils/json-loader-metadata.d.ts.map +1 -0
- package/dist/loader-utils/json-loader-metadata.js +31 -0
- package/dist/loader-utils/json-loader-metadata.js.map +1 -0
- package/dist/loader-utils/json-loader.cjs +80 -0
- package/dist/loader-utils/json-loader.cjs.map +6 -0
- package/dist/loader-utils/json-loader.d.ts +4 -4
- package/dist/loader-utils/json-loader.d.ts.map +1 -1
- package/dist/loader-utils/json-loader.js +3 -17
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/request-utils/authentication.d.ts +2 -0
- package/dist/loader-utils/lib/request-utils/authentication.d.ts.map +1 -1
- package/dist/loader-utils/lib/request-utils/authentication.js +12 -0
- package/dist/loader-utils/lib/request-utils/authentication.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts +4 -52
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js +16 -236
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts +2 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/raster-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/raster-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.d.ts +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.d.ts +2 -1
- package/dist/loader-utils/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.js +1 -1
- package/dist/loader-utils/tile-grid.js.map +1 -1
- package/dist/loader-utils/writer-types.d.ts +2 -0
- package/dist/loader-utils/writer-types.d.ts.map +1 -1
- package/dist/null-loader-metadata.cjs +89 -0
- package/dist/null-loader-metadata.cjs.map +6 -0
- package/dist/null-loader-metadata.d.ts +48 -0
- package/dist/null-loader-metadata.d.ts.map +1 -0
- package/dist/null-loader-metadata.js +30 -0
- package/dist/null-loader-metadata.js.map +1 -0
- package/dist/null-loader.cjs +84 -0
- package/dist/null-loader.cjs.map +6 -0
- package/dist/null-loader.d.ts +6 -6
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +2 -15
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +58 -28
- package/dist/null-worker.js +58 -28
- package/dist/scan/arrow-execution/expressions.cjs +9 -78
- package/dist/scan/arrow-execution/expressions.cjs.map +3 -3
- package/dist/scan/arrow-execution/expressions.d.ts +3 -9
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +2 -55
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +41 -179
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +3 -3
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +1 -5
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +44 -190
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/arrow-execution.cjs +2 -2
- package/dist/scan/arrow-execution.cjs.map +2 -2
- package/dist/scan/arrow-execution.d.ts +1 -1
- package/dist/scan/arrow-execution.d.ts.map +1 -1
- package/dist/scan/arrow-execution.js +1 -1
- package/dist/scan/arrow-execution.js.map +1 -1
- package/dist/scan/arrow-query.cjs +3 -3
- package/dist/scan/arrow-query.cjs.map +2 -2
- package/dist/scan/arrow-query.d.ts +2 -2
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/arrow-query.js +2 -2
- package/dist/scan/arrow-query.js.map +1 -1
- package/dist/scan/federated-table-scan-source.cjs +3 -3
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.js +1 -1
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +25 -53
- package/dist/scan/index.cjs.map +3 -3
- package/dist/scan/index.d.ts +7 -4
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +6 -4
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/plan-arrow-table-query.cjs +271 -0
- package/dist/scan/plan-arrow-table-query.cjs.map +7 -0
- package/dist/scan/plan-arrow-table-query.d.ts +50 -0
- package/dist/scan/plan-arrow-table-query.d.ts.map +1 -0
- package/dist/scan/plan-arrow-table-query.js +257 -0
- package/dist/scan/plan-arrow-table-query.js.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.cjs +7 -56
- package/dist/scan/query-arrow-table-in-batches.cjs.map +2 -2
- package/dist/scan/query-arrow-table-in-batches.d.ts +1 -1
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.js +7 -45
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -1
- package/dist/scan/query-arrow-table.cjs +7 -443
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +6 -54
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +6 -475
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-executor.cjs +202 -0
- package/dist/scan/query-executor.cjs.map +7 -0
- package/dist/scan/query-executor.d.ts +27 -0
- package/dist/scan/query-executor.d.ts.map +1 -0
- package/dist/scan/query-executor.js +203 -0
- package/dist/scan/query-executor.js.map +1 -0
- package/dist/scan/query-pushdown.cjs +3 -4
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.js +4 -5
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query.cjs +92 -204
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +5 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +94 -229
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/scan-engine.cjs +14 -7
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +1 -1
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js +4 -9
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -3
- package/dist/scan/vector-table-scan-source.cjs.map +2 -2
- package/dist/scan/vector-table-scan-source.d.ts +1 -1
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +2 -1
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema-utils/index.cjs +193 -47
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +3 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +3 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-converter.d.ts +24 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.js +43 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.js.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +2 -4
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +2 -43
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.d.ts +29 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.js +89 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.js.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.d.ts +17 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.js +24 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.js.map +1 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.d.ts +4 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.js +51 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.js.map +1 -0
- package/dist/wkt/twkb/index.cjs +68 -5
- package/dist/wkt/twkb/index.cjs.map +3 -3
- package/dist/wkt/twkb/index.d.ts +10 -2
- package/dist/wkt/twkb/index.d.ts.map +1 -1
- package/dist/wkt/twkb/index.js +49 -2
- package/dist/wkt/twkb/index.js.map +1 -1
- package/dist/worker-utils/index.cjs +4 -4
- package/dist/worker-utils/index.cjs.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/package.json +49 -23
- package/src/api.ts +99 -0
- package/src/arrow-geometry/geometry-codecs.ts +35 -78
- package/src/arrow-geometry/index.ts +5 -0
- package/src/arrow-geometry/triangulate-wkb-geometry-column.ts +122 -0
- package/src/arrow-geometry/triangulate-wkb.ts +37 -169
- package/src/constants/index.ts +2 -2
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +22 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +7 -32
- package/src/geoarrow/index.ts +2 -2
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +6 -30
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +24 -270
- package/src/index.ts +2 -94
- package/src/lib/api/encode-table.ts +31 -6
- package/src/lib/api/encode.ts +61 -11
- package/src/loader-utils/index.ts +1 -0
- package/src/loader-utils/json-loader-metadata.ts +35 -0
- package/src/loader-utils/json-loader.ts +3 -18
- package/src/loader-utils/lib/request-utils/authentication.ts +17 -0
- package/src/loader-utils/lib/scan-utils/columnar-predicate.ts +46 -363
- package/src/loader-utils/lib/scan-utils/relational-query.ts +7 -1
- package/src/loader-utils/lib/sources/raster-source.ts +4 -0
- package/src/loader-utils/tile-grid.ts +16 -1
- package/src/loader-utils/writer-types.ts +2 -0
- package/src/null-loader-metadata.ts +32 -0
- package/src/null-loader.ts +2 -17
- package/src/scan/arrow-execution/expressions.ts +2 -86
- package/src/scan/arrow-execution/filter-arrow-table.ts +54 -238
- package/src/scan/arrow-execution.ts +1 -1
- package/src/scan/arrow-query.ts +2 -2
- package/src/scan/federated-table-scan-source.ts +1 -1
- package/src/scan/index.ts +24 -4
- package/src/scan/plan-arrow-table-query.ts +367 -0
- package/src/scan/query-arrow-table-in-batches.ts +8 -54
- package/src/scan/query-arrow-table.ts +10 -626
- package/src/scan/query-executor.ts +286 -0
- package/src/scan/query-pushdown.ts +3 -4
- package/src/scan/query.ts +112 -293
- package/src/scan/scan-engine.ts +4 -11
- package/src/scan/vector-table-scan-source.ts +2 -1
- package/src/schema-utils/index.ts +14 -0
- package/src/schema-utils/lib/arrow/arrow-converter.ts +74 -0
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +2 -50
- package/src/schema-utils/lib/arrow/convert-arrow-variable-width.ts +121 -0
- package/src/schema-utils/lib/arrow/convert-arrow.ts +52 -0
- package/src/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.ts +83 -0
- package/src/wkt/twkb/index.ts +63 -2
- package/dist/cluster-source.cjs +0 -6606
- package/dist/cluster-source.cjs.map +0 -6
- package/dist/cluster-source.d.ts +0 -2
- package/dist/cluster-source.d.ts.map +0 -1
- package/dist/cluster-source.js +0 -2
- package/dist/cluster-source.js.map +0 -1
- package/dist/federated-table-scan-source.cjs +0 -2303
- package/dist/federated-table-scan-source.cjs.map +0 -6
- package/dist/federated-table-scan-source.d.ts +0 -2
- package/dist/federated-table-scan-source.d.ts.map +0 -1
- package/dist/federated-table-scan-source.js +0 -2
- package/dist/federated-table-scan-source.js.map +0 -1
- package/dist/geoarrow/geoarrow-builder.cjs +0 -31
- package/dist/geoarrow/geoarrow-builder.cjs.map +0 -7
- package/dist/geoarrow/geoarrow-builder.d.ts +0 -3
- package/dist/geoarrow/geoarrow-builder.d.ts.map +0 -1
- package/dist/geoarrow/geoarrow-builder.js +0 -5
- package/dist/geoarrow/geoarrow-builder.js.map +0 -1
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs +0 -41
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs.map +0 -7
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts +0 -5
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts.map +0 -1
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js +0 -23
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.cjs +0 -70
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +0 -7
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +0 -8
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.js +0 -39
- package/dist/scan/arrow-execution/project-arrow-table.js.map +0 -1
- package/dist/scan/query-arrow-table-math.cjs +0 -41
- package/dist/scan/query-arrow-table-math.cjs.map +0 -7
- package/dist/scan/query-arrow-table-math.d.ts +0 -5
- package/dist/scan/query-arrow-table-math.d.ts.map +0 -1
- package/dist/scan/query-arrow-table-math.js +0 -14
- package/dist/scan/query-arrow-table-math.js.map +0 -1
- package/dist/vector-table-scan-source.cjs +0 -1660
- package/dist/vector-table-scan-source.cjs.map +0 -6
- package/dist/vector-table-scan-source.d.ts +0 -2
- package/dist/vector-table-scan-source.d.ts.map +0 -1
- package/dist/vector-table-scan-source.js +0 -2
- package/dist/vector-table-scan-source.js.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs +0 -211
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs.map +0 -7
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts +0 -6
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.js +0 -204
- package/dist/wkt/twkb/convert-geometry-to-twkb.js.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs +0 -251
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs.map +0 -7
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts +0 -10
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.js +0 -261
- package/dist/wkt/twkb/convert-twkb-to-geometry.js.map +0 -1
- package/dist/wkt/twkb/twkb-io.cjs +0 -102
- package/dist/wkt/twkb/twkb-io.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-io.d.ts +0 -33
- package/dist/wkt/twkb/twkb-io.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-io.js +0 -78
- package/dist/wkt/twkb/twkb-io.js.map +0 -1
- package/dist/wkt/twkb/twkb-types.cjs +0 -40
- package/dist/wkt/twkb/twkb-types.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-types.d.ts +0 -11
- package/dist/wkt/twkb/twkb-types.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-types.js +0 -15
- package/dist/wkt/twkb/twkb-types.js.map +0 -1
- package/src/cluster-source.ts +0 -1
- package/src/federated-table-scan-source.ts +0 -1
- package/src/geoarrow/geoarrow-builder.ts +0 -21
- package/src/scan/arrow-execution/portable-predicate-compatibility.ts +0 -27
- package/src/scan/arrow-execution/project-arrow-table.ts +0 -53
- package/src/scan/query-arrow-table-math.ts +0 -23
- package/src/vector-table-scan-source.ts +0 -1
- package/src/wkt/twkb/convert-geometry-to-twkb.ts +0 -317
- package/src/wkt/twkb/convert-twkb-to-geometry.ts +0 -373
- package/src/wkt/twkb/twkb-io.ts +0 -85
- package/src/wkt/twkb/twkb-types.ts +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {inspectWKBHeader} from '@math.gl/core/arrow';\nimport type {WellKnownDimension, WKBGeometryType as MathWKBGeometryType} from '@math.gl/core/arrow';\nimport type {WKBGeometryType, WKBHeader} from './wkb-types';\nimport {MAX_SRID, WKT_MAGIC_STRINGS, WKT_MAGIC_BYTES} from './wkb-types';\n\n/**
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {inspectWKBHeader, inspectWKTHeader} from '@math.gl/core/arrow';\nimport type {WellKnownDimension, WKBGeometryType as MathWKBGeometryType} from '@math.gl/core/arrow';\nimport type {WKBGeometryType, WKBHeader} from './wkb-types';\nimport {MAX_SRID, WKT_MAGIC_STRINGS, WKT_MAGIC_BYTES} from './wkb-types';\n\n/** Checks whether the input starts with a supported WKT geometry header. */\nexport function isWKT(input: string | ArrayBufferLike): boolean {\n return getWKTGeometryType(input) !== null;\n}\n\n/** Classifies string WKT/EWKT headers or binary WKT prefixes without parsing coordinates. */\nexport function getWKTGeometryType(input: string | ArrayBufferLike): WKBGeometryType | null {\n if (typeof input === 'string') {\n const header = inspectWKTHeader(input);\n if (!header) return null;\n const geometryType = WKT_MAGIC_STRINGS.findIndex(magicString =>\n magicString.startsWith(header.geometryType.toUpperCase())\n );\n return geometryType >= 0 ? ((geometryType + 1) as WKBGeometryType) : null;\n }\n const inputArray = new Uint8Array(input);\n const index = WKT_MAGIC_BYTES.findIndex(magicBytes =>\n magicBytes.every((value, index) => value === inputArray[index])\n );\n return index >= 0 ? ((index + 1) as WKBGeometryType) : null;\n}\n\n/** Sanity checks that first to 5-9 bytes could represent a supported WKB dialect header */\nexport function isWKB(arrayBuffer: ArrayBufferLike): boolean {\n try {\n const header = inspectWKBHeader(arrayBuffer);\n return header.srid === undefined || header.srid <= MAX_SRID;\n } catch {\n return false;\n }\n}\n\n/**\n * Parses header and provides a byteOffset to start of geometry data\n * @param dataView\n * @param target optionally supply a WKBHeader object to avoid creating a new object for every call\n * @returns a header object describing the WKB data\n */\nexport function parseWKBHeader(dataView: DataView, target?: WKBHeader): WKBHeader {\n const text = new TextDecoder().decode(\n new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength)\n );\n if (isWKT(text)) {\n throw new Error('Cannot parse WKT');\n }\n let header: ReturnType<typeof inspectWKBHeader>;\n try {\n header = inspectWKBHeader(dataView, target?.byteOffset ?? 0);\n } catch (error) {\n const littleEndian = dataView.getUint8(0) === 1;\n const geometryCode = dataView.getUint32(1, littleEndian);\n if (geometryCode >= 1000) {\n throw new Error('Unsupported iso-wkb type');\n }\n throw error;\n }\n return Object.assign(target || {}, {\n type: 'wkb',\n variant: header.dialect,\n geometryType: getGeometryTypeCode(header.geometryType),\n dimensions: getDimensionSize(header.dimension),\n coordinates: header.dimension,\n littleEndian: header.littleEndian,\n byteOffset: header.bodyByteOffset,\n ...(header.srid === undefined ? {} : {srid: header.srid})\n } satisfies WKBHeader);\n}\n\nfunction getGeometryTypeCode(geometryType: MathWKBGeometryType): WKBGeometryType {\n return ([\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon',\n 'GeometryCollection'\n ].indexOf(geometryType) + 1) as WKBGeometryType;\n}\n\nfunction getDimensionSize(dimension: WellKnownDimension): 2 | 3 | 4 {\n return dimension === 'xy' ? 2 : dimension === 'xyzm' ? 4 : 3;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAiD;AAGjD,uBAA2D;AAGpD,SAAS,MAAM,OAA0C;AAC9D,SAAO,mBAAmB,KAAK,MAAM;AACvC;AAGO,SAAS,mBAAmB,OAAyD;AAC1F,MAAI,OAAO,UAA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C,aAAa,OAAO;AAAA,IACpB,cAAc,OAAO;AAAA,IACrB,YAAY,OAAO;AAAA,IACnB,GAAI,OAAO,SAAS,SAAY,CAAC,IAAI,EAAC,MAAM,OAAO,KAAI;AAAA,EACzD,CAAqB;AACvB;AAEA,SAAS,oBAAoB,cAAoD;AAC/E,SAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,QAAQ,YAAY,IAAI;AAC5B;AAEA,SAAS,iBAAiB,WAA0C;AAClE,SAAO,cAAc,OAAO,IAAI,cAAc,SAAS,IAAI;AAC7D;",
|
|
6
6
|
"names": ["index"]
|
|
7
7
|
}
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import type { WKBGeometryType, WKBHeader } from "./wkb-types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Check if a string is WKT.
|
|
4
|
-
* @param input A potential WKT geometry string
|
|
5
|
-
* @return `true` if input appears to be a WKT geometry string, `false` otherwise
|
|
6
|
-
|
|
7
|
-
* @note We only support the "geojson" subset of the OGC simple features standard
|
|
8
|
-
* @todo Does not handle leading spaces which appear to be permitted per the spec:
|
|
9
|
-
* "A WKT string contains no white space outside of double quotes.
|
|
10
|
-
* However padding with white space to improve human readability is permitted;
|
|
11
|
-
* the examples of WKT that are included in this document have
|
|
12
|
-
* spaces and line feeds inserted to improve clarity. Any padding is stripped out or ignored by parsers."
|
|
13
|
-
*/
|
|
2
|
+
/** Checks whether the input starts with a supported WKT geometry header. */
|
|
14
3
|
export declare function isWKT(input: string | ArrayBufferLike): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Get the geometry type of a WKT string.
|
|
17
|
-
* @param input A potential WKT geometry string
|
|
18
|
-
* @return `true` if input appears to be a WKT geometry string, `false` otherwise
|
|
19
|
-
|
|
20
|
-
* @note We only support the "geojson" subset of the OGC simple features standard
|
|
21
|
-
* @todo Does not handle leading spaces which appear to be permitted per the spec:
|
|
22
|
-
* "A WKT string contains no white space outside of double quotes.
|
|
23
|
-
* However padding with white space to improve human readability is permitted;
|
|
24
|
-
* the examples of WKT that are included in this document have
|
|
25
|
-
* spaces and line feeds inserted to improve clarity. Any padding is stripped out or ignored by parsers."
|
|
26
|
-
*/
|
|
4
|
+
/** Classifies string WKT/EWKT headers or binary WKT prefixes without parsing coordinates. */
|
|
27
5
|
export declare function getWKTGeometryType(input: string | ArrayBufferLike): WKBGeometryType | null;
|
|
28
6
|
/** Sanity checks that first to 5-9 bytes could represent a supported WKB dialect header */
|
|
29
7
|
export declare function isWKB(arrayBuffer: ArrayBufferLike): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-wkb-header.d.ts","sourceRoot":"","sources":["../../../../../../src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,eAAe,EAAE,SAAS,EAAC,uBAAoB;AAG5D
|
|
1
|
+
{"version":3,"file":"parse-wkb-header.d.ts","sourceRoot":"","sources":["../../../../../../src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,eAAe,EAAE,SAAS,EAAC,uBAAoB;AAG5D,4EAA4E;AAC5E,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,OAAO,CAE9D;AAED,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,GAAG,IAAI,CAc1F;AAED,2FAA2F;AAC3F,wBAAgB,KAAK,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAO3D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CA4BhF"}
|
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { inspectWKBHeader } from '@math.gl/core/arrow';
|
|
4
|
+
import { inspectWKBHeader, inspectWKTHeader } from '@math.gl/core/arrow';
|
|
5
5
|
import { MAX_SRID, WKT_MAGIC_STRINGS, WKT_MAGIC_BYTES } from "./wkb-types.js";
|
|
6
|
-
/**
|
|
7
|
-
* Check if a string is WKT.
|
|
8
|
-
* @param input A potential WKT geometry string
|
|
9
|
-
* @return `true` if input appears to be a WKT geometry string, `false` otherwise
|
|
10
|
-
|
|
11
|
-
* @note We only support the "geojson" subset of the OGC simple features standard
|
|
12
|
-
* @todo Does not handle leading spaces which appear to be permitted per the spec:
|
|
13
|
-
* "A WKT string contains no white space outside of double quotes.
|
|
14
|
-
* However padding with white space to improve human readability is permitted;
|
|
15
|
-
* the examples of WKT that are included in this document have
|
|
16
|
-
* spaces and line feeds inserted to improve clarity. Any padding is stripped out or ignored by parsers."
|
|
17
|
-
*/
|
|
6
|
+
/** Checks whether the input starts with a supported WKT geometry header. */
|
|
18
7
|
export function isWKT(input) {
|
|
19
8
|
return getWKTGeometryType(input) !== null;
|
|
20
9
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get the geometry type of a WKT string.
|
|
23
|
-
* @param input A potential WKT geometry string
|
|
24
|
-
* @return `true` if input appears to be a WKT geometry string, `false` otherwise
|
|
25
|
-
|
|
26
|
-
* @note We only support the "geojson" subset of the OGC simple features standard
|
|
27
|
-
* @todo Does not handle leading spaces which appear to be permitted per the spec:
|
|
28
|
-
* "A WKT string contains no white space outside of double quotes.
|
|
29
|
-
* However padding with white space to improve human readability is permitted;
|
|
30
|
-
* the examples of WKT that are included in this document have
|
|
31
|
-
* spaces and line feeds inserted to improve clarity. Any padding is stripped out or ignored by parsers."
|
|
32
|
-
*/
|
|
10
|
+
/** Classifies string WKT/EWKT headers or binary WKT prefixes without parsing coordinates. */
|
|
33
11
|
export function getWKTGeometryType(input) {
|
|
34
12
|
if (typeof input === 'string') {
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
13
|
+
const header = inspectWKTHeader(input);
|
|
14
|
+
if (!header)
|
|
37
15
|
return null;
|
|
38
|
-
const geometryType = WKT_MAGIC_STRINGS.findIndex(magicString => magicString.startsWith(
|
|
16
|
+
const geometryType = WKT_MAGIC_STRINGS.findIndex(magicString => magicString.startsWith(header.geometryType.toUpperCase()));
|
|
39
17
|
return geometryType >= 0 ? (geometryType + 1) : null;
|
|
40
18
|
}
|
|
41
19
|
const inputArray = new Uint8Array(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-wkb-header.js","sourceRoot":"","sources":["../../../../../../src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-wkb-header.js","sourceRoot":"","sources":["../../../../../../src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAC,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAC,uBAAoB;AAEzE,4EAA4E;AAC5E,MAAM,UAAU,KAAK,CAAC,KAA+B;IACnD,OAAO,kBAAkB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,kBAAkB,CAAC,KAA+B;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,M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ED,SAAS,gBAAgB,CAAC,SAA6B;IACrD,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -36,7 +36,8 @@ __export(decode_wkt_native_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(decode_wkt_native_exports);
|
|
38
38
|
var arrow = __toESM(require("apache-arrow"), 1);
|
|
39
|
-
var
|
|
39
|
+
var import_arrow = require("@math.gl/core/arrow");
|
|
40
|
+
var import_geoarrow_builder = require("../../../arrow-geometry/geoarrow-builder.cjs");
|
|
40
41
|
var UNION_GEOMETRY_KINDS = [
|
|
41
42
|
"Point",
|
|
42
43
|
"LineString",
|
|
@@ -45,15 +46,6 @@ var UNION_GEOMETRY_KINDS = [
|
|
|
45
46
|
"MultiLineString",
|
|
46
47
|
"MultiPolygon"
|
|
47
48
|
];
|
|
48
|
-
var GEOMETRY_KINDS = [
|
|
49
|
-
"Point",
|
|
50
|
-
"LineString",
|
|
51
|
-
"Polygon",
|
|
52
|
-
"MultiPoint",
|
|
53
|
-
"MultiLineString",
|
|
54
|
-
"MultiPolygon",
|
|
55
|
-
"GeometryCollection"
|
|
56
|
-
];
|
|
57
49
|
function decodeWKTNativeVector(column, targetEncoding, dimension, coordinates = "interleaved", offsetType = "int32", maxGeometryCollectionDepth = 64) {
|
|
58
50
|
const parsedRows = [];
|
|
59
51
|
let inferredDimension;
|
|
@@ -358,227 +350,29 @@ function writeMultiPolygon(builder, coordinates) {
|
|
|
358
350
|
builder.beginMultiPolygon(coordinates.length);
|
|
359
351
|
for (const polygon of coordinates) writePolygon(builder, polygon);
|
|
360
352
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
/** Parses one WKT value, including an optional SRID prefix. */
|
|
372
|
-
parse() {
|
|
373
|
-
this.skipWhitespace();
|
|
374
|
-
if (this.readLiteral("SRID")) {
|
|
375
|
-
this.skipWhitespace();
|
|
376
|
-
if (!this.readCharacter("=")) return null;
|
|
377
|
-
if (this.readNumber() === null) return null;
|
|
378
|
-
this.skipWhitespace();
|
|
379
|
-
if (!this.readCharacter(";")) return null;
|
|
380
|
-
}
|
|
381
|
-
const geometry = this.parseGeometry();
|
|
382
|
-
this.skipWhitespace();
|
|
383
|
-
return geometry && this.index === this.input.length ? geometry : null;
|
|
384
|
-
}
|
|
385
|
-
parseGeometry() {
|
|
386
|
-
this.skipWhitespace();
|
|
387
|
-
const kind = this.readGeometryKind();
|
|
388
|
-
if (!kind) return null;
|
|
389
|
-
this.skipWhitespace();
|
|
390
|
-
const dimensionToken = this.readDimensionToken();
|
|
391
|
-
this.skipWhitespace();
|
|
392
|
-
if (this.readLiteral("EMPTY")) {
|
|
393
|
-
return { kind, dimension: dimensionToken || "xy", coordinates: getEmptyCoordinates(kind) };
|
|
394
|
-
}
|
|
395
|
-
if (!this.readCharacter("(")) return null;
|
|
396
|
-
let coordinates;
|
|
397
|
-
let geometries;
|
|
398
|
-
switch (kind) {
|
|
399
|
-
case "Point":
|
|
400
|
-
coordinates = this.parseCoordinate();
|
|
401
|
-
break;
|
|
402
|
-
case "LineString":
|
|
403
|
-
coordinates = this.parseCoordinateList();
|
|
404
|
-
break;
|
|
405
|
-
case "Polygon":
|
|
406
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
407
|
-
break;
|
|
408
|
-
case "MultiPoint":
|
|
409
|
-
coordinates = this.parseMultiPointCoordinates();
|
|
410
|
-
break;
|
|
411
|
-
case "MultiLineString":
|
|
412
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
413
|
-
break;
|
|
414
|
-
case "MultiPolygon":
|
|
415
|
-
coordinates = this.parseNestedCoordinates(2);
|
|
416
|
-
break;
|
|
417
|
-
case "GeometryCollection":
|
|
418
|
-
this.geometryCollectionDepth++;
|
|
419
|
-
if (this.geometryCollectionDepth > this.maxGeometryCollectionDepth) return null;
|
|
420
|
-
geometries = this.parseGeometryList();
|
|
421
|
-
this.geometryCollectionDepth--;
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
if (coordinates === null || geometries === null || coordinates === void 0 && geometries === void 0)
|
|
425
|
-
return null;
|
|
426
|
-
if (!this.readCharacter(")")) return null;
|
|
427
|
-
const parsedCoordinates = coordinates || void 0;
|
|
428
|
-
const parsedGeometries = geometries || void 0;
|
|
429
|
-
const inferredDimension = dimensionToken || inferDimension(parsedCoordinates, parsedGeometries);
|
|
430
|
-
if (kind !== "GeometryCollection" && !hasValidArity(parsedCoordinates, void 0, inferredDimension)) {
|
|
431
|
-
return null;
|
|
432
|
-
}
|
|
433
|
-
return {
|
|
434
|
-
kind,
|
|
435
|
-
dimension: inferredDimension,
|
|
436
|
-
coordinates: parsedCoordinates,
|
|
437
|
-
geometries: parsedGeometries
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
parseCoordinateList() {
|
|
441
|
-
const coordinates = [];
|
|
442
|
-
while (true) {
|
|
443
|
-
const coordinate = this.parseCoordinate();
|
|
444
|
-
if (!coordinate) return null;
|
|
445
|
-
coordinates.push(coordinate);
|
|
446
|
-
this.skipWhitespace();
|
|
447
|
-
if (!this.readCharacter(",")) return coordinates;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
parseNestedCoordinates(depth) {
|
|
451
|
-
const values = [];
|
|
452
|
-
while (true) {
|
|
453
|
-
if (!this.readCharacter("(")) return null;
|
|
454
|
-
const value = depth === 1 ? this.parseCoordinateList() : this.parseNestedCoordinates(depth - 1);
|
|
455
|
-
if (!value || !this.readCharacter(")")) return null;
|
|
456
|
-
values.push(value);
|
|
457
|
-
this.skipWhitespace();
|
|
458
|
-
if (!this.readCharacter(",")) return values;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
parseMultiPointCoordinates() {
|
|
462
|
-
this.skipWhitespace();
|
|
463
|
-
if (this.peekCharacter("(")) {
|
|
464
|
-
const coordinates = [];
|
|
465
|
-
while (true) {
|
|
466
|
-
if (!this.readCharacter("(")) return null;
|
|
467
|
-
const coordinate = this.parseCoordinate();
|
|
468
|
-
if (!coordinate || !this.readCharacter(")")) return null;
|
|
469
|
-
coordinates.push(coordinate);
|
|
470
|
-
this.skipWhitespace();
|
|
471
|
-
if (!this.readCharacter(",")) return coordinates;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
return this.parseCoordinateList();
|
|
475
|
-
}
|
|
476
|
-
parseGeometryList() {
|
|
477
|
-
const geometries = [];
|
|
478
|
-
while (true) {
|
|
479
|
-
const geometry = this.parseGeometry();
|
|
480
|
-
if (!geometry) return null;
|
|
481
|
-
geometries.push(geometry);
|
|
482
|
-
this.skipWhitespace();
|
|
483
|
-
if (!this.readCharacter(",")) return geometries;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
parseCoordinate() {
|
|
487
|
-
const coordinate = [];
|
|
488
|
-
while (true) {
|
|
489
|
-
this.skipWhitespace();
|
|
490
|
-
const value = this.readNumber();
|
|
491
|
-
if (value === null) break;
|
|
492
|
-
coordinate.push(value);
|
|
493
|
-
}
|
|
494
|
-
return coordinate.length >= 2 ? coordinate : null;
|
|
495
|
-
}
|
|
496
|
-
readGeometryKind() {
|
|
497
|
-
const word = this.readWord()?.toUpperCase();
|
|
498
|
-
const kind = GEOMETRY_KINDS.find((value) => value.toUpperCase() === word);
|
|
499
|
-
return kind || null;
|
|
500
|
-
}
|
|
501
|
-
readDimensionToken() {
|
|
502
|
-
const position = this.index;
|
|
503
|
-
const word = this.readWord()?.toUpperCase();
|
|
504
|
-
if (word === "Z") return "xyz";
|
|
505
|
-
if (word === "M") return "xym";
|
|
506
|
-
if (word === "ZM") return "xyzm";
|
|
507
|
-
this.index = position;
|
|
353
|
+
function parseWKT(input, maxGeometryCollectionDepth = 64) {
|
|
354
|
+
try {
|
|
355
|
+
if (/\(\s*\)/.test(input)) return null;
|
|
356
|
+
const result = (0, import_arrow.parseWKTWithMetadata)(input, {
|
|
357
|
+
inferDimensions: true,
|
|
358
|
+
allowMissingInheritedOrdinates: true,
|
|
359
|
+
maximumDepth: maxGeometryCollectionDepth
|
|
360
|
+
});
|
|
361
|
+
return adaptParsedWKT(result);
|
|
362
|
+
} catch {
|
|
508
363
|
return null;
|
|
509
364
|
}
|
|
510
|
-
readWord() {
|
|
511
|
-
const match = this.input.slice(this.index).match(/^[A-Za-z]+/);
|
|
512
|
-
if (!match) return null;
|
|
513
|
-
this.index += match[0].length;
|
|
514
|
-
return match[0];
|
|
515
|
-
}
|
|
516
|
-
readNumber() {
|
|
517
|
-
const match = this.input.slice(this.index).match(/^[+-]?(?:(?:\d+\.\d*|\.\d+|\d+)(?:[eE][+-]?\d+)?)/);
|
|
518
|
-
if (!match) return null;
|
|
519
|
-
this.index += match[0].length;
|
|
520
|
-
const value = Number(match[0]);
|
|
521
|
-
return Number.isFinite(value) ? value : null;
|
|
522
|
-
}
|
|
523
|
-
readLiteral(literal) {
|
|
524
|
-
const position = this.index;
|
|
525
|
-
const word = this.readWord();
|
|
526
|
-
if (word?.toUpperCase() === literal) return true;
|
|
527
|
-
this.index = position;
|
|
528
|
-
return false;
|
|
529
|
-
}
|
|
530
|
-
readCharacter(character) {
|
|
531
|
-
if (this.input[this.index] !== character) return false;
|
|
532
|
-
this.index++;
|
|
533
|
-
this.skipWhitespace();
|
|
534
|
-
return true;
|
|
535
|
-
}
|
|
536
|
-
peekCharacter(character) {
|
|
537
|
-
return this.input[this.index] === character;
|
|
538
|
-
}
|
|
539
|
-
skipWhitespace() {
|
|
540
|
-
while (/\s/.test(this.input[this.index] || "")) this.index++;
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
function parseWKT(input, maxGeometryCollectionDepth = 64) {
|
|
544
|
-
return new WKTParser(input, maxGeometryCollectionDepth).parse();
|
|
545
|
-
}
|
|
546
|
-
function getEmptyCoordinates(kind) {
|
|
547
|
-
return kind === "Point" ? [] : [];
|
|
548
|
-
}
|
|
549
|
-
function inferDimension(coordinates, geometries) {
|
|
550
|
-
const coordinateSize = findCoordinateSize(coordinates);
|
|
551
|
-
if (coordinateSize) return dimensionFromSize(coordinateSize);
|
|
552
|
-
for (const geometry of geometries || []) return geometry.dimension;
|
|
553
|
-
return "xy";
|
|
554
365
|
}
|
|
555
|
-
function
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
366
|
+
function adaptParsedWKT({ geometry, dimension, children }) {
|
|
367
|
+
if (geometry.type === "GeometryCollection") {
|
|
368
|
+
const geometries = children?.map(adaptParsedWKT);
|
|
369
|
+
return {
|
|
370
|
+
kind: geometry.type,
|
|
371
|
+
dimension: dimension === "xy" ? geometries?.[0]?.dimension ?? dimension : dimension,
|
|
372
|
+
geometries
|
|
373
|
+
};
|
|
562
374
|
}
|
|
563
|
-
return
|
|
564
|
-
}
|
|
565
|
-
function dimensionFromSize(size) {
|
|
566
|
-
return size === 4 ? "xyzm" : size === 3 ? "xyz" : "xy";
|
|
567
|
-
}
|
|
568
|
-
function hasValidArity(coordinates, geometries, dimension) {
|
|
569
|
-
const expectedSize = dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3;
|
|
570
|
-
if (coordinates && !hasCoordinateArity(coordinates, expectedSize)) return false;
|
|
571
|
-
return (geometries || []).every(
|
|
572
|
-
(geometry) => geometry.dimension === dimension || geometry.kind === "GeometryCollection"
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
function hasCoordinateArity(value, expectedSize) {
|
|
576
|
-
if (value.length === 0) return true;
|
|
577
|
-
if (isCoordinate(value)) return value.length === expectedSize;
|
|
578
|
-
return value.every((child) => hasCoordinateArity(child, expectedSize));
|
|
579
|
-
}
|
|
580
|
-
function isCoordinate(value) {
|
|
581
|
-
return typeof value[0] === "number";
|
|
375
|
+
return { kind: geometry.type, dimension, coordinates: geometry.coordinates };
|
|
582
376
|
}
|
|
583
377
|
// Annotate the CommonJS export names for ESM import in node:
|
|
584
378
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/geoarrow/lib/kernels/decode-wkt-native.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport type {\n GeoArrowCoordinateLayout,\n GeoArrowDimension,\n GeoArrowOffsetType,\n GeoParquetGeometryType\n} from '@loaders.gl/core/schema';\nimport {\n GeoArrowBuilder,\n type GeoArrowBuilderEncoding,\n type GeoArrowGeometryWriter\n} from '../../geoarrow-builder';\n\ntype WKTGeometryKind =\n | 'Point'\n | 'LineString'\n | 'Polygon'\n | 'MultiPoint'\n | 'MultiLineString'\n | 'MultiPolygon'\n | 'GeometryCollection';\n\ntype WKTCoordinates = number[] | WKTCoordinates[];\n\ntype ParsedWKTGeometry = Readonly<{\n kind: WKTGeometryKind;\n dimension: GeoArrowDimension;\n coordinates?: WKTCoordinates;\n geometries?: readonly ParsedWKTGeometry[];\n}>;\n\ntype WKTUnionChild = Readonly<{\n kind: WKTGeometryKind;\n dimension: GeoArrowDimension;\n}>;\n\nconst UNION_GEOMETRY_KINDS: readonly Exclude<WKTGeometryKind, 'GeometryCollection'>[] = [\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon'\n];\n\nconst GEOMETRY_KINDS: readonly WKTGeometryKind[] = [\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon',\n 'GeometryCollection'\n];\n\n/**\n * Decodes homogeneous WKT rows directly into native GeoArrow buffers.\n *\n * The parser produces only numeric coordinate arrays and immediately feeds them to the\n * two-pass GeoArrow builder. It deliberately does not construct GeoJSON geometry objects.\n * Mixed WKT columns and geometry collections use the matching typed union kernels.\n *\n * @param column WKT Arrow vector.\n * @param targetEncoding Concrete native target encoding.\n * @param dimension Optional exact output dimension.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Native vector or `null` when the WKT column is not homogeneous and representable.\n */\nexport function decodeWKTNativeVector(\n column: arrow.Vector,\n targetEncoding: Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedRows: (ParsedWKTGeometry | null)[] = [];\n let inferredDimension: GeoArrowDimension | undefined;\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedRows.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed || parsed.kind !== getGeometryKind(targetEncoding)) return null;\n if (!dimension) {\n if (inferredDimension && inferredDimension !== parsed.dimension) return null;\n inferredDimension = parsed.dimension;\n }\n parsedRows.push(parsed);\n }\n\n const outputDimension = dimension || inferredDimension || 'xy';\n const writers: GeoArrowGeometryWriter[] = parsedRows.map(parsed =>\n parsed ? builder => writeParsedGeometry(builder, parsed) : null\n );\n const geometryArray = GeoArrowBuilder.buildGeometryArray(writers, {\n encoding: targetEncoding,\n dimension: outputDimension,\n coordinateLayout: coordinates,\n offsetType\n });\n return arrow.makeVector(GeoArrowBuilder.makeGeometryData(geometryArray));\n}\n\n/**\n * Decodes mixed WKT rows directly into a dense GeoArrow union.\n *\n * Each union child is built from numeric parser output with the same incremental builder used\n * by homogeneous WKT conversion. Child order and type IDs are canonical and independent of row\n * order, which makes the result safe to concatenate across record batches.\n *\n * @param column WKT Arrow vector.\n * @param dimension Optional dimension forced on every union child.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width inside union children.\n * @param geometryTypes Optional metadata used to seed stable absent children.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Dense union vector or `null` when a row cannot be represented.\n */\nexport function decodeWKTUnionVector(\n column: arrow.Vector,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n geometryTypes?: readonly GeoParquetGeometryType[],\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedRows: (ParsedWKTGeometry | null)[] = [];\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedRows.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed) return null;\n parsedRows.push(parsed);\n }\n return makeWKTUnionVector(parsedRows, dimension, coordinates, offsetType, geometryTypes, true);\n}\n\n/**\n * Decodes WKT GeometryCollection rows into a list of dense-union children.\n *\n * @param column WKT Arrow vector.\n * @param dimension Optional dimension forced on every union child.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width inside union children and the collection list.\n * @param geometryTypes Optional metadata used to seed stable absent children.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Geometry collection vector or `null` when a row cannot be represented.\n */\nexport function decodeWKTGeometryCollectionVector(\n column: arrow.Vector,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n geometryTypes?: readonly GeoParquetGeometryType[],\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedCollections: (ParsedWKTGeometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedCollections.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed || parsed.kind !== 'GeometryCollection') return null;\n parsedCollections.push(parsed);\n }\n return makeWKTCollectionVector(\n parsedCollections,\n dimension,\n coordinates,\n offsetType,\n geometryTypes\n );\n}\n\nfunction makeWKTUnionVector(\n parsedRows: readonly (ParsedWKTGeometry | null)[],\n dimension: GeoArrowDimension | undefined,\n coordinates: GeoArrowCoordinateLayout,\n offsetType: GeoArrowOffsetType,\n geometryTypes?: readonly GeoParquetGeometryType[],\n allowGeometryCollection = true\n): arrow.Vector | null {\n const children = new Map<string, WKTUnionChild>();\n for (const geometryType of geometryTypes || []) {\n const child = getWKTUnionChild(geometryType, dimension);\n if (child) children.set(getWKTUnionChildKey(child), child);\n }\n for (const parsed of parsedRows) {\n if (!parsed) continue;\n if (!allowGeometryCollection && parsed.kind === 'GeometryCollection') return null;\n const child = {\n kind: parsed.kind as WKTUnionChild['kind'],\n dimension: dimension || parsed.dimension\n };\n children.set(getWKTUnionChildKey(child), child);\n }\n\n const firstChild: WKTUnionChild = children.values().next().value || {\n kind: 'Point',\n dimension: 'xy'\n };\n children.set(getWKTUnionChildKey(firstChild), firstChild);\n const orderedChildren = [...children.values()].sort(\n (left, right) => getWKTUnionTypeId(left) - getWKTUnionTypeId(right)\n );\n const childRows = new Map<string, (ParsedWKTGeometry | null)[]>();\n const typeIds = new Int8Array(parsedRows.length);\n const valueOffsets = new Int32Array(parsedRows.length);\n\n for (let rowIndex = 0; rowIndex < parsedRows.length; rowIndex++) {\n const parsed = parsedRows[rowIndex];\n const child = parsed\n ? {kind: parsed.kind as WKTUnionChild['kind'], dimension: dimension || parsed.dimension}\n : firstChild;\n const key = getWKTUnionChildKey(child);\n const values = childRows.get(key) || [];\n valueOffsets[rowIndex] = values.length;\n values.push(parsed);\n childRows.set(key, values);\n typeIds[rowIndex] = getWKTUnionTypeId(child);\n }\n\n const fields: arrow.Field[] = [];\n const childData: arrow.Data[] = [];\n for (const child of orderedChildren) {\n const rows = childRows.get(getWKTUnionChildKey(child)) || [];\n if (child.kind === 'GeometryCollection') {\n const collectionVector = makeWKTCollectionVector(\n rows,\n dimension,\n coordinates,\n offsetType,\n geometryTypes\n );\n if (!collectionVector) return null;\n fields.push(new arrow.Field(getWKTUnionFieldName(child), collectionVector.type, true));\n childData.push(collectionVector.data[0]);\n continue;\n }\n const writers: GeoArrowGeometryWriter[] = rows.map(parsed =>\n parsed ? builder => writeParsedGeometry(builder, parsed) : null\n );\n const geometryArray = GeoArrowBuilder.buildGeometryArray(writers, {\n encoding: getBuilderEncoding(child.kind),\n dimension: child.dimension,\n coordinateLayout: coordinates,\n offsetType\n });\n const childVector = arrow.makeVector(GeoArrowBuilder.makeGeometryData(geometryArray));\n fields.push(new arrow.Field(getWKTUnionFieldName(child), childVector.type, true));\n childData.push(childVector.data[0]);\n }\n\n const unionType = new arrow.DenseUnion(orderedChildren.map(getWKTUnionTypeId), fields);\n return arrow.makeVector(\n arrow.makeData({\n type: unionType,\n length: parsedRows.length,\n nullCount: 0,\n typeIds,\n valueOffsets,\n children: childData\n } as any)\n );\n}\n\nfunction makeWKTCollectionVector(\n parsedRows: readonly (ParsedWKTGeometry | null)[],\n dimension: GeoArrowDimension | undefined,\n coordinates: GeoArrowCoordinateLayout,\n offsetType: GeoArrowOffsetType,\n geometryTypes?: readonly GeoParquetGeometryType[]\n): arrow.Vector | null {\n const flattenedChildren: ParsedWKTGeometry[] = [];\n const collectionOffsets = [0];\n const nullBitmap = new Uint8Array(Math.ceil(parsedRows.length / 8));\n let nullCount = 0;\n\n for (let rowIndex = 0; rowIndex < parsedRows.length; rowIndex++) {\n const parsed = parsedRows[rowIndex];\n if (!parsed) {\n nullCount++;\n collectionOffsets.push(flattenedChildren.length);\n continue;\n }\n if (parsed.kind !== 'GeometryCollection') return null;\n for (const child of parsed.geometries || []) flattenedChildren.push(child);\n nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);\n collectionOffsets.push(flattenedChildren.length);\n }\n\n const unionVector = makeWKTUnionVector(\n flattenedChildren,\n dimension,\n coordinates,\n offsetType,\n geometryTypes?.filter(\n geometryType => !geometryType.toLowerCase().startsWith('geometrycollection')\n ),\n false\n );\n if (!unionVector) return null;\n const listField = new arrow.Field('geometries', unionVector.type, true);\n const listType =\n offsetType === 'int64' ? new arrow.LargeList(listField) : new arrow.List(listField);\n return arrow.makeVector(\n arrow.makeData({\n type: listType,\n length: parsedRows.length,\n nullCount,\n valueOffsets: createWKTOffsets(collectionOffsets, offsetType),\n nullBitmap: nullCount > 0 ? nullBitmap : undefined,\n child: unionVector.data[0]\n } as any)\n );\n}\n\nfunction getBuilderEncoding(\n geometryKind: Exclude<WKTGeometryKind, 'GeometryCollection'>\n): GeoArrowBuilderEncoding {\n return `geoarrow.${geometryKind.toLowerCase()}` as GeoArrowBuilderEncoding;\n}\n\nfunction getWKTUnionChildKey(child: WKTUnionChild): string {\n return `${child.kind}:${child.dimension}`;\n}\n\nfunction getWKTUnionTypeId(child: WKTUnionChild): number {\n const baseTypeId =\n child.kind === 'GeometryCollection' ? 7 : UNION_GEOMETRY_KINDS.indexOf(child.kind) + 1;\n switch (child.dimension) {\n case 'xy':\n return baseTypeId;\n case 'xyz':\n return baseTypeId + 10;\n case 'xym':\n return baseTypeId + 20;\n case 'xyzm':\n return baseTypeId + 30;\n }\n}\n\nfunction getWKTUnionFieldName(child: WKTUnionChild): string {\n switch (child.dimension) {\n case 'xy':\n return child.kind;\n case 'xyz':\n return `${child.kind} Z`;\n case 'xym':\n return `${child.kind} M`;\n case 'xyzm':\n return `${child.kind} ZM`;\n }\n}\n\nfunction getWKTUnionChild(\n geometryType: GeoParquetGeometryType,\n requestedDimension?: GeoArrowDimension\n): WKTUnionChild | null {\n const dimension = requestedDimension || getWKTDimension(geometryType);\n const geometryKind = geometryType.replace(/ (?:ZM|Z|M)$/, '') as WKTGeometryKind;\n if (\n geometryKind !== 'GeometryCollection' &&\n !UNION_GEOMETRY_KINDS.includes(geometryKind as Exclude<WKTGeometryKind, 'GeometryCollection'>)\n ) {\n return null;\n }\n return {kind: geometryKind, dimension};\n}\n\nfunction getWKTDimension(geometryType: GeoParquetGeometryType): GeoArrowDimension {\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\nfunction createWKTOffsets(\n offsets: readonly number[],\n offsetType: GeoArrowOffsetType\n): Int32Array | BigInt64Array {\n return offsetType === 'int64'\n ? BigInt64Array.from(offsets, offset => BigInt(offset))\n : Int32Array.from(offsets);\n}\n\nfunction getGeometryKind(\n encoding: Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>\n): WKTGeometryKind {\n const geometryKindByEncoding: Record<\n Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>,\n WKTGeometryKind\n > = {\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 return geometryKindByEncoding[encoding];\n}\n\nfunction writeParsedGeometry(builder: GeoArrowBuilder, geometry: ParsedWKTGeometry): void {\n const coordinates = geometry.coordinates;\n switch (geometry.kind) {\n case 'Point':\n builder.beginPoint();\n writeCoordinate(builder, (coordinates as number[] | undefined) || []);\n return;\n case 'LineString':\n writeLineString(builder, (coordinates as number[][] | undefined) || []);\n return;\n case 'MultiPoint':\n writeMultiPoint(builder, (coordinates as number[][] | undefined) || []);\n return;\n case 'Polygon':\n writePolygon(builder, (coordinates as number[][][] | undefined) || []);\n return;\n case 'MultiLineString':\n writeMultiLineString(builder, (coordinates as number[][][] | undefined) || []);\n return;\n case 'MultiPolygon':\n writeMultiPolygon(builder, (coordinates as number[][][][] | undefined) || []);\n return;\n case 'GeometryCollection':\n throw new Error('GeometryCollection WKT requires the geometry union kernel.');\n }\n}\n\nfunction writeCoordinate(builder: GeoArrowBuilder, coordinate: number[]): void {\n builder.writeCoordinate(\n coordinate[0] ?? Number.NaN,\n coordinate[1] ?? Number.NaN,\n coordinate[2],\n coordinate[3]\n );\n}\n\nfunction writeLineString(builder: GeoArrowBuilder, coordinates: number[][]): void {\n builder.beginLineString(coordinates.length);\n for (const coordinate of coordinates) writeCoordinate(builder, coordinate);\n}\n\nfunction writeMultiPoint(builder: GeoArrowBuilder, coordinates: number[][]): void {\n builder.beginMultiPoint(coordinates.length);\n for (const coordinate of coordinates) {\n builder.beginPoint();\n writeCoordinate(builder, coordinate);\n }\n}\n\nfunction writePolygon(builder: GeoArrowBuilder, coordinates: number[][][]): void {\n builder.beginPolygon(coordinates.length);\n for (const ring of coordinates) {\n builder.beginLinearRing(ring.length);\n for (const coordinate of ring) writeCoordinate(builder, coordinate);\n }\n}\n\nfunction writeMultiLineString(builder: GeoArrowBuilder, coordinates: number[][][]): void {\n builder.beginMultiLineString(coordinates.length);\n for (const line of coordinates) writeLineString(builder, line);\n}\n\nfunction writeMultiPolygon(builder: GeoArrowBuilder, coordinates: number[][][][]): void {\n builder.beginMultiPolygon(coordinates.length);\n for (const polygon of coordinates) writePolygon(builder, polygon);\n}\n\nclass WKTParser {\n private index = 0;\n private geometryCollectionDepth = 0;\n\n /** Creates a parser for one WKT value. */\n constructor(\n private readonly input: string,\n private readonly maxGeometryCollectionDepth: number\n ) {}\n\n /** Parses one WKT value, including an optional SRID prefix. */\n parse(): ParsedWKTGeometry | null {\n this.skipWhitespace();\n if (this.readLiteral('SRID')) {\n this.skipWhitespace();\n if (!this.readCharacter('=')) return null;\n if (this.readNumber() === null) return null;\n this.skipWhitespace();\n if (!this.readCharacter(';')) return null;\n }\n const geometry = this.parseGeometry();\n this.skipWhitespace();\n return geometry && this.index === this.input.length ? geometry : null;\n }\n\n private parseGeometry(): ParsedWKTGeometry | null {\n this.skipWhitespace();\n const kind = this.readGeometryKind();\n if (!kind) return null;\n this.skipWhitespace();\n const dimensionToken = this.readDimensionToken();\n this.skipWhitespace();\n if (this.readLiteral('EMPTY')) {\n return {kind, dimension: dimensionToken || 'xy', coordinates: getEmptyCoordinates(kind)};\n }\n if (!this.readCharacter('(')) return null;\n\n let coordinates: WKTCoordinates | null | undefined;\n let geometries: ParsedWKTGeometry[] | null | undefined;\n switch (kind) {\n case 'Point':\n coordinates = this.parseCoordinate();\n break;\n case 'LineString':\n coordinates = this.parseCoordinateList();\n break;\n case 'Polygon':\n coordinates = this.parseNestedCoordinates(1);\n break;\n case 'MultiPoint':\n coordinates = this.parseMultiPointCoordinates();\n break;\n case 'MultiLineString':\n coordinates = this.parseNestedCoordinates(1);\n break;\n case 'MultiPolygon':\n coordinates = this.parseNestedCoordinates(2);\n break;\n case 'GeometryCollection':\n this.geometryCollectionDepth++;\n if (this.geometryCollectionDepth > this.maxGeometryCollectionDepth) return null;\n geometries = this.parseGeometryList();\n this.geometryCollectionDepth--;\n break;\n }\n if (\n coordinates === null ||\n geometries === null ||\n (coordinates === undefined && geometries === undefined)\n )\n return null;\n if (!this.readCharacter(')')) return null;\n\n const parsedCoordinates = coordinates || undefined;\n const parsedGeometries = geometries || undefined;\n const inferredDimension = dimensionToken || inferDimension(parsedCoordinates, parsedGeometries);\n if (\n kind !== 'GeometryCollection' &&\n !hasValidArity(parsedCoordinates, undefined, inferredDimension)\n ) {\n return null;\n }\n return {\n kind,\n dimension: inferredDimension,\n coordinates: parsedCoordinates,\n geometries: parsedGeometries\n };\n }\n\n private parseCoordinateList(): number[][] | null {\n const coordinates: number[][] = [];\n while (true) {\n const coordinate = this.parseCoordinate();\n if (!coordinate) return null;\n coordinates.push(coordinate);\n this.skipWhitespace();\n if (!this.readCharacter(',')) return coordinates;\n }\n }\n\n private parseNestedCoordinates(depth: number): WKTCoordinates | null {\n const values: WKTCoordinates[] = [];\n while (true) {\n if (!this.readCharacter('(')) return null;\n const value =\n depth === 1 ? this.parseCoordinateList() : this.parseNestedCoordinates(depth - 1);\n if (!value || !this.readCharacter(')')) return null;\n values.push(value);\n this.skipWhitespace();\n if (!this.readCharacter(',')) return values;\n }\n }\n\n private parseMultiPointCoordinates(): number[][] | null {\n this.skipWhitespace();\n if (this.peekCharacter('(')) {\n const coordinates: number[][] = [];\n while (true) {\n if (!this.readCharacter('(')) return null;\n const coordinate = this.parseCoordinate();\n if (!coordinate || !this.readCharacter(')')) return null;\n coordinates.push(coordinate);\n this.skipWhitespace();\n if (!this.readCharacter(',')) return coordinates;\n }\n }\n return this.parseCoordinateList();\n }\n\n private parseGeometryList(): ParsedWKTGeometry[] | null {\n const geometries: ParsedWKTGeometry[] = [];\n while (true) {\n const geometry = this.parseGeometry();\n if (!geometry) return null;\n geometries.push(geometry);\n this.skipWhitespace();\n if (!this.readCharacter(',')) return geometries;\n }\n }\n\n private parseCoordinate(): number[] | null {\n const coordinate: number[] = [];\n while (true) {\n this.skipWhitespace();\n const value = this.readNumber();\n if (value === null) break;\n coordinate.push(value);\n }\n return coordinate.length >= 2 ? coordinate : null;\n }\n\n private readGeometryKind(): WKTGeometryKind | null {\n const word = this.readWord()?.toUpperCase();\n const kind = GEOMETRY_KINDS.find(value => value.toUpperCase() === word);\n return kind || null;\n }\n\n private readDimensionToken(): GeoArrowDimension | null {\n const position = this.index;\n const word = this.readWord()?.toUpperCase();\n if (word === 'Z') return 'xyz';\n if (word === 'M') return 'xym';\n if (word === 'ZM') return 'xyzm';\n this.index = position;\n return null;\n }\n\n private readWord(): string | null {\n const match = this.input.slice(this.index).match(/^[A-Za-z]+/);\n if (!match) return null;\n this.index += match[0].length;\n return match[0];\n }\n\n private readNumber(): number | null {\n const match = this.input\n .slice(this.index)\n .match(/^[+-]?(?:(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eE][+-]?\\d+)?)/);\n if (!match) return null;\n this.index += match[0].length;\n const value = Number(match[0]);\n return Number.isFinite(value) ? value : null;\n }\n\n private readLiteral(literal: string): boolean {\n const position = this.index;\n const word = this.readWord();\n if (word?.toUpperCase() === literal) return true;\n this.index = position;\n return false;\n }\n\n private readCharacter(character: string): boolean {\n if (this.input[this.index] !== character) return false;\n this.index++;\n this.skipWhitespace();\n return true;\n }\n\n private peekCharacter(character: string): boolean {\n return this.input[this.index] === character;\n }\n\n private skipWhitespace(): void {\n while (/\\s/.test(this.input[this.index] || '')) this.index++;\n }\n}\n\nfunction parseWKT(input: string, maxGeometryCollectionDepth = 64): ParsedWKTGeometry | null {\n return new WKTParser(input, maxGeometryCollectionDepth).parse();\n}\n\nfunction getEmptyCoordinates(kind: WKTGeometryKind): WKTCoordinates {\n return kind === 'Point' ? [] : [];\n}\n\nfunction inferDimension(\n coordinates: WKTCoordinates | undefined,\n geometries: readonly ParsedWKTGeometry[] | undefined\n): GeoArrowDimension {\n const coordinateSize = findCoordinateSize(coordinates);\n if (coordinateSize) return dimensionFromSize(coordinateSize);\n for (const geometry of geometries || []) return geometry.dimension;\n return 'xy';\n}\n\nfunction findCoordinateSize(coordinates: WKTCoordinates | undefined): number | null {\n if (!coordinates) return null;\n if (coordinates.length === 0) return null;\n if (isCoordinate(coordinates)) return coordinates.length;\n for (const value of coordinates) {\n const size = findCoordinateSize(value as WKTCoordinates);\n if (size) return size;\n }\n return null;\n}\n\nfunction dimensionFromSize(size: number): GeoArrowDimension {\n return size === 4 ? 'xyzm' : size === 3 ? 'xyz' : 'xy';\n}\n\nfunction hasValidArity(\n coordinates: WKTCoordinates | undefined,\n geometries: readonly ParsedWKTGeometry[] | undefined,\n dimension: GeoArrowDimension\n): boolean {\n const expectedSize = dimension === 'xy' ? 2 : dimension === 'xyzm' ? 4 : 3;\n if (coordinates && !hasCoordinateArity(coordinates, expectedSize)) return false;\n return (geometries || []).every(\n geometry => geometry.dimension === dimension || geometry.kind === 'GeometryCollection'\n );\n}\n\nfunction hasCoordinateArity(value: WKTCoordinates, expectedSize: number): boolean {\n if (value.length === 0) return true;\n if (isCoordinate(value)) return value.length === expectedSize;\n return value.every(child => hasCoordinateArity(child, expectedSize));\n}\n\nfunction isCoordinate(value: WKTCoordinates): value is number[] {\n return typeof value[0] === 'number';\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AAOvB,8BAIO;AAyBP,IAAM,uBAAkF;AAAA,EACtF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,iBAA6C;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAiBO,SAAS,sBACd,QACA,gBACA,WACA,cAAwC,eACxC,aAAiC,SACjC,6BAA6B,IACR;AACrB,QAAM,aAA2C,CAAC;AAClD,MAAI;AAEJ,WAAS,WAAW,GAAG,WAAW,OAAO,QAAQ,YAAY;AAC3D,UAAM,QAAQ,OAAO,IAAI,QAAQ;AACjC,QAAI,SAAS,MAAM;AACjB,iBAAW,KAAK,IAAI;AACpB;AAAA,IACF;AACA,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,UAAM,SAAS,SAAS,OAAO,0BAA0B;AACzD,QAAI,CAAC,UAAU,OAAO,SAAS,gBAAgB,cAAc,EAAG,QAAO;AACvE,QAAI,CAAC,WAAW;AACd,UAAI,qBAAqB,sBAAsB,OAAO,UAAW,QAAO;AACxE,0BAAoB,OAAO;AAAA,IAC7B;AACA,eAAW,KAAK,MAAM;AAAA,EACxB;AAEA,QAAM,kBAAkB,aAAa,qBAAqB;AAC1D,QAAM,UAAoC,WAAW;AAAA,IAAI,YACvD,SAAS,aAAW,oBAAoB,SAAS,MAAM,IAAI;AAAA,EAC7D;AACA,QAAM,gBAAgB,wCAAgB,mBAAmB,SAAS;AAAA,IAChE,UAAU;AAAA,IACV,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB;AAAA,EACF,CAAC;AACD,SAAa,iBAAW,wCAAgB,iBAAiB,aAAa,CAAC;AACzE;AAiBO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AClD,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,mBAAmB,KAAuB;AACvD,QAAI,KAAM,QAAO;AAAA,EACnB;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,MAAiC;AAC1D,SAAO,SAAS,IAAI,SAAS,SAAS,IAAI,QAAQ;AACpD;AAEA,SAAS,cACP,aACA,YACA,WACS;AACT,QAAM,eAAe,cAAc,OAAO,IAAI,cAAc,SAAS,IAAI;AACzE,MAAI,eAAe,CAAC,mBAAmB,aAAa,YAAY,EAAG,QAAO;AAC1E,UAAQ,cAAc,CAAC,GAAG;AAAA,IACxB,cAAY,SAAS,cAAc,aAAa,SAAS,SAAS;AAAA,EACpE;AACF;AAEA,SAAS,mBAAmB,OAAuB,cAA+B;AAChF,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,MAAI,aAAa,KAAK,EAAG,QAAO,MAAM,WAAW;AACjD,SAAO,MAAM,MAAM,WAAS,mBAAmB,OAAO,YAAY,CAAC;AACrE;AAEA,SAAS,aAAa,OAA0C;AAC9D,SAAO,OAAO,MAAM,CAAC,MAAM;AAC7B;",
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport {parseWKTWithMetadata, type WKTParseResult} from '@math.gl/core/arrow';\nimport type {\n GeoArrowCoordinateLayout,\n GeoArrowDimension,\n GeoArrowOffsetType,\n GeoParquetGeometryType\n} from '@loaders.gl/core/schema';\nimport {\n GeoArrowBuilder,\n type GeoArrowBuilderEncoding,\n type GeoArrowGeometryWriter\n} from '../../../arrow-geometry/geoarrow-builder';\n\ntype WKTGeometryKind =\n | 'Point'\n | 'LineString'\n | 'Polygon'\n | 'MultiPoint'\n | 'MultiLineString'\n | 'MultiPolygon'\n | 'GeometryCollection';\n\ntype WKTCoordinates = number[] | WKTCoordinates[];\n\ntype ParsedWKTGeometry = Readonly<{\n kind: WKTGeometryKind;\n dimension: GeoArrowDimension;\n coordinates?: WKTCoordinates;\n geometries?: readonly ParsedWKTGeometry[];\n}>;\n\ntype WKTUnionChild = Readonly<{\n kind: WKTGeometryKind;\n dimension: GeoArrowDimension;\n}>;\n\nconst UNION_GEOMETRY_KINDS: readonly Exclude<WKTGeometryKind, 'GeometryCollection'>[] = [\n 'Point',\n 'LineString',\n 'Polygon',\n 'MultiPoint',\n 'MultiLineString',\n 'MultiPolygon'\n];\n\n/**\n * Decodes homogeneous WKT rows directly into native GeoArrow buffers.\n *\n * Parsed coordinate tuples are passed to the two-pass GeoArrow builder.\n * Mixed WKT columns and geometry collections use the matching typed union kernels.\n *\n * @param column WKT Arrow vector.\n * @param targetEncoding Concrete native target encoding.\n * @param dimension Optional exact output dimension.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Native vector or `null` when the WKT column is not homogeneous and representable.\n */\nexport function decodeWKTNativeVector(\n column: arrow.Vector,\n targetEncoding: Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedRows: (ParsedWKTGeometry | null)[] = [];\n let inferredDimension: GeoArrowDimension | undefined;\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedRows.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed || parsed.kind !== getGeometryKind(targetEncoding)) return null;\n if (!dimension) {\n if (inferredDimension && inferredDimension !== parsed.dimension) return null;\n inferredDimension = parsed.dimension;\n }\n parsedRows.push(parsed);\n }\n\n const outputDimension = dimension || inferredDimension || 'xy';\n const writers: GeoArrowGeometryWriter[] = parsedRows.map(parsed =>\n parsed ? builder => writeParsedGeometry(builder, parsed) : null\n );\n const geometryArray = GeoArrowBuilder.buildGeometryArray(writers, {\n encoding: targetEncoding,\n dimension: outputDimension,\n coordinateLayout: coordinates,\n offsetType\n });\n return arrow.makeVector(GeoArrowBuilder.makeGeometryData(geometryArray));\n}\n\n/**\n * Decodes mixed WKT rows directly into a dense GeoArrow union.\n *\n * Each union child is built from numeric parser output with the same incremental builder used\n * by homogeneous WKT conversion. Child order and type IDs are canonical and independent of row\n * order, which makes the result safe to concatenate across record batches.\n *\n * @param column WKT Arrow vector.\n * @param dimension Optional dimension forced on every union child.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width inside union children.\n * @param geometryTypes Optional metadata used to seed stable absent children.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Dense union vector or `null` when a row cannot be represented.\n */\nexport function decodeWKTUnionVector(\n column: arrow.Vector,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n geometryTypes?: readonly GeoParquetGeometryType[],\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedRows: (ParsedWKTGeometry | null)[] = [];\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedRows.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed) return null;\n parsedRows.push(parsed);\n }\n return makeWKTUnionVector(parsedRows, dimension, coordinates, offsetType, geometryTypes, true);\n}\n\n/**\n * Decodes WKT GeometryCollection rows into a list of dense-union children.\n *\n * @param column WKT Arrow vector.\n * @param dimension Optional dimension forced on every union child.\n * @param coordinates Output coordinate layout.\n * @param offsetType Output list offset width inside union children and the collection list.\n * @param geometryTypes Optional metadata used to seed stable absent children.\n * @param maxGeometryCollectionDepth Maximum nested collection depth.\n * @returns Geometry collection vector or `null` when a row cannot be represented.\n */\nexport function decodeWKTGeometryCollectionVector(\n column: arrow.Vector,\n dimension?: GeoArrowDimension,\n coordinates: GeoArrowCoordinateLayout = 'interleaved',\n offsetType: GeoArrowOffsetType = 'int32',\n geometryTypes?: readonly GeoParquetGeometryType[],\n maxGeometryCollectionDepth = 64\n): arrow.Vector | null {\n const parsedCollections: (ParsedWKTGeometry | null)[] = [];\n\n for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {\n const value = column.get(rowIndex);\n if (value == null) {\n parsedCollections.push(null);\n continue;\n }\n if (typeof value !== 'string') return null;\n const parsed = parseWKT(value, maxGeometryCollectionDepth);\n if (!parsed || parsed.kind !== 'GeometryCollection') return null;\n parsedCollections.push(parsed);\n }\n return makeWKTCollectionVector(\n parsedCollections,\n dimension,\n coordinates,\n offsetType,\n geometryTypes\n );\n}\n\nfunction makeWKTUnionVector(\n parsedRows: readonly (ParsedWKTGeometry | null)[],\n dimension: GeoArrowDimension | undefined,\n coordinates: GeoArrowCoordinateLayout,\n offsetType: GeoArrowOffsetType,\n geometryTypes?: readonly GeoParquetGeometryType[],\n allowGeometryCollection = true\n): arrow.Vector | null {\n const children = new Map<string, WKTUnionChild>();\n for (const geometryType of geometryTypes || []) {\n const child = getWKTUnionChild(geometryType, dimension);\n if (child) children.set(getWKTUnionChildKey(child), child);\n }\n for (const parsed of parsedRows) {\n if (!parsed) continue;\n if (!allowGeometryCollection && parsed.kind === 'GeometryCollection') return null;\n const child = {\n kind: parsed.kind as WKTUnionChild['kind'],\n dimension: dimension || parsed.dimension\n };\n children.set(getWKTUnionChildKey(child), child);\n }\n\n const firstChild: WKTUnionChild = children.values().next().value || {\n kind: 'Point',\n dimension: 'xy'\n };\n children.set(getWKTUnionChildKey(firstChild), firstChild);\n const orderedChildren = [...children.values()].sort(\n (left, right) => getWKTUnionTypeId(left) - getWKTUnionTypeId(right)\n );\n const childRows = new Map<string, (ParsedWKTGeometry | null)[]>();\n const typeIds = new Int8Array(parsedRows.length);\n const valueOffsets = new Int32Array(parsedRows.length);\n\n for (let rowIndex = 0; rowIndex < parsedRows.length; rowIndex++) {\n const parsed = parsedRows[rowIndex];\n const child = parsed\n ? {kind: parsed.kind as WKTUnionChild['kind'], dimension: dimension || parsed.dimension}\n : firstChild;\n const key = getWKTUnionChildKey(child);\n const values = childRows.get(key) || [];\n valueOffsets[rowIndex] = values.length;\n values.push(parsed);\n childRows.set(key, values);\n typeIds[rowIndex] = getWKTUnionTypeId(child);\n }\n\n const fields: arrow.Field[] = [];\n const childData: arrow.Data[] = [];\n for (const child of orderedChildren) {\n const rows = childRows.get(getWKTUnionChildKey(child)) || [];\n if (child.kind === 'GeometryCollection') {\n const collectionVector = makeWKTCollectionVector(\n rows,\n dimension,\n coordinates,\n offsetType,\n geometryTypes\n );\n if (!collectionVector) return null;\n fields.push(new arrow.Field(getWKTUnionFieldName(child), collectionVector.type, true));\n childData.push(collectionVector.data[0]);\n continue;\n }\n const writers: GeoArrowGeometryWriter[] = rows.map(parsed =>\n parsed ? builder => writeParsedGeometry(builder, parsed) : null\n );\n const geometryArray = GeoArrowBuilder.buildGeometryArray(writers, {\n encoding: getBuilderEncoding(child.kind),\n dimension: child.dimension,\n coordinateLayout: coordinates,\n offsetType\n });\n const childVector = arrow.makeVector(GeoArrowBuilder.makeGeometryData(geometryArray));\n fields.push(new arrow.Field(getWKTUnionFieldName(child), childVector.type, true));\n childData.push(childVector.data[0]);\n }\n\n const unionType = new arrow.DenseUnion(orderedChildren.map(getWKTUnionTypeId), fields);\n return arrow.makeVector(\n arrow.makeData({\n type: unionType,\n length: parsedRows.length,\n nullCount: 0,\n typeIds,\n valueOffsets,\n children: childData\n } as any)\n );\n}\n\nfunction makeWKTCollectionVector(\n parsedRows: readonly (ParsedWKTGeometry | null)[],\n dimension: GeoArrowDimension | undefined,\n coordinates: GeoArrowCoordinateLayout,\n offsetType: GeoArrowOffsetType,\n geometryTypes?: readonly GeoParquetGeometryType[]\n): arrow.Vector | null {\n const flattenedChildren: ParsedWKTGeometry[] = [];\n const collectionOffsets = [0];\n const nullBitmap = new Uint8Array(Math.ceil(parsedRows.length / 8));\n let nullCount = 0;\n\n for (let rowIndex = 0; rowIndex < parsedRows.length; rowIndex++) {\n const parsed = parsedRows[rowIndex];\n if (!parsed) {\n nullCount++;\n collectionOffsets.push(flattenedChildren.length);\n continue;\n }\n if (parsed.kind !== 'GeometryCollection') return null;\n for (const child of parsed.geometries || []) flattenedChildren.push(child);\n nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);\n collectionOffsets.push(flattenedChildren.length);\n }\n\n const unionVector = makeWKTUnionVector(\n flattenedChildren,\n dimension,\n coordinates,\n offsetType,\n geometryTypes?.filter(\n geometryType => !geometryType.toLowerCase().startsWith('geometrycollection')\n ),\n false\n );\n if (!unionVector) return null;\n const listField = new arrow.Field('geometries', unionVector.type, true);\n const listType =\n offsetType === 'int64' ? new arrow.LargeList(listField) : new arrow.List(listField);\n return arrow.makeVector(\n arrow.makeData({\n type: listType,\n length: parsedRows.length,\n nullCount,\n valueOffsets: createWKTOffsets(collectionOffsets, offsetType),\n nullBitmap: nullCount > 0 ? nullBitmap : undefined,\n child: unionVector.data[0]\n } as any)\n );\n}\n\nfunction getBuilderEncoding(\n geometryKind: Exclude<WKTGeometryKind, 'GeometryCollection'>\n): GeoArrowBuilderEncoding {\n return `geoarrow.${geometryKind.toLowerCase()}` as GeoArrowBuilderEncoding;\n}\n\nfunction getWKTUnionChildKey(child: WKTUnionChild): string {\n return `${child.kind}:${child.dimension}`;\n}\n\nfunction getWKTUnionTypeId(child: WKTUnionChild): number {\n const baseTypeId =\n child.kind === 'GeometryCollection' ? 7 : UNION_GEOMETRY_KINDS.indexOf(child.kind) + 1;\n switch (child.dimension) {\n case 'xy':\n return baseTypeId;\n case 'xyz':\n return baseTypeId + 10;\n case 'xym':\n return baseTypeId + 20;\n case 'xyzm':\n return baseTypeId + 30;\n }\n}\n\nfunction getWKTUnionFieldName(child: WKTUnionChild): string {\n switch (child.dimension) {\n case 'xy':\n return child.kind;\n case 'xyz':\n return `${child.kind} Z`;\n case 'xym':\n return `${child.kind} M`;\n case 'xyzm':\n return `${child.kind} ZM`;\n }\n}\n\nfunction getWKTUnionChild(\n geometryType: GeoParquetGeometryType,\n requestedDimension?: GeoArrowDimension\n): WKTUnionChild | null {\n const dimension = requestedDimension || getWKTDimension(geometryType);\n const geometryKind = geometryType.replace(/ (?:ZM|Z|M)$/, '') as WKTGeometryKind;\n if (\n geometryKind !== 'GeometryCollection' &&\n !UNION_GEOMETRY_KINDS.includes(geometryKind as Exclude<WKTGeometryKind, 'GeometryCollection'>)\n ) {\n return null;\n }\n return {kind: geometryKind, dimension};\n}\n\nfunction getWKTDimension(geometryType: GeoParquetGeometryType): GeoArrowDimension {\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\nfunction createWKTOffsets(\n offsets: readonly number[],\n offsetType: GeoArrowOffsetType\n): Int32Array | BigInt64Array {\n return offsetType === 'int64'\n ? BigInt64Array.from(offsets, offset => BigInt(offset))\n : Int32Array.from(offsets);\n}\n\nfunction getGeometryKind(\n encoding: Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>\n): WKTGeometryKind {\n const geometryKindByEncoding: Record<\n Exclude<GeoArrowBuilderEncoding, 'geoarrow.box'>,\n WKTGeometryKind\n > = {\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 return geometryKindByEncoding[encoding];\n}\n\nfunction writeParsedGeometry(builder: GeoArrowBuilder, geometry: ParsedWKTGeometry): void {\n const coordinates = geometry.coordinates;\n switch (geometry.kind) {\n case 'Point':\n builder.beginPoint();\n writeCoordinate(builder, (coordinates as number[] | undefined) || []);\n return;\n case 'LineString':\n writeLineString(builder, (coordinates as number[][] | undefined) || []);\n return;\n case 'MultiPoint':\n writeMultiPoint(builder, (coordinates as number[][] | undefined) || []);\n return;\n case 'Polygon':\n writePolygon(builder, (coordinates as number[][][] | undefined) || []);\n return;\n case 'MultiLineString':\n writeMultiLineString(builder, (coordinates as number[][][] | undefined) || []);\n return;\n case 'MultiPolygon':\n writeMultiPolygon(builder, (coordinates as number[][][][] | undefined) || []);\n return;\n case 'GeometryCollection':\n throw new Error('GeometryCollection WKT requires the geometry union kernel.');\n }\n}\n\nfunction writeCoordinate(builder: GeoArrowBuilder, coordinate: number[]): void {\n builder.writeCoordinate(\n coordinate[0] ?? Number.NaN,\n coordinate[1] ?? Number.NaN,\n coordinate[2],\n coordinate[3]\n );\n}\n\nfunction writeLineString(builder: GeoArrowBuilder, coordinates: number[][]): void {\n builder.beginLineString(coordinates.length);\n for (const coordinate of coordinates) writeCoordinate(builder, coordinate);\n}\n\nfunction writeMultiPoint(builder: GeoArrowBuilder, coordinates: number[][]): void {\n builder.beginMultiPoint(coordinates.length);\n for (const coordinate of coordinates) {\n builder.beginPoint();\n writeCoordinate(builder, coordinate);\n }\n}\n\nfunction writePolygon(builder: GeoArrowBuilder, coordinates: number[][][]): void {\n builder.beginPolygon(coordinates.length);\n for (const ring of coordinates) {\n builder.beginLinearRing(ring.length);\n for (const coordinate of ring) writeCoordinate(builder, coordinate);\n }\n}\n\nfunction writeMultiLineString(builder: GeoArrowBuilder, coordinates: number[][][]): void {\n builder.beginMultiLineString(coordinates.length);\n for (const line of coordinates) writeLineString(builder, line);\n}\n\nfunction writeMultiPolygon(builder: GeoArrowBuilder, coordinates: number[][][][]): void {\n builder.beginMultiPolygon(coordinates.length);\n for (const polygon of coordinates) writePolygon(builder, polygon);\n}\n\n/** Parses WKT while retaining the converter's null-on-invalid convention. */\nfunction parseWKT(input: string, maxGeometryCollectionDepth = 64): ParsedWKTGeometry | null {\n try {\n if (/\\(\\s*\\)/.test(input)) return null;\n const result = parseWKTWithMetadata(input, {\n inferDimensions: true,\n allowMissingInheritedOrdinates: true,\n maximumDepth: maxGeometryCollectionDepth\n });\n return adaptParsedWKT(result);\n } catch {\n return null;\n }\n}\n\n/** Adapts math.gl geometry metadata to the seeded union and collection kernels. */\nfunction adaptParsedWKT({geometry, dimension, children}: WKTParseResult): ParsedWKTGeometry {\n if (geometry.type === 'GeometryCollection') {\n const geometries = children?.map(adaptParsedWKT);\n return {\n kind: geometry.type,\n dimension: dimension === 'xy' ? (geometries?.[0]?.dimension ?? dimension) : dimension,\n geometries\n };\n }\n return {kind: geometry.type, dimension, coordinates: geometry.coordinates as WKTCoordinates};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AACvB,mBAAwD;AAOxD,8BAIO;AAyBP,IAAM,uBAAkF;AAAA,EACtF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAgBO,SAAS,sBACd,QACA,gBACA,WACA,cAAwC,eACxC,aAAiC,SACjC,6BAA6B,IACR;AACrB,QAAM,aAA2C,CAAC;AAClD,MAAI;AAEJ,WAAS,WAAW,GAAG,WAAW,OAAO,QAAQ,YAAY;AAC3D,UAAM,QAAQ,OAAO,IAAI,QAAQ;AACjC,QAAI,SAAS,MAAM;AACjB,iBAAW,KAAK,IAAI;AACpB;AAAA,IACF;AACA,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,UAAM,SAAS,SAAS,OAAO,0BAA0B;AACzD,QAAI,CAAC,UAAU,OAAO,SAAS,gBAAgB,cAAc,EAAG,QAAO;AACvE,QAAI,CAAC,WAAW;AACd,UAAI,qBAAqB,sBAAsB,OAAO,UAAW,QAAO;AACxE,0BAAoB,OAAO;AAAA,IAC7B;AACA,eAAW,KAAK,MAAM;AAAA,EACxB;AAEA,QAAM,kBAAkB,aAAa,qBAAqB;AAC1D,QAAM,UAAoC,WAAW;AAAA,IAAI,YAC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SAAS,kBAAkB,SAA0B,aAAmC;AACtF,UAAQ,kBAAkB,YAAY,MAAM;AAC5C,aAAW,WAAW,YAAa,cAAa,SAAS,OAAO;AAClE;AAGA,SAAS,SAAS,OAAe,6BAA6B,IAA8B;AAC1F,MAAI;AACF,QAAI,UAAU,KAAK,KAAK,EAAG,QAAO;AAClC,UAAM,aAAS,mCAAqB,OAAO;AAAA,MACzC,iBAAiB;AAAA,MACjB,gCAAgC;AAAA,MAChC,cAAc;AAAA,IAChB,CAAC;AACD,WAAO,eAAe,MAAM;AAAA,EAC9B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,SAAS,eAAe,EAAC,UAAU,WAAW,SAAQ,GAAsC;AAC1F,MAAI,SAAS,SAAS,sBAAsB;AAC1C,UAAM,aAAa,UAAU,IAAI,cAAc;AAC/C,WAAO;AAAA,MACL,MAAM,SAAS;AAAA,MACf,WAAW,cAAc,OAAQ,aAAa,CAAC,GAAG,aAAa,YAAa;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAC,MAAM,SAAS,MAAM,WAAW,aAAa,SAAS,YAA6B;AAC7F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as arrow from 'apache-arrow';
|
|
2
2
|
import type { GeoArrowCoordinateLayout, GeoArrowDimension, GeoArrowOffsetType, GeoParquetGeometryType } from '@loaders.gl/core/schema';
|
|
3
|
-
import { type GeoArrowBuilderEncoding } from "
|
|
3
|
+
import { type GeoArrowBuilderEncoding } from "../../../arrow-geometry/geoarrow-builder.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decodes homogeneous WKT rows directly into native GeoArrow buffers.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* two-pass GeoArrow builder. It deliberately does not construct GeoJSON geometry objects.
|
|
7
|
+
* Parsed coordinate tuples are passed to the two-pass GeoArrow builder.
|
|
9
8
|
* Mixed WKT columns and geometry collections use the matching typed union kernels.
|
|
10
9
|
*
|
|
11
10
|
* @param column WKT Arrow vector.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode-wkt-native.d.ts","sourceRoot":"","sources":["../../../../src/geoarrow/lib/kernels/decode-wkt-native.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"decode-wkt-native.d.ts","sourceRoot":"","sources":["../../../../src/geoarrow/lib/kernels/decode-wkt-native.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,uBAAuB,EAE7B,oDAAiD;AAkClD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,cAAc,EAAE,OAAO,CAAC,uBAAuB,EAAE,cAAc,CAAC,EAChE,SAAS,CAAC,EAAE,iBAAiB,EAC7B,WAAW,GAAE,wBAAwC,EACrD,UAAU,GAAE,kBAA4B,EACxC,0BAA0B,SAAK,GAC9B,KAAK,CAAC,MAAM,GAAG,IAAI,CA+BrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,CAAC,EAAE,iBAAiB,EAC7B,WAAW,GAAE,wBAAwC,EACrD,UAAU,GAAE,kBAA4B,EACxC,aAAa,CAAC,EAAE,SAAS,sBAAsB,EAAE,EACjD,0BAA0B,SAAK,GAC9B,KAAK,CAAC,MAAM,GAAG,IAAI,CAcrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,CAAC,EAAE,iBAAiB,EAC7B,WAAW,GAAE,wBAAwC,EACrD,UAAU,GAAE,kBAA4B,EACxC,aAAa,CAAC,EAAE,SAAS,sBAAsB,EAAE,EACjD,0BAA0B,SAAK,GAC9B,KAAK,CAAC,MAAM,GAAG,IAAI,CAqBrB"}
|