UNPKG

flight-planner

Version:

Plan and route VFR flights

74 lines (73 loc) 3.38 kB
import { AerodromeRepository, MetarStation, WeatherRepository } from "."; import { Aerodrome } from "./airport"; export type FnFetchAerodrome = (icao: string) => Promise<Aerodrome>; export declare class AerodromeService implements AerodromeRepository { private aerodromes; private fetchAerodrome?; constructor(aerodromes?: Aerodrome[]); set fetchFunction(fnFetchAerodrome: FnFetchAerodrome); findByICAO(icao: string): Promise<Aerodrome | undefined>; nearestAerodrome(location: GeoJSON.Position, exclude?: string[]): Promise<Aerodrome | undefined>; } /** * Represents a function that fetches METAR stations. * * @param search - The search string or bounding box to use for fetching METAR stations. * @returns A promise that resolves to an array of METAR stations. */ export type FnFetchMetarStation = (search: string | GeoJSON.BBox) => Promise<MetarStation[]>; export declare class WeatherService implements WeatherRepository { private metarStations; private fetchMetarStation?; /** * Creates a new instance of the WeatherService class. * * @param metarStations - An optional array of METAR stations to initialize the service with. * @returns An instance of the WeatherService class. */ constructor(metarStations?: MetarStation[]); /** * Sets the function to fetch METAR stations. * * @param fnFetchMetarStation - The function to fetch METAR stations. */ set fetchFunction(fnFetchMetarStation: FnFetchMetarStation); /** * Returns the METAR stations. * * @returns An array of METAR stations. */ get stations(): MetarStation[]; /** * Fetches and updates METAR stations based on a search query or bounding box. * Optionally extends the bounding box by a specified distance. * * @param search - The search string or bounding box to use for fetching METAR stations. * @param extend - Optional distance in kilometers to extend the bounding box (only applies when search is a bounding box). * @returns A promise that resolves when the data has been updated. */ fetchAndUpdateStations(search: string | GeoJSON.BBox, extend?: number): Promise<void>; /** * Fetches and updates METAR stations within a circular area around a given location. * * @param location - The center point coordinates as a GeoJSON Point. * @param radius - Radius in kilometers around the center point. Default is 35km. * @returns A promise that resolves when the stations have been fetched and updated. */ fetchStationsByRadius(location: GeoJSON.Point, radius?: number): Promise<void>; /** * Finds a METAR station by its ICAO code. * * @param icao - The ICAO code of the METAR station. * @returns A promise that resolves to the METAR station, or undefined if not found. */ findByICAO(icao: string): MetarStation | undefined; /** * Finds the nearest METAR station to the specified location. * * @param location - The location as a GeoJSON Point to find the nearest station to. * @param exclude - Optional array of station IDs to exclude from the search. * @returns The nearest METAR station, or undefined if none found or if no candidates available. */ findNearestStation(location: GeoJSON.Point, exclude?: string[]): MetarStation | undefined; }