kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
127 lines (126 loc) • 6.69 kB
TypeScript
/// <reference types="lodash" />
import { KeplerTable as KeplerDataset, Datasets as KeplerDatasets, GpuFilter } from '@kepler.gl/table';
import { AnimationConfig, Field, BindedLayerCallbacks, VisConfigBoolean, VisConfigRange, VisConfigColorRange, VisConfigNumber, VisConfigColorSelect, LayerColorConfig, LayerHeightConfig, Filter, Field as KeplerField, MapState, Merge } from '@kepler.gl/types';
import { default as KeplerLayer, LayerBaseConfig, LayerBaseConfigPartial, VisualChannel, VisualChannelDomain, VisualChannelField } from '../base-layer';
import TileDataset from './common-tile/tile-dataset';
import { FindDefaultLayerPropsReturnValue } from '../layer-utils';
export declare const DEFAULT_RADIUS = 1;
export declare type AbstractTileLayerVisConfigSettings = {
strokeColor: VisConfigColorSelect;
strokeOpacity: VisConfigNumber;
radius: VisConfigNumber;
radiusUnits: VisConfigBoolean;
enable3d: VisConfigBoolean;
stroked: VisConfigBoolean;
transition: VisConfigBoolean;
heightRange: VisConfigRange;
elevationScale: VisConfigNumber;
opacity: VisConfigNumber;
colorRange: VisConfigColorRange;
radiusByZoom: any;
dynamicColor: VisConfigBoolean;
};
export declare type LayerData = {
minZoom?: number;
maxZoom?: number;
bounds?: number[];
getPointRadius?: () => number;
};
export declare type LayerOpts = {
idx: number;
mapState: MapState;
data: LayerData;
gpuFilter: GpuFilter;
animationConfig: AnimationConfig;
tilesetDataUrl?: string | null;
layerCallbacks: BindedLayerCallbacks;
};
export declare const commonTileVisConfigs: {
strokeColor: "strokeColor";
strokeOpacity: {
property: string;
label: string | ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => string);
group: string | number | symbol;
description?: string | undefined;
condition?: ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => boolean) | undefined;
allowCustomValue?: boolean | undefined;
type: "number";
isRanged: false;
defaultValue: number;
range: import("@kepler.gl/types").SizeRange;
step: number;
};
radius: VisConfigNumber;
radiusUnits: VisConfigBoolean;
enable3d: "enable3d";
stroked: {
defaultValue: boolean;
label: string | ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => string);
group: string | number | symbol;
property: string;
description?: string | undefined;
condition?: ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => boolean) | undefined;
allowCustomValue?: boolean | undefined;
type: "boolean";
};
transition: VisConfigBoolean;
heightRange: "elevationRange";
elevationScale: {
allowCustomValue: boolean;
label: string | ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => string);
group: string | number | symbol;
property: string;
description?: string | undefined;
condition?: ((config: LayerBaseConfig & Partial<LayerColorConfig> & Partial<LayerHeightConfig> & Partial<import("@kepler.gl/types").LayerSizeConfig> & Partial<import("@kepler.gl/types").LayerWeightConfig>) => boolean) | undefined;
type: "number";
isRanged: false;
defaultValue: number;
range: import("@kepler.gl/types").SizeRange;
step: number;
};
opacity: "opacity";
colorRange: "colorRange";
radiusByZoom: any;
dynamicColor: VisConfigBoolean;
};
export declare type AbstractTileLayerConfig = Merge<LayerBaseConfig, {
colorField?: VisualChannelField;
colorScale?: string;
colorDomain?: VisualChannelDomain;
}>;
/**
* Abstract tile layer, including common functionality for viewport-based datasets,
* dynamic scales, and tile-based animation
*/
export default abstract class AbstractTileLayer<T, I extends Iterable<any> = T extends Iterable<any> ? T : never> extends KeplerLayer {
config: AbstractTileLayerConfig;
visConfigSettings: AbstractTileLayerVisConfigSettings;
constructor(props: ConstructorParameters<typeof KeplerLayer>[0]);
protected tileDataset: TileDataset<T, I>;
protected setLayerDomain: BindedLayerCallbacks['onSetLayerDomain'];
protected abstract initTileDataset(): TileDataset<T, I>;
static findDefaultLayerProps(dataset: KeplerDataset): FindDefaultLayerPropsReturnValue;
get requireData(): boolean;
get requiredLayerColumns(): string[];
get visualChannels(): Record<string, VisualChannel>;
/**
* Callback to invoke when the viewport changes
*/
onViewportLoad: (tiles: T[]) => void;
abstract accessRowValue(field?: KeplerField, indexKey?: number | null): (field: KeplerField, datum: T extends Iterable<infer V> ? V : never) => string | number | null;
accessVSFieldValue(inputField?: Field, indexKey?: number | null): any;
getScaleOptions(channelKey: string): string[];
setDynamicColorDomain: import("lodash").DebouncedFuncLeading<() => void>;
resetColorDomain(): void;
updateLayerConfig(newConfig: Partial<LayerBaseConfig> & Partial<LayerColorConfig>): AbstractTileLayer<T, I>;
get animationDomain(): [number, number] | null | undefined;
setInitialLayerConfig(dataset: KeplerDataset): AbstractTileLayer<T, I>;
getDefaultLayerConfig(props: LayerBaseConfigPartial): LayerBaseConfig & Partial<LayerColorConfig & LayerHeightConfig>;
shouldRenderLayer(): boolean;
updateAnimationDomainByField(channel: string): void;
updateAnimationDomain(domain: [number, number] | null | undefined): void;
updateLayerDomain(datasets: KeplerDatasets, newFilter?: Filter): AbstractTileLayer<T, I>;
updateLayerVisualChannel(dataset: KeplerDataset, channel: string): void;
formatLayerData(datasets: KeplerDatasets, oldLayerData: unknown, animationConfig: AnimationConfig): LayerData;
getGpuFilterValueAccessor({ gpuFilter, animationConfig }: LayerOpts): any;
}