@carto/api-client 0.4.5 → 0.5.0-alpha.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/build/api-client.cjs +2168 -206
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +2072 -237
- package/build/api-client.modern.js.map +1 -1
- package/build/constants.d.ts +22 -0
- package/build/filters/Filter.d.ts +13 -0
- package/build/filters/FilterTypes.d.ts +3 -0
- package/build/filters/geosjonFeatures.d.ts +8 -0
- package/build/filters/index.d.ts +6 -0
- package/build/filters/tileFeatures.d.ts +20 -0
- package/build/filters/tileFeaturesGeometries.d.ts +13 -0
- package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
- package/build/index.d.ts +4 -0
- package/build/models/index.d.ts +1 -1
- package/build/operations/aggregation.d.ts +8 -0
- package/build/operations/applySorting.d.ts +20 -0
- package/build/operations/groupBy.d.ts +15 -0
- package/build/operations/groupByDate.d.ts +11 -0
- package/build/operations/histogram.d.ts +13 -0
- package/build/operations/index.d.ts +6 -0
- package/build/operations/scatterPlot.d.ts +14 -0
- package/build/sources/h3-tileset-source.d.ts +2 -1
- package/build/sources/index.d.ts +1 -1
- package/build/sources/quadbin-tileset-source.d.ts +2 -1
- package/build/sources/vector-tileset-source.d.ts +2 -1
- package/build/types-internal.d.ts +4 -0
- package/build/types.d.ts +61 -1
- package/build/utils/dateUtils.d.ts +10 -0
- package/build/utils/getTileFormat.d.ts +3 -0
- package/build/utils/makeIntervalComplete.d.ts +2 -0
- package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
- package/build/utils/transformToTileCoords.d.ts +9 -0
- package/build/widget-sources/index.d.ts +2 -1
- package/build/widget-sources/types.d.ts +31 -22
- package/build/widget-sources/widget-query-source.d.ts +2 -2
- package/build/widget-sources/widget-remote-source.d.ts +18 -0
- package/build/widget-sources/{widget-base-source.d.ts → widget-source.d.ts} +13 -38
- package/build/widget-sources/widget-table-source.d.ts +2 -2
- package/build/widget-sources/widget-tileset-source.d.ts +76 -0
- package/package.json +10 -3
- package/src/constants.ts +25 -0
- package/src/filters/Filter.ts +169 -0
- package/src/filters/FilterTypes.ts +109 -0
- package/src/filters/geosjonFeatures.ts +32 -0
- package/src/filters/index.ts +6 -0
- package/src/filters/tileFeatures.ts +56 -0
- package/src/filters/tileFeaturesGeometries.ts +444 -0
- package/src/filters/tileFeaturesSpatialIndex.ts +119 -0
- package/src/index.ts +6 -0
- package/src/models/index.ts +1 -1
- package/src/operations/aggregation.ts +154 -0
- package/src/operations/applySorting.ts +109 -0
- package/src/operations/groupBy.ts +59 -0
- package/src/operations/groupByDate.ts +98 -0
- package/src/operations/histogram.ts +66 -0
- package/src/operations/index.ts +6 -0
- package/src/operations/scatterPlot.ts +50 -0
- package/src/sources/h3-tileset-source.ts +18 -6
- package/src/sources/index.ts +1 -1
- package/src/sources/quadbin-tileset-source.ts +18 -6
- package/src/sources/raster-source.ts +1 -0
- package/src/sources/vector-query-source.ts +5 -2
- package/src/sources/vector-table-source.ts +5 -2
- package/src/sources/vector-tileset-source.ts +19 -6
- package/src/types-internal.ts +6 -0
- package/src/types.ts +60 -2
- package/src/utils/dateUtils.ts +28 -0
- package/src/utils/getTileFormat.ts +9 -0
- package/src/utils/makeIntervalComplete.ts +17 -0
- package/src/utils/transformTileCoordsToWGS84.ts +77 -0
- package/src/utils/transformToTileCoords.ts +85 -0
- package/src/widget-sources/index.ts +2 -1
- package/src/widget-sources/types.ts +32 -22
- package/src/widget-sources/widget-query-source.ts +6 -3
- package/src/widget-sources/{widget-base-source.ts → widget-remote-source.ts} +12 -147
- package/src/widget-sources/widget-source.ts +160 -0
- package/src/widget-sources/widget-table-source.ts +6 -3
- package/src/widget-sources/widget-tileset-source.ts +407 -0
package/build/constants.d.ts
CHANGED
|
@@ -29,3 +29,25 @@ export declare enum ApiVersion {
|
|
|
29
29
|
}
|
|
30
30
|
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
31
31
|
export declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
32
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
33
|
+
export declare enum TileFormat {
|
|
34
|
+
MVT = "mvt",
|
|
35
|
+
JSON = "json",
|
|
36
|
+
GEOJSON = "geojson",
|
|
37
|
+
BINARY = "binary"
|
|
38
|
+
}
|
|
39
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
40
|
+
export declare enum SpatialIndex {
|
|
41
|
+
H3 = "h3",
|
|
42
|
+
S2 = "s2",
|
|
43
|
+
QUADBIN = "quadbin"
|
|
44
|
+
}
|
|
45
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
46
|
+
export declare enum Provider {
|
|
47
|
+
BIGQUERY = "bigquery",
|
|
48
|
+
REDSHIFT = "redshift",
|
|
49
|
+
POSTGRES = "postgres",
|
|
50
|
+
SNOWFLAKE = "snowflake",
|
|
51
|
+
DATABRICKS = "databricks",
|
|
52
|
+
DATABRICKS_REST = "databricksRest"
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FilterLogicalOperator, Filters } from '../types';
|
|
2
|
+
import { Feature } from 'geojson';
|
|
3
|
+
import { FeatureData } from '../types-internal';
|
|
4
|
+
import { BinaryFeature } from '@loaders.gl/schema';
|
|
5
|
+
export declare function buildFeatureFilter({ filters, type, filtersLogicalOperator, }: {
|
|
6
|
+
filters?: Filters;
|
|
7
|
+
type?: 'number' | 'boolean';
|
|
8
|
+
filtersLogicalOperator?: FilterLogicalOperator;
|
|
9
|
+
}): (feature: Feature | FeatureData) => number | boolean;
|
|
10
|
+
export declare function applyFilters(features: FeatureData[], filters: Filters, filtersLogicalOperator: FilterLogicalOperator): FeatureData[];
|
|
11
|
+
export declare function buildBinaryFeatureFilter({ filters }: {
|
|
12
|
+
filters: Filters;
|
|
13
|
+
}): (() => number) | ((featureIdIdx: number, binaryData: BinaryFeature) => boolean);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FeatureCollection } from 'geojson';
|
|
2
|
+
import { SpatialFilter } from '..';
|
|
3
|
+
import { FeatureData } from '../types-internal';
|
|
4
|
+
export declare function geojsonFeatures({ geojson, spatialFilter, uniqueIdProperty, }: {
|
|
5
|
+
geojson: FeatureCollection;
|
|
6
|
+
spatialFilter: SpatialFilter;
|
|
7
|
+
uniqueIdProperty?: string;
|
|
8
|
+
}): FeatureData[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SpatialFilter, Tile } from '../types';
|
|
2
|
+
import { TileFormat } from '../constants';
|
|
3
|
+
import { FeatureData } from '../types-internal';
|
|
4
|
+
import { SpatialDataType } from '../sources/types';
|
|
5
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
6
|
+
export type TileFeatures = {
|
|
7
|
+
tiles: Tile[];
|
|
8
|
+
tileFormat: TileFormat;
|
|
9
|
+
spatialDataType: SpatialDataType;
|
|
10
|
+
spatialDataColumn?: string;
|
|
11
|
+
spatialFilter?: SpatialFilter;
|
|
12
|
+
uniqueIdProperty?: string;
|
|
13
|
+
options?: TileFeatureExtractOptions;
|
|
14
|
+
};
|
|
15
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
16
|
+
export type TileFeatureExtractOptions = {
|
|
17
|
+
storeGeometry?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
20
|
+
export declare function tileFeatures({ tiles, spatialFilter, uniqueIdProperty, tileFormat, spatialDataColumn, spatialDataType, options, }: TileFeatures): FeatureData[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TileFormat } from '../constants.js';
|
|
2
|
+
import { SpatialFilter, Tile } from '../types.js';
|
|
3
|
+
import { FeatureData } from '../types-internal.js';
|
|
4
|
+
export declare const FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
5
|
+
export declare function tileFeaturesGeometries({ tiles, tileFormat, spatialFilter, uniqueIdProperty, options, }: {
|
|
6
|
+
tiles: Tile[];
|
|
7
|
+
tileFormat?: TileFormat;
|
|
8
|
+
spatialFilter: SpatialFilter;
|
|
9
|
+
uniqueIdProperty?: string;
|
|
10
|
+
options?: {
|
|
11
|
+
storeGeometry?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}): FeatureData[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SpatialFilter, SpatialIndexTile } from '../types.js';
|
|
2
|
+
import { FeatureData } from '../types-internal.js';
|
|
3
|
+
import { SpatialDataType } from '../sources/types.js';
|
|
4
|
+
export type TileFeaturesSpatialIndexOptions = {
|
|
5
|
+
tiles: SpatialIndexTile[];
|
|
6
|
+
spatialFilter: SpatialFilter;
|
|
7
|
+
spatialDataColumn: string;
|
|
8
|
+
spatialDataType: SpatialDataType;
|
|
9
|
+
};
|
|
10
|
+
export declare function tileFeaturesSpatialIndex({ tiles, spatialFilter, spatialDataColumn, spatialDataType, }: TileFeaturesSpatialIndexOptions): FeatureData[];
|
package/build/index.d.ts
CHANGED
|
@@ -8,3 +8,7 @@ export * from './types.js';
|
|
|
8
8
|
export { APIErrorContext, APIRequestType, CartoAPIError, QueryOptions, buildPublicMapUrl, // Internal, but required for fetchMap().
|
|
9
9
|
buildStatsUrl, // Internal, but required for fetchMap().
|
|
10
10
|
query, requestWithParameters, } from './api/index.js';
|
|
11
|
+
export * from './filters/index.js';
|
|
12
|
+
export * from './operations/index.js';
|
|
13
|
+
export * from './utils/makeIntervalComplete.js';
|
|
14
|
+
export * from './utils/transformToTileCoords.js';
|
package/build/models/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AggregationType } from '../types';
|
|
2
|
+
import { FeatureData } from '../types-internal';
|
|
3
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
4
|
+
export type AggregationFunction = (values: unknown[] | FeatureData[], keys?: string[] | string, joinOperation?: AggregationType) => number;
|
|
5
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
6
|
+
export declare const aggregationFunctions: Record<Exclude<AggregationType, 'custom'>, AggregationFunction>;
|
|
7
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
8
|
+
export declare function aggregate(feature: FeatureData, keys?: string[], operation?: AggregationType): unknown;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SortDirection } from '../types';
|
|
2
|
+
import { FeatureData } from '../types-internal';
|
|
3
|
+
type SortColumns = string | string[] | object[];
|
|
4
|
+
interface SortOptions {
|
|
5
|
+
sortBy?: SortColumns;
|
|
6
|
+
sortByDirection?: SortDirection;
|
|
7
|
+
sortByColumnType?: 'number' | 'string' | 'date';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Apply sort structure to a collection of features
|
|
11
|
+
* @param features
|
|
12
|
+
* @param [sortOptions]
|
|
13
|
+
* @param [sortOptions.sortBy] - One or more columns to sort by
|
|
14
|
+
* @param [sortOptions.sortByDirection] - Direction by the columns will be sorted
|
|
15
|
+
* @param [sortOptions.sortByColumnType] - Column type
|
|
16
|
+
* @internal
|
|
17
|
+
* @internalRemarks Source: @carto/react-core
|
|
18
|
+
*/
|
|
19
|
+
export declare function applySorting(features: FeatureData[], { sortBy, sortByDirection, sortByColumnType, }?: SortOptions): FeatureData[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AggregationType } from '../types';
|
|
2
|
+
import { FeatureData } from '../types-internal';
|
|
3
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
4
|
+
export type GroupByFeature = {
|
|
5
|
+
name: string;
|
|
6
|
+
value: number;
|
|
7
|
+
}[];
|
|
8
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
9
|
+
export declare function groupValuesByColumn({ data, valuesColumns, joinOperation, keysColumn, operation, }: {
|
|
10
|
+
data: FeatureData[];
|
|
11
|
+
valuesColumns?: string[];
|
|
12
|
+
joinOperation?: AggregationType;
|
|
13
|
+
keysColumn: string;
|
|
14
|
+
operation: AggregationType;
|
|
15
|
+
}): GroupByFeature | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AggregationType, GroupDateType } from '../types.js';
|
|
2
|
+
import { GroupByFeature } from './groupBy.js';
|
|
3
|
+
/** @internalRemarks Source: @carto/react-core */
|
|
4
|
+
export declare function groupValuesByDateColumn({ data, valuesColumns, joinOperation, keysColumn, groupType, operation, }: {
|
|
5
|
+
data: Record<string, unknown>[];
|
|
6
|
+
valuesColumns?: string[];
|
|
7
|
+
joinOperation?: Exclude<AggregationType, 'custom'>;
|
|
8
|
+
keysColumn: string;
|
|
9
|
+
groupType: GroupDateType;
|
|
10
|
+
operation?: Exclude<AggregationType, 'custom'>;
|
|
11
|
+
}): GroupByFeature | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AggregationType } from '../types';
|
|
2
|
+
import { FeatureData } from '../types-internal';
|
|
3
|
+
/**
|
|
4
|
+
* Histogram computation.
|
|
5
|
+
* @internalRemarks Source: @carto/react-core
|
|
6
|
+
*/
|
|
7
|
+
export declare function histogram({ data, valuesColumns, joinOperation, ticks, operation, }: {
|
|
8
|
+
data: FeatureData[];
|
|
9
|
+
valuesColumns?: string[];
|
|
10
|
+
joinOperation?: Exclude<AggregationType, 'custom'>;
|
|
11
|
+
ticks: number[];
|
|
12
|
+
operation: Exclude<AggregationType, 'custom'>;
|
|
13
|
+
}): number[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FeatureData } from '../types-internal';
|
|
2
|
+
import { AggregationType } from '../types';
|
|
3
|
+
export type ScatterPlotFeature = [number, number][];
|
|
4
|
+
/**
|
|
5
|
+
* Filters invalid features and formats data.
|
|
6
|
+
* @internalRemarks Source: @carto/react-core
|
|
7
|
+
*/
|
|
8
|
+
export declare function scatterPlot({ data, xAxisColumns, xAxisJoinOperation, yAxisColumns, yAxisJoinOperation, }: {
|
|
9
|
+
data: FeatureData[];
|
|
10
|
+
xAxisColumns: string[];
|
|
11
|
+
xAxisJoinOperation?: AggregationType;
|
|
12
|
+
yAxisColumns: string[];
|
|
13
|
+
yAxisJoinOperation?: AggregationType;
|
|
14
|
+
}): ScatterPlotFeature;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
1
2
|
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
|
|
2
3
|
export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
3
|
-
export type H3TilesetSourceResponse = TilejsonResult;
|
|
4
|
+
export type H3TilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
4
5
|
export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>;
|
package/build/sources/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { H3TableSourceOptions, H3TableSourceResponse, } from './h3-table-so
|
|
|
11
11
|
export { h3TilesetSource } from './h3-tileset-source';
|
|
12
12
|
export type { H3TilesetSourceOptions, H3TilesetSourceResponse, } from './h3-tileset-source';
|
|
13
13
|
export { rasterSource } from './raster-source';
|
|
14
|
-
export type { RasterSourceOptions
|
|
14
|
+
export type { RasterSourceOptions } from './raster-source';
|
|
15
15
|
export { quadbinQuerySource } from './quadbin-query-source';
|
|
16
16
|
export type { QuadbinQuerySourceOptions, QuadbinQuerySourceResponse, } from './quadbin-query-source';
|
|
17
17
|
export { quadbinTableSource } from './quadbin-table-source';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
1
2
|
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
|
|
2
3
|
export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
3
|
-
export type QuadbinTilesetSourceResponse = TilejsonResult;
|
|
4
|
+
export type QuadbinTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
4
5
|
export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
1
2
|
import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types';
|
|
2
3
|
export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
3
|
-
export type VectorTilesetSourceResponse = TilejsonResult;
|
|
4
|
+
export type VectorTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
4
5
|
export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>;
|
|
@@ -49,4 +49,8 @@ type MapInstantiationFormats = Record<Format, {
|
|
|
49
49
|
url: string[];
|
|
50
50
|
error?: any;
|
|
51
51
|
}>;
|
|
52
|
+
/******************************************************************************
|
|
53
|
+
* LOCAL CALCULATIONS
|
|
54
|
+
*/
|
|
55
|
+
export type FeatureData = Record<string, unknown>;
|
|
52
56
|
export {};
|
package/build/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FilterType } from './constants.js';
|
|
2
|
-
import type { Polygon, MultiPolygon } from 'geojson';
|
|
2
|
+
import type { Polygon, MultiPolygon, Feature } from 'geojson';
|
|
3
|
+
import type { BinaryFeature, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
3
4
|
/******************************************************************************
|
|
4
5
|
* MAPS AND TILES
|
|
5
6
|
*/
|
|
@@ -7,6 +8,50 @@ import type { Polygon, MultiPolygon } from 'geojson';
|
|
|
7
8
|
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
8
9
|
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
9
10
|
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
11
|
+
/**
|
|
12
|
+
* Alias for GeoJSON 'BBox' type, semantically representing a viewport.
|
|
13
|
+
* Order of values is "west", "south", "east", "north".
|
|
14
|
+
*/
|
|
15
|
+
export type Viewport = [number, number, number, number];
|
|
16
|
+
/**
|
|
17
|
+
* Subset of deck.gl's Tile2DHeader type, containing only the properties
|
|
18
|
+
* required for local widget calculations. Deeper dependencies on deck.gl
|
|
19
|
+
* APIs should be minimized within this library: @deck.gl/carto depends
|
|
20
|
+
* on the API client, not the other way around.
|
|
21
|
+
* @internalRemarks Source: @deck.gl/geo-layers
|
|
22
|
+
*/
|
|
23
|
+
export type Tile = {
|
|
24
|
+
index: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
z: number;
|
|
28
|
+
};
|
|
29
|
+
id: string;
|
|
30
|
+
content: unknown;
|
|
31
|
+
zoom: number;
|
|
32
|
+
bbox: {
|
|
33
|
+
west: number;
|
|
34
|
+
east: number;
|
|
35
|
+
north: number;
|
|
36
|
+
south: number;
|
|
37
|
+
};
|
|
38
|
+
isVisible: boolean;
|
|
39
|
+
data?: BinaryFeatureCollection;
|
|
40
|
+
};
|
|
41
|
+
/** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
|
|
42
|
+
export type SpatialIndexTile = Tile & {
|
|
43
|
+
data?: (Feature & {
|
|
44
|
+
id: bigint;
|
|
45
|
+
})[];
|
|
46
|
+
};
|
|
47
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
48
|
+
export type Raster = {
|
|
49
|
+
blockSize: number;
|
|
50
|
+
cells: {
|
|
51
|
+
numericProps: BinaryFeature['numericProps'];
|
|
52
|
+
properties: BinaryFeature['properties'];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
10
55
|
/******************************************************************************
|
|
11
56
|
* AGGREGATION
|
|
12
57
|
*/
|
|
@@ -49,10 +94,25 @@ export interface Filter {
|
|
|
49
94
|
[FilterType.STRING_SEARCH]?: {
|
|
50
95
|
owner?: string;
|
|
51
96
|
values: string[];
|
|
97
|
+
params?: StringSearchOptions;
|
|
52
98
|
};
|
|
53
99
|
}
|
|
54
100
|
/** @internalRemarks Source: @carto/react-core */
|
|
55
101
|
export type FilterLogicalOperator = 'and' | 'or';
|
|
102
|
+
/**
|
|
103
|
+
* Type for minimum or maximum value of an interval. Values 'null' and
|
|
104
|
+
* 'undefined' are intentionally allowed, and represent an unbounded value.
|
|
105
|
+
*/
|
|
106
|
+
export type FilterIntervalExtremum = number | null | undefined;
|
|
107
|
+
export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
|
|
108
|
+
export type FilterIntervalComplete = [number, number];
|
|
109
|
+
export type StringSearchOptions = {
|
|
110
|
+
useRegExp?: boolean;
|
|
111
|
+
mustStart?: boolean;
|
|
112
|
+
mustEnd?: boolean;
|
|
113
|
+
caseSensitive?: boolean;
|
|
114
|
+
keepSpecialCharacters?: boolean;
|
|
115
|
+
};
|
|
56
116
|
/******************************************************************************
|
|
57
117
|
* GROUPING
|
|
58
118
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns midnight (local time) on the Monday preceeding a given date, in
|
|
3
|
+
* milliseconds since the UNIX epoch.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getMonday(date: number | Date): number;
|
|
6
|
+
/**
|
|
7
|
+
* Returns midnight (UTC) on the Monday preceeding a given date, in
|
|
8
|
+
* milliseconds since the UNIX epoch.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getUTCMonday(date: number | Date): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BBox, Geometry } from 'geojson';
|
|
2
|
+
/**
|
|
3
|
+
* Transform tile coords to WGS84 coordinates.
|
|
4
|
+
*
|
|
5
|
+
* @param geometry - any valid geojson geometry
|
|
6
|
+
* @param bbox - geojson bbox
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformTileCoordsToWGS84<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BBox, Geometry } from 'geojson';
|
|
2
|
+
/**
|
|
3
|
+
* Transform WGS84 coordinates to tile coords.
|
|
4
|
+
* It's the inverse of deck.gl coordinate-transform (https://github.com/visgl/deck.gl/blob/master/modules/geo-layers/src/mvt-layer/coordinate-transform.js)
|
|
5
|
+
*
|
|
6
|
+
* @param geometry - any valid geojson geometry
|
|
7
|
+
* @param bbox - geojson bbox
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
@@ -8,7 +8,7 @@ export interface ViewState {
|
|
|
8
8
|
latitude: number;
|
|
9
9
|
longitude: number;
|
|
10
10
|
}
|
|
11
|
-
/** Common options for {@link
|
|
11
|
+
/** Common options for {@link WidgetRemoteSource} requests. */
|
|
12
12
|
interface BaseRequestOptions {
|
|
13
13
|
spatialFilter?: SpatialFilter;
|
|
14
14
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
@@ -17,14 +17,16 @@ interface BaseRequestOptions {
|
|
|
17
17
|
abortController?: AbortController;
|
|
18
18
|
filterOwner?: string;
|
|
19
19
|
}
|
|
20
|
-
/** Options for {@link
|
|
20
|
+
/** Options for {@link WidgetRemoteSource#getCategories}. */
|
|
21
21
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
22
22
|
column: string;
|
|
23
23
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
24
24
|
operationColumn?: string;
|
|
25
|
+
/** Local only. */
|
|
26
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
|
-
* Options for {@link
|
|
29
|
+
* Options for {@link WidgetRemoteSource#getFeatures}.
|
|
28
30
|
* @experimental
|
|
29
31
|
* @internal
|
|
30
32
|
*/
|
|
@@ -60,30 +62,33 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
|
60
62
|
*/
|
|
61
63
|
tileResolution?: TileResolution;
|
|
62
64
|
}
|
|
63
|
-
/** Options for {@link
|
|
65
|
+
/** Options for {@link WidgetRemoteSource#getFormula}. */
|
|
64
66
|
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
65
67
|
column: string;
|
|
66
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
68
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
67
69
|
operationExp?: string;
|
|
70
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
68
71
|
}
|
|
69
|
-
/** Options for {@link
|
|
72
|
+
/** Options for {@link WidgetRemoteSource#getHistogram}. */
|
|
70
73
|
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
71
74
|
column: string;
|
|
72
75
|
ticks: number[];
|
|
73
76
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
77
|
+
/** Local only. */
|
|
78
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
74
79
|
}
|
|
75
|
-
/** Options for {@link
|
|
80
|
+
/** Options for {@link WidgetRemoteSource#getRange}. */
|
|
76
81
|
export interface RangeRequestOptions extends BaseRequestOptions {
|
|
77
82
|
column: string;
|
|
78
83
|
}
|
|
79
|
-
/** Options for {@link
|
|
84
|
+
/** Options for {@link WidgetRemoteSource#getScatter}. */
|
|
80
85
|
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
81
86
|
xAxisColumn: string;
|
|
82
87
|
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
83
88
|
yAxisColumn: string;
|
|
84
89
|
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
85
90
|
}
|
|
86
|
-
/** Options for {@link
|
|
91
|
+
/** Options for {@link WidgetRemoteSource#getTable}. */
|
|
87
92
|
export interface TableRequestOptions extends BaseRequestOptions {
|
|
88
93
|
columns: string[];
|
|
89
94
|
sortBy?: string;
|
|
@@ -91,11 +96,15 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
91
96
|
sortByColumnType?: SortColumnType;
|
|
92
97
|
offset?: number;
|
|
93
98
|
limit?: number;
|
|
99
|
+
/** Local only. */
|
|
100
|
+
searchFilterColumn?: string;
|
|
101
|
+
/** Local only. */
|
|
102
|
+
searchFilterText?: string;
|
|
94
103
|
}
|
|
95
|
-
/** Options for {@link
|
|
104
|
+
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */
|
|
96
105
|
export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
97
106
|
column: string;
|
|
98
|
-
stepSize
|
|
107
|
+
stepSize: GroupDateType;
|
|
99
108
|
stepMultiplier?: number;
|
|
100
109
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
101
110
|
operationColumn?: string;
|
|
@@ -108,42 +117,42 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
|
108
117
|
* WIDGET API RESPONSES
|
|
109
118
|
*/
|
|
110
119
|
/**
|
|
111
|
-
* Response from {@link
|
|
120
|
+
* Response from {@link WidgetRemoteSource#getFeatures}.
|
|
112
121
|
* @experimental
|
|
113
122
|
* @internal
|
|
114
123
|
*/
|
|
115
124
|
export type FeaturesResponse = {
|
|
116
125
|
rows: Record<string, unknown>[];
|
|
117
126
|
};
|
|
118
|
-
/** Response from {@link
|
|
127
|
+
/** Response from {@link WidgetRemoteSource#getFormula}. */
|
|
119
128
|
export type FormulaResponse = {
|
|
120
|
-
value: number;
|
|
129
|
+
value: number | null;
|
|
121
130
|
};
|
|
122
|
-
/** Response from {@link
|
|
131
|
+
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
123
132
|
export type CategoryResponse = {
|
|
124
133
|
name: string;
|
|
125
134
|
value: number;
|
|
126
135
|
}[];
|
|
127
|
-
/** Response from {@link
|
|
136
|
+
/** Response from {@link WidgetRemoteSource#getRange}. */
|
|
128
137
|
export type RangeResponse = {
|
|
129
138
|
min: number;
|
|
130
139
|
max: number;
|
|
131
|
-
};
|
|
132
|
-
/** Response from {@link
|
|
140
|
+
} | null;
|
|
141
|
+
/** Response from {@link WidgetRemoteSource#getTable}. */
|
|
133
142
|
export type TableResponse = {
|
|
134
143
|
totalCount: number;
|
|
135
144
|
rows: Record<string, number | string>[];
|
|
136
145
|
};
|
|
137
|
-
/** Response from {@link
|
|
146
|
+
/** Response from {@link WidgetRemoteSource#getScatter}. */
|
|
138
147
|
export type ScatterResponse = [number, number][];
|
|
139
|
-
/** Response from {@link
|
|
148
|
+
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */
|
|
140
149
|
export type TimeSeriesResponse = {
|
|
141
150
|
rows: {
|
|
142
151
|
name: string;
|
|
143
152
|
value: number;
|
|
144
153
|
}[];
|
|
145
|
-
categories
|
|
154
|
+
categories?: string[];
|
|
146
155
|
};
|
|
147
|
-
/** Response from {@link
|
|
156
|
+
/** Response from {@link WidgetRemoteSource#getHistogram}. */
|
|
148
157
|
export type HistogramResponse = number[];
|
|
149
158
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
4
|
type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
|
|
5
5
|
export type WidgetQuerySourceResult = {
|
|
@@ -27,7 +27,7 @@ export type WidgetQuerySourceResult = {
|
|
|
27
27
|
* const { widgetSource } = await data;
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare class WidgetQuerySource extends
|
|
30
|
+
export declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> {
|
|
31
31
|
protected getModelSource(owner: string): ModelSource;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
|
|
2
|
+
import { WidgetSource, WidgetSourceProps } from './widget-source.js';
|
|
3
|
+
export type WidgetRemoteSourceProps = WidgetSourceProps;
|
|
4
|
+
/**
|
|
5
|
+
* Source for Widget API requests.
|
|
6
|
+
*
|
|
7
|
+
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class WidgetRemoteSource<Props extends WidgetRemoteSourceProps> extends WidgetSource<Props> {
|
|
10
|
+
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
11
|
+
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
12
|
+
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
13
|
+
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
14
|
+
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
15
|
+
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
16
|
+
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
17
|
+
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
18
|
+
}
|