Prettier
Refactor overfly fix
This commit is contained in:
parent
8b04be187e
commit
50077746f0
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@ -14,7 +14,8 @@
|
|||||||
"${workspaceFolder}\\browser\\src\\parser\\node.ts"
|
"${workspaceFolder}\\browser\\src\\parser\\node.ts"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}\\browser\\",
|
"cwd": "${workspaceFolder}\\browser\\",
|
||||||
"outFiles": ["${workspaceFolder}/**/*.js"]
|
"outFiles": ["${workspaceFolder}/**/*.js"],
|
||||||
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
TODO.md
16
TODO.md
@ -0,0 +1,16 @@
|
|||||||
|
How to use:
|
||||||
|
|
||||||
|
- Select Airport by ICAO
|
||||||
|
- List runways for selected airport
|
||||||
|
- List SID for selected runway
|
||||||
|
- List transitions for selected SID
|
||||||
|
- Parse SID and transition
|
||||||
|
- Display
|
||||||
|
- List STAR for selected runway
|
||||||
|
- List transitions for selected STAR
|
||||||
|
- Parse STAR and transition
|
||||||
|
- Display
|
||||||
|
- List IAPs for selected runway
|
||||||
|
- List transitions for selected IAP
|
||||||
|
- Parse IAP and transition
|
||||||
|
- Display
|
||||||
9
browser/.prettierrc.cjs
Normal file
9
browser/.prettierrc.cjs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 2,
|
||||||
|
semi: true,
|
||||||
|
trailingComma: "es5",
|
||||||
|
singleQuote: true,
|
||||||
|
arrowParens: "always",
|
||||||
|
plugins: ["prettier-plugin-organize-imports"],
|
||||||
|
};
|
||||||
@ -1,18 +1,18 @@
|
|||||||
import js from "@eslint/js";
|
import js from '@eslint/js';
|
||||||
import globals from "globals";
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
import reactHooks from "eslint-plugin-react-hooks";
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||||
import reactRefresh from "eslint-plugin-react-refresh";
|
import { globalIgnores } from 'eslint/config';
|
||||||
import tseslint from "typescript-eslint";
|
import globals from 'globals';
|
||||||
import { globalIgnores } from "eslint/config";
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
export default tseslint.config([
|
export default tseslint.config([
|
||||||
globalIgnores(["dist"]),
|
globalIgnores(['dist']),
|
||||||
{
|
{
|
||||||
files: ["**/*.{ts,tsx}"],
|
files: ['**/*.{ts,tsx}'],
|
||||||
extends: [
|
extends: [
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
tseslint.configs.recommended,
|
tseslint.configs.recommended,
|
||||||
reactHooks.configs["recommended-latest"],
|
reactHooks.configs['recommended-latest'],
|
||||||
reactRefresh.configs.vite,
|
reactRefresh.configs.vite,
|
||||||
],
|
],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
@ -20,7 +20,7 @@ export default tseslint.config([
|
|||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-shadow": "error",
|
'@typescript-eslint/no-shadow': 'error',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
"eslint-plugin-react-refresh": "^0.4.20",
|
"eslint-plugin-react-refresh": "^0.4.20",
|
||||||
"globals": "^16.3.0",
|
"globals": "^16.3.0",
|
||||||
"object-hash": "^3.0.0",
|
"object-hash": "^3.0.0",
|
||||||
|
"prettier": "^3.6.2",
|
||||||
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"typescript": "~5.8.3",
|
"typescript": "~5.8.3",
|
||||||
"typescript-eslint": "^8.36.0",
|
"typescript-eslint": "^8.36.0",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
|
|||||||
957
browser/pnpm-lock.yaml
generated
957
browser/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,13 @@
|
|||||||
import { MapContainer, GeoJSON, TileLayer } from "react-leaflet";
|
import { default as L, default as Leaflet } from 'leaflet';
|
||||||
import Parser from "./parser/parser";
|
import 'leaflet-svg-shape-markers';
|
||||||
import { createRef, useEffect, useState } from "react";
|
import hash from 'object-hash';
|
||||||
import hash from "object-hash";
|
import { createRef, useEffect, useState } from 'react';
|
||||||
import Leaflet from "leaflet";
|
import { GeoJSON, MapContainer, TileLayer } from 'react-leaflet';
|
||||||
import "leaflet-svg-shape-markers";
|
import Parser from './parser/parser';
|
||||||
import L from "leaflet";
|
|
||||||
|
|
||||||
const parser = await Parser.instance();
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
const terminals = [
|
const terminals = [10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654, 10657, 10659, 10679, 11798, 11909, 12765];
|
||||||
10394, 10395, 10475, 10480, 10482, 10485, 10653, 10654, 10657, 10659, 10679,
|
|
||||||
11798, 11909, 12765,
|
|
||||||
];
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
const [selectedTerminal, setSelectedTerminal] = useState(terminals[0]);
|
||||||
@ -36,14 +32,14 @@ function App() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "flex", height: "100vh", width: "100vw" }}>
|
<div style={{ display: 'flex', height: '100vh', width: '100vw' }}>
|
||||||
<MapContainer
|
<MapContainer
|
||||||
center={[51.505, -0.09]}
|
center={[51.505, -0.09]}
|
||||||
zoom={13}
|
zoom={13}
|
||||||
zoomSnap={0}
|
zoomSnap={0}
|
||||||
zoomDelta={0.1}
|
zoomDelta={0.1}
|
||||||
wheelPxPerZoomLevel={1000}
|
wheelPxPerZoomLevel={1000}
|
||||||
style={{ height: "100%", width: "100%" }}
|
style={{ height: '100%', width: '100%' }}
|
||||||
ref={mapRef}
|
ref={mapRef}
|
||||||
>
|
>
|
||||||
<TileLayer
|
<TileLayer
|
||||||
@ -53,90 +49,86 @@ function App() {
|
|||||||
{procedures.map((procedure) => (
|
{procedures.map((procedure) => (
|
||||||
<>
|
<>
|
||||||
<GeoJSON
|
<GeoJSON
|
||||||
key={hash(procedure ?? "") + "lines"}
|
key={hash(procedure ?? '') + 'lines'}
|
||||||
data={procedure}
|
data={procedure}
|
||||||
style={({ properties }) => ({
|
style={({ properties }) => ({
|
||||||
color: "#ff00ff",
|
color: '#ff00ff',
|
||||||
stroke: true,
|
stroke: true,
|
||||||
weight: 5,
|
weight: 5,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
dashArray: properties.isManual ? "20, 20" : undefined,
|
dashArray: properties.isManual ? '20, 20' : undefined,
|
||||||
})}
|
})}
|
||||||
filter={(feature) => feature.geometry.type !== "Point"}
|
filter={(feature) => feature.geometry.type !== 'Point'}
|
||||||
ref={layerRef}
|
ref={layerRef}
|
||||||
/>
|
/>
|
||||||
<GeoJSON
|
<GeoJSON
|
||||||
key={hash(procedure ?? "") + "points"}
|
key={hash(procedure ?? '') + 'points'}
|
||||||
data={procedure}
|
data={procedure}
|
||||||
style={{
|
style={{
|
||||||
color: "black",
|
color: 'black',
|
||||||
fill: true,
|
fill: true,
|
||||||
fillColor: "transparent",
|
fillColor: 'transparent',
|
||||||
stroke: true,
|
stroke: true,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}}
|
}}
|
||||||
pointToLayer={({ properties }, latlng) => {
|
pointToLayer={({ properties }, latlng) => {
|
||||||
if (properties.isFlyOver)
|
if (properties.isFlyOver)
|
||||||
return L.shapeMarker(latlng, {
|
return L.shapeMarker(latlng, {
|
||||||
shape: "triangle",
|
shape: 'triangle',
|
||||||
radius: 6,
|
radius: 6,
|
||||||
});
|
});
|
||||||
if (properties.isIntersection)
|
if (properties.isIntersection) return L.circleMarker(latlng, { radius: 6 });
|
||||||
return L.circleMarker(latlng, { radius: 6 });
|
|
||||||
|
|
||||||
return L.shapeMarker(latlng, {
|
return L.shapeMarker(latlng, {
|
||||||
shape: "star-4",
|
shape: 'star-4',
|
||||||
radius: 10,
|
radius: 10,
|
||||||
rotation: 45,
|
rotation: 45,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onEachFeature={({ geometry, properties }, layer) => {
|
onEachFeature={({ geometry, properties }, layer) => {
|
||||||
if (geometry.type === "Point") {
|
if (geometry.type === 'Point') {
|
||||||
layer.bindPopup(
|
layer.bindPopup(
|
||||||
`${properties.name}<br>
|
`${properties.name}<br>
|
||||||
${properties.altitude} ft<br>
|
${properties.altitude} ft<br>
|
||||||
${properties.speed} kts<br>
|
${properties.speed} kts<br>
|
||||||
CNSTR:
|
CNSTR:
|
||||||
${properties.altitudeConstraint ?? ""}
|
${properties.altitudeConstraint ?? ''}
|
||||||
${properties.speedConstraint ?? ""}<br>`
|
${properties.speedConstraint ?? ''}<br>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
filter={(feature) => feature.geometry.type === "Point"}
|
filter={(feature) => feature.geometry.type === 'Point'}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
))}
|
))}
|
||||||
</MapContainer>
|
</MapContainer>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
overflowY: "scroll",
|
overflowY: 'scroll',
|
||||||
width: "200px",
|
width: '200px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
padding: "5px",
|
padding: '5px',
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
flexDirection: "column",
|
flexDirection: 'column',
|
||||||
gap: "10px",
|
gap: '10px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{terminals.map((terminal) => (
|
{terminals.map((terminal) => (
|
||||||
<div
|
<div
|
||||||
key={terminal}
|
key={terminal}
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
flexDirection: "column",
|
flexDirection: 'column',
|
||||||
background: "#eeeeee",
|
background: '#eeeeee',
|
||||||
border:
|
border: selectedTerminal === terminal ? '1px solid black' : '1px solid #eeeeee',
|
||||||
selectedTerminal === terminal
|
padding: '5px',
|
||||||
? "1px solid black"
|
|
||||||
: "1px solid #eeeeee",
|
|
||||||
padding: "5px",
|
|
||||||
}}
|
}}
|
||||||
onClick={() => setSelectedTerminal(terminal)}
|
onClick={() => setSelectedTerminal(terminal)}
|
||||||
>
|
>
|
||||||
<span style={{ whiteSpace: "nowrap" }}>
|
<span style={{ whiteSpace: 'nowrap' }}>
|
||||||
{(() => {
|
{(() => {
|
||||||
const t = parser.terminals.find(({ ID }) => ID === terminal);
|
const t = parser.terminals.find(({ ID }) => ID === terminal);
|
||||||
return `${t?.ICAO} - ${t?.FullName}`;
|
return `${t?.ICAO} - ${t?.FullName}`;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { StrictMode } from "react";
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from 'react-dom/client';
|
||||||
import App from "./App.tsx";
|
import App from './App.tsx';
|
||||||
|
|
||||||
import "./index.css";
|
import 'leaflet/dist/leaflet.css';
|
||||||
import "leaflet/dist/leaflet.css";
|
import './index.css';
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
|
|||||||
@ -1,17 +1,24 @@
|
|||||||
import Parser from "./parser.ts";
|
import readline from 'readline';
|
||||||
|
import Parser from './parser.ts';
|
||||||
|
|
||||||
// mutate fetch to be local
|
// mutate fetch to be local
|
||||||
|
|
||||||
// @ts-expect-error Global override
|
// @ts-expect-error Global override
|
||||||
// eslint-disable-next-line no-global-assign
|
// eslint-disable-next-line no-global-assign
|
||||||
fetch = async (path: string) => {
|
fetch = async (path: string) => {
|
||||||
const fs = await import("fs");
|
const fs = await import('fs');
|
||||||
return {
|
return {
|
||||||
json: () =>
|
json: () => JSON.parse(fs.readFileSync(`public/${path}`) as unknown as string),
|
||||||
JSON.parse(fs.readFileSync(`public/${path}`) as unknown as string),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const parser = await Parser.instance();
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
console.log(JSON.stringify(await parser.parse(12765)));
|
const rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout,
|
||||||
|
});
|
||||||
|
rl.question(`Terminal ID? `, async (id) => {
|
||||||
|
console.log(JSON.stringify(await parser.parse(Number.parseInt(id))));
|
||||||
|
rl.close();
|
||||||
|
});
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
import "./utils/extensions.ts";
|
import geojson from 'geojson';
|
||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import geojson from "geojson";
|
import { TerminatorsAF } from './terminators/AF.ts';
|
||||||
import { TerminatorsCF } from "./terminators/CF.ts";
|
import { TerminatorsCA } from './terminators/CA.ts';
|
||||||
import { TerminatorsAF } from "./terminators/AF.ts";
|
import { TerminatorsCD } from './terminators/CD.ts';
|
||||||
import { TerminatorsCR } from "./terminators/CR.ts";
|
import { TerminatorsCF } from './terminators/CF.ts';
|
||||||
import { TerminatorsVM } from "./terminators/VM.ts";
|
import { TerminatorsCI } from './terminators/CI.ts';
|
||||||
import { TerminatorsFM } from "./terminators/FM.ts";
|
import { TerminatorsCR } from './terminators/CR.ts';
|
||||||
import { TerminatorsCI } from "./terminators/CI.ts";
|
import { TerminatorsDF } from './terminators/DF.ts';
|
||||||
import { TerminatorsVA } from "./terminators/VA.ts";
|
import { TerminatorsFA } from './terminators/FA.ts';
|
||||||
import { TerminatorsTF } from "./terminators/TF.ts";
|
import { TerminatorsFC } from './terminators/FC.ts';
|
||||||
import { TerminatorsVI } from "./terminators/VI.ts";
|
import { TerminatorsFD } from './terminators/FD.ts';
|
||||||
import { TerminatorsVD } from "./terminators/VD.ts";
|
import { TerminatorsFM } from './terminators/FM.ts';
|
||||||
import { TerminatorsRF } from "./terminators/RF.ts";
|
import { TerminatorsIF } from './terminators/IF.ts';
|
||||||
import { TerminatorsCA } from "./terminators/CA.ts";
|
import { TerminatorsRF } from './terminators/RF.ts';
|
||||||
import { TerminatorsDF } from "./terminators/DF.ts";
|
import { TerminatorsTF } from './terminators/TF.ts';
|
||||||
import { TerminatorsFD } from "./terminators/FD.ts";
|
import { TerminatorsVA } from './terminators/VA.ts';
|
||||||
import { TerminatorsFA } from "./terminators/FA.ts";
|
import { TerminatorsVD } from './terminators/VD.ts';
|
||||||
import { TerminatorsCD } from "./terminators/CD.ts";
|
import { TerminatorsVI } from './terminators/VI.ts';
|
||||||
import { TerminatorsVR } from "./terminators/VR.ts";
|
import { TerminatorsVM } from './terminators/VM.ts';
|
||||||
import { TerminatorsIF } from "./terminators/IF.ts";
|
import { TerminatorsVR } from './terminators/VR.ts';
|
||||||
import { TerminatorsFC } from "./terminators/FC.ts";
|
import './utils/extensions.ts';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Runway IDs for LIED
|
Runway IDs for LIED
|
||||||
@ -38,11 +38,7 @@ class Parser {
|
|||||||
public static AC_BANK = 30;
|
public static AC_BANK = 30;
|
||||||
public static AC_VS = 1400;
|
public static AC_VS = 1400;
|
||||||
|
|
||||||
private constructor(
|
private constructor(waypoints: Waypoint[], runways: Runway[], terminals: Terminal[]) {
|
||||||
waypoints: Waypoint[],
|
|
||||||
runways: Runway[],
|
|
||||||
terminals: Terminal[]
|
|
||||||
) {
|
|
||||||
this._waypoints = waypoints;
|
this._waypoints = waypoints;
|
||||||
this._runways = runways;
|
this._runways = runways;
|
||||||
this._terminals = terminals;
|
this._terminals = terminals;
|
||||||
@ -50,9 +46,9 @@ class Parser {
|
|||||||
|
|
||||||
public static instance = async () => {
|
public static instance = async () => {
|
||||||
if (!Parser._instance) {
|
if (!Parser._instance) {
|
||||||
const waypoints = await (await fetch("NavData/Waypoints.json")).json();
|
const waypoints = await (await fetch('NavData/Waypoints.json')).json();
|
||||||
const runways = await (await fetch("NavData/Runways.json")).json();
|
const runways = await (await fetch('NavData/Runways.json')).json();
|
||||||
const terminals = await (await fetch("NavData/Terminals.json")).json();
|
const terminals = await (await fetch('NavData/Terminals.json')).json();
|
||||||
|
|
||||||
Parser._instance = new Parser(waypoints, runways, terminals);
|
Parser._instance = new Parser(waypoints, runways, terminals);
|
||||||
}
|
}
|
||||||
@ -73,22 +69,20 @@ class Parser {
|
|||||||
public parse = async (terminalID: number) => {
|
public parse = async (terminalID: number) => {
|
||||||
// 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');
|
||||||
// Get runway this procedure is for
|
// Get runway this procedure is for
|
||||||
let runway = this.runways.find(({ ID }) => ID === terminal.RwyID);
|
let runway = this.runways.find(({ ID }) => ID === terminal.RwyID);
|
||||||
if (!runway) {
|
if (!runway) {
|
||||||
let id = 26156;
|
let id = 26156;
|
||||||
if (typeof prompt !== "undefined")
|
if (typeof prompt !== 'undefined')
|
||||||
// throw new Error("Prompt not defined, cannot continue");
|
// throw new Error("Prompt not defined, cannot continue");
|
||||||
|
|
||||||
id = Number.parseInt(prompt("Runway ID") ?? "");
|
id = Number.parseInt(prompt('Runway ID') ?? '');
|
||||||
runway = this.runways.find(({ ID }) => ID === id);
|
runway = this.runways.find(({ ID }) => ID === id);
|
||||||
if (!runway) throw new Error("Procedure links to non existent Runway");
|
if (!runway) throw new Error('Procedure links to non existent Runway');
|
||||||
}
|
}
|
||||||
// Load procedure
|
// Load procedure
|
||||||
const procedures = (await (
|
const procedures = (await (await fetch(`NavData/TermID_${terminalID}.json`)).json()) as TerminalEntry[];
|
||||||
await fetch(`NavData/TermID_${terminalID}.json`)
|
|
||||||
).json()) as TerminalEntry[];
|
|
||||||
// Split into transitions
|
// Split into transitions
|
||||||
const transitions = new Set(procedures.map((proc) => proc.Transition));
|
const transitions = new Set(procedures.map((proc) => proc.Transition));
|
||||||
|
|
||||||
@ -118,11 +112,7 @@ class Parser {
|
|||||||
* @param line New line
|
* @param line New line
|
||||||
* @param options Options for line rendering
|
* @param options Options for line rendering
|
||||||
*/
|
*/
|
||||||
const update = (
|
const update = (fix?: NavFix, line?: LineSegment[], options?: Record<string, unknown>) => {
|
||||||
fix?: NavFix,
|
|
||||||
line?: LineSegment[],
|
|
||||||
options?: Record<string, unknown>
|
|
||||||
) => {
|
|
||||||
if (fix) navFixes.push(fix);
|
if (fix) navFixes.push(fix);
|
||||||
if (line) {
|
if (line) {
|
||||||
lineSegments.push({ line, ...options });
|
lineSegments.push({ line, ...options });
|
||||||
@ -144,53 +134,34 @@ class Parser {
|
|||||||
});
|
});
|
||||||
let lastCourse = runway.TrueHeading;
|
let lastCourse = runway.TrueHeading;
|
||||||
|
|
||||||
const procedure = procedures.filter(
|
const procedure = procedures.filter((proc) => proc.Transition === transition);
|
||||||
(proc) => proc.Transition === transition
|
|
||||||
);
|
|
||||||
for (let index = 0; index < procedure.length; index++) {
|
for (let index = 0; index < procedure.length; index++) {
|
||||||
const leg = procedure[index];
|
const leg = procedure[index];
|
||||||
const previousFix = navFixes.at(-1)!;
|
const previousFix = navFixes.at(-1)!;
|
||||||
const waypoint = this.waypoints.filter(({ ID }) => ID === leg.WptID)[0];
|
const waypoint = this.waypoints.filter(({ ID }) => ID === leg.WptID)[0];
|
||||||
|
|
||||||
switch (leg.TrackCode) {
|
switch (leg.TrackCode) {
|
||||||
case "AF": {
|
case 'AF': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsAF(
|
const [fixToAdd, lineToAdd] = TerminatorsAF(leg as AFTerminalEntry, previousFix, waypoint);
|
||||||
leg as AFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CA": {
|
case 'CA': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCA(
|
const [fixToAdd, lineToAdd] = TerminatorsCA(leg as CATerminalEntry, previousFix, lastCourse);
|
||||||
leg as CATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CD": {
|
case 'CD': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCD(
|
const [fixToAdd, lineToAdd] = TerminatorsCD(leg as CDTerminalEntry, previousFix, lastCourse);
|
||||||
leg as CDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CF": {
|
case 'CF': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCF(
|
const [fixToAdd, lineToAdd] = TerminatorsCF(leg as CFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
leg as CFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CI": {
|
case 'CI': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCI(
|
const [fixToAdd, lineToAdd] = TerminatorsCI(
|
||||||
leg as CITerminalEntry,
|
leg as CITerminalEntry,
|
||||||
procedure[index + 1],
|
procedure[index + 1],
|
||||||
@ -200,76 +171,51 @@ class Parser {
|
|||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CR": {
|
case 'CR': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCR(
|
const [fixToAdd, lineToAdd] = TerminatorsCR(leg as CRTerminalEntry, previousFix, lastCourse);
|
||||||
leg as CRTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DF": {
|
case 'DF': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsDF(
|
const [fixToAdd, lineToAdd] = TerminatorsDF(leg as DFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
leg as DFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "FA": {
|
case 'FA': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFA(
|
const [fixToAdd, lineToAdd] = TerminatorsFA(leg as FATerminalEntry, previousFix, lastCourse);
|
||||||
leg as FATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "FC": {
|
case 'FC': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFC(
|
const [fixToAdd, lineToAdd] = TerminatorsFC(leg as FCTerminalEntry, previousFix, lastCourse);
|
||||||
leg as FCTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "FD": {
|
case 'FD': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFD(
|
const [fixToAdd, lineToAdd] = TerminatorsFD(leg as FDTerminalEntry, previousFix, lastCourse);
|
||||||
leg as FDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "FM": {
|
case 'FM': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFM(
|
const [fixToAdd, lineToAdd] = TerminatorsFM(leg as FMTerminalEntry, previousFix, lastCourse);
|
||||||
leg as FMTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd, { isManual: true });
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "HA":
|
case 'HA':
|
||||||
case "HF":
|
case 'HF':
|
||||||
case "HM":
|
case 'HM':
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
break;
|
break;
|
||||||
case "IF": {
|
case 'IF': {
|
||||||
const fixToAdd = TerminatorsIF(leg as RFTerminalEntry, waypoint);
|
const fixToAdd = TerminatorsIF(leg as RFTerminalEntry, waypoint);
|
||||||
navFixes.length = 0;
|
navFixes.length = 0;
|
||||||
navFixes.push(fixToAdd);
|
navFixes.push(fixToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "PI":
|
case 'PI':
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
break;
|
break;
|
||||||
case "RF": {
|
case 'RF': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsRF(
|
const [fixToAdd, lineToAdd] = TerminatorsRF(
|
||||||
leg as RFTerminalEntry,
|
leg as RFTerminalEntry,
|
||||||
procedure[index + 1],
|
procedure[index + 1],
|
||||||
@ -280,35 +226,22 @@ class Parser {
|
|||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "TF": {
|
case 'TF': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsTF(
|
const [fixToAdd, lineToAdd] = TerminatorsTF(leg as TFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
leg as TFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VA": {
|
case 'VA': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVA(
|
const [fixToAdd, lineToAdd] = TerminatorsVA(leg as VATerminalEntry, previousFix, lastCourse);
|
||||||
leg as VATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VD": {
|
case 'VD': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVD(
|
const [fixToAdd, lineToAdd] = TerminatorsVD(leg as VDTerminalEntry, previousFix, lastCourse);
|
||||||
leg as VDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VI": {
|
case 'VI': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVI(
|
const [fixToAdd, lineToAdd] = TerminatorsVI(
|
||||||
leg as VITerminalEntry,
|
leg as VITerminalEntry,
|
||||||
procedure[index + 1],
|
procedure[index + 1],
|
||||||
@ -318,34 +251,26 @@ class Parser {
|
|||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VM": {
|
case 'VM': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVM(
|
const [fixToAdd, lineToAdd] = TerminatorsVM(leg as VMTerminalEntry, previousFix, lastCourse);
|
||||||
leg as VMTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd, { isManual: true });
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "VR": {
|
case 'VR': {
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVR(
|
const [fixToAdd, lineToAdd] = TerminatorsVR(leg as VRTerminalEntry, previousFix, lastCourse);
|
||||||
leg as VRTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
update(fixToAdd, lineToAdd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output.push(
|
output.push(
|
||||||
geojson.parse([...navFixes, ...lineSegments], {
|
geojson.parse([...navFixes, ...lineSegments], {
|
||||||
LineString: "line",
|
LineString: 'line',
|
||||||
Point: ["latitude", "longitude"],
|
Point: ['latitude', 'longitude'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param crsIntoEndpoint Course into arc endpoint
|
* @param crsIntoEndpoint Course into arc endpoint
|
||||||
@ -21,14 +21,14 @@ export const generateAFArc = (
|
|||||||
|
|
||||||
if (crsIntoEndpoint !== crsFromOrigin) {
|
if (crsIntoEndpoint !== crsFromOrigin) {
|
||||||
// Turn Dir
|
// Turn Dir
|
||||||
if (!turnDir || turnDir === "E") {
|
if (!turnDir || turnDir === 'E') {
|
||||||
let prov = crsFromOrigin - crsIntoEndpoint;
|
let prov = crsFromOrigin - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
turnDir = prov > 0 ? "L" : "R";
|
turnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
|
|
||||||
while (crsFromOrigin !== crsIntoEndpoint) {
|
while (crsFromOrigin !== crsIntoEndpoint) {
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
||||||
crsFromOrigin += delta < 1 ? delta : 1;
|
crsFromOrigin += delta < 1 ? delta : 1;
|
||||||
crsFromOrigin = crsFromOrigin.normaliseDegrees();
|
crsFromOrigin = crsFromOrigin.normaliseDegrees();
|
||||||
@ -39,11 +39,7 @@ export const generateAFArc = (
|
|||||||
}
|
}
|
||||||
if (crsFromOrigin === crsIntoEndpoint) break;
|
if (crsFromOrigin === crsIntoEndpoint) break;
|
||||||
|
|
||||||
const arcFix = geolib.computeDestinationPoint(
|
const arcFix = geolib.computeDestinationPoint(center, radius.toMetre(), crsFromOrigin);
|
||||||
center,
|
|
||||||
radius.toMetre(),
|
|
||||||
crsFromOrigin
|
|
||||||
);
|
|
||||||
|
|
||||||
line.push([arcFix.longitude, arcFix.latitude]);
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
}
|
}
|
||||||
|
|||||||
44
browser/src/parser/pathGenerators/generateOverflyArc.ts
Normal file
44
browser/src/parser/pathGenerators/generateOverflyArc.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import * as geolib from 'geolib';
|
||||||
|
import { generatePerformanceArc } from './generatePerformanceArc.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, arc endpoint, course into arc endpoint
|
||||||
|
*/
|
||||||
|
export const generateOverflyArc = (
|
||||||
|
crsIntoEndpoint: number,
|
||||||
|
crsFromOrigin: number,
|
||||||
|
start: NavFix,
|
||||||
|
speed: number,
|
||||||
|
turnDir?: TurnDirection,
|
||||||
|
force360?: boolean
|
||||||
|
): [LineSegment[], NavFix, number] => {
|
||||||
|
let line: LineSegment[] = [];
|
||||||
|
|
||||||
|
// Compute overfly arc
|
||||||
|
if (start.isFlyOver) {
|
||||||
|
line = generatePerformanceArc(crsIntoEndpoint, crsFromOrigin, start, speed, turnDir, force360);
|
||||||
|
}
|
||||||
|
// Compute procedural arc
|
||||||
|
else {
|
||||||
|
line.push([start.longitude, start.latitude]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get arc endpoint and crs into arc endpoint
|
||||||
|
const arcEnd = { latitude: line.at(-1)![1], longitude: line.at(-1)![0] };
|
||||||
|
if (line.length > 1) {
|
||||||
|
crsFromOrigin = geolib.getGreatCircleBearing(
|
||||||
|
{
|
||||||
|
latitude: line.at(-2)![1],
|
||||||
|
longitude: line.at(-2)![0],
|
||||||
|
},
|
||||||
|
arcEnd
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [line, arcEnd, crsFromOrigin];
|
||||||
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
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";
|
import { computeTurnRate } from '../utils/computeTurnRate.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param crsIntoEndpoint Course into arc endpoint
|
* @param crsIntoEndpoint Course into arc endpoint
|
||||||
@ -27,16 +27,16 @@ export const generatePerformanceArc = (
|
|||||||
// Check if there even is an arc
|
// Check if there even is an arc
|
||||||
if (force360 || !crsFromOrigin.equal(crsIntoEndpoint)) {
|
if (force360 || !crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||||
// Turn Dir
|
// Turn Dir
|
||||||
if (!turnDir || turnDir === "E") {
|
if (!turnDir || turnDir === 'E') {
|
||||||
let prov = crsFromOrigin - crsIntoEndpoint;
|
let prov = crsFromOrigin - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
turnDir = prov > 0 ? "L" : "R";
|
turnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate arc
|
// Generate arc
|
||||||
while (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
while (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||||
let time = 0;
|
let time = 0;
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
||||||
const increment = delta < 1 ? delta : 1;
|
const increment = delta < 1 ? delta : 1;
|
||||||
crsFromOrigin = (crsFromOrigin + increment).normaliseDegrees();
|
crsFromOrigin = (crsFromOrigin + increment).normaliseDegrees();
|
||||||
@ -68,7 +68,7 @@ export const generatePerformanceArc = (
|
|||||||
|
|
||||||
while (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
while (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||||
let time = 0;
|
let time = 0;
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
const delta = (crsIntoEndpoint - crsFromOrigin).normaliseDegrees();
|
||||||
const increment = delta < 1 ? delta : 1;
|
const increment = delta < 1 ? delta : 1;
|
||||||
crsFromOrigin = (crsFromOrigin + increment).normaliseDegrees();
|
crsFromOrigin = (crsFromOrigin + increment).normaliseDegrees();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param crsIntoEndpoint Course into arc endpoint
|
* @param crsIntoEndpoint Course into arc endpoint
|
||||||
@ -19,15 +19,15 @@ export const generateRFArc = (
|
|||||||
|
|
||||||
if (crsIntoEndpoint !== crsIntoOrigin) {
|
if (crsIntoEndpoint !== crsIntoOrigin) {
|
||||||
// Turn Dir
|
// Turn Dir
|
||||||
if (!turnDir || turnDir === "E") {
|
if (!turnDir || turnDir === 'E') {
|
||||||
let prov = crsIntoOrigin - crsIntoEndpoint;
|
let prov = crsIntoOrigin - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
turnDir = prov > 0 ? "L" : "R";
|
turnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
|
|
||||||
let crsOrthogonalOnOrigin;
|
let crsOrthogonalOnOrigin;
|
||||||
let crsOrthogonalOnEndpoint;
|
let crsOrthogonalOnEndpoint;
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
crsOrthogonalOnOrigin = (crsIntoOrigin + 90).normaliseDegrees();
|
crsOrthogonalOnOrigin = (crsIntoOrigin + 90).normaliseDegrees();
|
||||||
crsOrthogonalOnEndpoint = (crsIntoEndpoint + 90).normaliseDegrees();
|
crsOrthogonalOnEndpoint = (crsIntoEndpoint + 90).normaliseDegrees();
|
||||||
} else {
|
} else {
|
||||||
@ -40,34 +40,24 @@ export const generateRFArc = (
|
|||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.reciprocalCourse();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.reciprocalCourse();
|
||||||
crsOrthogonalOnEndpoint = crsOrthogonalOnEndpoint.reciprocalCourse();
|
crsOrthogonalOnEndpoint = crsOrthogonalOnEndpoint.reciprocalCourse();
|
||||||
// Start turn immediately
|
// Start turn immediately
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
crsOrthogonalOnOrigin +=
|
crsOrthogonalOnOrigin += crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
||||||
crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
|
||||||
} else {
|
} else {
|
||||||
crsOrthogonalOnOrigin -=
|
crsOrthogonalOnOrigin -= crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
||||||
crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (crsOrthogonalOnOrigin !== crsOrthogonalOnEndpoint) {
|
while (crsOrthogonalOnOrigin !== crsOrthogonalOnEndpoint) {
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (
|
const delta = (crsOrthogonalOnEndpoint - crsOrthogonalOnOrigin).normaliseDegrees();
|
||||||
crsOrthogonalOnEndpoint - crsOrthogonalOnOrigin
|
|
||||||
).normaliseDegrees();
|
|
||||||
crsOrthogonalOnOrigin += delta < 1 ? delta : 1;
|
crsOrthogonalOnOrigin += delta < 1 ? delta : 1;
|
||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
||||||
} else {
|
} else {
|
||||||
const delta = (
|
const delta = (crsOrthogonalOnOrigin - crsOrthogonalOnEndpoint).normaliseDegrees();
|
||||||
crsOrthogonalOnOrigin - crsOrthogonalOnEndpoint
|
|
||||||
).normaliseDegrees();
|
|
||||||
crsOrthogonalOnOrigin -= delta < 1 ? delta : 1;
|
crsOrthogonalOnOrigin -= delta < 1 ? delta : 1;
|
||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
||||||
}
|
}
|
||||||
|
|
||||||
const arcFix = geolib.computeDestinationPoint(
|
const arcFix = geolib.computeDestinationPoint(center, arcRad, crsOrthogonalOnOrigin);
|
||||||
center,
|
|
||||||
arcRad,
|
|
||||||
crsOrthogonalOnOrigin
|
|
||||||
);
|
|
||||||
|
|
||||||
line.push([arcFix.longitude, arcFix.latitude]);
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param crsIntoEndpoint Course into arc endpoint
|
* @param crsIntoEndpoint Course into arc endpoint
|
||||||
@ -22,12 +22,12 @@ export const generateTangentArc = (
|
|||||||
if (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
if (!crsFromOrigin.equal(crsIntoEndpoint)) {
|
||||||
// Course to the end of the arc
|
// Course to the end of the arc
|
||||||
let crsFromStartToEnd;
|
let crsFromStartToEnd;
|
||||||
if (!turnDir || turnDir === "E") {
|
if (!turnDir || turnDir === 'E') {
|
||||||
let prov = crsFromOrigin - crsIntoEndpoint;
|
let prov = crsFromOrigin - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
turnDir = prov > 0 ? "L" : "R";
|
turnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (360 - crsFromOrigin + crsIntoEndpoint).normaliseDegrees();
|
const delta = (360 - crsFromOrigin + crsIntoEndpoint).normaliseDegrees();
|
||||||
crsFromStartToEnd = (crsFromOrigin + delta / 2).normaliseDegrees();
|
crsFromStartToEnd = (crsFromOrigin + delta / 2).normaliseDegrees();
|
||||||
} else {
|
} else {
|
||||||
@ -46,7 +46,7 @@ export const generateTangentArc = (
|
|||||||
|
|
||||||
let crsOrthogonalOnOrigin;
|
let crsOrthogonalOnOrigin;
|
||||||
let crsOrthogonalOnEndpoint;
|
let crsOrthogonalOnEndpoint;
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
crsOrthogonalOnOrigin = (crsFromOrigin + 90).normaliseDegrees();
|
crsOrthogonalOnOrigin = (crsFromOrigin + 90).normaliseDegrees();
|
||||||
crsOrthogonalOnEndpoint = (crsIntoEndpoint + 90).normaliseDegrees();
|
crsOrthogonalOnEndpoint = (crsIntoEndpoint + 90).normaliseDegrees();
|
||||||
} else {
|
} else {
|
||||||
@ -67,34 +67,24 @@ export const generateTangentArc = (
|
|||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.reciprocalCourse();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.reciprocalCourse();
|
||||||
crsOrthogonalOnEndpoint = crsOrthogonalOnEndpoint.reciprocalCourse();
|
crsOrthogonalOnEndpoint = crsOrthogonalOnEndpoint.reciprocalCourse();
|
||||||
// Start turn immediately
|
// Start turn immediately
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
crsOrthogonalOnOrigin +=
|
crsOrthogonalOnOrigin += crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
||||||
crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
|
||||||
} else {
|
} else {
|
||||||
crsOrthogonalOnOrigin -=
|
crsOrthogonalOnOrigin -= crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
||||||
crsOrthogonalOnOrigin < 1 ? crsOrthogonalOnOrigin : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!crsOrthogonalOnOrigin.equal(crsOrthogonalOnEndpoint)) {
|
while (!crsOrthogonalOnOrigin.equal(crsOrthogonalOnEndpoint)) {
|
||||||
if (turnDir === "R") {
|
if (turnDir === 'R') {
|
||||||
const delta = (
|
const delta = (crsOrthogonalOnEndpoint - crsOrthogonalOnOrigin).normaliseDegrees();
|
||||||
crsOrthogonalOnEndpoint - crsOrthogonalOnOrigin
|
|
||||||
).normaliseDegrees();
|
|
||||||
crsOrthogonalOnOrigin += delta < 1 ? delta : 1;
|
crsOrthogonalOnOrigin += delta < 1 ? delta : 1;
|
||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
||||||
} else {
|
} else {
|
||||||
const delta = (
|
const delta = (crsOrthogonalOnOrigin - crsOrthogonalOnEndpoint).normaliseDegrees();
|
||||||
crsOrthogonalOnOrigin - crsOrthogonalOnEndpoint
|
|
||||||
).normaliseDegrees();
|
|
||||||
crsOrthogonalOnOrigin -= delta < 1 ? delta : 1;
|
crsOrthogonalOnOrigin -= delta < 1 ? delta : 1;
|
||||||
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
crsOrthogonalOnOrigin = crsOrthogonalOnOrigin.normaliseDegrees();
|
||||||
}
|
}
|
||||||
|
|
||||||
const arcFix = geolib.computeDestinationPoint(
|
const arcFix = geolib.computeDestinationPoint(arcCenter, arcRad, crsOrthogonalOnOrigin);
|
||||||
arcCenter,
|
|
||||||
arcRad,
|
|
||||||
crsOrthogonalOnOrigin
|
|
||||||
);
|
|
||||||
|
|
||||||
line.push([arcFix.longitude, arcFix.latitude]);
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { generateTangentArc } from "./generateTangentArc.ts";
|
import { generatePerformanceArc } from './generatePerformanceArc.ts';
|
||||||
import { generatePerformanceArc } from "./generatePerformanceArc.ts";
|
import { generateTangentArc } from './generateTangentArc.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param crsIntoEndpoint Course into endpoint
|
* @param crsIntoEndpoint Course into endpoint
|
||||||
@ -25,21 +25,9 @@ export const handleTurnAtFix = (
|
|||||||
|
|
||||||
// Overfly turn
|
// Overfly turn
|
||||||
if (start.isFlyOver) {
|
if (start.isFlyOver) {
|
||||||
const arc1 = generateTangentArc(
|
const arc1 = generateTangentArc(crsIntoEndpoint, crsFromOrigin, start, end, turnDir);
|
||||||
crsIntoEndpoint,
|
|
||||||
crsFromOrigin,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
turnDir
|
|
||||||
);
|
|
||||||
|
|
||||||
const arc2 = generatePerformanceArc(
|
const arc2 = generatePerformanceArc(crsIntoIntercept, crsFromOrigin, start, speed, turnDir);
|
||||||
crsIntoIntercept,
|
|
||||||
crsFromOrigin,
|
|
||||||
start,
|
|
||||||
speed,
|
|
||||||
turnDir
|
|
||||||
);
|
|
||||||
|
|
||||||
// Decide on arc
|
// Decide on arc
|
||||||
let arc;
|
let arc;
|
||||||
@ -52,8 +40,7 @@ export const handleTurnAtFix = (
|
|||||||
end
|
end
|
||||||
);
|
);
|
||||||
|
|
||||||
if (endCrs <= crsIntoEndpoint + 1 && endCrs >= crsIntoEndpoint - 1)
|
if (endCrs <= crsIntoEndpoint + 1 && endCrs >= crsIntoEndpoint - 1) arc = arc1;
|
||||||
arc = arc1;
|
|
||||||
else arc = arc2;
|
else arc = arc2;
|
||||||
} else {
|
} else {
|
||||||
arc = arc2;
|
arc = arc2;
|
||||||
|
|||||||
@ -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 { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsAF = (
|
export const TerminatorsAF = (
|
||||||
leg: AFTerminalEntry,
|
leg: AFTerminalEntry,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import Parser from "../parser.ts";
|
import Parser from '../parser.ts';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsCA = (
|
export const TerminatorsCA = (
|
||||||
leg: CATerminalEntry,
|
leg: CATerminalEntry,
|
||||||
@ -11,37 +11,16 @@ export const TerminatorsCA = (
|
|||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and expected altitude
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(
|
...geolib.computeDestinationPoint(
|
||||||
arcEnd,
|
arcEnd,
|
||||||
(
|
(
|
||||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) / Parser.AC_VS) *
|
||||||
Parser.AC_VS) *
|
|
||||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||||
).toMetre(),
|
).toMetre(),
|
||||||
crsIntoEndpoint
|
crsIntoEndpoint
|
||||||
@ -53,7 +32,6 @@ export const TerminatorsCA = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
// NOTE: Distance not adjusted for altitude in this demo
|
// NOTE: Distance not adjusted for altitude in this demo
|
||||||
export const TerminatorsCD = (
|
export const TerminatorsCD = (
|
||||||
@ -12,35 +12,14 @@ export const TerminatorsCD = (
|
|||||||
latitude: leg.NavLat,
|
latitude: leg.NavLat,
|
||||||
longitude: leg.NavLon,
|
longitude: leg.NavLon,
|
||||||
};
|
};
|
||||||
|
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute distance to fly from arc end
|
||||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||||
let remainingDistance = leg.Distance.toMetre();
|
let remainingDistance = leg.Distance.toMetre();
|
||||||
@ -51,9 +30,10 @@ export const TerminatorsCD = (
|
|||||||
// Navaid in front of us
|
// Navaid in front of us
|
||||||
else {
|
else {
|
||||||
// Navaid will not be passed before distance is hit
|
// Navaid will not be passed before distance is hit
|
||||||
if (distToNavaid > remainingDistance)
|
if (distToNavaid > remainingDistance) remainingDistance = distToNavaid - remainingDistance;
|
||||||
remainingDistance = distToNavaid - remainingDistance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and distance
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||||
name: leg.Distance.toString(),
|
name: leg.Distance.toString(),
|
||||||
@ -63,7 +43,6 @@ export const TerminatorsCD = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { handleTurnAtFix } from "../pathGenerators/handleTurnAtFix.ts";
|
import { handleTurnAtFix } from '../pathGenerators/handleTurnAtFix.ts';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsCF = (
|
export const TerminatorsCF = (
|
||||||
leg: CFTerminalEntry,
|
leg: CFTerminalEntry,
|
||||||
@ -20,6 +20,7 @@ export const TerminatorsCF = (
|
|||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Compute arc
|
||||||
const line = handleTurnAtFix(
|
const line = handleTurnAtFix(
|
||||||
leg.Course.toTrue(previousFix),
|
leg.Course.toTrue(previousFix),
|
||||||
leg.Course.toTrue(previousFix),
|
leg.Course.toTrue(previousFix),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
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 { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from '../utils/getCourseAndFixForIntercepts.ts';
|
||||||
|
|
||||||
export const TerminatorsCI = (
|
export const TerminatorsCI = (
|
||||||
leg: CITerminalEntry,
|
leg: CITerminalEntry,
|
||||||
@ -12,14 +12,9 @@ export const TerminatorsCI = (
|
|||||||
const [crs, nextFix] = getCourseAndFixForIntercepts(nextLeg, previousFix);
|
const [crs, nextFix] = getCourseAndFixForIntercepts(nextLeg, previousFix);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
// Compute INTC
|
// Compute intercept fix
|
||||||
const interceptFix: NavFix = {
|
const interceptFix: NavFix = {
|
||||||
...computeIntersection(
|
...computeIntersection(previousFix, leg.Course.toTrue(nextFix), nextFix, crs)!,
|
||||||
previousFix,
|
|
||||||
leg.Course.toTrue(nextFix),
|
|
||||||
nextFix,
|
|
||||||
crs
|
|
||||||
)!,
|
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: speed,
|
speed: speed,
|
||||||
@ -27,6 +22,7 @@ export const TerminatorsCI = (
|
|||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Compute arc
|
||||||
const line = handleTurnAtFix(
|
const line = handleTurnAtFix(
|
||||||
crs,
|
crs,
|
||||||
leg.Course.toTrue(nextFix),
|
leg.Course.toTrue(nextFix),
|
||||||
@ -37,7 +33,7 @@ export const TerminatorsCI = (
|
|||||||
leg.TurnDir
|
leg.TurnDir
|
||||||
);
|
);
|
||||||
|
|
||||||
// Intercept based on previous intercept
|
// Recompute intercept
|
||||||
const interceptPoint2 = computeIntersection(
|
const interceptPoint2 = computeIntersection(
|
||||||
{ latitude: line.at(-2)![1], longitude: line.at(-2)![0] },
|
{ latitude: line.at(-2)![1], longitude: line.at(-2)![0] },
|
||||||
leg.Course.toTrue(nextFix),
|
leg.Course.toTrue(nextFix),
|
||||||
@ -47,10 +43,7 @@ export const TerminatorsCI = (
|
|||||||
if (interceptPoint2)
|
if (interceptPoint2)
|
||||||
return [
|
return [
|
||||||
{ ...interceptFix, ...interceptPoint2 },
|
{ ...interceptFix, ...interceptPoint2 },
|
||||||
[
|
[...line.slice(0, -1), [interceptPoint2.longitude, interceptPoint2.latitude]],
|
||||||
...line.slice(0, -1),
|
|
||||||
[interceptPoint2.longitude, interceptPoint2.latitude],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return [interceptFix, line];
|
return [interceptFix, line];
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection.ts';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
|
||||||
|
|
||||||
export const TerminatorsCR = (
|
export const TerminatorsCR = (
|
||||||
leg: CRTerminalEntry,
|
leg: CRTerminalEntry,
|
||||||
@ -16,31 +15,11 @@ export const TerminatorsCR = (
|
|||||||
const crsIntoEndpoint = leg.NavBear.toTrue(navaid);
|
const crsIntoEndpoint = leg.NavBear.toTrue(navaid);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsFromEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
line = generatePerformanceArc(
|
|
||||||
crsFromEndpoint,
|
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and radial
|
||||||
const interceptFix: NavFix = {
|
const interceptFix: NavFix = {
|
||||||
...computeIntersection(arcEnd, crsFromEndpoint, navaid, crsIntoEndpoint)!,
|
...computeIntersection(arcEnd, crsFromEndpoint, navaid, crsIntoEndpoint)!,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
@ -49,7 +28,6 @@ export const TerminatorsCR = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([interceptFix.longitude, interceptFix.latitude]);
|
line.push([interceptFix.longitude, interceptFix.latitude]);
|
||||||
|
|
||||||
return [interceptFix, line];
|
return [interceptFix, line];
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsDF = (
|
export const TerminatorsDF = (
|
||||||
leg: DFTerminalEntry,
|
leg: DFTerminalEntry,
|
||||||
@ -21,26 +21,18 @@ export const TerminatorsDF = (
|
|||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
const crsIntoEndpoint = geolib.getGreatCircleBearing(previousFix, targetFix);
|
||||||
|
|
||||||
if (previousFix.isFlyOver) {
|
// Compute overfly
|
||||||
const crsIntoEndpoint = geolib.getGreatCircleBearing(
|
const [line, _, _lastCourse] = generateOverflyArc(
|
||||||
previousFix,
|
crsIntoEndpoint,
|
||||||
targetFix
|
lastCourse,
|
||||||
);
|
previousFix,
|
||||||
|
speed,
|
||||||
line = generatePerformanceArc(
|
leg.TurnDir,
|
||||||
crsIntoEndpoint,
|
previousFix.latitude.equal(targetFix.latitude) && previousFix.longitude.equal(targetFix.longitude)
|
||||||
lastCourse,
|
);
|
||||||
previousFix,
|
lastCourse = _lastCourse;
|
||||||
speed,
|
|
||||||
leg.TurnDir,
|
|
||||||
previousFix.latitude.equal(targetFix.latitude) &&
|
|
||||||
previousFix.longitude.equal(targetFix.longitude)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
line.push([previousFix.longitude, previousFix.latitude]);
|
|
||||||
}
|
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import Parser from '../parser.ts';
|
||||||
import Parser from "../parser.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsFA = (
|
export const TerminatorsFA = (
|
||||||
leg: FATerminalEntry,
|
leg: FATerminalEntry,
|
||||||
@ -15,37 +15,16 @@ export const TerminatorsFA = (
|
|||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
const crsIntoEndpoint = leg.Course.toTrue(refFix);
|
const crsIntoEndpoint = leg.Course.toTrue(refFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and expected altitude
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(
|
...geolib.computeDestinationPoint(
|
||||||
arcEnd,
|
arcEnd,
|
||||||
(
|
(
|
||||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) / Parser.AC_VS) *
|
||||||
Parser.AC_VS) *
|
|
||||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||||
).toMetre(),
|
).toMetre(),
|
||||||
crsIntoEndpoint
|
crsIntoEndpoint
|
||||||
@ -57,7 +36,6 @@ export const TerminatorsFA = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import Parser from '../parser.ts';
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
import { computeTurnRate } from "../utils/computeTurnRate.ts";
|
import { computeTurnRate } from '../utils/computeTurnRate.ts';
|
||||||
|
|
||||||
// NOTE: Distance not adjusted for altitude in this demo
|
// NOTE: Distance not adjusted for altitude in this demo
|
||||||
export const TerminatorsFC = (
|
export const TerminatorsFC = (
|
||||||
@ -25,17 +25,17 @@ export const TerminatorsFC = (
|
|||||||
// Check if there even is an arc
|
// Check if there even is an arc
|
||||||
if (!crsIntoEndpoint.equal(lastCourse)) {
|
if (!crsIntoEndpoint.equal(lastCourse)) {
|
||||||
// Turn Dir
|
// Turn Dir
|
||||||
if (!leg.TurnDir || leg.TurnDir === "E") {
|
if (!leg.TurnDir || leg.TurnDir === 'E') {
|
||||||
let prov = lastCourse - crsIntoEndpoint;
|
let prov = lastCourse - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
leg.TurnDir = prov > 0 ? "L" : "R";
|
leg.TurnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate arc
|
// Generate arc
|
||||||
let condition = false;
|
let condition = false;
|
||||||
do {
|
do {
|
||||||
let time = 0;
|
let time = 0;
|
||||||
if (leg.TurnDir === "R") {
|
if (leg.TurnDir === 'R') {
|
||||||
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
||||||
const increment = delta < 1 ? delta : 1;
|
const increment = delta < 1 ? delta : 1;
|
||||||
lastCourse = (lastCourse + increment).normaliseDegrees();
|
lastCourse = (lastCourse + increment).normaliseDegrees();
|
||||||
@ -58,7 +58,7 @@ export const TerminatorsFC = (
|
|||||||
|
|
||||||
line.push([arcFix.longitude, arcFix.latitude]);
|
line.push([arcFix.longitude, arcFix.latitude]);
|
||||||
|
|
||||||
if (leg.TurnDir === "R") {
|
if (leg.TurnDir === 'R') {
|
||||||
condition = lastCourse > trackIntoEndpoint;
|
condition = lastCourse > trackIntoEndpoint;
|
||||||
} else {
|
} else {
|
||||||
condition = lastCourse < trackIntoEndpoint;
|
condition = lastCourse < trackIntoEndpoint;
|
||||||
@ -79,11 +79,7 @@ export const TerminatorsFC = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(
|
...geolib.computeDestinationPoint(arcEnd, leg.Distance.toMetre(), lastCourse),
|
||||||
arcEnd,
|
|
||||||
leg.Distance.toMetre(),
|
|
||||||
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,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
// NOTE: Distance not adjusted for altitude in this demo
|
// NOTE: Distance not adjusted for altitude in this demo
|
||||||
export const TerminatorsFD = (
|
export const TerminatorsFD = (
|
||||||
@ -16,35 +16,14 @@ export const TerminatorsFD = (
|
|||||||
latitude: leg.NavLat,
|
latitude: leg.NavLat,
|
||||||
longitude: leg.NavLon,
|
longitude: leg.NavLon,
|
||||||
};
|
};
|
||||||
|
const crsIntoEndpoint = leg.Course.toTrue(refFix);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute distance to fly from arc end
|
||||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||||
let remainingDistance = leg.Distance.toMetre();
|
let remainingDistance = leg.Distance.toMetre();
|
||||||
@ -55,9 +34,10 @@ export const TerminatorsFD = (
|
|||||||
// Navaid in front of us
|
// Navaid in front of us
|
||||||
else {
|
else {
|
||||||
// Navaid will not be passed before distance is hit
|
// Navaid will not be passed before distance is hit
|
||||||
if (distToNavaid > remainingDistance)
|
if (distToNavaid > remainingDistance) remainingDistance = distToNavaid - remainingDistance;
|
||||||
remainingDistance = distToNavaid - remainingDistance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and distance
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||||
name: leg.Distance.toString(),
|
name: leg.Distance.toString(),
|
||||||
@ -67,7 +47,6 @@ export const TerminatorsFD = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -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 { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsFM = (
|
export const TerminatorsFM = (
|
||||||
leg: FMTerminalEntry,
|
leg: FMTerminalEntry,
|
||||||
@ -9,11 +9,7 @@ export const TerminatorsFM = (
|
|||||||
): [NavFix?, LineSegment[]?] => {
|
): [NavFix?, LineSegment[]?] => {
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
const endpoint = geolib.computeDestinationPoint(
|
const endpoint = geolib.computeDestinationPoint(previousFix, (10).toMetre(), leg.Course.toTrue(previousFix));
|
||||||
previousFix,
|
|
||||||
(10).toMetre(),
|
|
||||||
leg.Course.toTrue(previousFix)
|
|
||||||
);
|
|
||||||
|
|
||||||
const line = handleTurnAtFix(
|
const line = handleTurnAtFix(
|
||||||
leg.Course.toTrue(previousFix),
|
leg.Course.toTrue(previousFix),
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
import Parser from "../parser.ts";
|
import Parser from '../parser.ts';
|
||||||
|
|
||||||
export const TerminatorsIF = (
|
export const TerminatorsIF = (leg: IFTerminalEntry, waypoint?: Waypoint): NavFix => {
|
||||||
leg: IFTerminalEntry,
|
|
||||||
waypoint?: Waypoint
|
|
||||||
): NavFix => {
|
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
latitude: leg.WptLat,
|
latitude: leg.WptLat,
|
||||||
longitude: leg.WptLon,
|
longitude: leg.WptLon,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { generateRFArc } from '../pathGenerators/generateRFArc.ts';
|
||||||
import { generateRFArc } from "../pathGenerators/generateRFArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { getCourseAndFixForIntercepts } from '../utils/getCourseAndFixForIntercepts.ts';
|
||||||
|
|
||||||
export const TerminatorsRF = (
|
export const TerminatorsRF = (
|
||||||
leg: RFTerminalEntry,
|
leg: RFTerminalEntry,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import Parser from '../parser.ts';
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from '../utils/computeSpeed.ts';
|
||||||
|
|
||||||
export const TerminatorsTF = (
|
export const TerminatorsTF = (
|
||||||
leg: TFTerminalEntry,
|
leg: TFTerminalEntry,
|
||||||
@ -21,10 +21,7 @@ export const TerminatorsTF = (
|
|||||||
|
|
||||||
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||||
|
|
||||||
const trackIntoEndpoint = geolib.getGreatCircleBearing(
|
const trackIntoEndpoint = geolib.getGreatCircleBearing(previousFix, targetFix);
|
||||||
previousFix,
|
|
||||||
targetFix
|
|
||||||
);
|
|
||||||
|
|
||||||
if (previousFix.isFlyOver) {
|
if (previousFix.isFlyOver) {
|
||||||
let crsIntoEndpoint = trackIntoEndpoint;
|
let crsIntoEndpoint = trackIntoEndpoint;
|
||||||
@ -32,16 +29,16 @@ export const TerminatorsTF = (
|
|||||||
// Check if there even is an arc
|
// Check if there even is an arc
|
||||||
if (crsIntoEndpoint !== lastCourse) {
|
if (crsIntoEndpoint !== lastCourse) {
|
||||||
// Turn Dir
|
// Turn Dir
|
||||||
if (!leg.TurnDir || leg.TurnDir === "E") {
|
if (!leg.TurnDir || leg.TurnDir === 'E') {
|
||||||
let prov = lastCourse - crsIntoEndpoint;
|
let prov = lastCourse - crsIntoEndpoint;
|
||||||
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
prov = prov > 180 ? prov - 360 : prov <= -180 ? prov + 360 : prov;
|
||||||
leg.TurnDir = prov > 0 ? "L" : "R";
|
leg.TurnDir = prov > 0 ? 'L' : 'R';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate arc
|
// Generate arc
|
||||||
let condition = false;
|
let condition = false;
|
||||||
do {
|
do {
|
||||||
if (leg.TurnDir === "R") {
|
if (leg.TurnDir === 'R') {
|
||||||
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
const delta = (crsIntoEndpoint - lastCourse).normaliseDegrees();
|
||||||
lastCourse += delta < 1 ? delta : 1;
|
lastCourse += delta < 1 ? delta : 1;
|
||||||
lastCourse = lastCourse.normaliseDegrees();
|
lastCourse = lastCourse.normaliseDegrees();
|
||||||
@ -56,9 +53,7 @@ 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 ? previousFix.speed : Parser.AC_SPEED) / 3600).toMetre(),
|
||||||
(previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 3600
|
|
||||||
).toMetre(),
|
|
||||||
lastCourse
|
lastCourse
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -66,7 +61,7 @@ export const TerminatorsTF = (
|
|||||||
|
|
||||||
crsIntoEndpoint = geolib.getGreatCircleBearing(arcFix, targetFix);
|
crsIntoEndpoint = geolib.getGreatCircleBearing(arcFix, targetFix);
|
||||||
|
|
||||||
if (leg.TurnDir === "R") {
|
if (leg.TurnDir === 'R') {
|
||||||
condition = crsIntoEndpoint > trackIntoEndpoint;
|
condition = crsIntoEndpoint > trackIntoEndpoint;
|
||||||
} else {
|
} else {
|
||||||
condition = crsIntoEndpoint < trackIntoEndpoint;
|
condition = crsIntoEndpoint < trackIntoEndpoint;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import Parser from "../parser.ts";
|
import Parser from '../parser.ts';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.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 = (
|
||||||
@ -12,37 +12,16 @@ export const TerminatorsVA = (
|
|||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and expected altitude
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(
|
...geolib.computeDestinationPoint(
|
||||||
arcEnd,
|
arcEnd,
|
||||||
(
|
(
|
||||||
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) /
|
((leg.Alt.parseAltitude() - (previousFix.altitude ?? 0)) / Parser.AC_VS) *
|
||||||
Parser.AC_VS) *
|
|
||||||
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
((previousFix.speed ? previousFix.speed : Parser.AC_SPEED) / 60)
|
||||||
).toMetre(),
|
).toMetre(),
|
||||||
crsIntoEndpoint
|
crsIntoEndpoint
|
||||||
@ -54,7 +33,6 @@ export const TerminatorsVA = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.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
|
||||||
// NOTE: Distance not adjusted for altitude in this demo
|
// NOTE: Distance not adjusted for altitude in this demo
|
||||||
@ -13,35 +13,14 @@ export const TerminatorsVD = (
|
|||||||
latitude: leg.NavLat,
|
latitude: leg.NavLat,
|
||||||
longitude: leg.NavLon,
|
longitude: leg.NavLon,
|
||||||
};
|
};
|
||||||
|
const crsIntoEndpoint = leg.Course.toTrue(previousFix);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsIntoEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute distance to fly from arc end
|
||||||
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
const crsToNavaid = geolib.getGreatCircleBearing(arcEnd, navaid);
|
||||||
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
const distToNavaid = geolib.getDistance(arcEnd, navaid);
|
||||||
let remainingDistance = leg.Distance.toMetre();
|
let remainingDistance = leg.Distance.toMetre();
|
||||||
@ -52,9 +31,10 @@ export const TerminatorsVD = (
|
|||||||
// Navaid in front of us
|
// Navaid in front of us
|
||||||
else {
|
else {
|
||||||
// Navaid will not be passed before distance is hit
|
// Navaid will not be passed before distance is hit
|
||||||
if (distToNavaid > remainingDistance)
|
if (distToNavaid > remainingDistance) remainingDistance = distToNavaid - remainingDistance;
|
||||||
remainingDistance = distToNavaid - remainingDistance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and distance
|
||||||
const targetFix: NavFix = {
|
const targetFix: NavFix = {
|
||||||
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
...geolib.computeDestinationPoint(arcEnd, remainingDistance, lastCourse),
|
||||||
name: leg.Distance.toString(),
|
name: leg.Distance.toString(),
|
||||||
@ -64,7 +44,6 @@ export const TerminatorsVD = (
|
|||||||
speedConstraint: leg.SpeedLimit,
|
speedConstraint: leg.SpeedLimit,
|
||||||
altitudeConstraint: leg.Alt,
|
altitudeConstraint: leg.Alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
line.push([targetFix.longitude, targetFix.latitude]);
|
line.push([targetFix.longitude, targetFix.latitude]);
|
||||||
|
|
||||||
return [targetFix, line];
|
return [targetFix, line];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
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 { 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
|
||||||
export const TerminatorsVI = (
|
export const TerminatorsVI = (
|
||||||
@ -15,12 +15,7 @@ export const TerminatorsVI = (
|
|||||||
|
|
||||||
// Compute INTC
|
// Compute INTC
|
||||||
const interceptFix: NavFix = {
|
const interceptFix: NavFix = {
|
||||||
...computeIntersection(
|
...computeIntersection(previousFix, leg.Course.toTrue(nextFix), nextFix, crs)!,
|
||||||
previousFix,
|
|
||||||
leg.Course.toTrue(nextFix),
|
|
||||||
nextFix,
|
|
||||||
crs
|
|
||||||
)!,
|
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
altitude: leg.Alt ? leg.Alt.parseAltitude() : previousFix.altitude,
|
||||||
speed: speed,
|
speed: speed,
|
||||||
@ -48,10 +43,7 @@ export const TerminatorsVI = (
|
|||||||
if (interceptPoint2)
|
if (interceptPoint2)
|
||||||
return [
|
return [
|
||||||
{ ...interceptFix, ...interceptPoint2 },
|
{ ...interceptFix, ...interceptPoint2 },
|
||||||
[
|
[...line.slice(0, -1), [interceptPoint2.longitude, interceptPoint2.latitude]],
|
||||||
...line.slice(0, -1),
|
|
||||||
[interceptPoint2.longitude, interceptPoint2.latitude],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return [interceptFix, line];
|
return [interceptFix, line];
|
||||||
|
|||||||
@ -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 { computeSpeed } from "../utils/computeSpeed.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 TerminatorsVM = (
|
export const TerminatorsVM = (
|
||||||
@ -10,11 +10,7 @@ export const TerminatorsVM = (
|
|||||||
): [NavFix?, LineSegment[]?] => {
|
): [NavFix?, LineSegment[]?] => {
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
const endpoint = geolib.computeDestinationPoint(
|
const endpoint = geolib.computeDestinationPoint(previousFix, (10).toMetre(), leg.Course.toTrue(previousFix));
|
||||||
previousFix,
|
|
||||||
(10).toMetre(),
|
|
||||||
leg.Course.toTrue(previousFix)
|
|
||||||
);
|
|
||||||
|
|
||||||
const line = handleTurnAtFix(
|
const line = handleTurnAtFix(
|
||||||
leg.Course.toTrue(previousFix),
|
leg.Course.toTrue(previousFix),
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import * as geolib from "geolib";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc.ts';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection.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
|
||||||
export const TerminatorsVR = (
|
export const TerminatorsVR = (
|
||||||
@ -17,31 +16,11 @@ export const TerminatorsVR = (
|
|||||||
const crsIntoEndpoint = leg.NavBear.toTrue(navaid);
|
const crsIntoEndpoint = leg.NavBear.toTrue(navaid);
|
||||||
const speed = computeSpeed(leg, previousFix);
|
const speed = computeSpeed(leg, previousFix);
|
||||||
|
|
||||||
let line: LineSegment[] = [];
|
// Compute overfly
|
||||||
|
const [line, arcEnd, _lastCourse] = generateOverflyArc(crsFromEndpoint, lastCourse, previousFix, speed, leg.TurnDir);
|
||||||
if (previousFix.isFlyOver) {
|
lastCourse = _lastCourse;
|
||||||
line = generatePerformanceArc(
|
|
||||||
crsFromEndpoint,
|
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Compute intercept of crs from arc end and radial
|
||||||
const interceptFix: NavFix = {
|
const interceptFix: NavFix = {
|
||||||
...computeIntersection(arcEnd, crsFromEndpoint, navaid, crsIntoEndpoint)!,
|
...computeIntersection(arcEnd, crsFromEndpoint, navaid, crsIntoEndpoint)!,
|
||||||
isFlyOver: leg.IsFlyOver,
|
isFlyOver: leg.IsFlyOver,
|
||||||
|
|||||||
@ -5,12 +5,7 @@
|
|||||||
* @param brng2 bearing from Point 2
|
* @param brng2 bearing from Point 2
|
||||||
* @returns Intersection point
|
* @returns Intersection point
|
||||||
*/
|
*/
|
||||||
export const computeIntersection = (
|
export const computeIntersection = (p1: NavFix, brng1: number, p2: NavFix, brng2: number): NavFix | undefined => {
|
||||||
p1: NavFix,
|
|
||||||
brng1: number,
|
|
||||||
p2: NavFix,
|
|
||||||
brng2: number
|
|
||||||
): NavFix | undefined => {
|
|
||||||
if (isNaN(brng1)) throw new TypeError(`invalid brng1 ${brng1}`);
|
if (isNaN(brng1)) throw new TypeError(`invalid brng1 ${brng1}`);
|
||||||
if (isNaN(brng2)) throw new TypeError(`invalid brng2 ${brng2}`);
|
if (isNaN(brng2)) throw new TypeError(`invalid brng2 ${brng2}`);
|
||||||
|
|
||||||
@ -31,20 +26,13 @@ export const computeIntersection = (
|
|||||||
const δ12 =
|
const δ12 =
|
||||||
2 *
|
2 *
|
||||||
Math.asin(
|
Math.asin(
|
||||||
Math.sqrt(
|
Math.sqrt(Math.sin(Δφ / 2) * Math.sin(Δφ / 2) + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2))
|
||||||
Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
||||||
Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
if (Math.abs(δ12) < Number.EPSILON) return p1; // coincident points
|
if (Math.abs(δ12) < Number.EPSILON) return p1; // coincident points
|
||||||
|
|
||||||
// initial/final bearings between points
|
// initial/final bearings between points
|
||||||
const cosθa =
|
const cosθa = (Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ1));
|
||||||
(Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) /
|
const cosθb = (Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ2));
|
||||||
(Math.sin(δ12) * Math.cos(φ1));
|
|
||||||
const cosθb =
|
|
||||||
(Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) /
|
|
||||||
(Math.sin(δ12) * Math.cos(φ2));
|
|
||||||
const θa = Math.acos(Math.min(Math.max(cosθa, -1), 1)); // protect against rounding errors
|
const θa = Math.acos(Math.min(Math.max(cosθa, -1), 1)); // protect against rounding errors
|
||||||
const θb = Math.acos(Math.min(Math.max(cosθb, -1), 1)); // protect against rounding errors
|
const θb = Math.acos(Math.min(Math.max(cosθb, -1), 1)); // protect against rounding errors
|
||||||
|
|
||||||
@ -57,29 +45,15 @@ export const computeIntersection = (
|
|||||||
if (Math.sin(α1) == 0 && Math.sin(α2) == 0) return undefined; // infinite intersections
|
if (Math.sin(α1) == 0 && Math.sin(α2) == 0) return undefined; // infinite intersections
|
||||||
if (Math.sin(α1) * Math.sin(α2) < 0) return undefined; // ambiguous intersection (antipodal/360°)
|
if (Math.sin(α1) * Math.sin(α2) < 0) return undefined; // ambiguous intersection (antipodal/360°)
|
||||||
|
|
||||||
const cosα3 =
|
const cosα3 = -Math.cos(α1) * Math.cos(α2) + Math.sin(α1) * Math.sin(α2) * Math.cos(δ12);
|
||||||
-Math.cos(α1) * Math.cos(α2) + Math.sin(α1) * Math.sin(α2) * Math.cos(δ12);
|
|
||||||
|
|
||||||
const δ13 = Math.atan2(
|
const δ13 = Math.atan2(Math.sin(δ12) * Math.sin(α1) * Math.sin(α2), Math.cos(α2) + Math.cos(α1) * cosα3);
|
||||||
Math.sin(δ12) * Math.sin(α1) * Math.sin(α2),
|
|
||||||
Math.cos(α2) + Math.cos(α1) * cosα3
|
|
||||||
);
|
|
||||||
|
|
||||||
const φ3 = Math.asin(
|
const φ3 = Math.asin(
|
||||||
Math.min(
|
Math.min(Math.max(Math.sin(φ1) * Math.cos(δ13) + Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13), -1), 1)
|
||||||
Math.max(
|
|
||||||
Math.sin(φ1) * Math.cos(δ13) +
|
|
||||||
Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13),
|
|
||||||
-1
|
|
||||||
),
|
|
||||||
1
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const Δλ13 = Math.atan2(
|
const Δλ13 = Math.atan2(Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1), Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3));
|
||||||
Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1),
|
|
||||||
Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3)
|
|
||||||
);
|
|
||||||
const λ3 = λ1 + Δλ13;
|
const λ3 = λ1 + Δλ13;
|
||||||
|
|
||||||
const lat = φ3.toDegrees();
|
const lat = φ3.toDegrees();
|
||||||
@ -89,7 +63,7 @@ export const computeIntersection = (
|
|||||||
...p1,
|
...p1,
|
||||||
latitude: lat,
|
latitude: lat,
|
||||||
longitude: lon,
|
longitude: lon,
|
||||||
name: "INTC",
|
name: 'INTC',
|
||||||
isIntersection: true,
|
isIntersection: true,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Parser from "../parser.ts";
|
import Parser from '../parser.ts';
|
||||||
|
|
||||||
export const computeSpeed = (leg: TerminalEntry, previousFix: NavFix) => {
|
export const computeSpeed = (leg: TerminalEntry, previousFix: NavFix) => {
|
||||||
if (leg.SpeedLimit) return leg.SpeedLimit;
|
if (leg.SpeedLimit) return leg.SpeedLimit;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { magvar } from "magvar";
|
import { magvar } from 'magvar';
|
||||||
|
|
||||||
Number.prototype.toRadians = function () {
|
Number.prototype.toRadians = function () {
|
||||||
return ((this as number) * Math.PI) / 180;
|
return ((this as number) * Math.PI) / 180;
|
||||||
@ -15,8 +15,8 @@ Number.prototype.normaliseDegrees = function () {
|
|||||||
return (this as number) >= 360
|
return (this as number) >= 360
|
||||||
? (this as number) - 360
|
? (this as number) - 360
|
||||||
: (this as number) < 0
|
: (this as number) < 0
|
||||||
? (this as number) + 360
|
? (this as number) + 360
|
||||||
: (this as number);
|
: (this as number);
|
||||||
};
|
};
|
||||||
Number.prototype.toTrue = function (fix) {
|
Number.prototype.toTrue = function (fix) {
|
||||||
const _magvar = magvar(fix.latitude, fix.longitude); //Magvar is returned + for East
|
const _magvar = magvar(fix.latitude, fix.longitude); //Magvar is returned + for East
|
||||||
|
|||||||
@ -1,26 +1,23 @@
|
|||||||
import * as geolib from "geolib";
|
import * as geolib from 'geolib';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param leg Leg to examine
|
* @param leg Leg to examine
|
||||||
* @param origin Origin of current leg
|
* @param origin Origin of current leg
|
||||||
* @returns Adjusted course and fix
|
* @returns Adjusted course and fix
|
||||||
*/
|
*/
|
||||||
export const getCourseAndFixForIntercepts = (
|
export const getCourseAndFixForIntercepts = (leg: TerminalEntry, origin: NavFix): [number, NavFix] => {
|
||||||
leg: TerminalEntry,
|
|
||||||
origin: NavFix
|
|
||||||
): [number, NavFix] => {
|
|
||||||
switch (leg.TrackCode) {
|
switch (leg.TrackCode) {
|
||||||
case "CF": {
|
case 'CF': {
|
||||||
const _leg = leg as CFTerminalEntry;
|
const _leg = leg as CFTerminalEntry;
|
||||||
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
||||||
return [_leg.Course.reciprocalCourse().toTrue(fix), fix];
|
return [_leg.Course.reciprocalCourse().toTrue(fix), fix];
|
||||||
}
|
}
|
||||||
case "FM": {
|
case 'FM': {
|
||||||
const _leg = leg as FMTerminalEntry;
|
const _leg = leg as FMTerminalEntry;
|
||||||
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
||||||
return [_leg.Course.toTrue(fix), fix];
|
return [_leg.Course.toTrue(fix), fix];
|
||||||
}
|
}
|
||||||
case "TF": {
|
case 'TF': {
|
||||||
const _leg = leg as FMTerminalEntry;
|
const _leg = leg as FMTerminalEntry;
|
||||||
return [
|
return [
|
||||||
geolib.getGreatCircleBearing(origin, {
|
geolib.getGreatCircleBearing(origin, {
|
||||||
@ -30,7 +27,7 @@ export const getCourseAndFixForIntercepts = (
|
|||||||
{ latitude: _leg.WptLat, longitude: _leg.WptLon },
|
{ latitude: _leg.WptLat, longitude: _leg.WptLon },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case "AF": {
|
case 'AF': {
|
||||||
const _leg = leg as AFTerminalEntry;
|
const _leg = leg as AFTerminalEntry;
|
||||||
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
||||||
return [_leg.Course.reciprocalCourse().toTrue(fix), fix];
|
return [_leg.Course.reciprocalCourse().toTrue(fix), fix];
|
||||||
|
|||||||
2
browser/src/types/geojson.d.ts
vendored
2
browser/src/types/geojson.d.ts
vendored
@ -1,3 +1,3 @@
|
|||||||
declare module "geojson" {
|
declare module 'geojson' {
|
||||||
export const parse: (data: object, format: object) => object;
|
export const parse: (data: object, format: object) => object;
|
||||||
}
|
}
|
||||||
|
|||||||
24
browser/src/types/leaflet.d.ts
vendored
24
browser/src/types/leaflet.d.ts
vendored
@ -1,21 +1,21 @@
|
|||||||
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
import * as L from "leaflet";
|
import 'leaflet';
|
||||||
|
|
||||||
declare module "leaflet" {
|
declare module 'leaflet' {
|
||||||
export function shapeMarker(
|
export function shapeMarker(
|
||||||
latlng: LatLngExpression,
|
latlng: LatLngExpression,
|
||||||
options?: PathOptions & {
|
options?: PathOptions & {
|
||||||
shape?:
|
shape?:
|
||||||
| "diamond"
|
| 'diamond'
|
||||||
| "square"
|
| 'square'
|
||||||
| "triangle"
|
| 'triangle'
|
||||||
| "triangle-up"
|
| 'triangle-up'
|
||||||
| "triangle-down"
|
| 'triangle-down'
|
||||||
| "arrowhead"
|
| 'arrowhead'
|
||||||
| "arrowhead-up"
|
| 'arrowhead-up'
|
||||||
| "arrowhead-down"
|
| 'arrowhead-down'
|
||||||
| "circle"
|
| 'circle'
|
||||||
| "x"
|
| 'x'
|
||||||
| string;
|
| string;
|
||||||
radius?: number;
|
radius?: number;
|
||||||
rotation?: number;
|
rotation?: number;
|
||||||
|
|||||||
2
browser/src/types/magvar.d.ts
vendored
2
browser/src/types/magvar.d.ts
vendored
@ -1,3 +1,3 @@
|
|||||||
declare module "magvar" {
|
declare module 'magvar' {
|
||||||
export const magvar: (latitude: number, longitude: number) => number;
|
export const magvar: (latitude: number, longitude: number) => number;
|
||||||
}
|
}
|
||||||
|
|||||||
11
browser/src/types/terminators/AF.d.ts
vendored
11
browser/src/types/terminators/AF.d.ts
vendored
@ -2,16 +2,7 @@ export declare global {
|
|||||||
type AFTerminalEntry = Required<
|
type AFTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
'WptID' | 'WptLat' | 'WptLon' | 'TurnDir' | 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'NavDist' | 'Course'
|
||||||
| "WptLat"
|
|
||||||
| "WptLon"
|
|
||||||
| "TurnDir"
|
|
||||||
| "NavID"
|
|
||||||
| "NavLat"
|
|
||||||
| "NavLon"
|
|
||||||
| "NavBear"
|
|
||||||
| "NavDist"
|
|
||||||
| "Course"
|
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
3
browser/src/types/terminators/CA.d.ts
vendored
3
browser/src/types/terminators/CA.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type CATerminalEntry = Required<Pick<TerminalEntry, "Course" | "Alt">> &
|
type CATerminalEntry = Required<Pick<TerminalEntry, 'Course' | 'Alt'>> & TerminalEntry;
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
browser/src/types/terminators/CD.d.ts
vendored
4
browser/src/types/terminators/CD.d.ts
vendored
@ -1,6 +1,4 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type CDTerminalEntry = Required<
|
type CDTerminalEntry = Required<Pick<TerminalEntry, 'NavID' | 'NavLat' | 'NavLon' | 'Course' | 'Distance'>> &
|
||||||
Pick<TerminalEntry, "NavID" | "NavLat" | "NavLon" | "Course" | "Distance">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
11
browser/src/types/terminators/CF.d.ts
vendored
11
browser/src/types/terminators/CF.d.ts
vendored
@ -2,16 +2,7 @@ export declare global {
|
|||||||
type CFTerminalEntry = Required<
|
type CFTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
'WptID' | 'WptLat' | 'WptLon' | 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'NavDist' | 'Course' | 'Distance'
|
||||||
| "WptLat"
|
|
||||||
| "WptLon"
|
|
||||||
| "NavID"
|
|
||||||
| "NavLat"
|
|
||||||
| "NavLon"
|
|
||||||
| "NavBear"
|
|
||||||
| "NavDist"
|
|
||||||
| "Course"
|
|
||||||
| "Distance"
|
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
3
browser/src/types/terminators/CI.d.ts
vendored
3
browser/src/types/terminators/CI.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type CITerminalEntry = Required<Pick<TerminalEntry, "Course">> &
|
type CITerminalEntry = Required<Pick<TerminalEntry, 'Course'>> & TerminalEntry;
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
browser/src/types/terminators/CR.d.ts
vendored
4
browser/src/types/terminators/CR.d.ts
vendored
@ -1,6 +1,4 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type CRTerminalEntry = Required<
|
type CRTerminalEntry = Required<Pick<TerminalEntry, 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'Course'>> &
|
||||||
Pick<TerminalEntry, "NavID" | "NavLat" | "NavLon" | "NavBear" | "Course">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
5
browser/src/types/terminators/DF.d.ts
vendored
5
browser/src/types/terminators/DF.d.ts
vendored
@ -1,6 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type DFTerminalEntry = Required<
|
type DFTerminalEntry = Required<Pick<TerminalEntry, 'WptID' | 'WptLat' | 'WptLon' | 'IsFlyOver'>> & TerminalEntry;
|
||||||
Pick<TerminalEntry, "WptID" | "WptLat" | "WptLon" | "IsFlyOver">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
browser/src/types/terminators/FA.d.ts
vendored
11
browser/src/types/terminators/FA.d.ts
vendored
@ -2,16 +2,7 @@ export declare global {
|
|||||||
type FATerminalEntry = Required<
|
type FATerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
'WptID' | 'WptLat' | 'WptLon' | 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'NavDist' | 'Course' | 'Alt'
|
||||||
| "WptLat"
|
|
||||||
| "WptLon"
|
|
||||||
| "NavID"
|
|
||||||
| "NavLat"
|
|
||||||
| "NavLon"
|
|
||||||
| "NavBear"
|
|
||||||
| "NavDist"
|
|
||||||
| "Course"
|
|
||||||
| "Alt"
|
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
22
browser/src/types/terminators/FC.d.ts
vendored
22
browser/src/types/terminators/FC.d.ts
vendored
@ -2,17 +2,17 @@ export declare global {
|
|||||||
type FCTerminalEntry = Required<
|
type FCTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
| 'WptID'
|
||||||
| "WptLat"
|
| 'WptLat'
|
||||||
| "WptLon"
|
| 'WptLon'
|
||||||
| "IsFlyOver"
|
| 'IsFlyOver'
|
||||||
| "NavID"
|
| 'NavID'
|
||||||
| "NavLat"
|
| 'NavLat'
|
||||||
| "NavLon"
|
| 'NavLon'
|
||||||
| "NavBear"
|
| 'NavBear'
|
||||||
| "NavDist"
|
| 'NavDist'
|
||||||
| "Course"
|
| 'Course'
|
||||||
| "Distance"
|
| 'Distance'
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
11
browser/src/types/terminators/FD.d.ts
vendored
11
browser/src/types/terminators/FD.d.ts
vendored
@ -2,16 +2,7 @@ export declare global {
|
|||||||
type FDTerminalEntry = Required<
|
type FDTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
'WptID' | 'WptLat' | 'WptLon' | 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'NavDist' | 'Course' | 'Distance'
|
||||||
| "WptLat"
|
|
||||||
| "WptLon"
|
|
||||||
| "NavID"
|
|
||||||
| "NavLat"
|
|
||||||
| "NavLon"
|
|
||||||
| "NavBear"
|
|
||||||
| "NavDist"
|
|
||||||
| "Course"
|
|
||||||
| "Distance"
|
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
10
browser/src/types/terminators/FM.d.ts
vendored
10
browser/src/types/terminators/FM.d.ts
vendored
@ -2,15 +2,7 @@ export declare global {
|
|||||||
type FMTerminalEntry = Required<
|
type FMTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
'WptID' | 'WptLat' | 'WptLon' | 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'NavDist' | 'Course'
|
||||||
| "WptLat"
|
|
||||||
| "WptLon"
|
|
||||||
| "NavID"
|
|
||||||
| "NavLat"
|
|
||||||
| "NavLon"
|
|
||||||
| "NavBear"
|
|
||||||
| "NavDist"
|
|
||||||
| "Course"
|
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
5
browser/src/types/terminators/IF.d.ts
vendored
5
browser/src/types/terminators/IF.d.ts
vendored
@ -1,6 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type IFTerminalEntry = Required<
|
type IFTerminalEntry = Required<Pick<TerminalEntry, 'WptID' | 'WptLat' | 'WptLon'>> & TerminalEntry;
|
||||||
Pick<TerminalEntry, "WptID" | "WptLat" | "WptLon">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
20
browser/src/types/terminators/RF.d.ts
vendored
20
browser/src/types/terminators/RF.d.ts
vendored
@ -2,16 +2,16 @@ export declare global {
|
|||||||
type RFTerminalEntry = Required<
|
type RFTerminalEntry = Required<
|
||||||
Pick<
|
Pick<
|
||||||
TerminalEntry,
|
TerminalEntry,
|
||||||
| "WptID"
|
| 'WptID'
|
||||||
| "WptLat"
|
| 'WptLat'
|
||||||
| "WptLon"
|
| 'WptLon'
|
||||||
| "TurnDir"
|
| 'TurnDir'
|
||||||
| "NavBear"
|
| 'NavBear'
|
||||||
| "Course"
|
| 'Course'
|
||||||
| "Distance"
|
| 'Distance'
|
||||||
| "CenterID"
|
| 'CenterID'
|
||||||
| "CenterLat"
|
| 'CenterLat'
|
||||||
| "CenterLon"
|
| 'CenterLon'
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
|
|||||||
5
browser/src/types/terminators/TF.d.ts
vendored
5
browser/src/types/terminators/TF.d.ts
vendored
@ -1,6 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type TFTerminalEntry = Required<
|
type TFTerminalEntry = Required<Pick<TerminalEntry, 'WptID' | 'WptLat' | 'WptLon' | 'IsFlyOver'>> & TerminalEntry;
|
||||||
Pick<TerminalEntry, "WptID" | "WptLat" | "WptLon" | "IsFlyOver">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
3
browser/src/types/terminators/VA.d.ts
vendored
3
browser/src/types/terminators/VA.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type VATerminalEntry = Required<Pick<TerminalEntry, "Course" | "Alt">> &
|
type VATerminalEntry = Required<Pick<TerminalEntry, 'Course' | 'Alt'>> & TerminalEntry;
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
browser/src/types/terminators/VD.d.ts
vendored
4
browser/src/types/terminators/VD.d.ts
vendored
@ -1,6 +1,4 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type VDTerminalEntry = Required<
|
type VDTerminalEntry = Required<Pick<TerminalEntry, 'NavID' | 'NavLat' | 'NavLon' | 'Course' | 'Distance'>> &
|
||||||
Pick<TerminalEntry, "NavID" | "NavLat" | "NavLon" | "Course" | "Distance">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
3
browser/src/types/terminators/VI.d.ts
vendored
3
browser/src/types/terminators/VI.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type VITerminalEntry = Required<Pick<TerminalEntry, "Course">> &
|
type VITerminalEntry = Required<Pick<TerminalEntry, 'Course'>> & TerminalEntry;
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
3
browser/src/types/terminators/VM.d.ts
vendored
3
browser/src/types/terminators/VM.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type VMTerminalEntry = Required<Pick<TerminalEntry, "Course">> &
|
type VMTerminalEntry = Required<Pick<TerminalEntry, 'Course'>> & TerminalEntry;
|
||||||
TerminalEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
browser/src/types/terminators/VR.d.ts
vendored
4
browser/src/types/terminators/VR.d.ts
vendored
@ -1,6 +1,4 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
type VRTerminalEntry = Required<
|
type VRTerminalEntry = Required<Pick<TerminalEntry, 'NavID' | 'NavLat' | 'NavLon' | 'NavBear' | 'Course'>> &
|
||||||
Pick<TerminalEntry, "NavID" | "NavLat" | "NavLon" | "NavBear" | "Course">
|
|
||||||
> &
|
|
||||||
TerminalEntry;
|
TerminalEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
50
browser/src/types/types.d.ts
vendored
50
browser/src/types/types.d.ts
vendored
@ -14,31 +14,31 @@ export declare global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type TrackCode =
|
type TrackCode =
|
||||||
| "AF"
|
| 'AF'
|
||||||
| "CA"
|
| 'CA'
|
||||||
| "CD"
|
| 'CD'
|
||||||
| "CF"
|
| 'CF'
|
||||||
| "CI"
|
| 'CI'
|
||||||
| "CR"
|
| 'CR'
|
||||||
| "DF"
|
| 'DF'
|
||||||
| "FA"
|
| 'FA'
|
||||||
| "FC"
|
| 'FC'
|
||||||
| "FD"
|
| 'FD'
|
||||||
| "FM"
|
| 'FM'
|
||||||
| "HA"
|
| 'HA'
|
||||||
| "HF"
|
| 'HF'
|
||||||
| "HM"
|
| 'HM'
|
||||||
| "IF"
|
| 'IF'
|
||||||
| "PI"
|
| 'PI'
|
||||||
| "RF"
|
| 'RF'
|
||||||
| "TF"
|
| 'TF'
|
||||||
| "VA"
|
| 'VA'
|
||||||
| "VD"
|
| 'VD'
|
||||||
| "VI"
|
| 'VI'
|
||||||
| "VM"
|
| 'VM'
|
||||||
| "VR";
|
| 'VR';
|
||||||
|
|
||||||
type TurnDirection = "E" | "L" | "R";
|
type TurnDirection = 'E' | 'L' | 'R';
|
||||||
|
|
||||||
type TerminalEntry = {
|
type TerminalEntry = {
|
||||||
ID: number;
|
ID: number;
|
||||||
@ -82,7 +82,7 @@ export declare global {
|
|||||||
speed?: number;
|
speed?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
isFlyOver?: boolean;
|
isFlyOver?: boolean;
|
||||||
"marker-color"?: string;
|
'marker-color'?: string;
|
||||||
altitudeConstraint?: string;
|
altitudeConstraint?: string;
|
||||||
speedConstraint?: number;
|
speedConstraint?: number;
|
||||||
// For map
|
// For map
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
"files": [],
|
||||||
"references": [
|
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { defineConfig } from 'vite'
|
import react from '@vitejs/plugin-react-swc';
|
||||||
import react from '@vitejs/plugin-react-swc'
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
})
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user