@loaders.gl/core 5.0.1 → 5.0.3
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 +15 -3
- package/dist/api.cjs.map +1 -1
- package/dist/dist.dev.js +16 -5
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/lib/api/encode-table.d.ts +5 -3
- package/dist/lib/api/encode-table.d.ts.map +1 -1
- package/dist/lib/api/encode-table.js +6 -1
- package/dist/lib/api/encode-table.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +14 -3
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +30 -2
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/index.d.ts +3 -2
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +2 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader-metadata.cjs +1 -1
- package/dist/loader-utils/json-loader-metadata.js +1 -1
- package/dist/loader-utils/json-loader.cjs +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js.map +1 -1
- package/dist/loader-utils/lib/sources/raster-source.d.ts +17 -1
- package/dist/loader-utils/lib/sources/raster-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/raster-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/raster-tile.d.ts +7 -0
- package/dist/loader-utils/lib/sources/raster-tile.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/raster-tile.js +34 -0
- package/dist/loader-utils/lib/sources/raster-tile.js.map +1 -0
- package/dist/null-loader-metadata.cjs +1 -1
- package/dist/null-loader-metadata.js +1 -1
- package/dist/null-loader.cjs +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs.map +2 -2
- package/dist/scan/arrow-query-worker.cjs.map +2 -2
- package/dist/scan/arrow-query.cjs +5 -0
- package/dist/scan/arrow-query.cjs.map +2 -2
- package/dist/scan/arrow-query.d.ts +2 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/arrow-query.js +2 -1
- package/dist/scan/arrow-query.js.map +1 -1
- package/dist/scan/index.cjs +0 -18
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -5
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +0 -4
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/query-grouped-sql.cjs +1 -1
- package/dist/scan/query-grouped-sql.cjs.map +2 -2
- package/dist/scan/query-grouped-sql.d.ts.map +1 -1
- package/dist/scan/query-grouped-sql.js +1 -0
- package/dist/scan/query-grouped-sql.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs.map +2 -2
- package/dist/schema-utils/index.cjs +22 -13
- package/dist/schema-utils/index.cjs.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +15 -3
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/package.json +7 -7
- package/src/lib/api/encode-table.ts +11 -5
- package/src/lib/loader-utils/native-arrow.ts +16 -4
- package/src/loader-utils/index.ts +3 -0
- package/src/loader-utils/lib/scan-utils/columnar-predicate.ts +1 -0
- package/src/loader-utils/lib/sources/raster-source.ts +18 -1
- package/src/loader-utils/lib/sources/raster-tile.ts +46 -0
- package/src/scan/arrow-query.ts +3 -1
- package/src/scan/index.ts +2 -11
- package/src/scan/query-grouped-sql.ts +1 -0
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +16 -10
|
@@ -332,6 +332,7 @@ export {DataSourceManager} from './lib/sources/data-source-manager';
|
|
|
332
332
|
export {
|
|
333
333
|
bindColumnarPredicateParameters,
|
|
334
334
|
copyColumnarPredicate,
|
|
335
|
+
compileColumnarPredicate,
|
|
335
336
|
filterColumnarRowIndices,
|
|
336
337
|
gatherColumnarColumns,
|
|
337
338
|
getColumnarPredicateColumns,
|
|
@@ -472,6 +473,7 @@ export type {TileSourceMetadata, GetTileParameters} from './lib/sources/tile-sou
|
|
|
472
473
|
export type {GetTileDataBatchResult, GetTileDataParameters} from './lib/sources/tile-source';
|
|
473
474
|
export {getTileDataBatch} from './lib/sources/tile-source-utils';
|
|
474
475
|
export {TileSourceAdapter} from './lib/sources/tile-source-adapter';
|
|
476
|
+
export {readRasterTile} from './lib/sources/raster-tile';
|
|
475
477
|
|
|
476
478
|
export type {ImageTileSource} from './lib/sources/image-tile-source';
|
|
477
479
|
|
|
@@ -487,6 +489,7 @@ export type {
|
|
|
487
489
|
RasterData,
|
|
488
490
|
RasterSelection,
|
|
489
491
|
GetRasterParameters,
|
|
492
|
+
GetRasterTileParameters,
|
|
490
493
|
RasterOverview,
|
|
491
494
|
RasterSourceMetadata
|
|
492
495
|
} from './lib/sources/raster-source';
|
|
@@ -126,6 +126,16 @@ export type GetRasterParameters = {
|
|
|
126
126
|
signal?: AbortSignal;
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
+
/** Experimental request for one tile of the source's native raster grid. */
|
|
130
|
+
export type GetRasterTileParameters = Omit<GetRasterParameters, 'viewport' | 'resampleMethod'> & {
|
|
131
|
+
/** Identifier of a matrix in the source's tile grid. */
|
|
132
|
+
tileMatrix: string;
|
|
133
|
+
/** Native tile column. */
|
|
134
|
+
x: number;
|
|
135
|
+
/** Native tile row. */
|
|
136
|
+
y: number;
|
|
137
|
+
};
|
|
138
|
+
|
|
129
139
|
/**
|
|
130
140
|
* Description of one available overview level.
|
|
131
141
|
*/
|
|
@@ -176,8 +186,13 @@ export type RasterSourceMetadata = {
|
|
|
176
186
|
supportsRegion?: boolean;
|
|
177
187
|
/** Native tile dimensions when the source is tiled. */
|
|
178
188
|
tileSize?: {width: number; height: number};
|
|
179
|
-
/** Native tiled overview geometry
|
|
189
|
+
/** Native tiled overview geometry with source-assigned matrix IDs. Edge tiles may extend beyond raster bounds. */
|
|
180
190
|
tileGrid?: TileGrid;
|
|
191
|
+
/**
|
|
192
|
+
* IDs in `tileGrid` that the source can read with the default bands (experimental).
|
|
193
|
+
* The source checks whether the requested matrix supports an explicit band selection.
|
|
194
|
+
*/
|
|
195
|
+
nativeTileMatrixIds?: string[];
|
|
181
196
|
/** Available overview levels. */
|
|
182
197
|
overviews?: RasterOverview[];
|
|
183
198
|
/** Source no-data value when defined. */
|
|
@@ -206,6 +221,8 @@ export interface RasterSource<
|
|
|
206
221
|
}): Promise<MetadataT>;
|
|
207
222
|
/** Loads raster samples for the supplied viewport request. */
|
|
208
223
|
getRaster(parameters: ParametersT): Promise<DataT>;
|
|
224
|
+
/** Experimental. Reads one native tile without resampling, or null for an unavailable tile. */
|
|
225
|
+
getRasterTile?(parameters: GetRasterTileParameters): Promise<NumericRasterData | null>;
|
|
209
226
|
}
|
|
210
227
|
|
|
211
228
|
/**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {GetRasterTileParameters, NumericRasterData, RasterSource} from './raster-source';
|
|
6
|
+
import {resolveTileGridTile} from './tile-grid';
|
|
7
|
+
import {waitForPromiseWithSignal} from '../request-utils/abort-utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reads one native tile without resampling (experimental).
|
|
11
|
+
* Uses the advertised matrix IDs for default bands and lets the source validate explicit bands.
|
|
12
|
+
*/
|
|
13
|
+
export async function readRasterTile(
|
|
14
|
+
source: RasterSource<NumericRasterData>,
|
|
15
|
+
parameters: GetRasterTileParameters
|
|
16
|
+
): Promise<NumericRasterData | null> {
|
|
17
|
+
const {tileMatrix, bands, signal} = parameters;
|
|
18
|
+
signal?.throwIfAborted();
|
|
19
|
+
const {tileGrid, nativeTileMatrixIds} = await waitForPromiseWithSignal(
|
|
20
|
+
source.getMetadata({signal}),
|
|
21
|
+
signal
|
|
22
|
+
);
|
|
23
|
+
signal?.throwIfAborted();
|
|
24
|
+
const matrixSet = tileGrid?.tileMatrixSet;
|
|
25
|
+
if (!matrixSet?.crs || !matrixSet.matrices.length)
|
|
26
|
+
throw new Error('readRasterTile requires a complete native tile matrix set');
|
|
27
|
+
|
|
28
|
+
const resolved = resolveTileGridTile(tileGrid, {...parameters, z: 0});
|
|
29
|
+
const matrix = matrixSet.matrices.find(candidate => candidate.id === tileMatrix)!;
|
|
30
|
+
if (bands === undefined && nativeTileMatrixIds && !nativeTileMatrixIds.includes(tileMatrix))
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Tile matrix "${tileMatrix}" does not support native tile reads. Readable matrix IDs: ${JSON.stringify(nativeTileMatrixIds)}`
|
|
33
|
+
);
|
|
34
|
+
if (!resolved) return null;
|
|
35
|
+
if (!source.getRasterTile) throw new Error('Raster source does not support native tile reads');
|
|
36
|
+
|
|
37
|
+
const raster = await waitForPromiseWithSignal(
|
|
38
|
+
source.getRasterTile({...parameters, x: resolved.x}),
|
|
39
|
+
signal
|
|
40
|
+
);
|
|
41
|
+
signal?.throwIfAborted();
|
|
42
|
+
if (!raster) return null;
|
|
43
|
+
if (raster.width !== matrix.tileSize[0] || raster.height !== matrix.tileSize[1])
|
|
44
|
+
throw new Error(`Raster tile dimensions do not match matrix "${tileMatrix}"`);
|
|
45
|
+
return raster;
|
|
46
|
+
}
|
package/src/scan/arrow-query.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
export {ARROW_TABLE_QUERY_CAPABILITIES} from './plan-arrow-table-query';
|
|
5
|
+
export {ARROW_TABLE_QUERY_CAPABILITIES, explainArrowTableQuery} from './plan-arrow-table-query';
|
|
6
6
|
export {queryArrowTable} from './query-arrow-table';
|
|
7
7
|
export {queryArrowTableInBatches} from './query-arrow-table-in-batches';
|
|
8
|
+
export {queryArrowSQL, type ArrowSQLQueryOptions} from '@math.gl/sql/query';
|
|
9
|
+
|
|
8
10
|
export {getSQLPredicateColumnNames, planTableQuery} from './table-query';
|
|
9
11
|
|
|
10
12
|
export type {
|
package/src/scan/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type {
|
|
|
24
24
|
// Re-export the query vocabulary from one optional entry point for applications. Format adapters
|
|
25
25
|
// should continue importing the lightweight contracts from @loaders.gl/core/loader-utils.
|
|
26
26
|
export {parseSQLPredicate} from './parse-sql-predicate';
|
|
27
|
+
export type {ArrowFilterOptions} from './arrow-execution';
|
|
27
28
|
export type {ArrowQueryOptions} from './query-arrow-table';
|
|
28
29
|
export type {SQLPredicate} from './sql-predicate-types';
|
|
29
30
|
export type {
|
|
@@ -102,8 +103,6 @@ export type {
|
|
|
102
103
|
VectorTileTableScanSourceOptions
|
|
103
104
|
} from './vector-table-scan-source';
|
|
104
105
|
|
|
105
|
-
export {ARROW_TABLE_QUERY_CAPABILITIES, explainArrowTableQuery} from './plan-arrow-table-query';
|
|
106
|
-
export {queryArrowTable} from './query-arrow-table';
|
|
107
106
|
export {bindSQLPredicate} from './bind-sql-predicate';
|
|
108
107
|
export {
|
|
109
108
|
isSQLPredicate,
|
|
@@ -146,9 +145,6 @@ export type {
|
|
|
146
145
|
LogicalTableQueryPlan
|
|
147
146
|
} from '../loader-utils/lib/scan-utils/logical-table-query';
|
|
148
147
|
|
|
149
|
-
export {projectArrowTable, filterArrowTable} from './arrow-execution';
|
|
150
|
-
export type {ArrowFilterOptions} from './arrow-execution';
|
|
151
|
-
|
|
152
148
|
export {queryGroupedSQL} from './query-grouped-sql';
|
|
153
149
|
export {preloadQuery, query, queryInBatches, queryProgressive} from './query';
|
|
154
150
|
export type {
|
|
@@ -180,9 +176,4 @@ export type {
|
|
|
180
176
|
QueryPushdownCapabilityHints
|
|
181
177
|
} from '@loaders.gl/core/loader-utils';
|
|
182
178
|
|
|
183
|
-
export {
|
|
184
|
-
createArrowQueryWorker,
|
|
185
|
-
queryArrowTableInWorker,
|
|
186
|
-
type ArrowQueryWorkerOptions,
|
|
187
|
-
type ArrowQueryWorkerSession
|
|
188
|
-
} from './arrow-query-worker';
|
|
179
|
+
export type {ArrowQueryWorkerOptions, ArrowQueryWorkerSession} from './arrow-query-worker';
|
|
@@ -16,6 +16,7 @@ export async function queryGroupedSQL(sql: string, options: QueryOptions): Promi
|
|
|
16
16
|
key?.type !== 'Identifier' ||
|
|
17
17
|
statement.joins.length ||
|
|
18
18
|
statement.from.alias ||
|
|
19
|
+
statement.having ||
|
|
19
20
|
statement.orderBy?.length ||
|
|
20
21
|
statement.limit !== undefined ||
|
|
21
22
|
statement.offset !== undefined
|
|
@@ -7,13 +7,22 @@ import {mergeArrowSchemas, snapshotArrowSchema} from '@math.gl/core/arrow';
|
|
|
7
7
|
|
|
8
8
|
export {mergeArrowSchemas, snapshotArrowSchema};
|
|
9
9
|
|
|
10
|
+
/** Creates a native batch with a metadata map on Arrow releases that lack one. */
|
|
11
|
+
function makeArrowBatch(schema: arrow.Schema, data?: arrow.RecordBatch['data']): arrow.RecordBatch {
|
|
12
|
+
const batch = new arrow.RecordBatch(schema, data);
|
|
13
|
+
// Older supported Arrow versions reject the metadata constructor argument.
|
|
14
|
+
if (!batch.metadata) {
|
|
15
|
+
Object.defineProperty(batch, 'metadata', {value: new Map<string, string>()});
|
|
16
|
+
}
|
|
17
|
+
return batch;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
/** Snapshots a batch's schema and metadata while retaining its data buffers and row count. */
|
|
11
21
|
function snapshotArrowBatch(batch: arrow.RecordBatch, schema: arrow.Schema): arrow.RecordBatch {
|
|
12
|
-
const snapshot =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
22
|
+
const snapshot = makeArrowBatch(snapshotArrowSchema(schema), batch.data);
|
|
23
|
+
for (const [key, value] of batch.metadata ?? []) {
|
|
24
|
+
snapshot.metadata.set(key, value);
|
|
25
|
+
}
|
|
17
26
|
// Arrow reconstructs the Struct length from its columns, which are absent in zero-column batches.
|
|
18
27
|
if (snapshot.numRows !== batch.numRows) {
|
|
19
28
|
Object.defineProperty(snapshot, 'data', {value: batch.data});
|
|
@@ -26,10 +35,7 @@ export function updateArrowTableSchema(table: arrow.Table, schema: arrow.Schema)
|
|
|
26
35
|
const snapshot = snapshotArrowSchema(schema);
|
|
27
36
|
const batches = table.batches.map(batch => snapshotArrowBatch(batch, snapshot));
|
|
28
37
|
// Preserve declared schemas even for schema-only empty tables.
|
|
29
|
-
return new arrow.Table(
|
|
30
|
-
snapshot,
|
|
31
|
-
batches.length ? batches : [new arrow.RecordBatch(snapshotArrowSchema(snapshot), undefined)]
|
|
32
|
-
);
|
|
38
|
+
return new arrow.Table(snapshot, batches.length ? batches : [makeArrowMetadataBatch(snapshot)]);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
/** Updates native Arrow metadata while preserving independent batch snapshots. */
|
|
@@ -46,7 +52,7 @@ export function updateNativeArrowTableMetadata(
|
|
|
46
52
|
|
|
47
53
|
/** Creates a zero-row metadata update retaining the complete declared schema. */
|
|
48
54
|
export function makeArrowMetadataBatch(schema: arrow.Schema): arrow.RecordBatch {
|
|
49
|
-
return
|
|
55
|
+
return makeArrowBatch(snapshotArrowSchema(schema));
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
/** Collects Arrow batches, retaining emission snapshots and merging final schema metadata. */
|