import { DataFilterExtension } from '@deck.gl/extensions'; import { PointLabelLayer } from '@deck.gl/carto'; import { ALL_FIELD_TYPES, SCALE_TYPES } from 'constants/default-settings'; import { ColorRange } from 'constants/color-ranges'; import { LayerVisConfig, LayerVisConfigSettings } from './layer-factory'; import { RGBColor, RGBAColor, MapState, Filter, Datasets, ValueOf, NestedPartial } from 'reducers'; import { LayerTextLabel, ColorUI } from './layer-factory'; import { KeplerTable } from '../utils'; import { DataContainerInterface } from 'utils/table-utils/data-container-interface'; import { Field, GpuFilter } from 'utils/table-utils/kepler-table'; import React from 'react'; export type LayerColumn = { value: string | null; fieldIdx: number; optional?: boolean; }; export type LayerColumns = { [key: string]: LayerColumn; }; export type VisualChannelDomain = number[] | string[]; export type VisualChannelField = Field | null; export type VisualChannelScale = keyof typeof SCALE_TYPES; export type LayerBaseConfig = { dataId: string | null; label: string; color: RGBColor; columns: LayerColumns; isVisible: boolean; isConfigActive: boolean; highlightColor: RGBColor | RGBAColor; hidden: boolean; visConfig: LayerVisConfig; textLabel: LayerTextLabel[]; colorUI: { color: ColorUI; colorRange: ColorUI; }; animation: { enabled: boolean; domain?: null; }; }; export type LayerColorConfig = { colorField: VisualChannelField; colorDomain: VisualChannelDomain; colorScale: VisualChannelScale; }; export type LayerSizeConfig = { sizeDomain: VisualChannelDomain; sizeScale: VisualChannelScale; sizeField: VisualChannelField; }; export type LayerHeightConfig = { heightField: VisualChannelField; heightDomain: VisualChannelDomain; heightScale: VisualChannelScale; }; export type LayerStrokeColorConfig = { strokeColorField: VisualChannelField; strokeColorDomain: VisualChannelDomain; strokeColorScale: VisualChannelScale; }; export type LayerCoverageConfig = { coverageField: VisualChannelField; coverageDomain: VisualChannelDomain; coverageScale: VisualChannelScale; }; export type LayerRadiusConfig = { radiusField: VisualChannelField; radiusDomain: VisualChannelDomain; radiusScale: VisualChannelScale; }; export type LayerWeightConfig = { weightField: VisualChannelField; }; export type VisualChannels = { [key: string]: VisualChannel; }; export type VisualChannelAggregation = 'colorAggregation' | 'sizeAggregation'; export type VisualChannel = { property: string; field: string; scale: string; domain: string; range: string; key: string; channelScaleType: string; nullValue?: any; defaultMeasure?: any; accessor?: string; condition?: (config: any) => boolean; getAttributeValue?: (config: any) => (d: any) => any; defaultValue?: any; fixed?: any; supportedFieldTypes?: Array; aggregation?: VisualChannelAggregation; }; export type VisualChannelDescription = { label: string; measure: string; }; export type ColumnPairs = { [key: string]: { pair: string; fieldPairKey: string; }; }; type ColumnValidator = (column: LayerColumn, columns: LayerColumns, allFields: Field[]) => boolean; export type UpdateTriggers = { [key: string]: UpdateTrigger; }; export type UpdateTrigger = { [key: string]: {}; }; export type LayerBounds = [number, number, number, number]; export type FindDefaultLayerPropsReturnValue = { props: any[]; foundLayers?: any[]; }; /** * Approx. number of points to sample in a large data set */ export declare const LAYER_ID_LENGTH = 6; declare const defaultDataAccessor: (dc: any) => (d: any) => any; declare const defaultGetFieldValue: (field: any, d: any) => any; export declare const OVERLAY_TYPE: { deckgl: "deckgl"; mapboxgl: "mapboxgl"; }; export declare const layerColors: RGBColor[]; export declare const colorMaker: Generator; declare class Layer { id: string; meta: {}; visConfigSettings: { [key: string]: ValueOf; }; config: LayerBaseConfig; _oldDataUpdateTriggers: any; legendSettings: Record; _interactivitySettings: Record; constructor(props?: { id?: string; } & Partial); get layerIcon(): React.ElementType; get overlayType(): keyof typeof OVERLAY_TYPE; get type(): string | null; get name(): string; get isAggregated(): boolean; get requiredLayerColumns(): string[]; get optionalColumns(): string[]; get noneLayerDataAffectingProps(): string[]; get visualChannels(): VisualChannels; get columnValidators(): { [key: string]: ColumnValidator; }; get columnPairs(): ColumnPairs | null; get defaultPointColumnPairs(): ColumnPairs; get defaultLinkColumnPairs(): ColumnPairs; /** * Return a React component for to render layer instructions in a modal * @returns {object} - an object * @example * return { * id: 'iconInfo', * template: IconInfoModal, * modalProps: { * title: 'How to draw icons' * }; * } */ get layerInfoModal(): any; get interactivitySettings(): any; set interactivitySettings(interactivitySettings: any); get hasTooltip(): boolean; get hasInteractivity(): boolean; static findDefaultLayerProps(dataset: KeplerTable, foundLayers?: any[]): FindDefaultLayerPropsReturnValue; /** * Given a array of preset required column names * found field that has the same name to set as layer column * * @param {object} defaultFields * @param {object[]} allFields * @returns {object[] | null} all possible required layer column pairs */ static findDefaultColumnField(defaultFields: any, allFields: any): any[]; static getAllPossibleColumnParis(requiredColumns: any): any[]; static hexToRgb(c: any): RGBColor; getDefaultLayerConfig(props?: Partial): LayerBaseConfig & Partial; /** * Get the description of a visualChannel config * @param key * @returns */ getVisualChannelDescription(key: string): VisualChannelDescription; /** * Assign a field to layer column, return column config * @param key - Column Key * @param field - Selected field * @returns {{}} - Column config */ assignColumn(key: string, field: Field): LayerColumns; /** * Assign a field pair to column config, return column config * @param key - Column Key * @param pair - field Pair * @returns {object} - Column config */ assignColumnPairs(key: any, pair: any): { [x: string]: any; }; /** * Calculate a radius zoom multiplier to render points, so they are visible in all zoom level * @param {object} mapState * @param {number} mapState.zoom - actual zoom * @param {number | void} mapState.zoomOffset - zoomOffset when render in the plot container for export image * @returns {number} */ getZoomFactor({ zoom, zoomOffset }: { zoom: any; zoomOffset?: number; }): number; /** * Calculate a elevation zoom multiplier to render points, so they are visible in all zoom level * @param {object} mapState * @param {number} mapState.zoom - actual zoom * @param {number | void} mapState.zoomOffset - zoomOffset when render in the plot container for export image * @returns {number} */ getElevationZoomFactor({ zoom, zoomOffset }: { zoom: number; zoomOffset?: number; }): number; formatLayerData(datasets: Datasets, oldLayerData?: any): {}; renderLayer(...args: any[]): any[]; getHoverData(object: any, dataContainer: DataContainerInterface, fields: Field[]): import("../utils/table-utils/data-row").DataRow; /** * When change layer type, try to copy over layer configs as much as possible * @param configToCopy - config to copy over * @param visConfigSettings - visConfig settings of config to copy */ assignConfigToLayer(configToCopy: any, visConfigSettings: any): void; copyLayerConfig(currentConfig: any, configToCopy: any, { shallowCopy, notToCopy }?: { shallowCopy?: string[]; notToCopy?: string[]; }): {}; registerVisConfig(layerVisConfigs: { [key: string]: keyof LayerVisConfigSettings | ValueOf; }): void; getLayerColumns(): {}; updateLayerConfig(newConfig: Partial): Layer; updateLayerVisConfig(newVisConfig: any): this; updateLayerColorUI(prop: string, newConfig: NestedPartial): Layer; updateCustomPalette(newConfig: any, previous: any, prop: any): void; /** * if open dropdown and prop is color range * Automatically set colorRangeConfig's step, reversed and type * @param {*} newConfig * @param {*} prop */ updateColorUIByColorRange(newConfig: any, prop: any): void; updateColorRangeByColorUI(newConfig: any, previous: any, prop: any): void; updateColorMap(prop: any, colorMap: any, colorRange: any): any; updateCategoryColorMap(colorMap: any, domain: any, colorRange: any): any; updateNumericColorMap(colorMap: any, domain: any, update: any): any; /** * Check whether layer has all columns * @returns yes or no */ hasAllColumns(): boolean; /** * Check whether layer has data * * @param {Array | Object} layerData * @returns {boolean} yes or no */ hasLayerData(layerData: any): boolean; isValidToSave(): boolean; shouldRenderLayer(data: any): boolean; getColorScale(colorScale: string, colorDomain: VisualChannelDomain, colorRange: ColorRange): any; getCustomMarkersScale(range: any, fallbackIcon: any): (() => any) | import("d3-scale").ScaleOrdinal; /** * Mapping from visual channels to deck.gl accesors * @param {Object} param Parameters * @param {Function} param.dataAccessor Access kepler.gl layer data from deck.gl layer * @param {import('utils/table-utils/data-container-interface').DataContainerInterface} param.dataContainer DataContainer to use use with dataAccessor * @return {Object} attributeAccessors - deck.gl layer attribute accessors */ getAttributeAccessors({ dataAccessor, dataContainer }: { dataAccessor?: typeof defaultDataAccessor; dataContainer: DataContainerInterface; }): { [key: string]: any; }; getVisChannelScale(scale: string, domain: VisualChannelDomain, range: any, fixed?: boolean): () => any | null; /** * Get longitude and latitude bounds of the data. * @param {import('utils/table-utils/data-container-interface').DataContainerInterface} dataContainer DataContainer to calculate bounds for. * @param {(d: {index: number}, dc: import('utils/table-utils/data-container-interface').DataContainerInterface) => number[]} getPosition Access kepler.gl layer data from deck.gl layer * @return {number[]|null} bounds of the data. */ getPointsBounds(dataContainer: any, getPosition: any): number[]; getChangedTriggers(dataUpdateTriggers: any): false | { [key: string]: true; }; getEncodedChannelValue({ channel, scale, data, field, dataContainer, aggregation, nullValue, getValue }: { channel: string; scale: (...value: any[]) => any; data: any[]; field: VisualChannelField; dataContainer: any; aggregation: any; nullValue?: RGBAColor; getValue?: typeof defaultGetFieldValue; }): any; updateMeta(meta: any): void; updateLayerLegend(settings: any): void; getDataUpdateTriggers({ filteredIndex, id, allData }: KeplerTable): any; updateData(datasets: any, oldLayerData: any): { data?: undefined; triggerChanged?: undefined; } | { data: any[]; triggerChanged: boolean | { [key: string]: true; }; }; /** * Update styled fields to match ones from new dataset. * * @param {Object} dataset */ updateVisualChannelFields(dataset: any): void; /** * helper function to update one layer domain when state.data changed * if state.data change is due ot update filter, newFiler will be passed * called by updateAllLayerDomainData * @param datasets * @param newFilter * @returns layer */ updateLayerDomain(datasets: Datasets, newFilter?: Filter): Layer; getDataset(datasets: any): any; /** * Validate visual channel field and scales based on supported field & scale type * @param channel */ validateVisualChannel(channel: string): void; /** * Validate field type based on channelScaleType */ validateFieldType(channel: string): void; /** * Validate scale type based on aggregation */ validateScale(channel: any): void; /** * Get scale options based on current field * @param {string} channel * @returns {string[]} */ getScaleOptions(channel: any): any; updateLayerVisualChannel(dataset: KeplerTable, channel: string): void; getVisualChannelUpdateTriggers(): UpdateTriggers; calculateLayerDomain(dataset: any, visualChannel: any): any; updateHexColorDomain(dataset: any): this; calculateHexColumnLegend(datasets: any): void; hasHoveredObject(objectInfo: any): any; isLayerHovered(objectInfo: any): boolean; getRadiusScaleByZoom(mapState: MapState, fixedRadius?: boolean): number; getRadiusScale(): any; getMaxMarkerSize(): number; shouldCalculateLayerData(props: string[]): boolean; getBrushingExtensionProps(interactionConfig: any, brushingTarget?: any): { autoHighlight: boolean; brushingRadius: number; brushingTarget: any; brushingEnabled: any; }; getDefaultDeckLayerProps({ idx, gpuFilter, mapState, visible, maskPolygon }: { idx: number; gpuFilter: GpuFilter; mapState: MapState; visible: boolean; maskPolygon: any; }): { id: string; idx: number; coordinateSystem: 1; pickable: boolean; wrapLongitude: boolean; parameters: { depthTest: boolean; }; hidden: boolean; visibilityByZoom: any; opacity: any; highlightColor: RGBAColor | RGBColor; extensions: (import("@deck.gl/extensions").MaskExtension | DataFilterExtension)[]; filterRange: number[][]; visible: boolean; maskId: string; }; getDefaultHoverLayerProps(): { id: string; pickable: boolean; wrapLongitude: boolean; coordinateSystem: 1; }; renderTextLabelLayer({ getPosition, getRadius, radiusScale, updateTriggers, sharedProps }: { getPosition: any; getRadius: any; radiusScale: any; updateTriggers: any; sharedProps: any; }, renderOpts: any): PointLabelLayer[]; /** * Create deck.gl `IconLayer` "autoPack" mode accessor for custom markers. * * @param {*} iconUrlAccessor deck.gl accessor (or value) that resolves to URL of icon for given row * @returns deck.gl accessor that returns UnpackedIcon ready to consume by IconLayer */ getCustomMarkerIconAccessor(iconUrlAccessor: any, mask?: boolean): (d: any) => { id: string; url: any; width: number; height: number; mask: boolean; }; calculateDataAttribute(keplerTable: KeplerTable, getPosition: any): any; updateLayerMeta(dataContainer: DataContainerInterface, getPosition: any): void; getPositionAccessor(dataContainer?: DataContainerInterface): (...args: any[]) => any; getHexColumn(range: any): any; isColoredByColorColumn(range: any): any; } export default Layer;