@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Core loading and writing APIs, workers, schemas, and geometry utilities for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"import": "./dist/index.js",
|
|
40
40
|
"require": "./dist/index.cjs"
|
|
41
41
|
},
|
|
42
|
+
"./api": {
|
|
43
|
+
"types": "./dist/api.d.ts",
|
|
44
|
+
"import": "./dist/api.js",
|
|
45
|
+
"require": "./dist/api.cjs"
|
|
46
|
+
},
|
|
42
47
|
"./loader-utils/tile-grid": {
|
|
43
48
|
"types": "./dist/loader-utils/tile-grid.d.ts",
|
|
44
49
|
"import": "./dist/loader-utils/tile-grid.js",
|
|
@@ -160,9 +165,9 @@
|
|
|
160
165
|
"require": "./dist/geoarrow/clustering/cluster-index.cjs"
|
|
161
166
|
},
|
|
162
167
|
"./cluster-source": {
|
|
163
|
-
"types": "./dist/cluster-source.d.ts",
|
|
164
|
-
"import": "./dist/cluster-source.js",
|
|
165
|
-
"require": "./dist/cluster-source.cjs"
|
|
168
|
+
"types": "./dist/geoarrow/clustering/cluster-source.d.ts",
|
|
169
|
+
"import": "./dist/geoarrow/clustering/cluster-source.js",
|
|
170
|
+
"require": "./dist/geoarrow/clustering/cluster-source.cjs"
|
|
166
171
|
},
|
|
167
172
|
"./geoarrow/get-representative-point": {
|
|
168
173
|
"types": "./dist/geoarrow/clustering/get-representative-point.d.ts",
|
|
@@ -220,9 +225,9 @@
|
|
|
220
225
|
"require": "./dist/geoarrow/geoarrow-converter/geoarrow-geometry-converter.cjs"
|
|
221
226
|
},
|
|
222
227
|
"./geoarrow/geoarrow-builder": {
|
|
223
|
-
"types": "./dist/
|
|
224
|
-
"import": "./dist/
|
|
225
|
-
"require": "./dist/
|
|
228
|
+
"types": "./dist/arrow-geometry/geoarrow-builder.d.ts",
|
|
229
|
+
"import": "./dist/arrow-geometry/geoarrow-builder.js",
|
|
230
|
+
"require": "./dist/arrow-geometry/geoarrow-builder.cjs"
|
|
226
231
|
},
|
|
227
232
|
"./query": {
|
|
228
233
|
"types": "./dist/scan/index.d.ts",
|
|
@@ -315,14 +320,14 @@
|
|
|
315
320
|
"require": "./dist/scan/scan-query.cjs"
|
|
316
321
|
},
|
|
317
322
|
"./federated-table-scan-source": {
|
|
318
|
-
"types": "./dist/federated-table-scan-source.d.ts",
|
|
319
|
-
"import": "./dist/federated-table-scan-source.js",
|
|
320
|
-
"require": "./dist/federated-table-scan-source.cjs"
|
|
323
|
+
"types": "./dist/scan/federated-table-scan-source.d.ts",
|
|
324
|
+
"import": "./dist/scan/federated-table-scan-source.js",
|
|
325
|
+
"require": "./dist/scan/federated-table-scan-source.cjs"
|
|
321
326
|
},
|
|
322
327
|
"./vector-table-scan-source": {
|
|
323
|
-
"types": "./dist/vector-table-scan-source.d.ts",
|
|
324
|
-
"import": "./dist/vector-table-scan-source.js",
|
|
325
|
-
"require": "./dist/vector-table-scan-source.cjs"
|
|
328
|
+
"types": "./dist/scan/vector-table-scan-source.d.ts",
|
|
329
|
+
"import": "./dist/scan/vector-table-scan-source.js",
|
|
330
|
+
"require": "./dist/scan/vector-table-scan-source.cjs"
|
|
326
331
|
},
|
|
327
332
|
"./wkt": {
|
|
328
333
|
"types": "./dist/wkt/index.d.ts",
|
|
@@ -348,6 +353,26 @@
|
|
|
348
353
|
"types": "./dist/scan/arrow-execution.d.ts",
|
|
349
354
|
"import": "./dist/scan/arrow-execution.js",
|
|
350
355
|
"require": "./dist/scan/arrow-execution.cjs"
|
|
356
|
+
},
|
|
357
|
+
"./null": {
|
|
358
|
+
"types": "./dist/null-loader-metadata.d.ts",
|
|
359
|
+
"import": "./dist/null-loader-metadata.js",
|
|
360
|
+
"require": "./dist/null-loader-metadata.cjs"
|
|
361
|
+
},
|
|
362
|
+
"./null/bundled": {
|
|
363
|
+
"types": "./dist/null-loader.d.ts",
|
|
364
|
+
"import": "./dist/null-loader.js",
|
|
365
|
+
"require": "./dist/null-loader.cjs"
|
|
366
|
+
},
|
|
367
|
+
"./json": {
|
|
368
|
+
"types": "./dist/loader-utils/json-loader-metadata.d.ts",
|
|
369
|
+
"import": "./dist/loader-utils/json-loader-metadata.js",
|
|
370
|
+
"require": "./dist/loader-utils/json-loader-metadata.cjs"
|
|
371
|
+
},
|
|
372
|
+
"./json/bundled": {
|
|
373
|
+
"types": "./dist/loader-utils/json-loader.d.ts",
|
|
374
|
+
"import": "./dist/loader-utils/json-loader.js",
|
|
375
|
+
"require": "./dist/loader-utils/json-loader.cjs"
|
|
351
376
|
}
|
|
352
377
|
},
|
|
353
378
|
"sideEffects": [
|
|
@@ -390,9 +415,9 @@
|
|
|
390
415
|
"third-party-licenses"
|
|
391
416
|
],
|
|
392
417
|
"scripts": {
|
|
393
|
-
"pre-build": "npm run build-bundle && npm run build-bundle-dev && npm run build-worker && npm run build-worker-node && npm run build-worker-utils-worker && npm run build-worker-utils-worker-node && npm run build-polyfills-node-entrypoint && npm run build-schema-subpaths && npm run generate-json-schema && npm run build-utility-subpaths && npm run build-constants",
|
|
394
|
-
"build-bundle": "
|
|
395
|
-
"build-bundle-dev": "
|
|
418
|
+
"pre-build": "npm run build-bundle && npm run build-bundle-dev && npm run build-worker && npm run build-worker-node && npm run build-worker-utils-worker && npm run build-worker-utils-worker-node && npm run build-polyfills-node-entrypoint && npm run build-schema-subpaths && npm run generate-json-schema && npm run build-utility-subpaths && npm run build-constants && npm run build-compatibility-entry",
|
|
419
|
+
"build-bundle": "node ../../scripts/build-codec-bundle.mjs ./bundle.ts --output=dist/dist.min.js",
|
|
420
|
+
"build-bundle-dev": "node ../../scripts/build-codec-bundle.mjs ./bundle.ts --env=dev --output=dist/dist.dev.js",
|
|
396
421
|
"build-worker": "esbuild src/workers/null-worker.ts --outfile=dist/null-worker.js --bundle --target=esnext --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
397
422
|
"build-worker-node": "esbuild src/workers/null-worker.ts --outfile=dist/null-worker-node.js --bundle --platform=node --target=node16 --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
398
423
|
"build-worker-utils-worker": "esbuild src/worker-utils/workers/null-worker.ts --outfile=dist/worker-utils/null-worker.js --target=esnext --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
@@ -401,20 +426,21 @@
|
|
|
401
426
|
"build-schema-subpaths": "esbuild src/schema/index.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema/index.cjs && esbuild src/schema/geospatial-metadata-zod-schema.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema/geospatial-metadata-zod-schema.cjs && esbuild src/schema-utils/index.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema-utils/index.cjs && esbuild src/arrow-worker-transport.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/arrow-worker-transport.cjs",
|
|
402
427
|
"generate-json-schema": "node ../../scripts/generate-json-schema.mjs --schema ./dist/schema/geospatial-metadata-zod-schema.js --export GeoParquetMetadataSchema --output ./dist/schema/geoparquet.schema.json --id https://unpkg.com/@loaders.gl/core/schema/geoparquet.schema.json --title 'loaders.gl GeoParquet metadata' && node ../../scripts/generate-json-schema.mjs --schema ./dist/schema/geospatial-metadata-zod-schema.js --export GeoArrowMetadataSchema --output ./dist/schema/geoarrow-metadata.schema.json --id https://unpkg.com/@loaders.gl/core/schema/geoarrow-metadata.schema.json --title 'loaders.gl GeoArrow field metadata'",
|
|
403
428
|
"build-utility-subpaths": "node ../../scripts/build-core-utility-subpaths.mjs",
|
|
404
|
-
"build-constants": "esbuild src/constants/index.ts --bundle --platform=node --format=cjs --outfile=dist/constants/index.cjs"
|
|
429
|
+
"build-constants": "esbuild src/constants/index.ts --bundle --platform=node --format=cjs --outfile=dist/constants/index.cjs",
|
|
430
|
+
"build-compatibility-entry": "esbuild dist/index.js --bundle --packages=external --external:@loaders.gl/core/* --platform=node --format=cjs --outfile=dist/index.cjs"
|
|
405
431
|
},
|
|
406
432
|
"dependencies": {
|
|
407
|
-
"@math.gl/core": "^5.0.
|
|
408
|
-
"@math.gl/geometry": "^5.0.
|
|
409
|
-
"@math.gl/geospatial": "^5.0.
|
|
410
|
-
"@math.gl/sql": "^5.0.
|
|
411
|
-
"@math.gl/tasks": "^5.0.
|
|
433
|
+
"@math.gl/core": "^5.0.4",
|
|
434
|
+
"@math.gl/geometry": "^5.0.4",
|
|
435
|
+
"@math.gl/geospatial": "^5.0.4",
|
|
436
|
+
"@math.gl/sql": "^5.0.4",
|
|
437
|
+
"@math.gl/tasks": "^5.0.4",
|
|
412
438
|
"@types/geojson": "^7946.0.7",
|
|
413
439
|
"apache-arrow": ">= 17.0.0",
|
|
414
440
|
"probe.gl": "^5.0.0",
|
|
415
441
|
"zod": "^4.1.12"
|
|
416
442
|
},
|
|
417
|
-
"gitHead": "
|
|
443
|
+
"gitHead": "e28aef9d87913a5f04901ed503aefefb85e2e700",
|
|
418
444
|
"peerDependencies": {
|
|
419
445
|
"sharp": "^0.35.5"
|
|
420
446
|
},
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// TYPES
|
|
6
|
+
export type {
|
|
7
|
+
Loader,
|
|
8
|
+
LoaderWithParser,
|
|
9
|
+
LoaderContext,
|
|
10
|
+
CoreAPI,
|
|
11
|
+
LoaderOptions,
|
|
12
|
+
Writer,
|
|
13
|
+
WriterWithEncoder,
|
|
14
|
+
WriterOptions,
|
|
15
|
+
DataType,
|
|
16
|
+
SyncDataType,
|
|
17
|
+
BatchableDataType,
|
|
18
|
+
ReadableFile,
|
|
19
|
+
WritableFile,
|
|
20
|
+
Stat,
|
|
21
|
+
FileSystem,
|
|
22
|
+
RandomAccessFileSystem
|
|
23
|
+
} from '@loaders.gl/core/loader-utils';
|
|
24
|
+
export type {SourceLoader} from '@loaders.gl/core/loader-utils';
|
|
25
|
+
|
|
26
|
+
// FILE READING AND WRITING
|
|
27
|
+
export {fetchFile} from './lib/fetch/fetch-file';
|
|
28
|
+
export {FetchError} from './lib/fetch/fetch-error';
|
|
29
|
+
|
|
30
|
+
export {readArrayBuffer} from './lib/fetch/read-array-buffer';
|
|
31
|
+
// export {readFileSync} from './lib/fetch/read-file';
|
|
32
|
+
// export {writeFile, writeFileSync} from './lib/fetch/write-file';
|
|
33
|
+
|
|
34
|
+
// CONFIGURATION
|
|
35
|
+
export {setLoaderOptions, getLoaderOptions, compareLoaderOptions} from './lib/api/loader-options';
|
|
36
|
+
export {registerLoaders} from './lib/api/register-loaders';
|
|
37
|
+
export {selectLoader, selectLoaderSync} from './lib/api/select-loader';
|
|
38
|
+
|
|
39
|
+
// LOADING (READING + PARSING)
|
|
40
|
+
export {parse} from './lib/api/parse';
|
|
41
|
+
export {parseFile} from './lib/api/parse-file';
|
|
42
|
+
export {parseSync} from './lib/api/parse-sync';
|
|
43
|
+
export {parseInBatches} from './lib/api/parse-in-batches';
|
|
44
|
+
export {preload, preloadSync} from './lib/api/preload';
|
|
45
|
+
export {coreApi} from './lib/api/core-api';
|
|
46
|
+
|
|
47
|
+
export {load} from './lib/api/load';
|
|
48
|
+
export {loadInBatches} from './lib/api/load-in-batches';
|
|
49
|
+
|
|
50
|
+
// ENCODING (ENCODING AND WRITING)
|
|
51
|
+
export {encodeTable, encodeTableAsText, encodeTableInBatches} from './lib/api/encode-table';
|
|
52
|
+
export {encode, encodeSync, encodeInBatches, encodeURLtoURL} from './lib/api/encode';
|
|
53
|
+
export {encodeText, encodeTextSync} from './lib/api/encode';
|
|
54
|
+
|
|
55
|
+
// SERVICES AND SOURCES
|
|
56
|
+
export {createDataSource, createDataSourceSync} from './lib/api/create-data-source';
|
|
57
|
+
export {selectSource as _selectSource} from './lib/api/select-source';
|
|
58
|
+
|
|
59
|
+
// CORE UTILS SHARED WITH LOADERS (RE-EXPORTED FROM LOADER-UTILS)
|
|
60
|
+
export {setPathPrefix, getPathPrefix, resolvePath} from '@loaders.gl/core/loader-utils';
|
|
61
|
+
export {RequestScheduler} from '@loaders.gl/core/loader-utils';
|
|
62
|
+
|
|
63
|
+
// ITERATOR UTILS
|
|
64
|
+
export {makeIterator} from './iterators/make-iterator/make-iterator';
|
|
65
|
+
export {makeStream} from './iterators/make-stream/make-stream';
|
|
66
|
+
|
|
67
|
+
// EXPERIMENTAL
|
|
68
|
+
export {fetchProgress as _fetchProgress} from './lib/progress/fetch-progress';
|
|
69
|
+
export {BrowserFileSystem as _BrowserFileSystem} from './lib/filesystems/browser-filesystem';
|
|
70
|
+
|
|
71
|
+
// FOR TESTING
|
|
72
|
+
export {_unregisterLoaders} from './lib/api/register-loaders';
|
|
73
|
+
|
|
74
|
+
//
|
|
75
|
+
// TODO - MOVE TO LOADER-UTILS AND DEPRECATE IN CORE?
|
|
76
|
+
//
|
|
77
|
+
|
|
78
|
+
export {isBrowser, isWorker, self, window, global, document} from '@loaders.gl/core/loader-utils';
|
|
79
|
+
export {assert} from '@loaders.gl/core/loader-utils';
|
|
80
|
+
export {forEach, concatenateArrayBuffersAsync} from '@loaders.gl/core/loader-utils';
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
makeTextDecoderIterator,
|
|
84
|
+
makeTextEncoderIterator,
|
|
85
|
+
makeLineIterator,
|
|
86
|
+
makeNumberedLineIterator
|
|
87
|
+
} from '@loaders.gl/core/loader-utils';
|
|
88
|
+
|
|
89
|
+
// "JAVASCRIPT" UTILS - move to loader-utils?
|
|
90
|
+
export {
|
|
91
|
+
isPureObject,
|
|
92
|
+
isPromise,
|
|
93
|
+
isIterable,
|
|
94
|
+
isAsyncIterable,
|
|
95
|
+
isIterator,
|
|
96
|
+
isResponse,
|
|
97
|
+
isReadableStream,
|
|
98
|
+
isWritableStream
|
|
99
|
+
} from '@loaders.gl/core/loader-utils';
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {parseWKB, parseWKTWithMetadata, writeWKB
|
|
5
|
+
import {inspectWKTHeader, parseWKB, parseWKTWithMetadata, writeWKB} from '@math.gl/core/arrow';
|
|
6
|
+
import {ensureArrayBuffer} from '../loader-utils/lib/binary-utils/memory-conversion-utils';
|
|
6
7
|
import type {WellKnownDimension, WellKnownGeometry, WKTParseResult} from '@math.gl/core/arrow';
|
|
7
8
|
import type {Feature, Geometry, GeoArrowDimension} from '@loaders.gl/core/schema';
|
|
8
9
|
import {normalizeEmptyPoints} from './geometry-utils';
|
|
@@ -35,7 +36,7 @@ export function convertWKBToGeometry(input: ArrayBufferLike | ArrayBufferView):
|
|
|
35
36
|
const bytes = ArrayBuffer.isView(input)
|
|
36
37
|
? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
|
|
37
38
|
: new Uint8Array(input);
|
|
38
|
-
return
|
|
39
|
+
return parseWKB(bytes, {normalizeEmptyPoints: true}).geometry as Geometry;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/** Encodes legacy geometry options with math.gl; collection child markers retain their dimensions. */
|
|
@@ -52,72 +53,51 @@ export function convertGeometryToWKB(
|
|
|
52
53
|
: options.hasM
|
|
53
54
|
? 'xym'
|
|
54
55
|
: 'xy';
|
|
55
|
-
const bytes =
|
|
56
|
-
return bytes
|
|
56
|
+
const bytes = writeWKB(describeGeometry(geometry, dimension));
|
|
57
|
+
return ensureArrayBuffer(bytes);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
/**
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
headerLength + children.reduce((total, child) => total + child.length, 0)
|
|
76
|
-
);
|
|
77
|
-
const writer = new WKBBuilder({mode: 'write', target: bytes, dimension});
|
|
78
|
-
writer.beginGeometry('GeometryCollection', children.length);
|
|
79
|
-
let byteOffset = writer.finishGeometry();
|
|
80
|
-
for (const child of children) {
|
|
81
|
-
bytes.set(child, byteOffset);
|
|
82
|
-
byteOffset += child.length;
|
|
83
|
-
}
|
|
84
|
-
return bytes;
|
|
60
|
+
/** Supplies each collection member's effective dimension to the math.gl writer. */
|
|
61
|
+
function describeGeometry(geometry: Geometry, dimension: WellKnownDimension): WKTParseResult {
|
|
62
|
+
return {
|
|
63
|
+
geometry: geometry as WellKnownGeometry,
|
|
64
|
+
dimension,
|
|
65
|
+
children:
|
|
66
|
+
geometry.type === 'GeometryCollection'
|
|
67
|
+
? geometry.geometries.map(child =>
|
|
68
|
+
describeGeometry(
|
|
69
|
+
child,
|
|
70
|
+
(child as Geometry & {__geoarrowDimension?: WellKnownDimension})
|
|
71
|
+
.__geoarrowDimension ?? dimension
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
: undefined
|
|
75
|
+
};
|
|
85
76
|
}
|
|
86
77
|
|
|
87
|
-
/** Reads the declared root
|
|
78
|
+
/** Reads the declared root dimension without parsing the coordinate payload. */
|
|
88
79
|
export function getWKTDimension(input: string): GeoArrowDimension | null {
|
|
89
|
-
|
|
90
|
-
.trim()
|
|
91
|
-
.match(
|
|
92
|
-
/^(?:POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)(?:\s+(ZM|Z|M))?(?:\s|\()/i
|
|
93
|
-
);
|
|
94
|
-
if (!match) return null;
|
|
95
|
-
return match[1]?.toUpperCase() === 'Z'
|
|
96
|
-
? 'xyz'
|
|
97
|
-
: match[1]?.toUpperCase() === 'M'
|
|
98
|
-
? 'xym'
|
|
99
|
-
: match[1]?.toUpperCase() === 'ZM'
|
|
100
|
-
? 'xyzm'
|
|
101
|
-
: 'xy';
|
|
80
|
+
return inspectWKTHeader(input)?.dimension ?? null;
|
|
102
81
|
}
|
|
103
82
|
|
|
104
83
|
/** Parses WKT with loaders.gl's legacy SRID and invalid-input behavior. */
|
|
105
84
|
export function convertWKTToGeometry(input: string, options?: ParseWKTOptions): Geometry | null {
|
|
106
|
-
const
|
|
85
|
+
const dimension = getWKTDimension(input);
|
|
107
86
|
try {
|
|
108
87
|
// Preserve the legacy parser's treatment of empty parentheses as invalid input.
|
|
109
|
-
if (/\(\s*\)\s*$/s.test(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const parseText =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
88
|
+
if (/\(\s*\)\s*$/s.test(input)) return null;
|
|
89
|
+
|
|
90
|
+
const collectionHeader =
|
|
91
|
+
/^(\s*(?:SRID\s*=\s*\d+\s*;\s*)?GEOMETRYCOLLECTION)\s+(?:ZM|Z|M)(?=\s|\()/i;
|
|
92
|
+
const parseText = dimension !== 'xym' ? input.replace(collectionHeader, '$1') : input;
|
|
93
|
+
const parsed = parseWKTWithMetadata(parseText, {
|
|
94
|
+
inferDimensions: true,
|
|
95
|
+
allowMissingInheritedOrdinates: true
|
|
96
|
+
});
|
|
97
|
+
const {srid} = parsed;
|
|
118
98
|
const geometry = toGeometryWithDimensionMetadata(
|
|
119
99
|
parsed,
|
|
120
|
-
collectionHeader ? dimension : undefined
|
|
100
|
+
collectionHeader.test(input) ? (dimension ?? undefined) : undefined
|
|
121
101
|
);
|
|
122
102
|
if (options?.wkt?.crs && srid !== undefined) {
|
|
123
103
|
Object.defineProperty(geometry, 'crs', {
|
|
@@ -161,26 +141,3 @@ function addDimensionMarker(geometry: Geometry, dimension?: WellKnownDimension):
|
|
|
161
141
|
}
|
|
162
142
|
return geometry;
|
|
163
143
|
}
|
|
164
|
-
|
|
165
|
-
/** Separates an optional EWKT SRID prefix and root dimension token. */
|
|
166
|
-
function splitWKTHeader(input: string): {
|
|
167
|
-
text: string;
|
|
168
|
-
srid?: string;
|
|
169
|
-
dimension?: WellKnownDimension;
|
|
170
|
-
} {
|
|
171
|
-
const sridMatch = input.match(/^\s*SRID=(\d+)\s*;\s*/i);
|
|
172
|
-
const text = sridMatch ? input.slice(sridMatch[0].length) : input;
|
|
173
|
-
const dimensionMatch = text.match(
|
|
174
|
-
/^\s*(?:POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)(?:\s+(ZM|Z|M))?(?:\s|\()/i
|
|
175
|
-
);
|
|
176
|
-
const dimensionToken = dimensionMatch?.[1]?.toUpperCase();
|
|
177
|
-
const dimension =
|
|
178
|
-
dimensionToken === 'Z'
|
|
179
|
-
? 'xyz'
|
|
180
|
-
: dimensionToken === 'M'
|
|
181
|
-
? 'xym'
|
|
182
|
-
: dimensionToken === 'ZM'
|
|
183
|
-
? 'xyzm'
|
|
184
|
-
: undefined;
|
|
185
|
-
return {text, srid: sridMatch?.[1], dimension};
|
|
186
|
-
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
import {parseWKB} from '@math.gl/core/arrow';
|
|
7
|
+
import {triangulateWKB} from './triangulate-wkb';
|
|
8
|
+
import type {Geometry, MultiPolygon, Polygon, Position} from '@loaders.gl/core/schema';
|
|
9
|
+
|
|
10
|
+
/** Tessellated columns derived from a GeoArrow WKB geometry column. */
|
|
11
|
+
export type TriangulatedWKBGeometryColumns = {
|
|
12
|
+
/** Triangle vertex indices into the matching row of the `vertices` column. */
|
|
13
|
+
vertexIndices: arrow.Vector<arrow.List<arrow.Int32>>;
|
|
14
|
+
/** XY vertices from the source WKB geometry, preserving the WKB vertex order. */
|
|
15
|
+
vertices: arrow.Vector<arrow.List<arrow.FixedSizeList<arrow.Float64>>>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Triangulates a GeoArrow WKB geometry column into triangle index and vertex columns.
|
|
20
|
+
* @param geometryColumn GeoArrow WKB geometry column.
|
|
21
|
+
* @returns Arrow columns with per-geometry triangle vertex indices and source vertices.
|
|
22
|
+
*/
|
|
23
|
+
export function triangulateWKBGeometryColumn(
|
|
24
|
+
geometryColumn: arrow.Vector<arrow.Binary>
|
|
25
|
+
): TriangulatedWKBGeometryColumns {
|
|
26
|
+
const vertexIndices: (number[] | null)[] = [];
|
|
27
|
+
const vertices: (number[][] | null)[] = [];
|
|
28
|
+
|
|
29
|
+
for (let geometryIndex = 0; geometryIndex < geometryColumn.length; geometryIndex++) {
|
|
30
|
+
const wkb = geometryColumn.get(geometryIndex);
|
|
31
|
+
if (!wkb) {
|
|
32
|
+
vertexIndices.push(null);
|
|
33
|
+
vertices.push(null);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vertexIndices.push(triangulateWKB(wkb));
|
|
38
|
+
vertices.push(getWKBGeometryVertices(wkb));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
vertexIndices: arrow.vectorFromArray(
|
|
43
|
+
vertexIndices,
|
|
44
|
+
new arrow.List(new arrow.Field('vertex_index', new arrow.Int32(), true))
|
|
45
|
+
),
|
|
46
|
+
vertices: arrow.vectorFromArray(
|
|
47
|
+
vertices,
|
|
48
|
+
new arrow.List(
|
|
49
|
+
new arrow.Field(
|
|
50
|
+
'vertex',
|
|
51
|
+
new arrow.FixedSizeList(2, new arrow.Field('coordinate', new arrow.Float64(), false)),
|
|
52
|
+
true
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Extracts XY vertices from a WKB Polygon or MultiPolygon, preserving source vertex order.
|
|
61
|
+
* @param wkb Binary WKB input.
|
|
62
|
+
* @returns XY vertex pairs.
|
|
63
|
+
*/
|
|
64
|
+
function getWKBGeometryVertices(wkb: ArrayBufferLike | ArrayBufferView): number[][] {
|
|
65
|
+
return getGeometryVertices(parseWKB(getWKBByteArray(wkb)).geometry as Geometry);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Converts WKB input to a byte view for math.gl's WKB parser.
|
|
70
|
+
* @param wkb Binary WKB input.
|
|
71
|
+
* @returns Byte view containing only the WKB bytes.
|
|
72
|
+
*/
|
|
73
|
+
function getWKBByteArray(wkb: ArrayBufferLike | ArrayBufferView): Uint8Array {
|
|
74
|
+
return ArrayBuffer.isView(wkb)
|
|
75
|
+
? new Uint8Array(wkb.buffer, wkb.byteOffset, wkb.byteLength)
|
|
76
|
+
: new Uint8Array(wkb);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Extracts XY vertices from a GeoJSON Polygon or MultiPolygon.
|
|
81
|
+
* @param geometry GeoJSON geometry.
|
|
82
|
+
* @returns XY vertex pairs.
|
|
83
|
+
*/
|
|
84
|
+
function getGeometryVertices(geometry: Geometry): number[][] {
|
|
85
|
+
switch (geometry.type) {
|
|
86
|
+
case 'Polygon':
|
|
87
|
+
return getPolygonVertices(geometry);
|
|
88
|
+
case 'MultiPolygon':
|
|
89
|
+
return getMultiPolygonVertices(geometry);
|
|
90
|
+
default:
|
|
91
|
+
throw new Error(`WKB: Expected Polygon or MultiPolygon, found ${geometry.type}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Extracts XY vertices from a GeoJSON Polygon.
|
|
97
|
+
* @param polygon GeoJSON polygon.
|
|
98
|
+
* @returns XY vertex pairs.
|
|
99
|
+
*/
|
|
100
|
+
function getPolygonVertices(polygon: Polygon): number[][] {
|
|
101
|
+
return polygon.coordinates.flatMap(ring => ring.map(getXYVertex));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Extracts XY vertices from a GeoJSON MultiPolygon.
|
|
106
|
+
* @param multiPolygon GeoJSON multipolygon.
|
|
107
|
+
* @returns XY vertex pairs.
|
|
108
|
+
*/
|
|
109
|
+
function getMultiPolygonVertices(multiPolygon: MultiPolygon): number[][] {
|
|
110
|
+
return multiPolygon.coordinates.flatMap(polygon =>
|
|
111
|
+
polygon.flatMap(ring => ring.map(getXYVertex))
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Converts one GeoJSON position to an XY vertex.
|
|
117
|
+
* @param position GeoJSON position.
|
|
118
|
+
* @returns XY vertex pair.
|
|
119
|
+
*/
|
|
120
|
+
function getXYVertex(position: Position): number[] {
|
|
121
|
+
return [position[0], position[1]];
|
|
122
|
+
}
|