CA/DF
This commit is contained in:
parent
0d797519cb
commit
49788eddab
@ -8,7 +8,7 @@ import L from "leaflet";
|
|||||||
|
|
||||||
const parser = await Parser.instance();
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
const terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653];
|
const terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654];
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
||||||
|
|||||||
@ -14,4 +14,4 @@ fetch = async (path: string) => {
|
|||||||
|
|
||||||
const parser = await Parser.instance();
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
console.log(JSON.stringify(await parser.parse(10480)));
|
console.log(JSON.stringify(await parser.parse(10654)));
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import { TerminatorsTF } from "./terminators/TF.ts";
|
|||||||
import { TerminatorsVI } from "./terminators/VI.ts";
|
import { TerminatorsVI } from "./terminators/VI.ts";
|
||||||
import { TerminatorsVD } from "./terminators/VD.ts";
|
import { TerminatorsVD } from "./terminators/VD.ts";
|
||||||
import { TerminatorsRF } from "./terminators/RF.ts";
|
import { TerminatorsRF } from "./terminators/RF.ts";
|
||||||
|
import { TerminatorsCA } from "./terminators/CA.ts";
|
||||||
|
import { TerminatorsDF } from "./terminators/DF.ts";
|
||||||
|
|
||||||
class Parser {
|
class Parser {
|
||||||
private static _instance: Parser;
|
private static _instance: Parser;
|
||||||
@ -63,6 +65,23 @@ class Parser {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fix New fix
|
||||||
|
* @param line New line
|
||||||
|
* @param options Options for line rendering
|
||||||
|
*/
|
||||||
|
const update = (
|
||||||
|
fix?: NavFix,
|
||||||
|
line?: LineSegment[],
|
||||||
|
options?: Record<string, unknown>
|
||||||
|
) => {
|
||||||
|
if (fix) navFixes.push(fix);
|
||||||
|
if (line) {
|
||||||
|
lineSegments.push({ line, ...options });
|
||||||
|
updateLastCourse(line);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Get Procedure main
|
// Get Procedure main
|
||||||
const terminal = this.terminals.find(({ ID }) => ID === terminalID);
|
const terminal = this.terminals.find(({ ID }) => ID === terminalID);
|
||||||
if (!terminal) throw new Error("Procedure does not exists");
|
if (!terminal) throw new Error("Procedure does not exists");
|
||||||
@ -101,14 +120,18 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
waypoint
|
waypoint
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
break;
|
||||||
lineSegments.push({ line: lineToAdd });
|
}
|
||||||
updateLastCourse(lineToAdd);
|
case "CA": {
|
||||||
}
|
const [fixToAdd, lineToAdd] = TerminatorsCA(
|
||||||
|
leg as CATerminalEntry,
|
||||||
|
previousFix,
|
||||||
|
lastCourse
|
||||||
|
);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CA":
|
|
||||||
case "CD":
|
case "CD":
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
console.error("Unknown TrackCode", leg.TrackCode);
|
||||||
break;
|
break;
|
||||||
@ -119,11 +142,7 @@ class Parser {
|
|||||||
lastCourse,
|
lastCourse,
|
||||||
waypoint
|
waypoint
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CI": {
|
case "CI": {
|
||||||
@ -133,11 +152,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CR": {
|
case "CR": {
|
||||||
@ -146,14 +161,19 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
break;
|
||||||
lineSegments.push({ line: lineToAdd });
|
}
|
||||||
updateLastCourse(lineToAdd);
|
case "DF": {
|
||||||
}
|
const [fixToAdd, lineToAdd] = TerminatorsDF(
|
||||||
|
leg as DFTerminalEntry,
|
||||||
|
previousFix,
|
||||||
|
lastCourse,
|
||||||
|
waypoint
|
||||||
|
);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DF":
|
|
||||||
case "FA":
|
case "FA":
|
||||||
case "FC":
|
case "FC":
|
||||||
case "FD":
|
case "FD":
|
||||||
@ -165,11 +185,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd, isManual: true });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "HA":
|
case "HA":
|
||||||
@ -187,11 +203,7 @@ class Parser {
|
|||||||
lastCourse,
|
lastCourse,
|
||||||
waypoint
|
waypoint
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "TF": {
|
case "TF": {
|
||||||
@ -201,11 +213,7 @@ class Parser {
|
|||||||
lastCourse,
|
lastCourse,
|
||||||
waypoint
|
waypoint
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VA": {
|
case "VA": {
|
||||||
@ -214,11 +222,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VD": {
|
case "VD": {
|
||||||
@ -227,11 +231,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VI": {
|
case "VI": {
|
||||||
@ -241,11 +241,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VM": {
|
case "VM": {
|
||||||
@ -254,11 +250,7 @@ class Parser {
|
|||||||
previousFix,
|
previousFix,
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
if (fixToAdd) navFixes.push(fixToAdd);
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
if (lineToAdd) {
|
|
||||||
lineSegments.push({ line: lineToAdd, isManual: true });
|
|
||||||
updateLastCourse(lineToAdd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VR":
|
case "VR":
|
||||||
|
|||||||
@ -42,7 +42,7 @@ export const generatePerformanceArc = (
|
|||||||
latitude: line.at(-1)![1],
|
latitude: line.at(-1)![1],
|
||||||
longitude: line.at(-1)![0],
|
longitude: line.at(-1)![0],
|
||||||
},
|
},
|
||||||
(Parser.AC_SPEED / 3600).toMetre(),
|
((start.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||||
crsFromOrigin
|
crsFromOrigin
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from "geolib";
|
||||||
import { generateAFArc } from "../pathGenerators/generateAFArc.ts";
|
import { generateAFArc } from "../pathGenerators/generateAFArc.ts";
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
export const TerminatorsAF = (
|
export const TerminatorsAF = (
|
||||||
leg: AFTerminalEntry,
|
leg: AFTerminalEntry,
|
||||||
@ -13,13 +13,7 @@ export const TerminatorsAF = (
|
|||||||
name: waypoint?.Ident ?? undefined,
|
name: waypoint?.Ident ?? undefined,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
39
browser/src/parser/terminators/CA.ts
Normal file
39
browser/src/parser/terminators/CA.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import * as geolib from "geolib";
|
||||||
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
|
import Parser from "../parser.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
|
export const TerminatorsCA = (
|
||||||
|
leg: CATerminalEntry,
|
||||||
|
previousFix: NavFix,
|
||||||
|
lastCourse: number
|
||||||
|
): [NavFix?, LineSegment[]?] => {
|
||||||
|
const targetFix: NavFix = {
|
||||||
|
...geolib.computeDestinationPoint(
|
||||||
|
previousFix,
|
||||||
|
(
|
||||||
|
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
||||||
|
Parser.AC_VS) *
|
||||||
|
(Parser.AC_SPEED / 60)
|
||||||
|
).toMetre(),
|
||||||
|
leg.Course.toTrue(previousFix)
|
||||||
|
),
|
||||||
|
name: leg.Alt,
|
||||||
|
isFlyOver: true,
|
||||||
|
altitude: leg.Alt.parseAltitude(),
|
||||||
|
speed: computeSpeed(leg, previousFix),
|
||||||
|
speedConstraint: leg.SpeedLimit,
|
||||||
|
altitudeConstraint: leg.Alt,
|
||||||
|
};
|
||||||
|
|
||||||
|
const line = handleTurnAtFix(
|
||||||
|
leg.Course.toTrue(previousFix),
|
||||||
|
leg.Course.toTrue(previousFix),
|
||||||
|
lastCourse,
|
||||||
|
previousFix,
|
||||||
|
targetFix,
|
||||||
|
leg.TurnDir
|
||||||
|
);
|
||||||
|
|
||||||
|
return [targetFix, line];
|
||||||
|
};
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import Parser from "../parser.ts";
|
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
export const TerminatorsCF = (
|
export const TerminatorsCF = (
|
||||||
leg: CFTerminalEntry,
|
leg: CFTerminalEntry,
|
||||||
@ -13,13 +13,7 @@ export const TerminatorsCF = (
|
|||||||
name: waypoint?.Ident ?? undefined,
|
name: waypoint?.Ident ?? undefined,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Parser from "../parser.ts";
|
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
||||||
|
|
||||||
export const TerminatorsCI = (
|
export const TerminatorsCI = (
|
||||||
@ -21,13 +21,7 @@ export const TerminatorsCI = (
|
|||||||
)!,
|
)!,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
export const TerminatorsCR = (
|
export const TerminatorsCR = (
|
||||||
leg: CRTerminalEntry,
|
leg: CRTerminalEntry,
|
||||||
@ -18,13 +18,7 @@ export const TerminatorsCR = (
|
|||||||
)!,
|
)!,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
68
browser/src/parser/terminators/DF.ts
Normal file
68
browser/src/parser/terminators/DF.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import * as geolib from "geolib";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
import Parser from "../parser.ts";
|
||||||
|
|
||||||
|
export const TerminatorsDF = (
|
||||||
|
leg: DFTerminalEntry,
|
||||||
|
previousFix: NavFix,
|
||||||
|
lastCourse: number,
|
||||||
|
waypoint?: Waypoint
|
||||||
|
): [NavFix?, LineSegment[]?] => {
|
||||||
|
const targetFix: NavFix = {
|
||||||
|
latitude: leg.WptLat,
|
||||||
|
longitude: leg.WptLon,
|
||||||
|
name: waypoint?.Ident ?? undefined,
|
||||||
|
isFlyOver: leg.IsFlyOver,
|
||||||
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
|
speed: computeSpeed(leg, previousFix),
|
||||||
|
speedConstraint: leg.SpeedLimit,
|
||||||
|
altitudeConstraint: leg.Alt,
|
||||||
|
};
|
||||||
|
|
||||||
|
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||||
|
|
||||||
|
if (previousFix.isFlyOver) {
|
||||||
|
const crsIntoEndpoint = geolib.getGreatCircleBearing(
|
||||||
|
previousFix,
|
||||||
|
targetFix
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if there even is an arc
|
||||||
|
if (crsIntoEndpoint !== lastCourse) {
|
||||||
|
// Turn Dir
|
||||||
|
if (!leg.TurnDir || leg.TurnDir === "E") {
|
||||||
|
let prov = lastCourse - crsIntoEndpoint;
|
||||||
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
|
leg.TurnDir = prov > 0 ? "L" : "R";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate arc
|
||||||
|
while (lastCourse !== crsIntoEndpoint) {
|
||||||
|
if (leg.TurnDir === "R") {
|
||||||
|
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
||||||
|
lastCourse += delta < 1 ? delta : 1;
|
||||||
|
lastCourse = lastCourse.normaliseDegrees();
|
||||||
|
} else {
|
||||||
|
const delta = (lastCourse - crsIntoEndpoint).normaliseDegrees();
|
||||||
|
lastCourse -= delta < 1 ? delta : 1;
|
||||||
|
lastCourse = lastCourse.normaliseDegrees();
|
||||||
|
}
|
||||||
|
|
||||||
|
const arcFix = geolib.computeDestinationPoint(
|
||||||
|
{
|
||||||
|
latitude: line.at(-1)![1],
|
||||||
|
longitude: line.at(-1)![0],
|
||||||
|
},
|
||||||
|
((previousFix.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||||
|
lastCourse
|
||||||
|
);
|
||||||
|
|
||||||
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
|
return [targetFix, line];
|
||||||
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import Parser from "../parser.ts";
|
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
||||||
import { generateRFArc } from "../pathGenerators/generateRFArc.ts";
|
import { generateRFArc } from "../pathGenerators/generateRFArc.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
export const TerminatorsRF = (
|
export const TerminatorsRF = (
|
||||||
leg: RFTerminalEntry,
|
leg: RFTerminalEntry,
|
||||||
@ -15,13 +15,7 @@ export const TerminatorsRF = (
|
|||||||
name: waypoint?.Ident ?? undefined,
|
name: waypoint?.Ident ?? undefined,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from "geolib";
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
import Parser from "../parser.ts";
|
import Parser from "../parser.ts";
|
||||||
|
|
||||||
export const TerminatorsTF = (
|
export const TerminatorsTF = (
|
||||||
@ -14,26 +14,59 @@ export const TerminatorsTF = (
|
|||||||
name: waypoint?.Ident ?? undefined,
|
name: waypoint?.Ident ?? undefined,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const crs = geolib.getGreatCircleBearing(previousFix, targetFix);
|
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||||
const line = handleTurnAtFix(
|
|
||||||
crs,
|
const trackIntoEndpoint = geolib.getGreatCircleBearing(
|
||||||
crs,
|
|
||||||
lastCourse,
|
|
||||||
previousFix,
|
previousFix,
|
||||||
targetFix,
|
targetFix
|
||||||
leg.TurnDir
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (previousFix.isFlyOver) {
|
||||||
|
let crsIntoEndpoint = trackIntoEndpoint;
|
||||||
|
|
||||||
|
// Check if there even is an arc
|
||||||
|
if (crsIntoEndpoint !== lastCourse) {
|
||||||
|
// Turn Dir
|
||||||
|
if (!leg.TurnDir || leg.TurnDir === "E") {
|
||||||
|
let prov = lastCourse - crsIntoEndpoint;
|
||||||
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
|
leg.TurnDir = prov > 0 ? "L" : "R";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate arc
|
||||||
|
do {
|
||||||
|
if (leg.TurnDir === "R") {
|
||||||
|
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
||||||
|
lastCourse += delta < 1 ? delta : 1;
|
||||||
|
lastCourse = lastCourse.normaliseDegrees();
|
||||||
|
} else {
|
||||||
|
const delta = (lastCourse - crsIntoEndpoint).normaliseDegrees();
|
||||||
|
lastCourse -= delta < 1 ? delta : 1;
|
||||||
|
lastCourse = lastCourse.normaliseDegrees();
|
||||||
|
}
|
||||||
|
|
||||||
|
const arcFix = geolib.computeDestinationPoint(
|
||||||
|
{
|
||||||
|
latitude: line.at(-1)![1],
|
||||||
|
longitude: line.at(-1)![0],
|
||||||
|
},
|
||||||
|
((previousFix.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||||
|
lastCourse
|
||||||
|
);
|
||||||
|
|
||||||
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
|
|
||||||
|
crsIntoEndpoint = geolib.getGreatCircleBearing(arcFix, targetFix);
|
||||||
|
} while (crsIntoEndpoint > trackIntoEndpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from "geolib";
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
import Parser from "../parser.ts";
|
import Parser from "../parser.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
||||||
export const TerminatorsVA = (
|
export const TerminatorsVA = (
|
||||||
@ -21,13 +22,7 @@ export const TerminatorsVA = (
|
|||||||
name: leg.Alt,
|
name: leg.Alt,
|
||||||
isFlyOver: true,
|
isFlyOver: true,
|
||||||
altitude: leg.Alt.parseAltitude(),
|
altitude: leg.Alt.parseAltitude(),
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from "geolib";
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
|
|
||||||
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
||||||
export const TerminatorsVD = (
|
export const TerminatorsVD = (
|
||||||
@ -17,13 +17,7 @@ export const TerminatorsVD = (
|
|||||||
name: leg.Distance.toString(),
|
name: leg.Distance.toString(),
|
||||||
isFlyOver: true,
|
isFlyOver: true,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Parser from "../parser.ts";
|
|
||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||||
|
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
||||||
|
|
||||||
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
||||||
@ -22,13 +22,7 @@ export const TerminatorsVI = (
|
|||||||
)!,
|
)!,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: leg.SpeedLimit
|
speed: computeSpeed(leg, previousFix),
|
||||||
? leg.SpeedLimit > Parser.AC_SPEED
|
|
||||||
? Parser.AC_SPEED
|
|
||||||
: leg.SpeedLimit
|
|
||||||
: previousFix.speed
|
|
||||||
? previousFix.speed
|
|
||||||
: Parser.AC_SPEED,
|
|
||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|||||||
12
browser/src/parser/utils/computeSpeed.ts
Normal file
12
browser/src/parser/utils/computeSpeed.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import Parser from "../parser.ts";
|
||||||
|
|
||||||
|
export const computeSpeed = (leg: TerminalEntry, previousFix: NavFix) => {
|
||||||
|
if (leg.SpeedLimit) return leg.SpeedLimit;
|
||||||
|
if (previousFix.speed) {
|
||||||
|
if (previousFix.speed < Parser.AC_SPEED) return Parser.AC_SPEED;
|
||||||
|
|
||||||
|
return previousFix.speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Parser.AC_SPEED;
|
||||||
|
};
|
||||||
@ -27,5 +27,17 @@ Number.prototype.toMetre = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.parseAltitude = function () {
|
String.prototype.parseAltitude = function () {
|
||||||
return Number.parseInt(this.substring(0, 5));
|
switch (this.length) {
|
||||||
|
case 5:
|
||||||
|
return Number.parseInt(this as string);
|
||||||
|
case 6:
|
||||||
|
return Number.parseInt(this.substring(0, 5));
|
||||||
|
case 12: {
|
||||||
|
const upper = Number.parseInt(this.substring(0, 5));
|
||||||
|
const lower = Number.parseInt(this.substring(6, 12));
|
||||||
|
return (upper - lower) / 2;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
4
browser/src/types/terminators/CA.d.ts
vendored
Normal file
4
browser/src/types/terminators/CA.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export declare global {
|
||||||
|
type CATerminalEntry = Required<Pick<TerminalEntry, "Course" | "Alt">> &
|
||||||
|
TerminalEntry;
|
||||||
|
}
|
||||||
6
browser/src/types/terminators/DF.d.ts
vendored
Normal file
6
browser/src/types/terminators/DF.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export declare global {
|
||||||
|
type DFTerminalEntry = Required<
|
||||||
|
Pick<TerminalEntry, "WptID" | "WptLat" | "WptLon" | "IsFlyOver">
|
||||||
|
> &
|
||||||
|
TerminalEntry;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user