@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
+
import {parseWKTWithMetadata, type WKTParseResult} from '@math.gl/core/arrow';
|
|
6
7
|
import type {
|
|
7
8
|
GeoArrowCoordinateLayout,
|
|
8
9
|
GeoArrowDimension,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
GeoArrowBuilder,
|
|
14
15
|
type GeoArrowBuilderEncoding,
|
|
15
16
|
type GeoArrowGeometryWriter
|
|
16
|
-
} from '
|
|
17
|
+
} from '../../../arrow-geometry/geoarrow-builder';
|
|
17
18
|
|
|
18
19
|
type WKTGeometryKind =
|
|
19
20
|
| 'Point'
|
|
@@ -47,21 +48,10 @@ const UNION_GEOMETRY_KINDS: readonly Exclude<WKTGeometryKind, 'GeometryCollectio
|
|
|
47
48
|
'MultiPolygon'
|
|
48
49
|
];
|
|
49
50
|
|
|
50
|
-
const GEOMETRY_KINDS: readonly WKTGeometryKind[] = [
|
|
51
|
-
'Point',
|
|
52
|
-
'LineString',
|
|
53
|
-
'Polygon',
|
|
54
|
-
'MultiPoint',
|
|
55
|
-
'MultiLineString',
|
|
56
|
-
'MultiPolygon',
|
|
57
|
-
'GeometryCollection'
|
|
58
|
-
];
|
|
59
|
-
|
|
60
51
|
/**
|
|
61
52
|
* Decodes homogeneous WKT rows directly into native GeoArrow buffers.
|
|
62
53
|
*
|
|
63
|
-
*
|
|
64
|
-
* two-pass GeoArrow builder. It deliberately does not construct GeoJSON geometry objects.
|
|
54
|
+
* Parsed coordinate tuples are passed to the two-pass GeoArrow builder.
|
|
65
55
|
* Mixed WKT columns and geometry collections use the matching typed union kernels.
|
|
66
56
|
*
|
|
67
57
|
* @param column WKT Arrow vector.
|
|
@@ -487,266 +477,30 @@ function writeMultiPolygon(builder: GeoArrowBuilder, coordinates: number[][][][]
|
|
|
487
477
|
for (const polygon of coordinates) writePolygon(builder, polygon);
|
|
488
478
|
}
|
|
489
479
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
parse(): ParsedWKTGeometry | null {
|
|
502
|
-
this.skipWhitespace();
|
|
503
|
-
if (this.readLiteral('SRID')) {
|
|
504
|
-
this.skipWhitespace();
|
|
505
|
-
if (!this.readCharacter('=')) return null;
|
|
506
|
-
if (this.readNumber() === null) return null;
|
|
507
|
-
this.skipWhitespace();
|
|
508
|
-
if (!this.readCharacter(';')) return null;
|
|
509
|
-
}
|
|
510
|
-
const geometry = this.parseGeometry();
|
|
511
|
-
this.skipWhitespace();
|
|
512
|
-
return geometry && this.index === this.input.length ? geometry : null;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
private parseGeometry(): ParsedWKTGeometry | null {
|
|
516
|
-
this.skipWhitespace();
|
|
517
|
-
const kind = this.readGeometryKind();
|
|
518
|
-
if (!kind) return null;
|
|
519
|
-
this.skipWhitespace();
|
|
520
|
-
const dimensionToken = this.readDimensionToken();
|
|
521
|
-
this.skipWhitespace();
|
|
522
|
-
if (this.readLiteral('EMPTY')) {
|
|
523
|
-
return {kind, dimension: dimensionToken || 'xy', coordinates: getEmptyCoordinates(kind)};
|
|
524
|
-
}
|
|
525
|
-
if (!this.readCharacter('(')) return null;
|
|
526
|
-
|
|
527
|
-
let coordinates: WKTCoordinates | null | undefined;
|
|
528
|
-
let geometries: ParsedWKTGeometry[] | null | undefined;
|
|
529
|
-
switch (kind) {
|
|
530
|
-
case 'Point':
|
|
531
|
-
coordinates = this.parseCoordinate();
|
|
532
|
-
break;
|
|
533
|
-
case 'LineString':
|
|
534
|
-
coordinates = this.parseCoordinateList();
|
|
535
|
-
break;
|
|
536
|
-
case 'Polygon':
|
|
537
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
538
|
-
break;
|
|
539
|
-
case 'MultiPoint':
|
|
540
|
-
coordinates = this.parseMultiPointCoordinates();
|
|
541
|
-
break;
|
|
542
|
-
case 'MultiLineString':
|
|
543
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
544
|
-
break;
|
|
545
|
-
case 'MultiPolygon':
|
|
546
|
-
coordinates = this.parseNestedCoordinates(2);
|
|
547
|
-
break;
|
|
548
|
-
case 'GeometryCollection':
|
|
549
|
-
this.geometryCollectionDepth++;
|
|
550
|
-
if (this.geometryCollectionDepth > this.maxGeometryCollectionDepth) return null;
|
|
551
|
-
geometries = this.parseGeometryList();
|
|
552
|
-
this.geometryCollectionDepth--;
|
|
553
|
-
break;
|
|
554
|
-
}
|
|
555
|
-
if (
|
|
556
|
-
coordinates === null ||
|
|
557
|
-
geometries === null ||
|
|
558
|
-
(coordinates === undefined && geometries === undefined)
|
|
559
|
-
)
|
|
560
|
-
return null;
|
|
561
|
-
if (!this.readCharacter(')')) return null;
|
|
562
|
-
|
|
563
|
-
const parsedCoordinates = coordinates || undefined;
|
|
564
|
-
const parsedGeometries = geometries || undefined;
|
|
565
|
-
const inferredDimension = dimensionToken || inferDimension(parsedCoordinates, parsedGeometries);
|
|
566
|
-
if (
|
|
567
|
-
kind !== 'GeometryCollection' &&
|
|
568
|
-
!hasValidArity(parsedCoordinates, undefined, inferredDimension)
|
|
569
|
-
) {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
return {
|
|
573
|
-
kind,
|
|
574
|
-
dimension: inferredDimension,
|
|
575
|
-
coordinates: parsedCoordinates,
|
|
576
|
-
geometries: parsedGeometries
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
private parseCoordinateList(): number[][] | null {
|
|
581
|
-
const coordinates: number[][] = [];
|
|
582
|
-
while (true) {
|
|
583
|
-
const coordinate = this.parseCoordinate();
|
|
584
|
-
if (!coordinate) return null;
|
|
585
|
-
coordinates.push(coordinate);
|
|
586
|
-
this.skipWhitespace();
|
|
587
|
-
if (!this.readCharacter(',')) return coordinates;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
private parseNestedCoordinates(depth: number): WKTCoordinates | null {
|
|
592
|
-
const values: WKTCoordinates[] = [];
|
|
593
|
-
while (true) {
|
|
594
|
-
if (!this.readCharacter('(')) return null;
|
|
595
|
-
const value =
|
|
596
|
-
depth === 1 ? this.parseCoordinateList() : this.parseNestedCoordinates(depth - 1);
|
|
597
|
-
if (!value || !this.readCharacter(')')) return null;
|
|
598
|
-
values.push(value);
|
|
599
|
-
this.skipWhitespace();
|
|
600
|
-
if (!this.readCharacter(',')) return values;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
private parseMultiPointCoordinates(): number[][] | null {
|
|
605
|
-
this.skipWhitespace();
|
|
606
|
-
if (this.peekCharacter('(')) {
|
|
607
|
-
const coordinates: number[][] = [];
|
|
608
|
-
while (true) {
|
|
609
|
-
if (!this.readCharacter('(')) return null;
|
|
610
|
-
const coordinate = this.parseCoordinate();
|
|
611
|
-
if (!coordinate || !this.readCharacter(')')) return null;
|
|
612
|
-
coordinates.push(coordinate);
|
|
613
|
-
this.skipWhitespace();
|
|
614
|
-
if (!this.readCharacter(',')) return coordinates;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
return this.parseCoordinateList();
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
private parseGeometryList(): ParsedWKTGeometry[] | null {
|
|
621
|
-
const geometries: ParsedWKTGeometry[] = [];
|
|
622
|
-
while (true) {
|
|
623
|
-
const geometry = this.parseGeometry();
|
|
624
|
-
if (!geometry) return null;
|
|
625
|
-
geometries.push(geometry);
|
|
626
|
-
this.skipWhitespace();
|
|
627
|
-
if (!this.readCharacter(',')) return geometries;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
private parseCoordinate(): number[] | null {
|
|
632
|
-
const coordinate: number[] = [];
|
|
633
|
-
while (true) {
|
|
634
|
-
this.skipWhitespace();
|
|
635
|
-
const value = this.readNumber();
|
|
636
|
-
if (value === null) break;
|
|
637
|
-
coordinate.push(value);
|
|
638
|
-
}
|
|
639
|
-
return coordinate.length >= 2 ? coordinate : null;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
private readGeometryKind(): WKTGeometryKind | null {
|
|
643
|
-
const word = this.readWord()?.toUpperCase();
|
|
644
|
-
const kind = GEOMETRY_KINDS.find(value => value.toUpperCase() === word);
|
|
645
|
-
return kind || null;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
private readDimensionToken(): GeoArrowDimension | null {
|
|
649
|
-
const position = this.index;
|
|
650
|
-
const word = this.readWord()?.toUpperCase();
|
|
651
|
-
if (word === 'Z') return 'xyz';
|
|
652
|
-
if (word === 'M') return 'xym';
|
|
653
|
-
if (word === 'ZM') return 'xyzm';
|
|
654
|
-
this.index = position;
|
|
480
|
+
/** Parses WKT while retaining the converter's null-on-invalid convention. */
|
|
481
|
+
function parseWKT(input: string, maxGeometryCollectionDepth = 64): ParsedWKTGeometry | null {
|
|
482
|
+
try {
|
|
483
|
+
if (/\(\s*\)/.test(input)) return null;
|
|
484
|
+
const result = parseWKTWithMetadata(input, {
|
|
485
|
+
inferDimensions: true,
|
|
486
|
+
allowMissingInheritedOrdinates: true,
|
|
487
|
+
maximumDepth: maxGeometryCollectionDepth
|
|
488
|
+
});
|
|
489
|
+
return adaptParsedWKT(result);
|
|
490
|
+
} catch {
|
|
655
491
|
return null;
|
|
656
492
|
}
|
|
657
|
-
|
|
658
|
-
private readWord(): string | null {
|
|
659
|
-
const match = this.input.slice(this.index).match(/^[A-Za-z]+/);
|
|
660
|
-
if (!match) return null;
|
|
661
|
-
this.index += match[0].length;
|
|
662
|
-
return match[0];
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
private readNumber(): number | null {
|
|
666
|
-
const match = this.input
|
|
667
|
-
.slice(this.index)
|
|
668
|
-
.match(/^[+-]?(?:(?:\d+\.\d*|\.\d+|\d+)(?:[eE][+-]?\d+)?)/);
|
|
669
|
-
if (!match) return null;
|
|
670
|
-
this.index += match[0].length;
|
|
671
|
-
const value = Number(match[0]);
|
|
672
|
-
return Number.isFinite(value) ? value : null;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
private readLiteral(literal: string): boolean {
|
|
676
|
-
const position = this.index;
|
|
677
|
-
const word = this.readWord();
|
|
678
|
-
if (word?.toUpperCase() === literal) return true;
|
|
679
|
-
this.index = position;
|
|
680
|
-
return false;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
private readCharacter(character: string): boolean {
|
|
684
|
-
if (this.input[this.index] !== character) return false;
|
|
685
|
-
this.index++;
|
|
686
|
-
this.skipWhitespace();
|
|
687
|
-
return true;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
private peekCharacter(character: string): boolean {
|
|
691
|
-
return this.input[this.index] === character;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
private skipWhitespace(): void {
|
|
695
|
-
while (/\s/.test(this.input[this.index] || '')) this.index++;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
function parseWKT(input: string, maxGeometryCollectionDepth = 64): ParsedWKTGeometry | null {
|
|
700
|
-
return new WKTParser(input, maxGeometryCollectionDepth).parse();
|
|
701
493
|
}
|
|
702
494
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (coordinateSize) return dimensionFromSize(coordinateSize);
|
|
713
|
-
for (const geometry of geometries || []) return geometry.dimension;
|
|
714
|
-
return 'xy';
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
function findCoordinateSize(coordinates: WKTCoordinates | undefined): number | null {
|
|
718
|
-
if (!coordinates) return null;
|
|
719
|
-
if (coordinates.length === 0) return null;
|
|
720
|
-
if (isCoordinate(coordinates)) return coordinates.length;
|
|
721
|
-
for (const value of coordinates) {
|
|
722
|
-
const size = findCoordinateSize(value as WKTCoordinates);
|
|
723
|
-
if (size) return size;
|
|
495
|
+
/** Adapts math.gl geometry metadata to the seeded union and collection kernels. */
|
|
496
|
+
function adaptParsedWKT({geometry, dimension, children}: WKTParseResult): ParsedWKTGeometry {
|
|
497
|
+
if (geometry.type === 'GeometryCollection') {
|
|
498
|
+
const geometries = children?.map(adaptParsedWKT);
|
|
499
|
+
return {
|
|
500
|
+
kind: geometry.type,
|
|
501
|
+
dimension: dimension === 'xy' ? (geometries?.[0]?.dimension ?? dimension) : dimension,
|
|
502
|
+
geometries
|
|
503
|
+
};
|
|
724
504
|
}
|
|
725
|
-
return
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
function dimensionFromSize(size: number): GeoArrowDimension {
|
|
729
|
-
return size === 4 ? 'xyzm' : size === 3 ? 'xyz' : 'xy';
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
function hasValidArity(
|
|
733
|
-
coordinates: WKTCoordinates | undefined,
|
|
734
|
-
geometries: readonly ParsedWKTGeometry[] | undefined,
|
|
735
|
-
dimension: GeoArrowDimension
|
|
736
|
-
): boolean {
|
|
737
|
-
const expectedSize = dimension === 'xy' ? 2 : dimension === 'xyzm' ? 4 : 3;
|
|
738
|
-
if (coordinates && !hasCoordinateArity(coordinates, expectedSize)) return false;
|
|
739
|
-
return (geometries || []).every(
|
|
740
|
-
geometry => geometry.dimension === dimension || geometry.kind === 'GeometryCollection'
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
function hasCoordinateArity(value: WKTCoordinates, expectedSize: number): boolean {
|
|
745
|
-
if (value.length === 0) return true;
|
|
746
|
-
if (isCoordinate(value)) return value.length === expectedSize;
|
|
747
|
-
return value.every(child => hasCoordinateArity(child, expectedSize));
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
function isCoordinate(value: WKTCoordinates): value is number[] {
|
|
751
|
-
return typeof value[0] === 'number';
|
|
505
|
+
return {kind: geometry.type, dimension, coordinates: geometry.coordinates as WKTCoordinates};
|
|
752
506
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,101 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
export
|
|
7
|
-
Loader,
|
|
8
|
-
LoaderWithParser,
|
|
9
|
-
LoaderContext,
|
|
10
|
-
CoreAPI,
|
|
11
|
-
LoaderOptions,
|
|
12
|
-
Writer,
|
|
13
|
-
WriterOptions,
|
|
14
|
-
DataType,
|
|
15
|
-
SyncDataType,
|
|
16
|
-
BatchableDataType,
|
|
17
|
-
ReadableFile,
|
|
18
|
-
WritableFile,
|
|
19
|
-
Stat,
|
|
20
|
-
FileSystem,
|
|
21
|
-
RandomAccessFileSystem
|
|
22
|
-
} from '@loaders.gl/core/loader-utils';
|
|
23
|
-
export type {SourceLoader} from '@loaders.gl/core/loader-utils';
|
|
24
|
-
|
|
25
|
-
// FILE READING AND WRITING
|
|
26
|
-
export {fetchFile} from './lib/fetch/fetch-file';
|
|
27
|
-
export {FetchError} from './lib/fetch/fetch-error';
|
|
28
|
-
|
|
29
|
-
export {readArrayBuffer} from './lib/fetch/read-array-buffer';
|
|
30
|
-
// export {readFileSync} from './lib/fetch/read-file';
|
|
31
|
-
// export {writeFile, writeFileSync} from './lib/fetch/write-file';
|
|
32
|
-
|
|
33
|
-
// CONFIGURATION
|
|
34
|
-
export {setLoaderOptions, getLoaderOptions, compareLoaderOptions} from './lib/api/loader-options';
|
|
35
|
-
export {registerLoaders} from './lib/api/register-loaders';
|
|
36
|
-
export {selectLoader, selectLoaderSync} from './lib/api/select-loader';
|
|
37
|
-
|
|
38
|
-
// LOADING (READING + PARSING)
|
|
39
|
-
export {parse} from './lib/api/parse';
|
|
40
|
-
export {parseFile} from './lib/api/parse-file';
|
|
41
|
-
export {parseSync} from './lib/api/parse-sync';
|
|
42
|
-
export {parseInBatches} from './lib/api/parse-in-batches';
|
|
43
|
-
export {preload, preloadSync} from './lib/api/preload';
|
|
44
|
-
export {coreApi} from './lib/api/core-api';
|
|
45
|
-
|
|
46
|
-
export {load} from './lib/api/load';
|
|
47
|
-
export {loadInBatches} from './lib/api/load-in-batches';
|
|
48
|
-
|
|
49
|
-
// ENCODING (ENCODING AND WRITING)
|
|
50
|
-
export {encodeTable, encodeTableAsText, encodeTableInBatches} from './lib/api/encode-table';
|
|
51
|
-
export {encode, encodeSync, encodeInBatches, encodeURLtoURL} from './lib/api/encode';
|
|
52
|
-
export {encodeText, encodeTextSync} from './lib/api/encode';
|
|
53
|
-
|
|
54
|
-
// SERVICES AND SOURCES
|
|
55
|
-
export {createDataSource, createDataSourceSync} from './lib/api/create-data-source';
|
|
56
|
-
export {selectSource as _selectSource} from './lib/api/select-source';
|
|
57
|
-
|
|
58
|
-
// CORE UTILS SHARED WITH LOADERS (RE-EXPORTED FROM LOADER-UTILS)
|
|
59
|
-
export {setPathPrefix, getPathPrefix, resolvePath} from '@loaders.gl/core/loader-utils';
|
|
60
|
-
export {RequestScheduler} from '@loaders.gl/core/loader-utils';
|
|
61
|
-
|
|
62
|
-
// ITERATOR UTILS
|
|
63
|
-
export {makeIterator} from './iterators/make-iterator/make-iterator';
|
|
64
|
-
export {makeStream} from './iterators/make-stream/make-stream';
|
|
5
|
+
// Compatibility entry point for applications using the original core imports.
|
|
6
|
+
export * from '@loaders.gl/core/api';
|
|
65
7
|
|
|
66
8
|
// CORE LOADERS
|
|
67
9
|
export {NullLoader} from './null-loader';
|
|
68
10
|
export {JSONLoader} from '@loaders.gl/core/loader-utils';
|
|
69
|
-
|
|
70
|
-
// EXPERIMENTAL
|
|
71
|
-
export {fetchProgress as _fetchProgress} from './lib/progress/fetch-progress';
|
|
72
|
-
export {BrowserFileSystem as _BrowserFileSystem} from './lib/filesystems/browser-filesystem';
|
|
73
|
-
|
|
74
|
-
// FOR TESTING
|
|
75
|
-
export {_unregisterLoaders} from './lib/api/register-loaders';
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
// TODO - MOVE TO LOADER-UTILS AND DEPRECATE IN CORE?
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
export {isBrowser, isWorker, self, window, global, document} from '@loaders.gl/core/loader-utils';
|
|
82
|
-
export {assert} from '@loaders.gl/core/loader-utils';
|
|
83
|
-
export {forEach, concatenateArrayBuffersAsync} from '@loaders.gl/core/loader-utils';
|
|
84
|
-
|
|
85
|
-
export {
|
|
86
|
-
makeTextDecoderIterator,
|
|
87
|
-
makeTextEncoderIterator,
|
|
88
|
-
makeLineIterator,
|
|
89
|
-
makeNumberedLineIterator
|
|
90
|
-
} from '@loaders.gl/core/loader-utils';
|
|
91
|
-
|
|
92
|
-
// "JAVASCRIPT" UTILS - move to loader-utils?
|
|
93
|
-
export {
|
|
94
|
-
isPureObject,
|
|
95
|
-
isPromise,
|
|
96
|
-
isIterable,
|
|
97
|
-
isAsyncIterable,
|
|
98
|
-
isIterator,
|
|
99
|
-
isResponse,
|
|
100
|
-
isReadableStream,
|
|
101
|
-
isWritableStream
|
|
102
|
-
} from '@loaders.gl/core/loader-utils';
|
|
@@ -7,16 +7,21 @@
|
|
|
7
7
|
import {
|
|
8
8
|
concatenateArrayBuffers,
|
|
9
9
|
ensureArrayBuffer,
|
|
10
|
+
Writer,
|
|
11
|
+
WriterOptions,
|
|
10
12
|
WriterOptionsType,
|
|
11
13
|
WriterWithEncoder
|
|
12
14
|
} from '@loaders.gl/core/loader-utils';
|
|
13
15
|
import type {Table} from '@loaders.gl/core/schema';
|
|
14
16
|
|
|
15
|
-
export async function encodeTable<WriterT extends
|
|
17
|
+
export async function encodeTable<WriterT extends Writer = Writer>(
|
|
16
18
|
data: Table,
|
|
17
|
-
|
|
19
|
+
writerDefinition: WriterT,
|
|
18
20
|
options?: WriterOptionsType<WriterT>
|
|
19
21
|
): Promise<ArrayBuffer> {
|
|
22
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition.preload
|
|
23
|
+
? await writerDefinition.preload()
|
|
24
|
+
: writerDefinition;
|
|
20
25
|
if (writer.encode) {
|
|
21
26
|
return await writer.encode(data, options);
|
|
22
27
|
}
|
|
@@ -42,11 +47,14 @@ export async function encodeTable<WriterT extends WriterWithEncoder = WriterWith
|
|
|
42
47
|
throw new Error('Writer could not encode data');
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
export async function encodeTableAsText<WriterT extends
|
|
50
|
+
export async function encodeTableAsText<WriterT extends Writer = Writer>(
|
|
46
51
|
data: Table,
|
|
47
|
-
|
|
52
|
+
writerDefinition: WriterT,
|
|
48
53
|
options?: WriterOptionsType<WriterT>
|
|
49
54
|
): Promise<string> {
|
|
55
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition.preload
|
|
56
|
+
? await writerDefinition.preload()
|
|
57
|
+
: writerDefinition;
|
|
50
58
|
if (writer.text && writer.encodeText) {
|
|
51
59
|
return await writer.encodeText(data, options);
|
|
52
60
|
}
|
|
@@ -58,10 +66,27 @@ export async function encodeTableAsText<WriterT extends WriterWithEncoder = Writ
|
|
|
58
66
|
throw new Error(`Writer ${writer.name} could not encode data as text`);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
export function encodeTableInBatches<WriterT extends
|
|
69
|
+
export function encodeTableInBatches<WriterT extends Writer = Writer>(
|
|
62
70
|
data: Table,
|
|
63
|
-
|
|
71
|
+
writerDefinition: WriterT,
|
|
64
72
|
options?: WriterOptionsType<WriterT>
|
|
73
|
+
): AsyncIterable<ArrayBuffer> {
|
|
74
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition;
|
|
75
|
+
if (!writer.encodeInBatches && writer.preload) {
|
|
76
|
+
const preload = writer.preload.bind(writer);
|
|
77
|
+
return (async function* () {
|
|
78
|
+
const implementation = await preload();
|
|
79
|
+
yield* encodeWriterTableInBatches(data, implementation, options);
|
|
80
|
+
})();
|
|
81
|
+
}
|
|
82
|
+
return encodeWriterTableInBatches(data, writer, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Encodes table batches using the resolved writer's batch method. */
|
|
86
|
+
function encodeWriterTableInBatches(
|
|
87
|
+
data: Table,
|
|
88
|
+
writer: Writer & Partial<WriterWithEncoder>,
|
|
89
|
+
options?: WriterOptions
|
|
65
90
|
): AsyncIterable<ArrayBuffer> {
|
|
66
91
|
if (writer.encodeInBatches) {
|
|
67
92
|
const dataIterator = getIterator(data);
|
package/src/lib/api/encode.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
+
Writer,
|
|
6
7
|
WriterOptions,
|
|
7
8
|
WriterWithEncoder,
|
|
8
9
|
WriterOptionsType,
|
|
@@ -23,11 +24,14 @@ import {getLoaderOptions} from './loader-options';
|
|
|
23
24
|
/**
|
|
24
25
|
* Encode loaded data into a binary ArrayBuffer using the specified Writer.
|
|
25
26
|
*/
|
|
26
|
-
export async function encode<WriterT extends
|
|
27
|
+
export async function encode<WriterT extends Writer>(
|
|
27
28
|
data: WriterDataType<WriterT>,
|
|
28
|
-
|
|
29
|
+
writerDefinition: WriterT,
|
|
29
30
|
options_?: WriterOptionsType<WriterT>
|
|
30
31
|
): Promise<ArrayBuffer> {
|
|
32
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition.preload
|
|
33
|
+
? await writerDefinition.preload()
|
|
34
|
+
: writerDefinition;
|
|
31
35
|
const globalOptions = getLoaderOptions() as WriterOptions;
|
|
32
36
|
// const globalOptions: WriterOptions = {}; // getWriterOptions();
|
|
33
37
|
const options = {...globalOptions, ...options_};
|
|
@@ -43,6 +47,9 @@ export async function encode<WriterT extends WriterWithEncoder>(
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
// TODO Merge default writer options with options argument like it is done in load module.
|
|
50
|
+
if (!writer.encode) {
|
|
51
|
+
throw new Error(`Writer ${writer.name} could not encode data`);
|
|
52
|
+
}
|
|
46
53
|
return await writer.encode(data, options);
|
|
47
54
|
}
|
|
48
55
|
|
|
@@ -69,11 +76,14 @@ export function encodeSync<WriterT extends WriterWithEncoder>(
|
|
|
69
76
|
* It is not optimized for performance. Data maybe converted from text to binary and back.
|
|
70
77
|
* @throws if the writer does not generate text output
|
|
71
78
|
*/
|
|
72
|
-
export async function encodeText<WriterT extends
|
|
79
|
+
export async function encodeText<WriterT extends Writer>(
|
|
73
80
|
data: WriterDataType<WriterT>,
|
|
74
|
-
|
|
81
|
+
writerDefinition: WriterT,
|
|
75
82
|
options?: WriterOptionsType<WriterT>
|
|
76
83
|
): Promise<string> {
|
|
84
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition.preload
|
|
85
|
+
? await writerDefinition.preload()
|
|
86
|
+
: writerDefinition;
|
|
77
87
|
if (writer.encodeText) {
|
|
78
88
|
return await writer.encodeText(data, options);
|
|
79
89
|
}
|
|
@@ -82,7 +92,7 @@ export async function encodeText<WriterT extends WriterWithEncoder>(
|
|
|
82
92
|
return writer.encodeTextSync(data, options);
|
|
83
93
|
}
|
|
84
94
|
|
|
85
|
-
if (writer.text) {
|
|
95
|
+
if (writer.text && writer.encode) {
|
|
86
96
|
const arrayBuffer = await writer.encode(data, options);
|
|
87
97
|
return new TextDecoder().decode(arrayBuffer);
|
|
88
98
|
}
|
|
@@ -116,13 +126,30 @@ export function encodeTextSync<WriterT extends WriterWithEncoder>(
|
|
|
116
126
|
/**
|
|
117
127
|
* Encode loaded data into a sequence (iterator) of binary ArrayBuffers using the specified Writer.
|
|
118
128
|
*/
|
|
119
|
-
export function encodeInBatches<WriterT extends
|
|
129
|
+
export function encodeInBatches<WriterT extends Writer>(
|
|
120
130
|
data:
|
|
121
131
|
| WriterBatchType<WriterT>
|
|
122
132
|
| Iterable<WriterBatchType<WriterT>>
|
|
123
133
|
| AsyncIterable<WriterBatchType<WriterT>>,
|
|
124
|
-
|
|
134
|
+
writerDefinition: WriterT,
|
|
125
135
|
options?: WriterOptionsType<WriterT>
|
|
136
|
+
): AsyncIterable<ArrayBuffer> {
|
|
137
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition;
|
|
138
|
+
if (!writer.encodeInBatches && writer.preload) {
|
|
139
|
+
const preload = writer.preload.bind(writer);
|
|
140
|
+
return (async function* () {
|
|
141
|
+
const implementation = await preload();
|
|
142
|
+
yield* encodeWriterInBatches(data, implementation, options);
|
|
143
|
+
})();
|
|
144
|
+
}
|
|
145
|
+
return encodeWriterInBatches(data, writer, options);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Encodes binary batches using the resolved writer's batch method. */
|
|
149
|
+
function encodeWriterInBatches(
|
|
150
|
+
data: unknown,
|
|
151
|
+
writer: Writer & Partial<WriterWithEncoder>,
|
|
152
|
+
options?: WriterOptions
|
|
126
153
|
): AsyncIterable<ArrayBuffer> {
|
|
127
154
|
if (writer.encodeInBatches) {
|
|
128
155
|
let dataIterator: unknown;
|
|
@@ -146,7 +173,24 @@ export function encodeInBatches<WriterT extends WriterWithEncoder>(
|
|
|
146
173
|
*/
|
|
147
174
|
export function encodeTextInBatches(
|
|
148
175
|
data: unknown,
|
|
149
|
-
|
|
176
|
+
writerDefinition: Writer,
|
|
177
|
+
options?: WriterOptions
|
|
178
|
+
): AsyncIterable<ArrayBuffer> {
|
|
179
|
+
const writer: Writer & Partial<WriterWithEncoder> = writerDefinition;
|
|
180
|
+
if (!writer.encodeTextInBatches && writer.preload) {
|
|
181
|
+
const preload = writer.preload.bind(writer);
|
|
182
|
+
return (async function* () {
|
|
183
|
+
const implementation = await preload();
|
|
184
|
+
yield* encodeWriterTextInBatches(data, implementation, options);
|
|
185
|
+
})();
|
|
186
|
+
}
|
|
187
|
+
return encodeWriterTextInBatches(data, writer, options);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Encodes text batches using the resolved writer's batch method. */
|
|
191
|
+
function encodeWriterTextInBatches(
|
|
192
|
+
data: unknown,
|
|
193
|
+
writer: Writer & Partial<WriterWithEncoder>,
|
|
150
194
|
options?: WriterOptions
|
|
151
195
|
): AsyncIterable<ArrayBuffer> {
|
|
152
196
|
if (writer.encodeTextInBatches) {
|
|
@@ -165,12 +209,18 @@ export function encodeTextInBatches(
|
|
|
165
209
|
export async function encodeURLtoURL(
|
|
166
210
|
inputUrl: string,
|
|
167
211
|
outputUrl: string,
|
|
168
|
-
|
|
212
|
+
writerDefinition: Omit<WriterWithEncoder, 'encode'>,
|
|
169
213
|
options?: WriterOptions
|
|
170
214
|
): Promise<string> {
|
|
171
215
|
inputUrl = resolvePath(inputUrl);
|
|
172
216
|
outputUrl = resolvePath(outputUrl);
|
|
173
|
-
if (isBrowser
|
|
217
|
+
if (isBrowser) {
|
|
218
|
+
throw new Error();
|
|
219
|
+
}
|
|
220
|
+
const writer = writerDefinition.encodeURLtoURL
|
|
221
|
+
? writerDefinition
|
|
222
|
+
: ((await writerDefinition.preload?.()) ?? writerDefinition);
|
|
223
|
+
if (!writer.encodeURLtoURL) {
|
|
174
224
|
throw new Error();
|
|
175
225
|
}
|
|
176
226
|
const outputFilename = await writer.encodeURLtoURL(inputUrl, outputUrl, options);
|
|
@@ -179,7 +229,7 @@ export async function encodeURLtoURL(
|
|
|
179
229
|
|
|
180
230
|
/** Helper function to encode via external tool (typically command line execution in Node.js) */
|
|
181
231
|
async function encodeWithCommandLineTool(
|
|
182
|
-
writer: WriterWithEncoder,
|
|
232
|
+
writer: Omit<WriterWithEncoder, 'encode'>,
|
|
183
233
|
data: unknown,
|
|
184
234
|
options: WriterOptions
|
|
185
235
|
): Promise<ArrayBuffer> {
|
|
@@ -161,6 +161,7 @@ export {
|
|
|
161
161
|
// REQUEST UTILS
|
|
162
162
|
export {default as RequestScheduler} from './lib/request-utils/request-scheduler';
|
|
163
163
|
export {
|
|
164
|
+
createSourceLoadOptionsResolver,
|
|
164
165
|
resolveCredentials,
|
|
165
166
|
resolveAuthenticationOptions,
|
|
166
167
|
resolveLoaderAuthenticationOptions
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Table, TableBatch} from '@loaders.gl/core/schema';
|
|
6
|
+
|
|
7
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
10
|
+
|
|
11
|
+
/** Shared metadata for JSONLoader. */
|
|
12
|
+
export const JSONLoaderMetadata = {
|
|
13
|
+
dataType: null as unknown as Table,
|
|
14
|
+
batchType: null as unknown as TableBatch,
|
|
15
|
+
name: 'JSON',
|
|
16
|
+
id: 'json',
|
|
17
|
+
module: 'json',
|
|
18
|
+
version: VERSION,
|
|
19
|
+
encoding: 'json',
|
|
20
|
+
format: 'json',
|
|
21
|
+
extensions: ['json', 'geojson'] as string[],
|
|
22
|
+
mimeTypes: ['application/json'] as string[],
|
|
23
|
+
category: 'json',
|
|
24
|
+
text: true,
|
|
25
|
+
options: {}
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
/** Defers the JSONLoader parser until first use. */
|
|
29
|
+
export const JSONLoader = {
|
|
30
|
+
...JSONLoaderMetadata,
|
|
31
|
+
async preload() {
|
|
32
|
+
const implementation = await import('./json-loader.js');
|
|
33
|
+
return implementation.JSONLoader;
|
|
34
|
+
}
|
|
35
|
+
} as const;
|