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