@carto/api-client 0.5.14 → 0.5.15-alpha.raster-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.
@@ -1,5 +1,6 @@
1
1
  import { Feature, Polygon, MultiPolygon, BBox, FeatureCollection, Geometry } from 'geojson';
2
2
  import { BinaryFeatureCollection, BinaryFeature } from '@loaders.gl/schema';
3
+ import jsep from 'jsep';
3
4
 
4
5
  /**
5
6
  * Returns current client ID, used to categorize API requests. For internal use only.
@@ -574,13 +575,50 @@ interface Tilestats {
574
575
  }
575
576
  interface Layer {
576
577
  layer: string;
578
+ /** Number of features in the layer. */
577
579
  count: number;
580
+ /** Number of attributes in the layer. */
578
581
  attributeCount: number;
579
582
  attributes: Attribute[];
583
+ /** Type of geometry as in geojson geometry type (Point, LineString, Polygon, etc.) */
584
+ geometry?: string;
585
+ }
586
+ interface AttributeCategoryItem {
587
+ category: string;
588
+ frequency: number;
589
+ }
590
+ /**
591
+ * Quantiles by number of buckets.
592
+ *
593
+ * Example:
594
+ * ```ts
595
+ * {
596
+ * // for 3 buckets, first 1/3 of items lies in range [min, 20], second 1/3 is in [20, 40], and last 1/3 is in [40, max]
597
+ * 3: [20, 40],
598
+ * 4: [20, 30, 50], for 4 buckets ...
599
+ * }
600
+ * ```
601
+ */
602
+ interface QuantileStats {
603
+ [bucketCount: number]: number[];
580
604
  }
581
605
  interface Attribute {
582
- attribute: string;
606
+ /**
607
+ * String, Number, Timestamp, Boolean
608
+ */
583
609
  type: string;
610
+ /**
611
+ * Attribute name.
612
+ */
613
+ attribute: string;
614
+ min?: number;
615
+ max?: number;
616
+ sum?: number;
617
+ /** Quantiles by number of buckets */
618
+ quantiles?: {
619
+ global: QuantileStats;
620
+ } | QuantileStats;
621
+ categories?: AttributeCategoryItem[];
584
622
  }
585
623
  interface VectorLayer {
586
624
  id: string;
@@ -600,17 +638,8 @@ type RasterMetadataBandStats = {
600
638
  count: number;
601
639
  /**
602
640
  * Quantiles by number of buckets.
603
- *
604
- * Example:
605
- * ```ts
606
- * {
607
- * // for 3 buckets, first 1/3 of items lies in range [min, 20], second 1/3 is in [20, 40], and last 1/3 is in [40, max]
608
- * 3: [20, 40],
609
- * 4: [20, 30, 50], for 4 buckets ...
610
- * }
611
- * ```
612
641
  */
613
- quantiles?: Record<number, number[]>;
642
+ quantiles?: QuantileStats;
614
643
  /**
615
644
  * Top values by number of values.
616
645
  *
@@ -746,10 +775,12 @@ declare function opacityToAlpha(opacity?: number): number;
746
775
  declare function getColorAccessor({ name, colorColumn }: VisualChannelField, scaleType: ScaleType, { aggregation, range }: {
747
776
  aggregation: string;
748
777
  range: any;
749
- }, opacity: number | undefined, data: any): {
778
+ }, opacity: number | undefined, data: TilejsonResult): {
750
779
  accessor: any;
751
780
  scale: any;
752
781
  };
782
+ declare function calculateLayerScale(name: string, scaleType: ScaleType, range: ColorRange, data: TilejsonResult): D3Scale;
783
+ declare function createColorScale<T>(scaleType: ScaleType, domain: string[] | number[], range: T[], unknown: T): D3Scale;
753
784
  declare function getIconUrlAccessor(field: VisualChannelField | null | undefined, range: CustomMarkersRange | null | undefined, { fallbackUrl, maxIconSize, useMaskedIcons, }: {
754
785
  fallbackUrl?: string | null;
755
786
  maxIconSize: number;
@@ -758,7 +789,7 @@ declare function getIconUrlAccessor(field: VisualChannelField | null | undefined
758
789
  declare function getMaxMarkerSize(visConfig: VisConfig, visualChannels: VisualChannels): number;
759
790
  type Accessor = number | ((d: any, i: any) => number);
760
791
  declare function negateAccessor(accessor: Accessor): Accessor;
761
- declare function getSizeAccessor({ name }: VisualChannelField, scaleType: ScaleType | undefined, aggregation: string | null | undefined, range: Iterable<Range> | null | undefined, data: any): {
792
+ declare function getSizeAccessor({ name }: VisualChannelField, scaleType: ScaleType | undefined, aggregation: string | null | undefined, range: Iterable<Range> | null | undefined, data: TilejsonResult): {
762
793
  accessor: any;
763
794
  scale: any;
764
795
  };
@@ -804,6 +835,7 @@ type ColorRange = {
804
835
  colorMap: string[][] | undefined;
805
836
  name: string;
806
837
  type: string;
838
+ uiCustomScaleType?: 'logarithmic';
807
839
  };
808
840
  type CustomMarkersRange = {
809
841
  markerMap: {
@@ -812,6 +844,12 @@ type CustomMarkersRange = {
812
844
  }[];
813
845
  othersMarker?: string;
814
846
  };
847
+ type ColorBand = 'red' | 'green' | 'blue' | 'alpha';
848
+ type RasterLayerConfigColorBand = {
849
+ band: ColorBand;
850
+ type: 'none' | 'band' | 'expression';
851
+ value: string;
852
+ };
815
853
  type VisConfig = {
816
854
  filled?: boolean;
817
855
  opacity?: number;
@@ -833,6 +871,9 @@ type VisConfig = {
833
871
  weightAggregation?: any;
834
872
  clusterLevel?: number;
835
873
  isTextVisible?: boolean;
874
+ rasterStyleType?: 'Rgb' | 'ColorRange' | 'UniqueValues';
875
+ colorBands?: RasterLayerConfigColorBand[];
876
+ uniqueValuesColorRange?: ColorRange;
836
877
  };
837
878
  type TextLabel = {
838
879
  field: VisualChannelField | null | undefined;
@@ -967,6 +1008,9 @@ type Dataset = {
967
1008
  exportToBucketAvailable?: boolean;
968
1009
  };
969
1010
 
1011
+ type StyleLayerGroupSlug = 'label' | 'road' | 'border' | 'building' | 'water' | 'land';
1012
+ declare function applyLayerGroupFilters(style: any, // this Maplibre/Mapbox style, we don't want to add a dependency on Maplibre
1013
+ visibleLayerGroups: Record<StyleLayerGroupSlug, boolean>): any;
970
1014
  declare const _default: {
971
1015
  readonly VOYAGER: string;
972
1016
  readonly POSITRON: string;
@@ -976,17 +1020,32 @@ declare const _default: {
976
1020
  readonly DARK_MATTER_NOLABELS: string;
977
1021
  };
978
1022
 
1023
+ declare function getRasterTileLayerStyleProps({ layerConfig, visualChannels, rasterMetadata, }: {
1024
+ layerConfig: MapLayerConfig;
1025
+ visualChannels: VisualChannels;
1026
+ rasterMetadata: RasterMetadata;
1027
+ }): {
1028
+ dataTransform: () => any;
1029
+ updateTriggers: {
1030
+ getFillColor: Record<string, unknown>;
1031
+ };
1032
+ } | {
1033
+ dataTransform?: undefined;
1034
+ updateTriggers?: undefined;
1035
+ };
1036
+
979
1037
  type Scale = {
980
1038
  field: VisualChannelField;
981
1039
  domain: string[] | number[];
982
1040
  range: string[] | number[];
983
1041
  type: ScaleType;
984
1042
  };
1043
+ type ScaleKey = 'fillColor' | 'pointRadius' | 'lineColor' | 'elevation' | 'weight';
985
1044
  type LayerDescriptor = {
986
1045
  type: LayerType;
987
1046
  props: Record<string, any>;
988
1047
  filters?: Filters;
989
- scales: Record<ScaleKey, Scale>;
1048
+ scales: Partial<Record<ScaleKey, Scale>>;
990
1049
  };
991
1050
  type ParseMapResult = {
992
1051
  /** Map id. */
@@ -1004,6 +1063,11 @@ type ParseMapResult = {
1004
1063
  token: string;
1005
1064
  layers: LayerDescriptor[];
1006
1065
  };
1066
+ declare function getLayerDescriptor({ mapConfig, layer, dataset, }: {
1067
+ mapConfig: KeplerMapConfig;
1068
+ layer: MapConfigLayer;
1069
+ dataset: Dataset;
1070
+ }): LayerDescriptor;
1007
1071
  declare function parseMap(json: any): {
1008
1072
  id: any;
1009
1073
  title: any;
@@ -1021,7 +1085,6 @@ declare function parseMap(json: any): {
1021
1085
  token: any;
1022
1086
  layers: (LayerDescriptor | undefined)[];
1023
1087
  };
1024
- type ScaleKey = 'fillColor' | 'pointRadius' | 'lineColor' | 'elevation' | 'weight';
1025
1088
 
1026
1089
  type FetchMapOptions = {
1027
1090
  /**
@@ -1085,6 +1148,38 @@ declare function fetchBasemapProps({ config, errorContext, applyLayerFilters, }:
1085
1148
  errorContext?: APIErrorContext;
1086
1149
  }): Promise<Basemap | null>;
1087
1150
 
1151
+ /**
1152
+ * Create vector expresion evaluator.
1153
+ *
1154
+ * Used to calculate vector expressions, such as `(band_1 * 3) + band_2/2`,
1155
+ * where `band_1` and `band_2` are arrays or typed arrays.
1156
+ *
1157
+ * Note that all vector operations are element-wise, in paricular `band_1 * band_2`
1158
+ * is not "mathematical" dot or cross product, but just element-wise multiplication.
1159
+ *
1160
+ * Based on:
1161
+ * - Copyright (c) 2013 Stephen Oney, http://jsep.from.so/, MIT License
1162
+ * - Copyright (c) 2023 Don McCurdy, https://github.com/donmccurdy/expression-eval, MIT License
1163
+ */
1164
+ declare function createVecExprEvaluator(expression: string | jsep.Expression): VecExprEvaluator | null;
1165
+ declare function evaluateVecExpr(expression: string | jsep.Expression, context: Record<string, VecExprResult>): VecExprResult | null | undefined;
1166
+ declare enum ErrorCode {
1167
+ InvalidSyntax = 0,
1168
+ UnknownIdentifier = 1
1169
+ }
1170
+ type ValidationResult = {
1171
+ valid: boolean;
1172
+ errorCode?: ErrorCode;
1173
+ errorMessage?: string;
1174
+ };
1175
+ declare function validateVecExprSyntax(expression: string | jsep.Expression, context: Record<string, unknown>): ValidationResult;
1176
+ type VecExprVecLike = number[] | Float32Array | Float64Array | Uint8Array | Int8Array | Int32Array | Uint32Array | Uint16Array | Int16Array;
1177
+ type VecExprResult = number | VecExprVecLike;
1178
+ type VecExprEvaluator = {
1179
+ (context: object): VecExprResult;
1180
+ symbols?: string[];
1181
+ };
1182
+
1088
1183
  type FilterTypeOptions<T extends FilterType> = {
1089
1184
  type: T;
1090
1185
  column: string;
@@ -1987,4 +2082,4 @@ declare function getColumnNameFromGeoColumn(geoColumn: string | null | undefined
1987
2082
  */
1988
2083
  declare function getSpatialIndexFromGeoColumn(geoColumn: string): SpatialIndex | null;
1989
2084
 
1990
- export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, _buildFeatureFilter, domainFromValues as _domainFromValues, _getHexagonResolution, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, clearDefaultRequestCache, clearFilters, configureSource, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
2085
+ export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, _getHexagonResolution, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
@@ -1,5 +1,6 @@
1
1
  import { Feature, Polygon, MultiPolygon, BBox, FeatureCollection, Geometry } from 'geojson';
2
2
  import { BinaryFeatureCollection, BinaryFeature } from '@loaders.gl/schema';
3
+ import jsep from 'jsep';
3
4
 
4
5
  /**
5
6
  * Returns current client ID, used to categorize API requests. For internal use only.
@@ -574,13 +575,50 @@ interface Tilestats {
574
575
  }
575
576
  interface Layer {
576
577
  layer: string;
578
+ /** Number of features in the layer. */
577
579
  count: number;
580
+ /** Number of attributes in the layer. */
578
581
  attributeCount: number;
579
582
  attributes: Attribute[];
583
+ /** Type of geometry as in geojson geometry type (Point, LineString, Polygon, etc.) */
584
+ geometry?: string;
585
+ }
586
+ interface AttributeCategoryItem {
587
+ category: string;
588
+ frequency: number;
589
+ }
590
+ /**
591
+ * Quantiles by number of buckets.
592
+ *
593
+ * Example:
594
+ * ```ts
595
+ * {
596
+ * // for 3 buckets, first 1/3 of items lies in range [min, 20], second 1/3 is in [20, 40], and last 1/3 is in [40, max]
597
+ * 3: [20, 40],
598
+ * 4: [20, 30, 50], for 4 buckets ...
599
+ * }
600
+ * ```
601
+ */
602
+ interface QuantileStats {
603
+ [bucketCount: number]: number[];
580
604
  }
581
605
  interface Attribute {
582
- attribute: string;
606
+ /**
607
+ * String, Number, Timestamp, Boolean
608
+ */
583
609
  type: string;
610
+ /**
611
+ * Attribute name.
612
+ */
613
+ attribute: string;
614
+ min?: number;
615
+ max?: number;
616
+ sum?: number;
617
+ /** Quantiles by number of buckets */
618
+ quantiles?: {
619
+ global: QuantileStats;
620
+ } | QuantileStats;
621
+ categories?: AttributeCategoryItem[];
584
622
  }
585
623
  interface VectorLayer {
586
624
  id: string;
@@ -600,17 +638,8 @@ type RasterMetadataBandStats = {
600
638
  count: number;
601
639
  /**
602
640
  * Quantiles by number of buckets.
603
- *
604
- * Example:
605
- * ```ts
606
- * {
607
- * // for 3 buckets, first 1/3 of items lies in range [min, 20], second 1/3 is in [20, 40], and last 1/3 is in [40, max]
608
- * 3: [20, 40],
609
- * 4: [20, 30, 50], for 4 buckets ...
610
- * }
611
- * ```
612
641
  */
613
- quantiles?: Record<number, number[]>;
642
+ quantiles?: QuantileStats;
614
643
  /**
615
644
  * Top values by number of values.
616
645
  *
@@ -746,10 +775,12 @@ declare function opacityToAlpha(opacity?: number): number;
746
775
  declare function getColorAccessor({ name, colorColumn }: VisualChannelField, scaleType: ScaleType, { aggregation, range }: {
747
776
  aggregation: string;
748
777
  range: any;
749
- }, opacity: number | undefined, data: any): {
778
+ }, opacity: number | undefined, data: TilejsonResult): {
750
779
  accessor: any;
751
780
  scale: any;
752
781
  };
782
+ declare function calculateLayerScale(name: string, scaleType: ScaleType, range: ColorRange, data: TilejsonResult): D3Scale;
783
+ declare function createColorScale<T>(scaleType: ScaleType, domain: string[] | number[], range: T[], unknown: T): D3Scale;
753
784
  declare function getIconUrlAccessor(field: VisualChannelField | null | undefined, range: CustomMarkersRange | null | undefined, { fallbackUrl, maxIconSize, useMaskedIcons, }: {
754
785
  fallbackUrl?: string | null;
755
786
  maxIconSize: number;
@@ -758,7 +789,7 @@ declare function getIconUrlAccessor(field: VisualChannelField | null | undefined
758
789
  declare function getMaxMarkerSize(visConfig: VisConfig, visualChannels: VisualChannels): number;
759
790
  type Accessor = number | ((d: any, i: any) => number);
760
791
  declare function negateAccessor(accessor: Accessor): Accessor;
761
- declare function getSizeAccessor({ name }: VisualChannelField, scaleType: ScaleType | undefined, aggregation: string | null | undefined, range: Iterable<Range> | null | undefined, data: any): {
792
+ declare function getSizeAccessor({ name }: VisualChannelField, scaleType: ScaleType | undefined, aggregation: string | null | undefined, range: Iterable<Range> | null | undefined, data: TilejsonResult): {
762
793
  accessor: any;
763
794
  scale: any;
764
795
  };
@@ -804,6 +835,7 @@ type ColorRange = {
804
835
  colorMap: string[][] | undefined;
805
836
  name: string;
806
837
  type: string;
838
+ uiCustomScaleType?: 'logarithmic';
807
839
  };
808
840
  type CustomMarkersRange = {
809
841
  markerMap: {
@@ -812,6 +844,12 @@ type CustomMarkersRange = {
812
844
  }[];
813
845
  othersMarker?: string;
814
846
  };
847
+ type ColorBand = 'red' | 'green' | 'blue' | 'alpha';
848
+ type RasterLayerConfigColorBand = {
849
+ band: ColorBand;
850
+ type: 'none' | 'band' | 'expression';
851
+ value: string;
852
+ };
815
853
  type VisConfig = {
816
854
  filled?: boolean;
817
855
  opacity?: number;
@@ -833,6 +871,9 @@ type VisConfig = {
833
871
  weightAggregation?: any;
834
872
  clusterLevel?: number;
835
873
  isTextVisible?: boolean;
874
+ rasterStyleType?: 'Rgb' | 'ColorRange' | 'UniqueValues';
875
+ colorBands?: RasterLayerConfigColorBand[];
876
+ uniqueValuesColorRange?: ColorRange;
836
877
  };
837
878
  type TextLabel = {
838
879
  field: VisualChannelField | null | undefined;
@@ -967,6 +1008,9 @@ type Dataset = {
967
1008
  exportToBucketAvailable?: boolean;
968
1009
  };
969
1010
 
1011
+ type StyleLayerGroupSlug = 'label' | 'road' | 'border' | 'building' | 'water' | 'land';
1012
+ declare function applyLayerGroupFilters(style: any, // this Maplibre/Mapbox style, we don't want to add a dependency on Maplibre
1013
+ visibleLayerGroups: Record<StyleLayerGroupSlug, boolean>): any;
970
1014
  declare const _default: {
971
1015
  readonly VOYAGER: string;
972
1016
  readonly POSITRON: string;
@@ -976,17 +1020,32 @@ declare const _default: {
976
1020
  readonly DARK_MATTER_NOLABELS: string;
977
1021
  };
978
1022
 
1023
+ declare function getRasterTileLayerStyleProps({ layerConfig, visualChannels, rasterMetadata, }: {
1024
+ layerConfig: MapLayerConfig;
1025
+ visualChannels: VisualChannels;
1026
+ rasterMetadata: RasterMetadata;
1027
+ }): {
1028
+ dataTransform: () => any;
1029
+ updateTriggers: {
1030
+ getFillColor: Record<string, unknown>;
1031
+ };
1032
+ } | {
1033
+ dataTransform?: undefined;
1034
+ updateTriggers?: undefined;
1035
+ };
1036
+
979
1037
  type Scale = {
980
1038
  field: VisualChannelField;
981
1039
  domain: string[] | number[];
982
1040
  range: string[] | number[];
983
1041
  type: ScaleType;
984
1042
  };
1043
+ type ScaleKey = 'fillColor' | 'pointRadius' | 'lineColor' | 'elevation' | 'weight';
985
1044
  type LayerDescriptor = {
986
1045
  type: LayerType;
987
1046
  props: Record<string, any>;
988
1047
  filters?: Filters;
989
- scales: Record<ScaleKey, Scale>;
1048
+ scales: Partial<Record<ScaleKey, Scale>>;
990
1049
  };
991
1050
  type ParseMapResult = {
992
1051
  /** Map id. */
@@ -1004,6 +1063,11 @@ type ParseMapResult = {
1004
1063
  token: string;
1005
1064
  layers: LayerDescriptor[];
1006
1065
  };
1066
+ declare function getLayerDescriptor({ mapConfig, layer, dataset, }: {
1067
+ mapConfig: KeplerMapConfig;
1068
+ layer: MapConfigLayer;
1069
+ dataset: Dataset;
1070
+ }): LayerDescriptor;
1007
1071
  declare function parseMap(json: any): {
1008
1072
  id: any;
1009
1073
  title: any;
@@ -1021,7 +1085,6 @@ declare function parseMap(json: any): {
1021
1085
  token: any;
1022
1086
  layers: (LayerDescriptor | undefined)[];
1023
1087
  };
1024
- type ScaleKey = 'fillColor' | 'pointRadius' | 'lineColor' | 'elevation' | 'weight';
1025
1088
 
1026
1089
  type FetchMapOptions = {
1027
1090
  /**
@@ -1085,6 +1148,38 @@ declare function fetchBasemapProps({ config, errorContext, applyLayerFilters, }:
1085
1148
  errorContext?: APIErrorContext;
1086
1149
  }): Promise<Basemap | null>;
1087
1150
 
1151
+ /**
1152
+ * Create vector expresion evaluator.
1153
+ *
1154
+ * Used to calculate vector expressions, such as `(band_1 * 3) + band_2/2`,
1155
+ * where `band_1` and `band_2` are arrays or typed arrays.
1156
+ *
1157
+ * Note that all vector operations are element-wise, in paricular `band_1 * band_2`
1158
+ * is not "mathematical" dot or cross product, but just element-wise multiplication.
1159
+ *
1160
+ * Based on:
1161
+ * - Copyright (c) 2013 Stephen Oney, http://jsep.from.so/, MIT License
1162
+ * - Copyright (c) 2023 Don McCurdy, https://github.com/donmccurdy/expression-eval, MIT License
1163
+ */
1164
+ declare function createVecExprEvaluator(expression: string | jsep.Expression): VecExprEvaluator | null;
1165
+ declare function evaluateVecExpr(expression: string | jsep.Expression, context: Record<string, VecExprResult>): VecExprResult | null | undefined;
1166
+ declare enum ErrorCode {
1167
+ InvalidSyntax = 0,
1168
+ UnknownIdentifier = 1
1169
+ }
1170
+ type ValidationResult = {
1171
+ valid: boolean;
1172
+ errorCode?: ErrorCode;
1173
+ errorMessage?: string;
1174
+ };
1175
+ declare function validateVecExprSyntax(expression: string | jsep.Expression, context: Record<string, unknown>): ValidationResult;
1176
+ type VecExprVecLike = number[] | Float32Array | Float64Array | Uint8Array | Int8Array | Int32Array | Uint32Array | Uint16Array | Int16Array;
1177
+ type VecExprResult = number | VecExprVecLike;
1178
+ type VecExprEvaluator = {
1179
+ (context: object): VecExprResult;
1180
+ symbols?: string[];
1181
+ };
1182
+
1088
1183
  type FilterTypeOptions<T extends FilterType> = {
1089
1184
  type: T;
1090
1185
  column: string;
@@ -1987,4 +2082,4 @@ declare function getColumnNameFromGeoColumn(geoColumn: string | null | undefined
1987
2082
  */
1988
2083
  declare function getSpatialIndexFromGeoColumn(geoColumn: string): SpatialIndex | null;
1989
2084
 
1990
- export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, _buildFeatureFilter, domainFromValues as _domainFromValues, _getHexagonResolution, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, clearDefaultRequestCache, clearFilters, configureSource, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
2085
+ export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, _getHexagonResolution, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };