import * as geolib from "geolib";
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";

export const TerminatorsFM = (
  leg: FMTerminalEntry,
  previousFix: NavFix,
  lastCourse: number
): [NavFix?, LineSegment[]?] => {
  const endpoint = geolib.computeDestinationPoint(
    previousFix,
    (10).toMetre(),
    leg.Course.toTrue(previousFix)
  );

  const line = handleTurnAtFix(
    leg.Course.toTrue(previousFix),
    leg.Course.toTrue(previousFix),
    lastCourse,
    previousFix,
    endpoint,
    leg.TurnDir
  );

  return [undefined, line];
};
