21 lines
834 B
TypeScript
21 lines
834 B
TypeScript
import { SimBrief } from '../types/general';
|
|
|
|
export const ImportFlightPlanKH = (plan: any, maxZFW: number, maxTOW: number, maxFuel: number, isImperial: boolean) => {
|
|
if (!plan) return { type: 'error', message: 'Empty plan' };
|
|
|
|
let convFactor = 1;
|
|
if (plan.params.units === 'kgs' && isImperial) convFactor = 2.20462262185;
|
|
if (plan.params.units === 'lbs' && !isImperial) convFactor = 1 / 2.20462262185;
|
|
|
|
return {
|
|
type: 'data',
|
|
message: {
|
|
plannedZFW: Math.min(maxZFW, Math.round(plan.weights.est_zfw * convFactor)),
|
|
plannedGW: Math.min(maxTOW, Math.round(plan.weights.est_ramp * convFactor)),
|
|
pax: plan.weights.pax_count_actual,
|
|
cargo: Math.round(plan.weights.freight_added * convFactor),
|
|
fuel: Math.min(maxFuel, Math.round(plan.fuel.plan_ramp * convFactor)),
|
|
} as SimBrief,
|
|
};
|
|
};
|