kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
117 lines (116 loc) • 3.93 kB
TypeScript
import { ProcessorResult, RGBColor, RowData, Field, FieldPair, TooltipFields, ProtoDataset } from '@kepler.gl/types';
import { TooltipFormat } from '@kepler.gl/constants';
export declare const datasetColorMaker: Generator<RGBColor, any, unknown>;
/**
* Choose a field to use as the default color field of a layer.
*
* The heuristic is:
*
* First, exclude fields that are on the exclusion list and don't
* have names that suggest they contain metrics. Also exclude
* field names that are blank.
*
* Next, look for a field that is of real type and contains one
* of the preferred names (in order of the preferred names).
*
* Next, look for a field that is of integer type and contains
* one of the preferred names (in order of the preferred names).
*
* Next, look for the first field that is of real type (in order
* of field index).
*
* Next, look for the first field that is of integer type (in
* order of field index).
*
* It's possible no field will be chosen (i.e. because all fields
* are strings.)
*
* @param dataset
*/
export declare function findDefaultColorField({ fields, fieldPairs }: {
fields: Field[];
fieldPairs: FieldPair[];
}): null | Field;
export declare const ACCEPTED_ANALYZER_TYPES: any[];
/**
* Validate input data, adding missing field types, rename duplicate columns
*/
export declare function validateInputData(data: ProtoDataset['data']): ProcessorResult;
/**
* Getting sample data for analyzing field type.
*/
export declare function getSampleForTypeAnalyze({ fields, rows, sampleCount }: {
fields: string[];
rows: unknown[][];
sampleCount?: number;
}): RowData;
/**
* Check if string is a valid Well-known binary (WKB) in HEX format
* https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
*
* @param str input string
* @returns true if string is a valid WKB in HEX format
*/
export declare function isHexWkb(str: string | null): boolean;
/**
* Analyze field types from data in `string` format, e.g. uploaded csv.
* Assign `type`, `fieldIdx` and `format` (timestamp only) to each field
*
* @param data array of row object
* @param fieldOrder array of field names as string
* @returns formatted fields
* @public
* @example
*
* import {getFieldsFromData} from 'kepler.gl/processors';
* const data = [{
* time: '2016-09-17 00:09:55',
* value: '4',
* surge: '1.2',
* isTrip: 'true',
* zeroOnes: '0'
* }, {
* time: '2016-09-17 00:30:08',
* value: '3',
* surge: null,
* isTrip: 'false',
* zeroOnes: '1'
* }, {
* time: null,
* value: '2',
* surge: '1.3',
* isTrip: null,
* zeroOnes: '1'
* }];
*
* const fieldOrder = ['time', 'value', 'surge', 'isTrip', 'zeroOnes'];
* const fields = getFieldsFromData(data, fieldOrder);
* // fields = [
* // {name: 'time', format: 'YYYY-M-D H:m:s', fieldIdx: 1, type: 'timestamp'},
* // {name: 'value', format: '', fieldIdx: 4, type: 'integer'},
* // {name: 'surge', format: '', fieldIdx: 5, type: 'real'},
* // {name: 'isTrip', format: '', fieldIdx: 6, type: 'boolean'},
* // {name: 'zeroOnes', format: '', fieldIdx: 7, type: 'integer'}];
*
*/
export declare function getFieldsFromData(data: RowData, fieldOrder: string[]): Field[];
/**
* pass in an array of field names, rename duplicated one
* and return a map from old field index to new name
*
* @param fieldOrder
* @returns new field name by index
*/
export declare function renameDuplicateFields(fieldOrder: string[]): {
allNames: string[];
fieldByIndex: string[];
};
/**
* Convert type-analyzer output to kepler.gl field types
*
* @param aType
* @returns corresponding type in `ALL_FIELD_TYPES`
*/
export declare function analyzerTypeToFieldType(aType: string): string;
export declare function getFieldFormatLabels(fieldType?: string): TooltipFormat[];
export declare function getFormatLabels(fields: TooltipFields[], fieldName: string): TooltipFormat[];