CD/VD/FD/DF reworked perf. arc calc
This commit is contained in:
parent
49788eddab
commit
d90ba6c5e3
18
README.md
18
README.md
@ -55,6 +55,8 @@ LGAV BIBE1L SID (Cycle 2507, ID 10654)
|
||||
### Instructions
|
||||
|
||||
- From preceding fix, fly along `Course` until reaching `Alt`.
|
||||
- If preceding fix was overfly, offset outbound `Course` to end of turn (tangent).
|
||||
- Earliest leg terminations is at point of tangent.
|
||||
|
||||
### Units
|
||||
|
||||
@ -84,6 +86,8 @@ LGAV BIBE2F SID (Cycle 2507, ID 10657)
|
||||
|
||||
- From preceding fix, fly along `Course` until reaching `Distance` from the navaid identified by
|
||||
`NavID`.
|
||||
- If preceding fix was overfly, offset outbound `Course` to end of turn (tangent).
|
||||
- Earliest leg terminations is at point of tangent.
|
||||
|
||||
### Units
|
||||
|
||||
@ -116,6 +120,7 @@ LGAV BIBE2F SID (Cycle 2507, ID 10657)
|
||||
|
||||
- From preceding fix, fly `Course` to the fix identified by (`WptID`, `WptLat`, `WptLon`) *or*
|
||||
(`NavID`, `NavLat`, `NavLon`, `NavDist`, `NavBear`).
|
||||
- If preceding fix was overfly, continue turn until intercept `Course`, then continue on `Course`.
|
||||
|
||||
### Units
|
||||
|
||||
@ -208,7 +213,7 @@ LGAV KOR1D SID (Cycle 2507, ID 10679)
|
||||
- `IsFlyOver`: Boolean indicating if fix is a mandatory fly over.
|
||||
|
||||
|
||||
## Fix to Altitude (FA)
|
||||
## Track from Fix to Altitude (FA)
|
||||
|
||||
### Example
|
||||
|
||||
@ -227,6 +232,8 @@ LGAV BIBE2F SID (Cycle 2507, ID 10657)
|
||||
|
||||
- From the fix identified by (`WptID`, `WptLat`, `WptLon`) *or*
|
||||
(`NavID`, `NavLat`, `NavLon`, `NavDist`, `NavBear`), fly `Course` until reaching `Alt`.
|
||||
- If preceding fix was overfly, continue turn until intercept `Course`, then continue on `Course`.
|
||||
- Earliest leg terminations is at point of intercept.
|
||||
|
||||
### Units
|
||||
|
||||
@ -261,6 +268,9 @@ LIED CAR6F SID (Cycle 2507, ID 11798)
|
||||
|
||||
- From the fix identified by (`WptID`, `WptLat`, `WptLon`) *or*
|
||||
(`NavID`, `NavLat`, `NavLon`, `NavDist`, `NavBear`), fly `Course` until reaching `Distance`.
|
||||
- If preceding fix was overfly, continue turn until intercept `Course`, then continue on `Course`.
|
||||
- Earliest leg terminations is at point of intercept.
|
||||
|
||||
|
||||
### Units
|
||||
|
||||
@ -292,8 +302,10 @@ LGAV BIBE2T SID (Cycle 2507, ID 10659)
|
||||
### Instructions
|
||||
|
||||
- From the fix identified by (`WptID`, `WptLat`, `WptLon`) *or*
|
||||
(`NavID`, `NavLat`, `NavLon`, `NavDist`, `NavBear`), fly `Course` until
|
||||
reaching `Distance` from navaid identified by `NavID`.
|
||||
(`NavID`, `NavLat`, `NavLon`, `NavDist`, `NavBear`), fly `Course` until reaching `Distance` from
|
||||
navaid identified by `NavID`.
|
||||
- If preceding fix was overfly, continue turn until intercept `Course`, then continue on `Course`.
|
||||
- Earliest leg terminations is at point of intercept.
|
||||
|
||||
### Units
|
||||
|
||||
|
||||
@ -8,7 +8,9 @@ import L from "leaflet";
|
||||
|
||||
const parser = await Parser.instance();
|
||||
|
||||
const terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654];
|
||||
const terminals = [
|
||||
10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654, 10657, 10659,
|
||||
];
|
||||
|
||||
function App() {
|
||||
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
||||
@ -106,6 +108,7 @@ function App() {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "10px",
|
||||
width: "max-content",
|
||||
}}
|
||||
>
|
||||
{terminals.map((terminal) => (
|
||||
@ -113,14 +116,18 @@ function App() {
|
||||
key={terminal}
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "10px",
|
||||
flexDirection: "column",
|
||||
background: selectedTerminal === terminal ? "#eeeeee" : undefined,
|
||||
}}
|
||||
onClick={() => setSelectedTerminal(terminal)}
|
||||
>
|
||||
<pre>ID {terminal}</pre>
|
||||
<button onClick={() => setSelectedTerminal(terminal)}>
|
||||
Select
|
||||
</button>
|
||||
<span style={{ whiteSpace: "nowrap" }}>
|
||||
{(() => {
|
||||
const t = parser.terminals.find(({ ID }) => ID === terminal);
|
||||
return `${t?.ICAO} - ${t?.FullName}`;
|
||||
})()}
|
||||
</span>
|
||||
<pre>({terminal})</pre>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -14,4 +14,4 @@ fetch = async (path: string) => {
|
||||
|
||||
const parser = await Parser.instance();
|
||||
|
||||
console.log(JSON.stringify(await parser.parse(10654)));
|
||||
console.log(JSON.stringify(await parser.parse(10657)));
|
||||
|
||||
@ -14,25 +14,29 @@ import { TerminatorsVD } from "./terminators/VD.ts";
|
||||
import { TerminatorsRF } from "./terminators/RF.ts";
|
||||
import { TerminatorsCA } from "./terminators/CA.ts";
|
||||
import { TerminatorsDF } from "./terminators/DF.ts";
|
||||
import { TerminatorsFD } from "./terminators/FD.ts";
|
||||
import { TerminatorsFA } from "./terminators/FA.ts";
|
||||
import { TerminatorsCD } from "./terminators/CD.ts";
|
||||
|
||||
class Parser {
|
||||
private static _instance: Parser;
|
||||
|
||||
private waypoints: Waypoint[];
|
||||
private runways: Runway[];
|
||||
private terminals: Terminal[];
|
||||
private _waypoints: Waypoint[];
|
||||
private _runways: Runway[];
|
||||
private _terminals: Terminal[];
|
||||
|
||||
public static AC_SPEED = 250;
|
||||
public static AC_VS = 1500;
|
||||
public static AC_BANK = 30;
|
||||
public static AC_VS = 1400;
|
||||
|
||||
private constructor(
|
||||
waypoints: Waypoint[],
|
||||
runways: Runway[],
|
||||
terminals: Terminal[]
|
||||
) {
|
||||
this.waypoints = waypoints;
|
||||
this.runways = runways;
|
||||
this.terminals = terminals;
|
||||
this._waypoints = waypoints;
|
||||
this._runways = runways;
|
||||
this._terminals = terminals;
|
||||
}
|
||||
|
||||
public static instance = async () => {
|
||||
@ -47,6 +51,16 @@ class Parser {
|
||||
return Parser._instance;
|
||||
};
|
||||
|
||||
public get terminals() {
|
||||
return this._terminals;
|
||||
}
|
||||
public get waypoints() {
|
||||
return this._waypoints;
|
||||
}
|
||||
public get runways() {
|
||||
return this._runways;
|
||||
}
|
||||
|
||||
public parse = async (terminalID: number) => {
|
||||
// Private functions
|
||||
/**
|
||||
@ -132,9 +146,15 @@ class Parser {
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CD":
|
||||
console.error("Unknown TrackCode", leg.TrackCode);
|
||||
case "CD": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsCD(
|
||||
leg as CDTerminalEntry,
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "CF": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsCF(
|
||||
leg as CFTerminalEntry,
|
||||
@ -174,11 +194,27 @@ class Parser {
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "FA":
|
||||
case "FA": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsFA(
|
||||
leg as FATerminalEntry,
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "FC":
|
||||
case "FD":
|
||||
console.error("Unknown TrackCode", leg.TrackCode);
|
||||
break;
|
||||
case "FD": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsFD(
|
||||
leg as FDTerminalEntry,
|
||||
previousFix,
|
||||
lastCourse
|
||||
);
|
||||
update(fixToAdd, lineToAdd);
|
||||
break;
|
||||
}
|
||||
case "FM": {
|
||||
const [fixToAdd, lineToAdd] = TerminatorsFM(
|
||||
leg as FMTerminalEntry,
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import * as geolib from "geolib";
|
||||
import Parser from "../parser.ts";
|
||||
import { computeTurnRate } from "../utils/computeTurnRate.ts";
|
||||
|
||||
/**
|
||||
* @param crsIntoEndpoint Course into arc endpoint
|
||||
* @param crsFromOrigin Course from arc origin point
|
||||
* @param start Arc origin point
|
||||
* @param speed Speed within arc
|
||||
* @param turnDir Turn direction
|
||||
* @returns Line segments
|
||||
*/
|
||||
@ -12,12 +14,15 @@ export const generatePerformanceArc = (
|
||||
crsIntoEndpoint: number,
|
||||
crsFromOrigin: number,
|
||||
start: NavFix,
|
||||
speed: number,
|
||||
turnDir?: TurnDirection
|
||||
) => {
|
||||
const turnRate = computeTurnRate(speed, Parser.AC_BANK);
|
||||
|
||||
const line: LineSegment[] = [[start.longitude, start.latitude]];
|
||||
|
||||
// Check if there even is an arc
|
||||
if (crsIntoEndpoint !== crsFromOrigin) {
|
||||
if (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||
// Turn Dir
|
||||
if (!turnDir || turnDir === "E") {
|
||||
let prov = crsFromOrigin - crsIntoEndpoint;
|
||||
@ -26,15 +31,18 @@ export const generatePerformanceArc = (
|
||||
}
|
||||
|
||||
// Generate arc
|
||||
while (crsFromOrigin !== crsIntoEndpoint) {
|
||||
while (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||
let time = 0;
|
||||
if (turnDir === "R") {
|
||||
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
||||
crsFromOrigin += delta < 1 ? delta : 1;
|
||||
crsFromOrigin = crsFromOrigin.normaliseDegrees();
|
||||
const increment = delta < 1 ? delta : 1;
|
||||
crsFromOrigin = (crsFromOrigin + increment).normaliseDegrees();
|
||||
time = increment / turnRate;
|
||||
} else {
|
||||
const delta = (crsFromOrigin - crsIntoEndpoint).normaliseDegrees();
|
||||
crsFromOrigin -= delta < 1 ? delta : 1;
|
||||
crsFromOrigin = crsFromOrigin.normaliseDegrees();
|
||||
const increment = delta < 1 ? delta : 1;
|
||||
crsFromOrigin = (crsFromOrigin - increment).normaliseDegrees();
|
||||
time = increment / turnRate;
|
||||
}
|
||||
|
||||
const arcFix = geolib.computeDestinationPoint(
|
||||
@ -42,7 +50,7 @@ export const generatePerformanceArc = (
|
||||
latitude: line.at(-1)![1],
|
||||
longitude: line.at(-1)![0],
|
||||
},
|
||||
((start.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||
((speed / 3600) * time).toMetre(),
|
||||
crsFromOrigin
|
||||
);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import * as geolib from "geolib";
|
||||
import { generateTangentArc } from "./generateTangentArc.ts";
|
||||
import { generatePerformanceArc } from "./generatePerformanceArc.ts";
|
||||
import Parser from "../parser.ts";
|
||||
|
||||
/**
|
||||
* @param crsIntoEndpoint Course into endpoint
|
||||
@ -35,6 +36,7 @@ export const handleTurnAtFix = (
|
||||
crsIntoIntercept,
|
||||
crsFromOrigin,
|
||||
start,
|
||||
start.speed ? start.speed : Parser.AC_SPEED,
|
||||
turnDir
|
||||
);
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ export const TerminatorsCA = (
|
||||
(
|
||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
||||
Parser.AC_VS) *
|
||||
(Parser.AC_SPEED / 60)
|
||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||
).toMetre(),
|
||||
leg.Course.toTrue(previousFix)
|
||||
),
|
||||
|
||||
67
browser/src/parser/terminators/CD.ts
Normal file
67
browser/src/parser/terminators/CD.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import * as geolib from "geolib";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
||||
|
||||
// NOTE: Distance not adjusted for altitude in this demo
|
||||
export const TerminatorsCD = (
|
||||
leg: CDTerminalEntry,
|
||||
previousFix: NavFix,
|
||||
lastCourse: number
|
||||
): [NavFix?, LineSegment[]?] => {
|
||||
const navaid = {
|
||||
latitude: leg.NavLat,
|
||||
longitude: leg.NavLon,
|
||||
};
|
||||
const speed = computeSpeed(leg, previousFix);
|
||||
|
||||
let line: LineSegment[] = [];
|
||||
if (previousFix.isFlyOver) {
|
||||
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||
|
||||
line = generatePerformanceArc(
|
||||
crsIntoEndpoint,
|
||||
lastCourse,
|
||||
previousFix,
|
||||
speed,
|
||||
leg.TurnDir
|
||||
);
|
||||
} else {
|
||||
line.push([previousFix.longitude, previousFix.latitude]);
|
||||
}
|
||||
|
||||
const arcEnd = { latitude: line.at(-1)![1], longitude: line.at(-1)![0] };
|
||||
if (line.length > 1) {
|
||||
lastCourse = geolib.getGreatCircleBearing(
|
||||
{
|
||||
latitude: line.at(-2)![1],
|
||||
longitude: line.at(-2)![0],
|
||||
},
|
||||
arcEnd
|
||||
);
|
||||
}
|
||||
|
||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||
let remainingDistance = leg.Distance.toMetre();
|
||||
// Navaid behind us
|
||||
if (Math.abs(crsToNavaid - lastCourse) > 90) {
|
||||
remainingDistance -= distToNavaid;
|
||||
}
|
||||
// Navaid in front of us
|
||||
else {
|
||||
remainingDistance = distToNavaid - remainingDistance;
|
||||
}
|
||||
const targetFix: NavFix = {
|
||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||
name: leg.Distance.toString(),
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
line.push([targetFix.longitude, targetFix.latitude]);
|
||||
|
||||
return [targetFix, line];
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
import * as geolib from "geolib";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import Parser from "../parser.ts";
|
||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
||||
|
||||
export const TerminatorsDF = (
|
||||
leg: DFTerminalEntry,
|
||||
@ -8,58 +8,35 @@ export const TerminatorsDF = (
|
||||
lastCourse: number,
|
||||
waypoint?: Waypoint
|
||||
): [NavFix?, LineSegment[]?] => {
|
||||
const speed = computeSpeed(leg, previousFix);
|
||||
|
||||
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),
|
||||
speed: speed,
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||
|
||||
let line: LineSegment[] = [];
|
||||
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 = generatePerformanceArc(
|
||||
crsIntoEndpoint,
|
||||
lastCourse,
|
||||
previousFix,
|
||||
speed,
|
||||
leg.TurnDir
|
||||
);
|
||||
|
||||
line.push([arcFix.longitude, arcFix.latitude]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
line.push([previousFix.longitude, previousFix.latitude]);
|
||||
}
|
||||
|
||||
line.push([targetFix.longitude, targetFix.latitude]);
|
||||
|
||||
39
browser/src/parser/terminators/FA.ts
Normal file
39
browser/src/parser/terminators/FA.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import * as geolib from "geolib";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import Parser from "../parser.ts";
|
||||
|
||||
export const TerminatorsFA = (
|
||||
leg: FATerminalEntry,
|
||||
previousFix: NavFix,
|
||||
lastCourse: number
|
||||
): [NavFix?, LineSegment[]?] => {
|
||||
const targetFix: NavFix = {
|
||||
...geolib.computeDestinationPoint(
|
||||
{ latitude: leg.WptLat, longitude: leg.WptLon },
|
||||
(
|
||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
||||
Parser.AC_VS) *
|
||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||
).toMetre(),
|
||||
leg.Course.toTrue(previousFix)
|
||||
),
|
||||
name: leg.Alt,
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
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];
|
||||
};
|
||||
71
browser/src/parser/terminators/FD.ts
Normal file
71
browser/src/parser/terminators/FD.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import * as geolib from "geolib";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
||||
|
||||
// NOTE: Distance not adjusted for altitude in this demo
|
||||
export const TerminatorsFD = (
|
||||
leg: FDTerminalEntry,
|
||||
previousFix: NavFix,
|
||||
lastCourse: number
|
||||
): [NavFix?, LineSegment[]?] => {
|
||||
const refFix = {
|
||||
latitude: leg.WptLat,
|
||||
longitude: leg.WptLon,
|
||||
};
|
||||
const navaid = {
|
||||
latitude: leg.NavLat,
|
||||
longitude: leg.NavLon,
|
||||
};
|
||||
const speed = computeSpeed(leg, previousFix);
|
||||
|
||||
let line: LineSegment[] = [];
|
||||
if (previousFix.isFlyOver) {
|
||||
const crsIntoEndpoint = leg.Course.toTrue(refFix);
|
||||
|
||||
line = generatePerformanceArc(
|
||||
crsIntoEndpoint,
|
||||
lastCourse,
|
||||
previousFix,
|
||||
speed,
|
||||
leg.TurnDir
|
||||
);
|
||||
} else {
|
||||
line.push([previousFix.longitude, previousFix.latitude]);
|
||||
}
|
||||
|
||||
const arcEnd = { latitude: line.at(-1)![1], longitude: line.at(-1)![0] };
|
||||
if (line.length > 1) {
|
||||
lastCourse = geolib.getGreatCircleBearing(
|
||||
{
|
||||
latitude: line.at(-2)![1],
|
||||
longitude: line.at(-2)![0],
|
||||
},
|
||||
arcEnd
|
||||
);
|
||||
}
|
||||
|
||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||
let remainingDistance = leg.Distance.toMetre();
|
||||
// Navaid behind us
|
||||
if (Math.abs(crsToNavaid - lastCourse) > 90) {
|
||||
remainingDistance -= distToNavaid;
|
||||
}
|
||||
// Navaid in front of us
|
||||
else {
|
||||
remainingDistance = distToNavaid - remainingDistance;
|
||||
}
|
||||
const targetFix: NavFix = {
|
||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||
name: leg.Distance.toString(),
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
speed: computeSpeed(leg, previousFix),
|
||||
speedConstraint: leg.SpeedLimit,
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
line.push([targetFix.longitude, targetFix.latitude]);
|
||||
|
||||
return [targetFix, line];
|
||||
};
|
||||
@ -39,6 +39,7 @@ export const TerminatorsTF = (
|
||||
}
|
||||
|
||||
// Generate arc
|
||||
let condition = false;
|
||||
do {
|
||||
if (leg.TurnDir === "R") {
|
||||
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
||||
@ -55,14 +56,22 @@ export const TerminatorsTF = (
|
||||
latitude: line.at(-1)![1],
|
||||
longitude: line.at(-1)![0],
|
||||
},
|
||||
((previousFix.speed ?? Parser.AC_SPEED) / 3600).toMetre(),
|
||||
(
|
||||
(previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 3600
|
||||
).toMetre(),
|
||||
lastCourse
|
||||
);
|
||||
|
||||
line.push([arcFix.longitude, arcFix.latitude]);
|
||||
|
||||
crsIntoEndpoint = geolib.getGreatCircleBearing(arcFix, targetFix);
|
||||
} while (crsIntoEndpoint > trackIntoEndpoint);
|
||||
|
||||
if (leg.TurnDir === "R") {
|
||||
condition = crsIntoEndpoint > trackIntoEndpoint;
|
||||
} else {
|
||||
condition = crsIntoEndpoint < trackIntoEndpoint;
|
||||
}
|
||||
} while (condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ export const TerminatorsVA = (
|
||||
(
|
||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
||||
Parser.AC_VS) *
|
||||
(Parser.AC_SPEED / 60)
|
||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||
).toMetre(),
|
||||
leg.Course.toTrue(previousFix)
|
||||
),
|
||||
|
||||
@ -1,19 +1,59 @@
|
||||
import * as geolib from "geolib";
|
||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
||||
|
||||
// NOTE: No wind adjustments to be made, no clue how *that* would draw
|
||||
// NOTE: Distance not adjusted for altitude in this demo
|
||||
export const TerminatorsVD = (
|
||||
leg: VDTerminalEntry,
|
||||
previousFix: NavFix,
|
||||
lastCourse: number
|
||||
): [NavFix?, LineSegment[]?] => {
|
||||
const targetFix: NavFix = {
|
||||
...geolib.computeDestinationPoint(
|
||||
const navaid = {
|
||||
latitude: leg.NavLat,
|
||||
longitude: leg.NavLon,
|
||||
};
|
||||
const speed = computeSpeed(leg, previousFix);
|
||||
|
||||
let line: LineSegment[] = [];
|
||||
if (previousFix.isFlyOver) {
|
||||
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||
|
||||
line = generatePerformanceArc(
|
||||
crsIntoEndpoint,
|
||||
lastCourse,
|
||||
previousFix,
|
||||
leg.Distance.toMetre(),
|
||||
leg.Course.toTrue(previousFix)
|
||||
),
|
||||
speed,
|
||||
leg.TurnDir
|
||||
);
|
||||
} else {
|
||||
line.push([previousFix.longitude, previousFix.latitude]);
|
||||
}
|
||||
|
||||
const arcEnd = { latitude: line.at(-1)![1], longitude: line.at(-1)![0] };
|
||||
if (line.length > 1) {
|
||||
lastCourse = geolib.getGreatCircleBearing(
|
||||
{
|
||||
latitude: line.at(-2)![1],
|
||||
longitude: line.at(-2)![0],
|
||||
},
|
||||
arcEnd
|
||||
);
|
||||
}
|
||||
|
||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||
let remainingDistance = leg.Distance.toMetre();
|
||||
// Navaid behind us
|
||||
if (Math.abs(crsToNavaid - lastCourse) > 90) {
|
||||
remainingDistance -= distToNavaid;
|
||||
}
|
||||
// Navaid in front of us
|
||||
else {
|
||||
remainingDistance = distToNavaid - remainingDistance;
|
||||
}
|
||||
const targetFix: NavFix = {
|
||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||
name: leg.Distance.toString(),
|
||||
isFlyOver: true,
|
||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||
@ -22,14 +62,7 @@ export const TerminatorsVD = (
|
||||
altitudeConstraint: leg.Alt,
|
||||
};
|
||||
|
||||
const line = handleTurnAtFix(
|
||||
leg.Course.toTrue(previousFix),
|
||||
leg.Course.toTrue(previousFix),
|
||||
lastCourse,
|
||||
previousFix,
|
||||
targetFix,
|
||||
leg.TurnDir
|
||||
);
|
||||
line.push([targetFix.longitude, targetFix.latitude]);
|
||||
|
||||
return [targetFix, line];
|
||||
};
|
||||
|
||||
3
browser/src/parser/utils/computeTurnRate.ts
Normal file
3
browser/src/parser/utils/computeTurnRate.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const computeTurnRate = (speed: number, bank: number) => {
|
||||
return (1091 * Math.tan(bank.toRadians())) / speed;
|
||||
};
|
||||
@ -25,6 +25,9 @@ Number.prototype.toTrue = function (fix) {
|
||||
Number.prototype.toMetre = function () {
|
||||
return (this as number) * 1852.0;
|
||||
};
|
||||
Number.prototype.equal = function (other: number) {
|
||||
return Math.abs((this as number) - other) < 0.1;
|
||||
};
|
||||
|
||||
String.prototype.parseAltitude = function () {
|
||||
switch (this.length) {
|
||||
|
||||
4
browser/src/types/extensions.d.ts
vendored
4
browser/src/types/extensions.d.ts
vendored
@ -25,6 +25,10 @@ export declare global {
|
||||
* @returns Value converted from nmi to metres
|
||||
*/
|
||||
toMetre: () => number;
|
||||
/**
|
||||
* @returns True if delta is less than 0.1
|
||||
*/
|
||||
equal: (other: number) => boolean;
|
||||
}
|
||||
|
||||
interface String {
|
||||
|
||||
6
browser/src/types/terminators/CD.d.ts
vendored
Normal file
6
browser/src/types/terminators/CD.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export declare global {
|
||||
type CDTerminalEntry = Required<
|
||||
Pick<TerminalEntry, "NavID" | "NavLat" | "NavLon" | "Course" | "Distance">
|
||||
> &
|
||||
TerminalEntry;
|
||||
}
|
||||
18
browser/src/types/terminators/FA.d.ts
vendored
Normal file
18
browser/src/types/terminators/FA.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
export declare global {
|
||||
type FATerminalEntry = Required<
|
||||
Pick<
|
||||
TerminalEntry,
|
||||
| "WptID"
|
||||
| "WptLat"
|
||||
| "WptLon"
|
||||
| "NavID"
|
||||
| "NavLat"
|
||||
| "NavLon"
|
||||
| "NavBear"
|
||||
| "NavDist"
|
||||
| "Course"
|
||||
| "Alt"
|
||||
>
|
||||
> &
|
||||
TerminalEntry;
|
||||
}
|
||||
18
browser/src/types/terminators/FD.d.ts
vendored
Normal file
18
browser/src/types/terminators/FD.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
export declare global {
|
||||
type FDTerminalEntry = Required<
|
||||
Pick<
|
||||
TerminalEntry,
|
||||
| "WptID"
|
||||
| "WptLat"
|
||||
| "WptLon"
|
||||
| "NavID"
|
||||
| "NavLat"
|
||||
| "NavLon"
|
||||
| "NavBear"
|
||||
| "NavDist"
|
||||
| "Course"
|
||||
| "Distance"
|
||||
>
|
||||
> &
|
||||
TerminalEntry;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user