import type L from "leaflet"; import type { WxLayerOptions, WxLngLat, WxRasterData, WxRequestInit, WxTileInfo } from "@metoceanapi/wxtiles-common/types"; import { type XYZ } from "@metoceanapi/wxtiles-common/utils/wxtools"; import type { WxLayer as InnerWxLayer } from "@metoceanapi/wxtiles-common/wxlayer/wxlayer"; import type { WxDataSetManager } from "../wxAPI/WxDataSetManager"; import { type FrameworkOptions, FrameworkParentClass } from "./wxsourcetypes"; export type WxLayer = InnerWxLayer; export declare const WxLayerBaseImplementation: { new (...args: any[]): { _animation: boolean; _animationSeed: number; _redrawRequested?: Promise | undefined; readonly wxdatasetManager: import("@metoceanapi/wxtiles-common/managers/BaseDatasetManager").BaseDatasetManager; getCurrentVariableMeta(): import("@metoceanapi/wxtiles-common/types").WxVariableMeta; getDatasetMeta(): import("@metoceanapi/wxtiles-common/types").WxDatasetMeta; getMetadata(): import("@metoceanapi/wxtiles-common/types").WxVariableMeta; getVariablesNames(): import("@metoceanapi/wxtiles-common/types").WxLayerVarsNames; clearCache(): void; getCache(): import("@metoceanapi/wxtiles-common/types").WxRasterDataCache; getCurrentStyleObjectCopy(): import("@metoceanapi/wxtiles-common/utils/wxtools").WxColorStyleStrict; getTime(): string; getAllTimes(): string[]; setTime(time?: import("@metoceanapi/wxtiles-common/types").WxDate | undefined, requestInit?: WxRequestInit | undefined, redraw?: boolean | undefined): Promise; preloadTime(time: import("@metoceanapi/wxtiles-common/types").WxDate, requestInit?: WxRequestInit | undefined): Promise; startAnimation(): void; stopAnimation(): Promise; setCoarseLevel(level?: number): Promise; unsetCoarseLevel(): Promise; setStyleByName(wxstyleName: string, reload?: boolean): Promise; updateCurrentStyleObject(style?: import("@metoceanapi/wxtiles-common/utils/wxtools").WxColorStyleWeak | undefined, reload?: boolean, requestInit?: WxRequestInit | undefined): Promise; _redrawTiles(): Promise; _reloadVisible(_requestInit?: WxRequestInit | undefined, _redraw?: boolean | undefined): Promise; coveringTiles(): XYZ[]; update(): void; _needUpdateDSManager: boolean; _loadTileHelper(coords: XYZ, requestInit?: WxRequestInit | undefined): Promise; id: string; _layer: InnerWxLayer; fire(type: T, data: import("@metoceanapi/wxtiles-common/types").WxEventType[T]): void; }; } & { new (options: FrameworkOptions, wxLayerOptions: WxLayerOptions): FrameworkParentClass; extend(props: any): (new (...args: any[]) => any) & typeof L.Class; include(props: any): any; mergeOptions(props: any): any; addInitHook(initHookFn: () => void): any; addInitHook(methodName: string, ...args: any[]): any; callInitHooks(): void; }; /** * A class to represent a single tile in the WxTileSource layer. * Each tile contains its coordinates, a drawing context, and optional raster data. **/ declare class WxTile { coords: XYZ; ctx: CanvasRenderingContext2D; raster_data: WxRasterData | null; /** * Creates a WxTile instance. * @param {XYZ} coords - The tile's XYZ coordinates. * @param {CanvasRenderingContext2D} ctx - The 2D canvas rendering context for the tile. * @param {WxRasterData | null} raster_data - Raster data for the tile. Can be null if no data is available. */ constructor(coords: XYZ, ctx: CanvasRenderingContext2D, raster_data: WxRasterData | null); /** * Draws the tile content on its canvas. * @param {HTMLCanvasElement | null} [canvas] - The canvas containing pre-rendered content to be drawn. */ draw(canvas?: HTMLCanvasElement | null): void; } /** * A custom layer source implementation for displaying weather data tiles. * This class integrates with Leaflet and the WxTiles API to fetch, display, and manage tiles * representing weather data such as temperature, wind speed, or other meteorological variables. * * @example * ```ts * async function initializeWxSource() { * try { * const wxapi = new WxAPI({ dataServerURL: 'http://dataserver.com' }); * const datasetName = 'gfs.global'; * const variable = 'air.temperature.at-2m'; * * // Create a dataset manager * const wxDatasetManager = await wxapi.createDatasetManager(datasetName); * * // Create a layer source * const wxsource = wxdatasetManager.createSourceLayer( * { variable }, * { attribution: 'WxTiles' }, * ); * * console.log('WxTileSource initialized:', wxSource); * } catch (error) { * console.error('Error initializing WxTileSource:', error); * } * } * * initializeWxSource(); * ``` * * Alternatively, use {@link WxDataSetManager.createSourceLayer} to simplify the creation process. */ export declare class WxTileSource extends WxLayerBaseImplementation { /** * Initializes a new WxTileSource instance. * * @param {WxLayerOptions} wxlayeroptions - Configuration options for the WxLayerBaseImplementation. * @param {FrameworkOptions} frameworkOptions - Framework-specific options. */ constructor(wxlayeroptions: WxLayerOptions, frameworkOptions: FrameworkOptions); /** * Retrieves information about a specific point on the map. * * @param {WxLngLat} lnglat - The longitude and latitude of the point. * @param {any} anymap - The map instance. This is kept generic to allow flexibility. * @returns {WxTileInfo | undefined} Information about the tile at the specified point, or undefined if unavailable. */ getLayerInfoAtLatLon(lnglat: WxLngLat, anymap: any): WxTileInfo | undefined; /** * Reloads the visible tiles on the map. * This method is typically used during animations or time-based updates. * * @param {WxRequestInit} [requestInit] - Request options such as signals for aborting requests. */ _reloadVisible(requestInit?: WxRequestInit): Promise; /** * Retrieves the coordinates of tiles currently visible on the map. * @returns {XYZ[]} An array of tile coordinates. */ coveringTiles(): XYZ[]; /** * Redraws the tiles currently visible on the map. * This ensures that updated raster data or animations are displayed. */ update(): void; /** * Iterates over all tiles and applies a callback function. * @param {(wxtile: WxTile) => T} func - The callback function to execute for each tile. * @param {string} name - A name for logging purposes. * @returns {T[]} An array of results from the callback function. */ protected _ForEachWxTile(func: (wxtile: WxTile) => T, name: string): T[]; /** * Creates a new tile element and loads its data. * * @param {L.Coords} coords - The coordinates of the tile to load. * @param {L.DoneCallback} done - A callback function to signal completion. * @returns {HTMLElement} The created canvas element representing the tile. */ protected createTile(coords: L.Coords, done: L.DoneCallback): HTMLElement; /** * Cleans up the layer when it is removed from a map. * @param {L.Map} map - The map instance. * @returns {this} The current WxTileSource instance. */ onRemove(map: L.Map): this; } export {};