flight-planner
Version:
Plan and route VFR flights
70 lines (69 loc) • 3.08 kB
TypeScript
import { MetarStation, Waypoint } from "../index.js";
import { WeatherRepository } from "../repositories/weather.repository.js";
/**
* WeatherService class provides methods to manage and retrieve METAR station data.
*
* @class WeatherService
* @property {RepositoryBase<MetarStation>} [repository] - Optional repository for fetching METAR data.
*/
declare class WeatherService {
private repository;
/**
* Creates a new instance of the WeatherService class.
*
* @param repository - The weather repository for data operations.
* @throws Error if the repository is not provided.
*/
constructor(repository: WeatherRepository);
/**
* Finds a single METAR station by ICAO code.
*
* @param icao - The ICAO code to search for.
* @returns A promise that resolves to a MetarStation object.
* @throws Error if the ICAO code is invalid or if no station is found.
*/
findOne(icao: string): Promise<MetarStation>;
/**
* Finds multiple METAR stations by ICAO codes.
*
* @param icaoCodes - An array of ICAO codes to search for.
* @returns A promise that resolves to an array of MetarStation objects.
* @throws Error if no valid ICAO codes are provided or if no stations are found.
*/
findMany(icaoCodes: string[]): Promise<MetarStation[]>;
/**
* Finds the nearest METAR station to the given location.
*
* @param location - The geographical location to find the nearest METAR station to.
* @param radius - The search radius in kilometers (default is 100 km).
* @param exclude - An optional array of ICAO codes to exclude from the search.
* @returns A promise that resolves to the nearest METAR station.
* @throws Error if no METAR stations are found within the specified radius.
*/
nearest(location: GeoJSON.Position, radius?: number, exclude?: string[]): Promise<MetarStation>;
/**
* Fetches data by geographic location within specified radius.
*
* @param location - The location coordinates [longitude, latitude].
* @param radius - The radius in kilometers (default: 100, max: 1000).
* @returns A promise that resolves to an array of data.
*/
getByLocation(location: GeoJSON.Position, radius?: number): Promise<MetarStation[]>;
/**
* Checks if a METAR station exists.
*
* @param icaoCode - The ICAO code of the METAR station to check.
* @returns A promise that resolves to true if the METAR station exists, false otherwise.
* @throws Error if the ICAO code is invalid.
*/
exists(icaoCode: string): Promise<boolean>;
/**
* Attaches weather data to waypoints based on their ICAO codes.
*
* @param waypoints - An array of waypoints to attach weather data to.
* @param reassign - Whether to reassign existing weather data (default: false).
* @returns A promise that resolves when the operation is complete.
*/
attachWeather(waypoints: Waypoint[], reassign?: boolean): Promise<void>;
}
export default WeatherService;