@loaders.gl/core 5.0.0-rc.1 → 5.0.0
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/SCAN-README.md +8 -8
- package/dist/arrow-geometry/binary-features.cjs +2 -2
- package/dist/arrow-geometry/binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/binary-features.js +1 -1
- package/dist/arrow-geometry/binary-features.js.map +1 -1
- 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/legacy-binary/convert-flat-geojson-to-binary-features.cjs +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js.map +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.cjs +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.js +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.js.map +1 -1
- 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/cluster-source.cjs +128 -374
- package/dist/cluster-source.cjs.map +3 -3
- 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 +63 -15
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +174 -660
- package/dist/federated-table-scan-source.cjs.map +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/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/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.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 +20 -226
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts +1 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js +23 -264
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js.map +1 -1
- package/dist/index.cjs +67 -19
- package/dist/index.cjs.map +1 -1
- package/dist/lib/api/load.js +36 -7
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse.js +5 -2
- package/dist/lib/api/parse.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 +67 -229
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/json-loader.js +1 -1
- 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/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/sources/tile-grid.d.ts +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js.map +1 -1
- package/dist/loader-utils/lib/sources/tile-source-adapter.js +1 -1
- package/dist/loader-utils/lib/sources/tile-source-adapter.js.map +1 -1
- package/dist/loader-utils/lib/sources/tile-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +6 -0
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/tile-grid.cjs +5 -5
- package/dist/loader-utils/tile-grid.cjs.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- 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 +2 -8
- 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 +9 -49
- package/dist/scan/index.cjs.map +3 -3
- package/dist/scan/index.d.ts +2 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -2
- 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 +2 -39
- 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 +3 -26
- 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-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-scales.cjs +2 -1
- package/dist/scan/query-scales.cjs.map +2 -2
- package/dist/scan/query-scales.d.ts +2 -1
- package/dist/scan/query-scales.d.ts.map +1 -1
- package/dist/scan/query-scales.js +2 -1
- package/dist/scan/query-scales.js.map +1 -1
- package/dist/scan/query.cjs +10 -9
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +14 -5
- 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 +2 -2
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js +5 -10
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/sql-predicate-schema.cjs +10 -94
- package/dist/scan/sql-predicate-schema.cjs.map +3 -3
- package/dist/scan/sql-predicate-schema.d.ts +1 -1
- package/dist/scan/sql-predicate-schema.d.ts.map +1 -1
- package/dist/scan/sql-predicate-schema.js +9 -103
- package/dist/scan/sql-predicate-schema.js.map +1 -1
- package/dist/scan/sql-predicate-zod.cjs.map +1 -1
- package/dist/scan/sql-predicate-zod.d.ts +1 -1
- package/dist/scan/sql-predicate-zod.js +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 +11 -47
- package/dist/schema-utils/index.cjs.map +1 -1
- 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/vector-table-scan-source.cjs +905 -1453
- package/dist/vector-table-scan-source.cjs.map +3 -3
- 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 +33 -9
- 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/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +4 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +40 -6
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/package.json +24 -104
- package/src/arrow-geometry/binary-features.ts +1 -1
- package/src/arrow-geometry/geometry-codecs.ts +35 -78
- package/src/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.ts +1 -1
- package/src/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.ts +1 -1
- 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/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +6 -30
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +23 -269
- package/src/lib/api/load.ts +36 -7
- package/src/lib/api/parse.ts +6 -2
- 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/tile-grid.ts +6 -2
- package/src/loader-utils/lib/sources/tile-source-adapter.ts +1 -1
- package/src/loader-utils/lib/sources/tile-source.ts +1 -1
- package/src/loader-utils/loader-types.ts +6 -0
- 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 +2 -2
- package/src/scan/plan-arrow-table-query.ts +367 -0
- package/src/scan/query-arrow-table-in-batches.ts +4 -33
- package/src/scan/query-arrow-table.ts +10 -626
- package/src/scan/query-pushdown.ts +3 -4
- package/src/scan/query-scales.ts +3 -4
- package/src/scan/query.ts +16 -10
- package/src/scan/scan-engine.ts +5 -12
- package/src/scan/sql-predicate-schema.ts +14 -125
- package/src/scan/sql-predicate-zod.ts +1 -1
- package/src/scan/vector-table-scan-source.ts +2 -1
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +2 -50
- package/src/wkt/twkb/index.ts +63 -2
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +39 -6
- 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/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/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/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,
|
|
@@ -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/lib/api/load.ts
CHANGED
|
@@ -116,6 +116,7 @@ export async function load(
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
resolvedOptions ||= getGlobalLoaderOptions();
|
|
119
|
+
let fetchedResponse: Response | undefined;
|
|
119
120
|
|
|
120
121
|
if (typeof url === 'string' || isBlob(url)) {
|
|
121
122
|
const selectedLoader = await selectLoader(url, resolvedLoaders as Loader | Loader[], {
|
|
@@ -123,31 +124,59 @@ export async function load(
|
|
|
123
124
|
core: {...resolvedOptions?.core, nothrow: true}
|
|
124
125
|
});
|
|
125
126
|
|
|
127
|
+
const canFetchBeforePreload = typeof url === 'string' && selectedLoader?.fetchBeforePreload;
|
|
126
128
|
const loaderImplementation =
|
|
127
129
|
selectedLoader && (typeof url === 'string' || selectedLoader.createDataSourceSync)
|
|
128
|
-
?
|
|
130
|
+
? getLoaderImplementation(
|
|
129
131
|
selectedLoader,
|
|
130
132
|
resolvedOptions,
|
|
131
133
|
typeof url === 'string' ? url : undefined
|
|
132
134
|
)
|
|
133
135
|
: null;
|
|
136
|
+
if (canFetchBeforePreload) {
|
|
137
|
+
const loadOptions = resolvedOptions;
|
|
138
|
+
const controller = new AbortController();
|
|
139
|
+
const fetchOption = loadOptions.core?.fetch;
|
|
140
|
+
const callerSignal =
|
|
141
|
+
loadOptions.signal ||
|
|
142
|
+
context?.signal ||
|
|
143
|
+
(typeof fetchOption === 'object' ? fetchOption?.signal : undefined);
|
|
144
|
+
const signal = callerSignal
|
|
145
|
+
? AbortSignal.any([callerSignal, controller.signal])
|
|
146
|
+
: controller.signal;
|
|
147
|
+
try {
|
|
148
|
+
[, fetchedResponse] = await Promise.all([
|
|
149
|
+
loaderImplementation,
|
|
150
|
+
resolveLoaderAuthenticationOptions(selectedLoader, url, loadOptions).then(options => {
|
|
151
|
+
signal.throwIfAborted();
|
|
152
|
+
resolvedOptions = resolveAuthenticationOptions(options);
|
|
153
|
+
const fetch = getFetchFunction({...resolvedOptions, signal}, context);
|
|
154
|
+
return fetch(applySearchParamsToUrl(url, resolvedOptions));
|
|
155
|
+
})
|
|
156
|
+
]);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
controller.abort(error);
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const implementation = await loaderImplementation;
|
|
134
163
|
if (
|
|
135
164
|
selectedLoader &&
|
|
136
|
-
|
|
137
|
-
!isLoaderWithParser(
|
|
165
|
+
implementation?.createDataSourceSync &&
|
|
166
|
+
!isLoaderWithParser(implementation)
|
|
138
167
|
) {
|
|
139
168
|
throw new Error(
|
|
140
169
|
`${selectedLoader.id} creates sources. Use createDataSource() instead of load().`
|
|
141
170
|
);
|
|
142
171
|
}
|
|
143
172
|
|
|
144
|
-
if (selectedLoader &&
|
|
173
|
+
if (!fetchedResponse && selectedLoader && implementation && typeof url === 'string') {
|
|
145
174
|
resolvedOptions = await resolveLoaderAuthenticationOptions(
|
|
146
|
-
selectedLoader.getAuthentications ? selectedLoader :
|
|
175
|
+
selectedLoader.getAuthentications ? selectedLoader : implementation,
|
|
147
176
|
url,
|
|
148
177
|
resolvedOptions || {}
|
|
149
178
|
);
|
|
150
|
-
const {parseUrl} =
|
|
179
|
+
const {parseUrl} = implementation;
|
|
151
180
|
if (parseUrl) {
|
|
152
181
|
const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
|
|
153
182
|
const options = normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url);
|
|
@@ -164,7 +193,7 @@ export async function load(
|
|
|
164
193
|
let data = url;
|
|
165
194
|
// url is a string, fetch the url
|
|
166
195
|
if (typeof url === 'string') {
|
|
167
|
-
data = await fetch(applySearchParamsToUrl(url, resolvedOptions));
|
|
196
|
+
data = fetchedResponse ?? (await fetch(applySearchParamsToUrl(url, resolvedOptions)));
|
|
168
197
|
// URL is Blob or File, fetchFile handles it (alt: we could generate ObjectURL here)
|
|
169
198
|
}
|
|
170
199
|
|
package/src/lib/api/parse.ts
CHANGED
|
@@ -185,8 +185,12 @@ async function parseWithLoader(
|
|
|
185
185
|
let result: unknown;
|
|
186
186
|
|
|
187
187
|
if (shouldParseWithWorker(loaderWithParser, data, parseOptions, context, loader)) {
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
// Start the worker while the response body downloads. Transfer only the complete buffer.
|
|
189
|
+
const input =
|
|
190
|
+
isResponse(data) && data.ok
|
|
191
|
+
? getArrayBufferFromData(data, parseOptions)
|
|
192
|
+
: await getArrayBufferFromData(data, parseOptions);
|
|
193
|
+
result = await parseWithWorker(loaderWithParser, input, parseOptions, context, parse);
|
|
190
194
|
} else if (isBlob(data) && loaderWithParser.parseBlob) {
|
|
191
195
|
result = await loaderWithParser.parseBlob(data, parseOptions, context);
|
|
192
196
|
} else {
|