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 terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653];
|
||||
const terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654];
|
||||
|
||||
function App() {
|
||||
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
||||
|
||||
@ -14,4 +14,4 @@ fetch = async (path: string) => {
|
||||
|
||||
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 { TerminatorsVD } from "./terminators/VD.ts";
|
||||
import { TerminatorsRF } from "./terminators/RF.ts";
|
||||
import { TerminatorsCA } from "./terminators/CA.ts";
|
||||
import { TerminatorsDF } from "./terminators/DF.ts";
|
||||
|
||||
class 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
|
||||
const terminal = this.terminals.find(({ ID }) => ID === terminalID);
|
||||
if (!terminal) throw new Error("Procedure does not exists");
|
||||
@ -101,14 +120,18 @@ class Parser {
|
||||
previousFix,
|
||||
waypoint
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CA": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsCA(
|
||||
leg as CATerminalEntry,
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CA":
|
||||
case "CD":
|
||||
console.error("Unknown TrackCode", leg.TrackCode);
|
||||
break;
|
||||
@ -119,11 +142,7 @@ class Parser {
|
||||
lastCourse,
|
||||
waypoint
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CI": {
|
||||
@ -133,11 +152,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CR": {
|
||||
@ -146,14 +161,19 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "DF": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsDF(
|
||||
leg as DFTerminalEntry,
|
||||
previousFix,
|
||||
lastCourse,
|
||||
waypoint
|
||||
);
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "DF":
|
||||
case "FA":
|
||||
case "FC":
|
||||
case "FD":
|
||||
@ -165,11 +185,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd, isManual: true });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd, { isManual: true });
|
||||
break;
|
||||
}
|
||||
case "HA":
|
||||
@ -187,11 +203,7 @@ class Parser {
|
||||
lastCourse,
|
||||
waypoint
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "TF": {
|
||||
@ -201,11 +213,7 @@ class Parser {
|
||||
lastCourse,
|
||||
waypoint
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "VA": {
|
||||
@ -214,11 +222,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "VD": {
|
||||
@ -227,11 +231,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "VI": {
|
||||
@ -241,11 +241,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "VM": {
|
||||
@ -254,11 +250,7 @@ class Parser {
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
if (fixToAdd) navFixes.push(fixToAdd);
|
||||
if (lineToAdd) {
|
||||
lineSegments.push({ line: lineToAdd, isManual: true });
|
||||
updateLastCourse(lineToAdd);
|
||||
}
|
||||
update(fixToAdd, lineToAdd, { isManual: true });
|
||||
break;
|
||||
}
|
||||
case "VR":
|
||||
|
||||
@ -42,7 +42,7 @@ export const generatePerformanceArc = (
|
||||
latitude: line.at(-1)![1],
|
||||
longitude: line.at(-1)![0],
|
||||
},
|
||||
(Parser.AC_SPEED / 3600).toMetre(),
|
||||
((start.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||
crsFromOrigin
|
||||
);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import * as geolib from "geolib";
|
||||
import { generateAFArc } from "../pathGenerators/generateAFArc.ts";
|
||||
import Parser from "../parser.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
|
||||
export const TerminatorsAF = (
|
||||
leg: AFTerminalEntry,
|
||||
@ -13,13 +13,7 @@ export const TerminatorsAF = (
|
||||
name: waypoint?.Ident ?? undefined,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
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 { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
|
||||
export const TerminatorsCF = (
|
||||
leg: CFTerminalEntry,
|
||||
@ -13,13 +13,7 @@ export const TerminatorsCF = (
|
||||
name: waypoint?.Ident ?? undefined,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Parser from "../parser.ts";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
||||
|
||||
export const TerminatorsCI = (
|
||||
@ -21,13 +21,7 @@ export const TerminatorsCI = (
|
||||
)!,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import Parser from "../parser.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
|
||||
export const TerminatorsCR = (
|
||||
leg: CRTerminalEntry,
|
||||
@ -18,13 +18,7 @@ export const TerminatorsCR = (
|
||||
)!,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
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 { generateRFArc } from "../pathGenerators/generateRFArc.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
|
||||
export const TerminatorsRF = (
|
||||
leg: RFTerminalEntry,
|
||||
@ -15,13 +15,7 @@ export const TerminatorsRF = (
|
||||
name: waypoint?.Ident ?? undefined,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import * as geolib from "geolib";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import Parser from "../parser.ts";
|
||||
|
||||
export const TerminatorsTF = (
|
||||
@ -14,26 +14,59 @@ export const TerminatorsTF = (
|
||||
name: waypoint?.Ident ?? undefined,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
const crs = geolib.getGreatCircleBearing(previousFix, targetFix);
|
||||
const line = handleTurnAtFix(
|
||||
crs,
|
||||
crs,
|
||||
lastCourse,
|
||||
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||
|
||||
const trackIntoEndpoint = geolib.getGreatCircleBearing(
|
||||
previousFix,
|
||||
targetFix,
|
||||
leg.TurnDir
|
||||
targetFix
|
||||
);
|
||||
|
||||
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];
|
||||
};
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import * as geolib from "geolib";
|
||||
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
|
||||
export const TerminatorsVA = (
|
||||
@ -21,13 +22,7 @@ export const TerminatorsVA = (
|
||||
name: leg.Alt,
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt.parseAltitude(),
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import * as geolib from "geolib";
|
||||
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
|
||||
export const TerminatorsVD = (
|
||||
@ -17,13 +17,7 @@ export const TerminatorsVD = (
|
||||
name: leg.Distance.toString(),
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Parser from "../parser.ts";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
||||
|
||||
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
||||
@ -22,13 +22,7 @@ export const TerminatorsVI = (
|
||||
)!,
|
||||
isFlyOver: leg.IsFlyOver,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: leg.SpeedLimit
|
||||
? leg.SpeedLimit > Parser.AC_SPEED
|
||||
? Parser.AC_SPEED
|
||||
: leg.SpeedLimit
|
||||
: previousFix.speed
|
||||
? previousFix.speed
|
||||
: Parser.AC_SPEED,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
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 () {
|
||||
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