UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

71 lines (70 loc) 2.14 kB
import { RowData, Field } from '@kepler.gl/types'; export declare const ACCEPTED_ANALYZER_TYPES: any[]; /** * Getting sample data for analyzing field type. */ export declare function getSampleForTypeAnalyze({ fields, rows, sampleCount }: { fields: string[]; rows: unknown[][] | RowData; sampleCount?: number; }): RowData; /** * 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; /** * 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/common-utils'; * 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[]; };