UNPKG

kepler.gl

Version:

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

128 lines (127 loc) 6.6 kB
/** * Utility functions and constants for processing STAC metadata and other raster tile data */ import { TypedArray } from '@loaders.gl/loader-utils/src/types'; import { StacTypes } from '@kepler.gl/types'; import { DataSourceParams, PresetData, CompleteSTACObject, CompleteSTACAssetLinks, Tile2DHeader, AssetRequestInfo, PresetOption, BandCombination, CategoricalColormapOptions } from './types'; declare type Item = StacTypes.STACItem; declare type Collection = StacTypes.STACCollection; declare type EOBand = StacTypes.Band; declare type DataTypeOfTheBand = StacTypes.DataTypeOfTheBand; export declare const CATEGORICAL_TEXTURE_WIDTH = 256; export declare function isColormapAllowed(bandCombination: BandCombination): boolean; export declare function isRescalingAllowed(bandCombination: BandCombination): boolean; export declare function isFilterAllowed(bandCombination: BandCombination): boolean; /** * Max value for data type * * Values of null might be calculated in runtime */ export declare const dtypeMaxValue: Record<DataTypeOfTheBand, number | null>; /** * Is this a STAC Collection that supports custom searching * TODO: currently this is a custom hack to support Sentinel. It will need to be generalized before being accessible * @param stac STAC object * @return If True, supports searching */ export declare function isSearchableStac(stac: CompleteSTACObject): boolean; /** * Find min and max values throughout a raster band image * @param imageData raster band image data * @returns min and max values throughout the band */ export declare function getImageMinMax(imageData: TypedArray): [number | null, number | null]; /** * Find asset names and band indexes for given commonNames * Right now in Kepler, our available methods of rendering raster data are quite simple. We only allow a user to choose among `presets`, and under the hood we select which data files to load. * @param usableAssets [stac description] * @param commonNames an array of eo:common_name to search within bands * @return Band information or null if not all bands exist */ export declare function getBandIdsForCommonNames(stac: CompleteSTACObject, usableAssets: CompleteSTACAssetLinks, commonNames: string[]): AssetRequestInfo | null; /** * Find the Asset in the STAC object that containing an eo:band with the desired common_name or name * @param assets assets object. Keys should be asset name and values should be asset data * @param name name or common_name in eo:bands * @param property 'name' or 'common_name' * @return name of asset containing desired band, index of band within asset */ export declare function findAssetWithName(assets: CompleteSTACAssetLinks, name: string, property: 'name' | 'common_name'): [string, number] | null; export declare function getRasterStatisticsMinMax(stac: CompleteSTACObject, presetId: string, singleBandInfo: PresetOption['singleBand']): [number | undefined, number | undefined]; export declare function getSingleBandPresetOptions(stac: CompleteSTACObject, singleBandName: string): PresetOption['singleBand']; /** * Calculate viewport-related min and max raster values from loaded tiles * @param tiles - deck.gl tiles * @returns [minPixelValue, maxPixelValue] */ export declare function getMinMaxFromTile2DHeaders(tiles: (Tile2DHeader | null)[]): [number, number]; /** * Get loading params * @param stac STAC Object * @param preset Preset for display * @return Parameters for loading data */ export declare function getDataSourceParams(stac: CompleteSTACObject, presetId: string, presetOptions?: PresetOption): DataSourceParams | null; /** * Get Bounding Box of STAC object * @param stac * @return bounding box */ export declare function getSTACBounds(stac: Item | Collection): number[] | null; /** * Get all eo:band objects from STAC object * @param stac STAC object * @return array of eo:band objects or null */ export declare function getEOBands(stac: CompleteSTACObject): EOBand[] | null; /** * Filter presets by those that can be used with the given stac item * Each preset has a commonNames key, which is a list of eo `common_name` values. Some STAC items * may not have assets that span all of these combinations of `common_name`, so this filters the * input array. * @param stac STAC object * @param presetData object with requirements for each preset * @return An array of preset option ids that can be used with the given STAC item */ export declare function filterAvailablePresets(stac: CompleteSTACObject, presetData: Record<string, PresetData>): string[] | null; export declare function getAssets(stac: CompleteSTACObject): CompleteSTACAssetLinks; /** * Find usable assets in main assets object * The `assets` object can point to many different objects, including original XML or JSON metadata, * thumbnails, etc. These aren't usable as image data in Studio. * @param stac STAC object * @return asset mapping including only assets usable in Studio */ export declare function getUsableAssets(stac: CompleteSTACObject): CompleteSTACAssetLinks; /** * Get the max number of requests the TileLayer should be able to send at once * With HTTP 1 under Chrome, you can make a max of 6 concurrent requests per domain, so this number * should be 6 * number of domains tiles are loaded from. * @param stac STAC object * @return Number of permissible concurrent requests */ export declare function getMaxRequests(rasterTileServerUrls: []): number; /** * Determine if two axis-aligned boxes intersect * @param bbox1 axis-aligned box * @param bbox2 axis-aligned box * @return true if boxes intersect */ export declare function bboxIntersects(bbox1: number[], bbox2: number[]): boolean; /** * Compute zRange of tiles in viewport. * Derived from https://github.com/visgl/deck.gl/blob/8d824a4b836fee3bfebe6fc962e0f03d8c1dbd0d/modules/geo-layers/src/terrain-layer/terrain-layer.js#L173-L196 * @param tiles Array of tiles in current viewport */ export declare function computeZRange(tiles: (Tile2DHeader | null)[] | null): [number, number] | null; /** * Create RGBA bitmap array for categorical color scale from categorical color map * @param categoricalOptions - color map configuration and min-max values of categorical band * @returns typed array with bitmap data */ export declare function generateCategoricalBitmapArray(categoricalOptions: CategoricalColormapOptions): Uint8Array | null; export declare function timeRangeToStacTemporalInterval(stac: StacTypes.STACCollection, startDate: string, endDate: string): { startDate: string; endDate: string; }; export {};