Working on queries to get latest metar airports first
This commit is contained in:
10
ui/src/lib/metar.ts
Normal file
10
ui/src/lib/metar.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Metar } from '@lib/metar.types.ts';
|
||||
import { getRequest } from '@lib/index.ts';
|
||||
|
||||
export async function getMetars({ icaos, force }: { icaos: string[]; force?: boolean }): Promise<Metar[]> {
|
||||
const response = await getRequest('metars', {
|
||||
icaos: icaos,
|
||||
force: force
|
||||
});
|
||||
return response?.json() || {};
|
||||
}
|
||||
@@ -3,12 +3,24 @@ export interface SkyCondition {
|
||||
cloud_base_ft_agl: number;
|
||||
}
|
||||
|
||||
export interface QualityControlFlags {
|
||||
auto: boolean;
|
||||
auto_station_without_precipitation: boolean;
|
||||
auto_station_with_precipication: boolean;
|
||||
maintenance_indicator_on: boolean;
|
||||
corrected: boolean;
|
||||
export interface PeakWind {
|
||||
degrees: number;
|
||||
speed: number;
|
||||
hour?: number;
|
||||
minute?: number;
|
||||
}
|
||||
|
||||
export interface Remarks {
|
||||
peak_wind?: PeakWind;
|
||||
auto_station_type?: string;
|
||||
maintenance_indicator_on?: boolean;
|
||||
rvr_missing?: boolean;
|
||||
precipitation_identifier_information_not_available?: boolean;
|
||||
precipitation_information_not_available?: boolean;
|
||||
freezing_rain_information_not_available?: boolean;
|
||||
thunderstorm_information_not_available?: boolean;
|
||||
visibility_at_secondary_location_not_available?: boolean;
|
||||
sky_condition_at_secondary_location_not_available?: boolean;
|
||||
}
|
||||
|
||||
export interface RunwayVisualRange {
|
||||
@@ -19,25 +31,44 @@ export interface RunwayVisualRange {
|
||||
}
|
||||
|
||||
export interface Metar {
|
||||
icao: string;
|
||||
raw_text: string;
|
||||
station_id: string;
|
||||
observation_time: string;
|
||||
temp_c: number;
|
||||
dewpoint_c: number;
|
||||
wind_dir_degrees: string;
|
||||
wind_speed_kt: number;
|
||||
wind_gust_kt: number;
|
||||
variable_wind_dir_degrees: string;
|
||||
visibility_statute_mi: string;
|
||||
flight_category: 'VFR' | 'MVFR' | 'LIFR' | 'IFR' | 'UNKN';
|
||||
report_modifier?: string;
|
||||
becoming_change?: boolean;
|
||||
no_significant_change?: boolean;
|
||||
temporary_change?: boolean;
|
||||
temp_c?: number;
|
||||
dew_point_c?: number;
|
||||
estimated_humidity?: number;
|
||||
wind_dir_degrees?: string;
|
||||
wind_speed_kt?: number;
|
||||
wind_gust_kt?: number;
|
||||
variable_wind_dir_degrees?: string;
|
||||
visibility_statute_mi?: string;
|
||||
runway_visual_range: RunwayVisualRange[];
|
||||
altim_in_hg: number;
|
||||
sea_level_pressure_mb: number;
|
||||
quality_control_flags: QualityControlFlags;
|
||||
altimeter_in_hg?: number;
|
||||
sea_level_pressure_mb?: number;
|
||||
remarks: Remarks;
|
||||
weather_phenomena: string[];
|
||||
sky_condition: SkyCondition[];
|
||||
flight_category: 'VFR' | 'MVFR' | 'LIFR' | 'IFR' | 'UNKN';
|
||||
three_hr_pressure_tendency_mb: number;
|
||||
max_t_c: number;
|
||||
min_t_c: number;
|
||||
precip_in: number;
|
||||
max_temp_c?: number;
|
||||
min_temp_c?: number;
|
||||
density_altutude?: number;
|
||||
}
|
||||
|
||||
export function getMarkerColor(flightCategory: 'VFR' | 'MVFR' | 'LIFR' | 'IFR' | 'UNKN'): string {
|
||||
switch (flightCategory) {
|
||||
case 'IFR':
|
||||
return '#ff0100';
|
||||
case 'LIFR':
|
||||
return '#7f007f';
|
||||
case 'MVFR':
|
||||
return '#00f';
|
||||
case 'VFR':
|
||||
return '#018000';
|
||||
case 'UNKN':
|
||||
return '#696969';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user