kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
135 lines (134 loc) • 5.58 kB
TypeScript
import { TooltipFormat } from '@kepler.gl/constants';
import { Field, Millisecond, ProtoDatasetField } from '@kepler.gl/types';
export declare type FieldFormatter = (value: any, field?: ProtoDatasetField) => string;
export declare const MAX_LATITUDE = 89.9;
export declare const MIN_LATITUDE = -89.9;
export declare const MAX_LONGITUDE = 180;
export declare const MIN_LONGITUDE = -180;
/**
* Validates a latitude value.
* Ensures that the latitude is within the defined minimum and maximum latitude bounds.
* If the value is out of bounds, it returns the nearest bound value.
* @param latitude - The latitude value to validate.
* @returns The validated latitude value.
*/
export declare function validateLatitude(latitude: number | undefined): number;
/**
* Validates a longitude value.
* Ensures that the longitude is within the defined minimum and maximum longitude bounds.
* If the value is out of bounds, it returns the nearest bound value.
* @param longitude - The longitude value to validate.
* @returns The validated longitude value.
*/
export declare function validateLongitude(longitude: number | undefined): number;
/**
* Validates a coordinate value.
* Ensures that the value is within the specified minimum and maximum bounds.
* If the value is out of bounds, it returns the nearest bound value.
* @param value - The coordinate value to validate.
* @param minValue - The minimum bound for the value.
* @param maxValue - The maximum bound for the value.
* @returns The validated coordinate value.
*/
export declare function validateCoordinate(value: number, minValue: number, maxValue: number): number;
/**
* simple getting unique values of an array
*
* @param values
* @returns unique values
*/
export declare function unique<T>(values: T[]): T[];
export declare function getLatLngBounds(points: number[][], idx: number, limit: [number, number]): [number, number] | null;
export declare function clamp([min, max]: [number, number], val?: number): number;
export declare function getSampleData(data: any, sampleSize?: number, getValue?: (d: any) => any): any[];
/**
* Convert different time format to unix milliseconds
*/
export declare function timeToUnixMilli(value: string | number | Date, format: string): Millisecond | null;
/**
* Whether d is a number, this filtered out NaN as well
*/
export declare function isNumber(d: unknown): d is number;
/**
* whether object has property
* @param {string} prop
* @returns {boolean} - yes or no
*/
export declare function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
export declare function numberSort(a: number, b: number): number;
export declare function getSortingFunction(fieldType: string): typeof numberSort | undefined;
/**
* round number with exact number of decimals
* return as a string
*/
export declare function preciseRound(num: number, decimals: number): string;
/**
* round a giving number at most 4 decimal places
* e.g. 10 -> 10, 1.12345 -> 1.2345, 2.0 -> 2
*/
export declare function roundToFour(num: number): number;
/**
* get number of decimals to round to for slider from step
* @param step
* @returns- number of decimal
*/
export declare function getRoundingDecimalFromStep(step: number): number;
/**
* If marks is provided, snap to marks, if not normalize to step
* @param val
* @param minValue
* @param step
* @param marks
*/
export declare function normalizeSliderValue(val: number, minValue: number | undefined, step: number, marks?: number[] | null): number;
/**
* round the value to step for the slider
* @param minValue
* @param step
* @param val
* @returns - rounded number
*/
export declare function roundValToStep(minValue: number | undefined, step: number, val: number): number;
/**
* Get the value format based on field and format options
* Used in render tooltip value
*/
export declare const defaultFormatter: FieldFormatter;
export declare const floatFormatter: (v: any) => string;
/**
* Transforms a WKB in Uint8Array form into a hex WKB string.
* @param uint8Array WKB in Uint8Array form.
* @returns hex WKB string.
*/
export declare function uint8ArrayToHex(data: Uint8Array): string;
export declare const FIELD_DISPLAY_FORMAT: {
[key: string]: FieldFormatter;
};
/**
* Parse field value and type and return a string representation
*/
export declare const parseFieldValue: (value: any, type: string, field?: Field) => string;
/**
* Get the value format based on field and format options
* Used in render tooltip value
* @param format
* @param field
*/
export declare function getFormatter(format?: string | Record<string, string> | null, field?: Field): FieldFormatter;
export declare function getColumnFormatter(field: Pick<Field, 'type'> & Partial<Pick<Field, 'format' | 'displayFormat'>>): FieldFormatter;
export declare function applyValueMap(format: any): (v: any) => any;
export declare function applyDefaultFormat(tooltipFormat: TooltipFormat): (v: any) => string;
export declare function getBooleanFormatter(format: string): FieldFormatter;
export declare function applyCustomFormat(format: any, field: {
type?: string;
}): FieldFormatter;
export declare function formatNumber(n: number, type?: string): string;
/**
* Convert a formatted number from string back to number
*/
export declare function reverseFormatNumber(str: string): number;
/**
* Format epoch milliseconds with a format string
* @type timezone
*/
export declare function datetimeFormatter(timezone?: string | null): (format?: string) => (ts: number) => string;