flight-planner
Version:
Plan and route VFR flights
111 lines (110 loc) • 4.26 kB
TypeScript
import { Cloud, Wind } from './metar.types.js';
/**
* Represents a wind vector with angle and decomposed components.
*
* @interface WindVector
* @property {number} angle - The angle of the wind in degrees.
* @property {number} headwind - The headwind component of the wind vector.
* @property {number} crosswind - The crosswind component of the wind vector.
*/
export interface WindVector {
angle: number;
headwind: number;
crosswind: number;
}
/**
* Calculates the wind vector relative to the given true track.
*
* @param wind - An object representing the wind, containing direction and speed.
* @param trueTrack - The current true track in degrees.
* @returns An object containing the wind angle, headwind, and crosswind components.
*/
export declare const calculateWindVector: (wind: Wind, trueTrack: number) => WindVector;
/**
* Calculates True Airspeed.
*
* @param indicatedAltitudeFt Indicated altitude in feet.
* @param qnhHpa Altimeter setting in hPa.
* @param oatCelsius Outside Air Temperature in Celsius.
* @param kcas Knots Calibrated Airspeed (or KEAS if compressibility is negligible).
* @returns Knots True Airspeed.
*/
export declare const calculateTrueAirspeed: (indicatedAltitudeFt: number, qnhHpa: number, oatCelsius: number, kcas: number) => number;
/**
* Calculates the wind correction angle for the given wind, true track, and airspeed.
*
* @param wind - An object representing the wind, containing direction and speed.
* @param trueTrack - The true track in degrees.
* @param airSpeed - The airspeed in knots.
* @returns The wind correction angle in degrees.
*/
export declare const calculateWindCorrectionAngle: (wind: Wind, trueTrack: number, airSpeed: number) => number;
/**
* Calculates the groundspeed for the given wind, airspeed, and heading.
*
* @param wind - An object representing the wind, containing degrees and speed.
* @param airSpeed - The airspeed in knots.
* @param heading - The heading in degrees.
* @returns The groundspeed in knots.
*/
export declare const calculateGroundspeed: (wind: Wind, airSpeed: number, heading: number) => number;
/**
* Creates a bounding box around a geographic center point with a specified radius.
*
* This function generates a circular polygon around the center point and returns
* its bounding box, which can be used for geographic searches or spatial queries.
*
* @param center - The center point as a GeoJSON Position [longitude, latitude]
* @param radiusKm - The radius in kilometers to extend from the center point
* @returns A GeoJSON BBox [minLon, minLat, maxLon, maxLat] encompassing the circular area
*
* @example
* ```typescript
* // Create a bounding box 50km around Amsterdam
* const bbox = createBoundingBox([4.9041, 52.3676], 50);
* // Returns: [4.254, 51.918, 5.554, 52.817]
* ```
*/
export declare const createBoundingBox: (center: GeoJSON.Position, radiusKm: number) => GeoJSON.BBox;
/**
* Sorts an array of clouds by their height in ascending order.
*
* @param clouds - The array of clouds to sort
* @returns The sorted array of clouds
*/
export declare const sortClouds: (clouds: Cloud[]) => Cloud[];
/**
* Checks if the given string is a valid ICAO code.
*
* @param icao - The string to check
* @returns True if the string is a valid ICAO code, false otherwise
*/
export declare const isICAO: (icao: string) => boolean;
/**
* Normalizes the given ICAO code to uppercase.
*
* @param icao - The ICAO code to normalize
* @returns The normalized ICAO code
*/
export declare const normalizeICAO: (icao: string) => string;
/**
* Checks if the given string is a valid IATA code.
*
* @param iata - The string to check
* @returns True if the string is a valid IATA code, false otherwise
*/
export declare const isIATA: (iata: string) => boolean;
/**
* Normalizes the given IATA code to uppercase.
*
* @param iata - The IATA code to normalize
* @returns The normalized IATA code
*/
export declare const normalizeIATA: (iata: string) => string;
/**
* Capitalizes the first letter of each word in a string
*
* @param text - The input text to capitalize
* @returns The text with the first letter of each word capitalized
*/
export declare const capitalizeWords: (text: string) => string;