Compare commits
4 Commits
8b04be187e
...
f593cbd29a
| Author | SHA1 | Date | |
|---|---|---|---|
| f593cbd29a | |||
| e4ed55cac9 | |||
| 13bea68195 | |||
| 50077746f0 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -21,4 +21,6 @@ dist-ssr
|
|||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
.env
|
||||||
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -5,16 +5,11 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Parser Node",
|
"name": "Launch Chrome against localhost",
|
||||||
"skipFiles": ["<node_internals>/**"],
|
"url": "http://localhost:3000",
|
||||||
"args": [
|
"webRoot": "${workspaceFolder}/browser"
|
||||||
"--experimental-strip-types",
|
|
||||||
"${workspaceFolder}\\browser\\src\\parser\\node.ts"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}\\browser\\",
|
|
||||||
"outFiles": ["${workspaceFolder}/**/*.js"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
6
TODO.md
6
TODO.md
@ -0,0 +1,6 @@
|
|||||||
|
Revise list of charts to only show those applicable to the selected procedure (so terminal itself and all transitions accompanied)
|
||||||
|
Revise image overlay
|
||||||
|
- Find center of full page
|
||||||
|
- Find center of georeferenced area
|
||||||
|
- Calculate skew parameters
|
||||||
|
- Skew geobounds
|
||||||
3
browser/.prettierignore
Normal file
3
browser/.prettierignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
public
|
||||||
|
pnpm-lock.yaml
|
||||||
|
node_modules
|
||||||
9
browser/.prettierrc
Normal file
9
browser/.prettierrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 120,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": true,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"singleQuote": true,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"]
|
||||||
|
}
|
||||||
@ -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,13 @@ export default tseslint.config([
|
|||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-shadow": "error",
|
'@typescript-eslint/no-shadow': 'error',
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
destructuredArrayIgnorePattern: '^_+$',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<link href="/src/style.css" rel="stylesheet">
|
||||||
|
|
||||||
<title>MD-11 NavData Browser</title>
|
<title>MD-11 NavData Browser</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -4,26 +4,30 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite --port 3000 --host",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint . --ext .ts,.tsx --fix",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"parser": "node --experimental-strip-types src/parser/node.ts"
|
"parser": "node --experimental-strip-types src/parser/node.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"browser-image-manipulation": "^0.4.0",
|
||||||
"geojson": "^0.5.0",
|
"geojson": "^0.5.0",
|
||||||
"geolib": "^3.3.4",
|
"geolib": "^3.3.4",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"leaflet-svg-shape-markers": "^1.4.0",
|
"leaflet-svg-shape-markers": "^1.4.0",
|
||||||
"magvar": "^2.0.0",
|
"magvar": "^2.0.0",
|
||||||
|
"navigraph": "^1.4.1",
|
||||||
|
"qrcode.react": "^4.2.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-leaflet": "^5.0.0"
|
"react-leaflet": "^5.0.0",
|
||||||
|
"tailwindcss": "^4.1.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.31.0",
|
"@eslint/js": "^9.31.0",
|
||||||
|
"@tailwindcss/vite": "^4.1.11",
|
||||||
"@types/leaflet": "^1.9.20",
|
"@types/leaflet": "^1.9.20",
|
||||||
"@types/node": "^24.0.13",
|
|
||||||
"@types/object-hash": "^3.0.6",
|
"@types/object-hash": "^3.0.6",
|
||||||
"@types/react": "^19.1.8",
|
"@types/react": "^19.1.8",
|
||||||
"@types/react-dom": "^19.1.6",
|
"@types/react-dom": "^19.1.6",
|
||||||
@ -33,8 +37,11 @@
|
|||||||
"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",
|
||||||
|
"prettier-plugin-tailwindcss": "^0.6.14",
|
||||||
"typescript": "~5.8.3",
|
"typescript": "~5.8.3",
|
||||||
"typescript-eslint": "^8.36.0",
|
"typescript-eslint": "^8.37.0",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
919
browser/pnpm-lock.yaml
generated
919
browser/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
1
browser/public/navdata/Airports.json
Normal file
1
browser/public/navdata/Airports.json
Normal file
File diff suppressed because one or more lines are too long
1
browser/public/navdata/README.MD
Normal file
1
browser/public/navdata/README.MD
Normal file
@ -0,0 +1 @@
|
|||||||
|
Copy over contents of `Data/Primary` retaining the structure.
|
||||||
@ -1,153 +1,77 @@
|
|||||||
import { MapContainer, GeoJSON, TileLayer } from "react-leaflet";
|
import type { DeviceFlowParams } from 'navigraph/auth';
|
||||||
import Parser from "./parser/parser";
|
import { QRCodeSVG } from 'qrcode.react';
|
||||||
import { createRef, useEffect, useState } from "react";
|
import { useState } from 'react';
|
||||||
import hash from "object-hash";
|
import { ProcedureSelect } from './components//ProcedureSelect';
|
||||||
import Leaflet from "leaflet";
|
import { Map } from './components/Map';
|
||||||
import "leaflet-svg-shape-markers";
|
import { useNavigraphAuth } from './hooks/useNavigraphAuth';
|
||||||
import L from "leaflet";
|
import Parser from './parser/parser';
|
||||||
|
|
||||||
const parser = await Parser.instance();
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
const terminals = [
|
|
||||||
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 [selectedAirport, setSelectedAirport] = useState<Airport>();
|
||||||
const [procedures, setProcedures] = useState<object[]>([]);
|
const [selectedRunway, setSelectedRunway] = useState<Runway>();
|
||||||
|
const [selectedTerminal, setSelectedTerminal] = useState<Terminal>();
|
||||||
|
const [procedures, setProcedures] = useState<{ name: string; data: object }[]>([]);
|
||||||
|
const [params, setParams] = useState<DeviceFlowParams | null>(null);
|
||||||
|
|
||||||
const mapRef = createRef<Leaflet.Map>();
|
const { user, signIn, initialized } = useNavigraphAuth();
|
||||||
const layerRef = createRef<Leaflet.GeoJSON>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleSignIn = () => signIn((p) => setParams(p));
|
||||||
(async () => {
|
|
||||||
setProcedures(await parser.parse(selectedTerminal));
|
|
||||||
})();
|
|
||||||
}, [selectedTerminal]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (layerRef.current && mapRef.current) {
|
|
||||||
mapRef.current.flyToBounds(layerRef.current.getBounds(), {
|
|
||||||
animate: false,
|
|
||||||
padding: [50, 50],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "flex", height: "100vh", width: "100vw" }}>
|
<>
|
||||||
<MapContainer
|
{procedures.length === 0 ? (
|
||||||
center={[51.505, -0.09]}
|
<div className="flex min-h-dvh w-full">
|
||||||
zoom={13}
|
{!initialized && <div>Loading...</div>}
|
||||||
zoomSnap={0}
|
|
||||||
zoomDelta={0.1}
|
|
||||||
wheelPxPerZoomLevel={1000}
|
|
||||||
style={{ height: "100%", width: "100%" }}
|
|
||||||
ref={mapRef}
|
|
||||||
>
|
|
||||||
<TileLayer
|
|
||||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
||||||
/>
|
|
||||||
{procedures.map((procedure) => (
|
|
||||||
<>
|
|
||||||
<GeoJSON
|
|
||||||
key={hash(procedure ?? "") + "lines"}
|
|
||||||
data={procedure}
|
|
||||||
style={({ properties }) => ({
|
|
||||||
color: "#ff00ff",
|
|
||||||
stroke: true,
|
|
||||||
weight: 5,
|
|
||||||
opacity: 1,
|
|
||||||
dashArray: properties.isManual ? "20, 20" : undefined,
|
|
||||||
})}
|
|
||||||
filter={(feature) => feature.geometry.type !== "Point"}
|
|
||||||
ref={layerRef}
|
|
||||||
/>
|
|
||||||
<GeoJSON
|
|
||||||
key={hash(procedure ?? "") + "points"}
|
|
||||||
data={procedure}
|
|
||||||
style={{
|
|
||||||
color: "black",
|
|
||||||
fill: true,
|
|
||||||
fillColor: "transparent",
|
|
||||||
stroke: true,
|
|
||||||
weight: 3,
|
|
||||||
}}
|
|
||||||
pointToLayer={({ properties }, latlng) => {
|
|
||||||
if (properties.isFlyOver)
|
|
||||||
return L.shapeMarker(latlng, {
|
|
||||||
shape: "triangle",
|
|
||||||
radius: 6,
|
|
||||||
});
|
|
||||||
if (properties.isIntersection)
|
|
||||||
return L.circleMarker(latlng, { radius: 6 });
|
|
||||||
|
|
||||||
return L.shapeMarker(latlng, {
|
{initialized && !params && !user && <button onClick={handleSignIn}>Sign in</button>}
|
||||||
shape: "star-4",
|
|
||||||
radius: 10,
|
{params?.verification_uri_complete && !user && (
|
||||||
rotation: 45,
|
<>
|
||||||
});
|
<QRCodeSVG value={params.verification_uri_complete} size={250} />
|
||||||
}}
|
<a href={params.verification_uri_complete} target="_blank" rel="noreferrer">
|
||||||
onEachFeature={({ geometry, properties }, layer) => {
|
Open sign in page
|
||||||
if (geometry.type === "Point") {
|
</a>
|
||||||
layer.bindPopup(
|
</>
|
||||||
`${properties.name}<br>
|
)}
|
||||||
${properties.altitude} ft<br>
|
{user && (
|
||||||
${properties.speed} kts<br>
|
<ProcedureSelect
|
||||||
CNSTR:
|
selectedAirport={selectedAirport}
|
||||||
${properties.altitudeConstraint ?? ""}
|
selectedRunway={selectedRunway}
|
||||||
${properties.speedConstraint ?? ""}<br>`
|
selectedTerminal={selectedTerminal}
|
||||||
);
|
setSelectedAirport={setSelectedAirport}
|
||||||
}
|
setSelectedRunway={setSelectedRunway}
|
||||||
}}
|
setSelectedTerminal={setSelectedTerminal}
|
||||||
filter={(feature) => feature.geometry.type === "Point"}
|
handleSelection={(selectedTransitions) =>
|
||||||
|
setProcedures(
|
||||||
|
selectedTransitions.map((transition) => ({
|
||||||
|
name: transition,
|
||||||
|
data: parser.parse(selectedRunway!, transition),
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
)}
|
||||||
))}
|
|
||||||
</MapContainer>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
overflowY: "scroll",
|
|
||||||
width: "200px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
padding: "5px",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
gap: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{terminals.map((terminal) => (
|
|
||||||
<div
|
|
||||||
key={terminal}
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
background: "#eeeeee",
|
|
||||||
border:
|
|
||||||
selectedTerminal === terminal
|
|
||||||
? "1px solid black"
|
|
||||||
: "1px solid #eeeeee",
|
|
||||||
padding: "5px",
|
|
||||||
}}
|
|
||||||
onClick={() => setSelectedTerminal(terminal)}
|
|
||||||
>
|
|
||||||
<span style={{ whiteSpace: "nowrap" }}>
|
|
||||||
{(() => {
|
|
||||||
const t = parser.terminals.find(({ ID }) => ID === terminal);
|
|
||||||
return `${t?.ICAO} - ${t?.FullName}`;
|
|
||||||
})()}
|
|
||||||
</span>
|
|
||||||
<pre>({terminal})</pre>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : (
|
||||||
</div>
|
<div className="flex h-dvh w-dvw">
|
||||||
|
{procedures.length > 0 && selectedAirport && selectedTerminal ? (
|
||||||
|
<Map
|
||||||
|
airport={selectedAirport}
|
||||||
|
terminal={selectedTerminal}
|
||||||
|
procedures={procedures}
|
||||||
|
backAction={() => {
|
||||||
|
setSelectedTerminal(undefined);
|
||||||
|
setProcedures([]);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<h1 className="text-center text-3xl">Error</h1>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
197
browser/src/components/Map.tsx
Normal file
197
browser/src/components/Map.tsx
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
import BrowserImageManipulation from 'browser-image-manipulation';
|
||||||
|
import { default as L, type LatLngBoundsExpression } from 'leaflet';
|
||||||
|
import 'leaflet-svg-shape-markers';
|
||||||
|
import { type Chart } from 'navigraph/charts';
|
||||||
|
import { createRef, useEffect, useState, type FC } from 'react';
|
||||||
|
import { GeoJSON, ImageOverlay, MapContainer, TileLayer } from 'react-leaflet';
|
||||||
|
import { charts } from '../lib/navigraph';
|
||||||
|
|
||||||
|
interface MapProps {
|
||||||
|
airport: Airport;
|
||||||
|
terminal: Terminal;
|
||||||
|
procedures: { name: string; data: object }[];
|
||||||
|
backAction: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Map: FC<MapProps> = ({ airport, terminal, procedures, backAction }) => {
|
||||||
|
const [selectedProcedure, setSelectedProcedure] = useState(procedures[0]);
|
||||||
|
const [chartIndex, setChartIndex] = useState<Chart[]>([]);
|
||||||
|
const [selectedChart, setSelectedChart] = useState<{
|
||||||
|
data: string;
|
||||||
|
index_number: string;
|
||||||
|
bounds: LatLngBoundsExpression;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const mapRef = createRef<L.Map>();
|
||||||
|
const imageRef = createRef<L.ImageOverlay>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
setChartIndex((await charts.getChartsIndex({ icao: airport.ICAO, version: 'STD' })) ?? []);
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
className="fixed top-2 left-2 z-[5000] cursor-pointer rounded border border-red-500 bg-red-500 px-2 py-1 font-semibold text-stone-50 focus:outline-2 focus:outline-black focus-visible:outline-2 focus-visible:outline-black"
|
||||||
|
onClick={backAction}
|
||||||
|
>
|
||||||
|
Go back
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<MapContainer
|
||||||
|
center={[airport.Latitude, airport.Longitude]}
|
||||||
|
zoom={13}
|
||||||
|
zoomSnap={0}
|
||||||
|
className="h-full w-full"
|
||||||
|
ref={(_mapRef) => {
|
||||||
|
_mapRef?.attributionControl.setPosition('topright');
|
||||||
|
_mapRef?.zoomControl.setPosition('topright');
|
||||||
|
mapRef.current = _mapRef;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TileLayer
|
||||||
|
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{selectedChart && selectedChart.bounds && (
|
||||||
|
<ImageOverlay
|
||||||
|
url={selectedChart.data}
|
||||||
|
bounds={selectedChart.bounds}
|
||||||
|
opacity={0.75}
|
||||||
|
ref={(_imageRef) => {
|
||||||
|
if (_imageRef) {
|
||||||
|
mapRef.current?.fitBounds(_imageRef.getBounds(), {
|
||||||
|
padding: [-50, -50],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
imageRef.current = _imageRef;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<GeoJSON
|
||||||
|
key={`${selectedProcedure.name}-lines`}
|
||||||
|
data={selectedProcedure.data}
|
||||||
|
style={({ properties }) => ({
|
||||||
|
color: '#ff00ff',
|
||||||
|
stroke: true,
|
||||||
|
weight: 5,
|
||||||
|
opacity: 1,
|
||||||
|
dashArray: properties.isManual ? '20, 20' : undefined,
|
||||||
|
})}
|
||||||
|
filter={(feature) => feature.geometry.type !== 'Point'}
|
||||||
|
/>
|
||||||
|
<GeoJSON
|
||||||
|
key={`${selectedProcedure.name}-points`}
|
||||||
|
data={selectedProcedure.data}
|
||||||
|
style={{
|
||||||
|
color: 'black',
|
||||||
|
fill: true,
|
||||||
|
fillColor: 'transparent',
|
||||||
|
stroke: true,
|
||||||
|
weight: 3,
|
||||||
|
}}
|
||||||
|
pointToLayer={({ properties }, latlng) => {
|
||||||
|
if (properties.isFlyOver)
|
||||||
|
return L.shapeMarker(latlng, {
|
||||||
|
shape: 'triangle',
|
||||||
|
radius: 6,
|
||||||
|
});
|
||||||
|
if (properties.isIntersection) return L.circleMarker(latlng, { radius: 6 });
|
||||||
|
|
||||||
|
return L.shapeMarker(latlng, {
|
||||||
|
shape: 'star-4',
|
||||||
|
radius: 10,
|
||||||
|
rotation: 45,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
onEachFeature={({ geometry, properties }, layer) => {
|
||||||
|
if (geometry.type === 'Point') {
|
||||||
|
layer.bindPopup(
|
||||||
|
`${properties.name}<br>
|
||||||
|
${properties.altitude} ft<br>
|
||||||
|
${properties.speed} kts<br>
|
||||||
|
CNSTR:
|
||||||
|
${properties.altitudeConstraint ?? ''}
|
||||||
|
${properties.speedConstraint ?? ''}<br>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
filter={(feature) => feature.geometry.type === 'Point'}
|
||||||
|
/>
|
||||||
|
</MapContainer>
|
||||||
|
|
||||||
|
<div className="absolute right-0 bottom-0 left-0 z-[5000] bg-[#ffffff77] bg-blend-color backdrop-blur-xs">
|
||||||
|
<div className="flex items-center gap-2 overflow-x-auto p-2">
|
||||||
|
<span className="text-lg font-semibold">Procedures:</span>
|
||||||
|
{procedures.map((procedure) => (
|
||||||
|
<button
|
||||||
|
key={procedure.name}
|
||||||
|
className={`cursor-pointer rounded border border-gray-300 bg-gray-300 px-2 py-1 font-semibold focus:outline-2 focus:outline-black focus-visible:outline-2 focus-visible:outline-black ${selectedProcedure.name === procedure.name ? 'outline-2' : ''}`}
|
||||||
|
onClick={() => {
|
||||||
|
if (selectedProcedure.name === procedure.name) return;
|
||||||
|
|
||||||
|
setSelectedProcedure(procedure);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{procedure.name ? procedure.name : 'ZZZZ'}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-lg font-semibold">Charts:</span>
|
||||||
|
<div className="flex items-center gap-2 overflow-x-auto p-2">
|
||||||
|
{chartIndex
|
||||||
|
.filter((chart) => chart.is_georeferenced)
|
||||||
|
.map((chart) => (
|
||||||
|
<button
|
||||||
|
key={chart.index_number}
|
||||||
|
className={`cursor-pointer rounded border border-gray-300 bg-gray-300 px-2 py-1 font-semibold whitespace-nowrap focus:outline-2 focus:outline-black focus-visible:outline-2 focus-visible:outline-black ${selectedChart?.index_number === chart.index_number ? 'outline-2' : ''}`}
|
||||||
|
onClick={async () => {
|
||||||
|
if (selectedChart?.index_number === chart.index_number) return;
|
||||||
|
|
||||||
|
if (!mapRef.current) return;
|
||||||
|
|
||||||
|
if (!chart.bounding_boxes) return;
|
||||||
|
|
||||||
|
const planView = chart.bounding_boxes.planview;
|
||||||
|
|
||||||
|
const chartImage = await charts.getChartImage({ chart, theme: 'light' });
|
||||||
|
if (!chartImage) return;
|
||||||
|
// Crop
|
||||||
|
const dataURL = await new BrowserImageManipulation()
|
||||||
|
.loadBlob(chartImage)
|
||||||
|
.crop(
|
||||||
|
planView.pixels.x2 - planView.pixels.x1,
|
||||||
|
planView.pixels.y1 - planView.pixels.y2,
|
||||||
|
planView.pixels.x1,
|
||||||
|
planView.pixels.y2
|
||||||
|
)
|
||||||
|
.saveAsImage();
|
||||||
|
|
||||||
|
const bounds = new L.LatLngBounds(
|
||||||
|
[planView.latlng.lat1, planView.latlng.lng1],
|
||||||
|
[planView.latlng.lat2, planView.latlng.lng2]
|
||||||
|
);
|
||||||
|
|
||||||
|
setSelectedChart({ data: dataURL, index_number: chart.index_number, bounds });
|
||||||
|
|
||||||
|
if (imageRef.current) {
|
||||||
|
mapRef.current?.fitBounds(imageRef.current.getBounds(), {
|
||||||
|
padding: [-50, -50],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{chart.name}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
125
browser/src/components/ProcedureSelect.tsx
Normal file
125
browser/src/components/ProcedureSelect.tsx
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
import { createRef, useMemo, useState, type Dispatch, type FC, type SetStateAction } from 'react';
|
||||||
|
import Parser from '../parser/parser';
|
||||||
|
|
||||||
|
const parser = await Parser.instance();
|
||||||
|
|
||||||
|
interface ProcedureSelectProps {
|
||||||
|
selectedAirport: Airport | undefined;
|
||||||
|
selectedRunway: Runway | undefined;
|
||||||
|
selectedTerminal: Terminal | undefined;
|
||||||
|
setSelectedAirport: Dispatch<SetStateAction<Airport | undefined>>;
|
||||||
|
setSelectedRunway: Dispatch<SetStateAction<Runway | undefined>>;
|
||||||
|
setSelectedTerminal: Dispatch<SetStateAction<Terminal | undefined>>;
|
||||||
|
handleSelection: (transitions: string[]) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProcedureSelect: FC<ProcedureSelectProps> = ({
|
||||||
|
selectedAirport,
|
||||||
|
selectedRunway,
|
||||||
|
selectedTerminal,
|
||||||
|
setSelectedAirport,
|
||||||
|
setSelectedRunway,
|
||||||
|
setSelectedTerminal,
|
||||||
|
handleSelection,
|
||||||
|
}) => {
|
||||||
|
const inputRef = createRef<HTMLInputElement>();
|
||||||
|
const [error, setError] = useState<string>();
|
||||||
|
|
||||||
|
const runways = useMemo(
|
||||||
|
() => parser.runways.filter(({ AirportID }) => AirportID === selectedAirport?.ID),
|
||||||
|
[selectedAirport]
|
||||||
|
);
|
||||||
|
const terminals = useMemo(
|
||||||
|
() =>
|
||||||
|
parser.terminals.filter(
|
||||||
|
({ AirportID, RwyID }) => AirportID === selectedAirport?.ID && (!RwyID || RwyID === selectedRunway?.ID)
|
||||||
|
),
|
||||||
|
[selectedAirport, selectedRunway]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex w-full flex-col items-center justify-center gap-2 p-2">
|
||||||
|
{selectedAirport && (
|
||||||
|
<button
|
||||||
|
className="fixed top-2 left-2 cursor-pointer rounded border border-red-500 bg-red-500 px-2 py-1 font-semibold text-stone-50 focus:outline-2 focus:outline-black focus-visible:outline-2 focus-visible:outline-black"
|
||||||
|
onClick={() => {
|
||||||
|
setError(undefined);
|
||||||
|
|
||||||
|
if (selectedTerminal) {
|
||||||
|
setSelectedTerminal(undefined);
|
||||||
|
} else if (selectedRunway) {
|
||||||
|
setSelectedRunway(undefined);
|
||||||
|
} else if (selectedAirport) {
|
||||||
|
setSelectedAirport(undefined);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Go back
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!selectedAirport && (
|
||||||
|
<div className="flex w-full flex-col gap-2">
|
||||||
|
<h1 className="text-center text-3xl">Enter Airport ICAO</h1>
|
||||||
|
<input
|
||||||
|
ref={inputRef}
|
||||||
|
className="rounded border border-black px-2 py-1 focus:outline-2 focus-visible:outline-2"
|
||||||
|
onChange={(e) => {
|
||||||
|
if (e.target.value.length <= 4) e.target.value = e.target.value.toUpperCase();
|
||||||
|
else e.target.value = e.target.value.slice(0, 4);
|
||||||
|
}}
|
||||||
|
></input>
|
||||||
|
<button
|
||||||
|
className="w-full cursor-pointer rounded border border-gray-300 bg-gray-300 px-2 py-1 font-semibold focus:outline-2 focus-visible:outline-2"
|
||||||
|
onClick={() => {
|
||||||
|
const airport = parser.airports.find(({ ICAO }) => ICAO === inputRef.current?.value.toUpperCase());
|
||||||
|
if (!airport) {
|
||||||
|
setError('Airport not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSelectedAirport(airport);
|
||||||
|
setError(undefined);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Select Airport
|
||||||
|
</button>
|
||||||
|
{error && <span className="text-center text-red-700">{error}</span>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{selectedAirport && !selectedRunway && (
|
||||||
|
<div className="flex w-full flex-col gap-2">
|
||||||
|
<h1 className="text-center text-3xl">Select Runway</h1>
|
||||||
|
{runways.map((runway) => (
|
||||||
|
<button
|
||||||
|
key={runway.ID}
|
||||||
|
className="w-full cursor-pointer rounded border border-gray-300 bg-gray-300 px-2 py-1 font-semibold focus:outline-2 focus-visible:outline-2"
|
||||||
|
onClick={() => setSelectedRunway(runway)}
|
||||||
|
>
|
||||||
|
Runway {runway.Ident}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{selectedAirport && selectedRunway && !selectedTerminal && (
|
||||||
|
<div className="flex w-full flex-col gap-2">
|
||||||
|
<h1 className="text-center text-3xl">Select Procedure</h1>
|
||||||
|
{terminals.map((terminal) => (
|
||||||
|
<button
|
||||||
|
key={terminal.ID}
|
||||||
|
className="cursor-pointer rounded border border-gray-300 bg-gray-300 px-2 py-1 font-semibold focus:outline-2 focus-visible:outline-2"
|
||||||
|
onClick={() => {
|
||||||
|
parser.loadTerminal(terminal.ID).then(() => {
|
||||||
|
setSelectedTerminal(terminal);
|
||||||
|
const transitions = new Set(parser.procedures.map((proc) => proc.Transition));
|
||||||
|
handleSelection(Array.from(transitions));
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{terminal.FullName}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
53
browser/src/hooks/useNavigraphAuth.tsx
Normal file
53
browser/src/hooks/useNavigraphAuth.tsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { type User } from 'navigraph/auth';
|
||||||
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||||
|
import { auth } from '../lib/navigraph';
|
||||||
|
|
||||||
|
interface NavigraphAuthContext {
|
||||||
|
initialized: boolean;
|
||||||
|
user: User | null;
|
||||||
|
signIn: typeof auth.signInWithDeviceFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
const authContext = createContext<NavigraphAuthContext>({
|
||||||
|
initialized: false,
|
||||||
|
user: null,
|
||||||
|
signIn: () => Promise.reject('Not initialized'),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provider hook that creates auth object and handles state
|
||||||
|
function useProvideAuth() {
|
||||||
|
const [user, setUser] = useState<User | null>(null);
|
||||||
|
const [initialized, setinitialized] = useState(false);
|
||||||
|
|
||||||
|
// Subscribe to user on mount
|
||||||
|
// Because this sets state in the callback it will cause any
|
||||||
|
// component that utilizes this hook to re-render with the latest auth object.
|
||||||
|
useEffect(() => {
|
||||||
|
const unsubscribe = auth.onAuthStateChanged((u) => {
|
||||||
|
if (!initialized) setinitialized(true);
|
||||||
|
setUser(u);
|
||||||
|
});
|
||||||
|
// Cleanup subscription on unmount
|
||||||
|
return () => unsubscribe();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
user,
|
||||||
|
initialized,
|
||||||
|
signIn: auth.signInWithDeviceFlow,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provider component that wraps your app and makes auth object
|
||||||
|
// available to any child component that calls useAuth().
|
||||||
|
export function NavigraphAuthProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const auth = useProvideAuth();
|
||||||
|
return <authContext.Provider value={auth}>{children}</authContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook for child components to get the auth object
|
||||||
|
// and re-render when it changes.
|
||||||
|
export const useNavigraphAuth = () => {
|
||||||
|
return useContext(authContext);
|
||||||
|
};
|
||||||
@ -1,8 +0,0 @@
|
|||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
21
browser/src/lib/navigraph.ts
Normal file
21
browser/src/lib/navigraph.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { initializeApp, Scope, type NavigraphApp } from 'navigraph/app';
|
||||||
|
import { getAuth } from 'navigraph/auth';
|
||||||
|
import { getChartsAPI } from 'navigraph/charts';
|
||||||
|
|
||||||
|
const config: NavigraphApp = {
|
||||||
|
clientId: import.meta.env.VITE_NG_CLIENT_ID,
|
||||||
|
clientSecret: import.meta.env.VITE_NG_CLIENT_SECRET,
|
||||||
|
scopes: [Scope.CHARTS],
|
||||||
|
};
|
||||||
|
|
||||||
|
initializeApp(config);
|
||||||
|
|
||||||
|
export const auth = getAuth({
|
||||||
|
storage: {
|
||||||
|
// Optional
|
||||||
|
getItem: (key) => localStorage.getItem('NG' + key),
|
||||||
|
setItem: (key, value) => localStorage.setItem('NG' + key, value),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const charts = getChartsAPI();
|
||||||
@ -1,12 +1,14 @@
|
|||||||
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 { NavigraphAuthProvider } from './hooks/useNavigraphAuth.tsx';
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<NavigraphAuthProvider>
|
||||||
|
<App />
|
||||||
|
</NavigraphAuthProvider>
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
import Parser from "./parser.ts";
|
|
||||||
|
|
||||||
// mutate fetch to be local
|
|
||||||
|
|
||||||
// @ts-expect-error Global override
|
|
||||||
// eslint-disable-next-line no-global-assign
|
|
||||||
fetch = async (path: string) => {
|
|
||||||
const fs = await import("fs");
|
|
||||||
return {
|
|
||||||
json: () =>
|
|
||||||
JSON.parse(fs.readFileSync(`public/${path}`) as unknown as string),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const parser = await Parser.instance();
|
|
||||||
|
|
||||||
console.log(JSON.stringify(await parser.parse(12765)));
|
|
||||||
@ -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';
|
||||||
import { TerminatorsCF } from "./terminators/CF.ts";
|
import { TerminatorsCA } from './terminators/CA';
|
||||||
import { TerminatorsAF } from "./terminators/AF.ts";
|
import { TerminatorsCD } from './terminators/CD';
|
||||||
import { TerminatorsCR } from "./terminators/CR.ts";
|
import { TerminatorsCF } from './terminators/CF';
|
||||||
import { TerminatorsVM } from "./terminators/VM.ts";
|
import { TerminatorsCI } from './terminators/CI';
|
||||||
import { TerminatorsFM } from "./terminators/FM.ts";
|
import { TerminatorsCR } from './terminators/CR';
|
||||||
import { TerminatorsCI } from "./terminators/CI.ts";
|
import { TerminatorsDF } from './terminators/DF';
|
||||||
import { TerminatorsVA } from "./terminators/VA.ts";
|
import { TerminatorsFA } from './terminators/FA';
|
||||||
import { TerminatorsTF } from "./terminators/TF.ts";
|
import { TerminatorsFC } from './terminators/FC';
|
||||||
import { TerminatorsVI } from "./terminators/VI.ts";
|
import { TerminatorsFD } from './terminators/FD';
|
||||||
import { TerminatorsVD } from "./terminators/VD.ts";
|
import { TerminatorsFM } from './terminators/FM';
|
||||||
import { TerminatorsRF } from "./terminators/RF.ts";
|
import { TerminatorsIF } from './terminators/IF';
|
||||||
import { TerminatorsCA } from "./terminators/CA.ts";
|
import { TerminatorsRF } from './terminators/RF';
|
||||||
import { TerminatorsDF } from "./terminators/DF.ts";
|
import { TerminatorsTF } from './terminators/TF';
|
||||||
import { TerminatorsFD } from "./terminators/FD.ts";
|
import { TerminatorsVA } from './terminators/VA';
|
||||||
import { TerminatorsFA } from "./terminators/FA.ts";
|
import { TerminatorsVD } from './terminators/VD';
|
||||||
import { TerminatorsCD } from "./terminators/CD.ts";
|
import { TerminatorsVI } from './terminators/VI';
|
||||||
import { TerminatorsVR } from "./terminators/VR.ts";
|
import { TerminatorsVM } from './terminators/VM';
|
||||||
import { TerminatorsIF } from "./terminators/IF.ts";
|
import { TerminatorsVR } from './terminators/VR';
|
||||||
import { TerminatorsFC } from "./terminators/FC.ts";
|
import './utils/extensions';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Runway IDs for LIED
|
Runway IDs for LIED
|
||||||
@ -30,19 +30,19 @@ Runway IDs for LIED
|
|||||||
class Parser {
|
class Parser {
|
||||||
private static _instance: Parser;
|
private static _instance: Parser;
|
||||||
|
|
||||||
|
private _airports: Airport[];
|
||||||
private _waypoints: Waypoint[];
|
private _waypoints: Waypoint[];
|
||||||
private _runways: Runway[];
|
private _runways: Runway[];
|
||||||
private _terminals: Terminal[];
|
private _terminals: Terminal[];
|
||||||
|
|
||||||
|
private _procedures: TerminalEntry[] = [];
|
||||||
|
|
||||||
public static AC_SPEED = 250;
|
public static AC_SPEED = 250;
|
||||||
public static AC_BANK = 30;
|
public static AC_BANK = 30;
|
||||||
public static AC_VS = 1400;
|
public static AC_VS = 1400;
|
||||||
|
|
||||||
private constructor(
|
private constructor(airports: Airport[], waypoints: Waypoint[], runways: Runway[], terminals: Terminal[]) {
|
||||||
waypoints: Waypoint[],
|
this._airports = airports;
|
||||||
runways: Runway[],
|
|
||||||
terminals: Terminal[]
|
|
||||||
) {
|
|
||||||
this._waypoints = waypoints;
|
this._waypoints = waypoints;
|
||||||
this._runways = runways;
|
this._runways = runways;
|
||||||
this._terminals = terminals;
|
this._terminals = terminals;
|
||||||
@ -50,16 +50,20 @@ 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 airports = await (await fetch('NavData/Airports.json')).json();
|
||||||
const runways = await (await fetch("NavData/Runways.json")).json();
|
const waypoints = await (await fetch('NavData/Waypoints.json')).json();
|
||||||
const terminals = await (await fetch("NavData/Terminals.json")).json();
|
const runways = await (await fetch('NavData/Runways.json')).json();
|
||||||
|
const terminals = await (await fetch('NavData/Terminals.json')).json();
|
||||||
|
|
||||||
Parser._instance = new Parser(waypoints, runways, terminals);
|
Parser._instance = new Parser(airports, waypoints, runways, terminals);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Parser._instance;
|
return Parser._instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public get airports() {
|
||||||
|
return this._airports;
|
||||||
|
}
|
||||||
public get terminals() {
|
public get terminals() {
|
||||||
return this._terminals;
|
return this._terminals;
|
||||||
}
|
}
|
||||||
@ -70,287 +74,199 @@ class Parser {
|
|||||||
return this._runways;
|
return this._runways;
|
||||||
}
|
}
|
||||||
|
|
||||||
public parse = async (terminalID: number) => {
|
public get procedures() {
|
||||||
// Get Procedure main
|
return this._procedures;
|
||||||
const terminal = this.terminals.find(({ ID }) => ID === terminalID);
|
}
|
||||||
if (!terminal) throw new Error("Procedure does not exists");
|
|
||||||
// Get runway this procedure is for
|
|
||||||
let runway = this.runways.find(({ ID }) => ID === terminal.RwyID);
|
|
||||||
if (!runway) {
|
|
||||||
let id = 26156;
|
|
||||||
if (typeof prompt !== "undefined")
|
|
||||||
// throw new Error("Prompt not defined, cannot continue");
|
|
||||||
|
|
||||||
id = Number.parseInt(prompt("Runway ID") ?? "");
|
public loadTerminal = async (terminalID: number) => {
|
||||||
runway = this.runways.find(({ ID }) => ID === id);
|
this._procedures = (await (
|
||||||
if (!runway) throw new Error("Procedure links to non existent Runway");
|
await fetch(`NavData/ProcedureLegs/TermID_${terminalID}.json`)
|
||||||
}
|
|
||||||
// Load procedure
|
|
||||||
const procedures = (await (
|
|
||||||
await fetch(`NavData/TermID_${terminalID}.json`)
|
|
||||||
).json()) as TerminalEntry[];
|
).json()) as TerminalEntry[];
|
||||||
// Split into transitions
|
};
|
||||||
const transitions = new Set(procedures.map((proc) => proc.Transition));
|
|
||||||
|
|
||||||
const output: object[] = [];
|
public parse = (runway: Runway, transition: string) => {
|
||||||
|
// Private functions
|
||||||
|
/**
|
||||||
|
* @param line Line segments
|
||||||
|
*/
|
||||||
|
const updateLastCourse = (line: LineSegment[]) => {
|
||||||
|
lastCourse = geolib.getGreatCircleBearing(
|
||||||
|
{
|
||||||
|
latitude: line.at(-2)![1],
|
||||||
|
longitude: line.at(-2)![0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
latitude: line.at(-1)![1],
|
||||||
|
longitude: line.at(-1)![0],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fix New fix
|
||||||
|
* @param line New line
|
||||||
|
* @param options Options for line rendering
|
||||||
|
*/
|
||||||
|
const update = (fix?: NavFix, line?: LineSegment[], options?: Record<string, unknown>) => {
|
||||||
|
if (fix) navFixes.push(fix);
|
||||||
|
if (line) {
|
||||||
|
lineSegments.push({ line, ...options });
|
||||||
|
updateLastCourse(line);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Output variables
|
||||||
|
const navFixes: NavFix[] = [];
|
||||||
|
const lineSegments: { line: LineSegment[]; [x: string]: unknown }[] = [];
|
||||||
|
|
||||||
|
// Initials
|
||||||
|
navFixes.push({
|
||||||
|
latitude: runway.Latitude,
|
||||||
|
longitude: runway.Longitude,
|
||||||
|
altitude: runway.Elevation,
|
||||||
|
speed: 0,
|
||||||
|
name: runway.Ident,
|
||||||
|
});
|
||||||
|
let lastCourse = runway.TrueHeading;
|
||||||
|
const procedure = this._procedures.filter(({ Transition }) => !Transition || Transition === transition);
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
transitions.forEach((transition) => {
|
for (let index = 0; index < procedure.length; index++) {
|
||||||
// Private functions
|
const leg = procedure[index];
|
||||||
/**
|
const previousFix = navFixes.at(-1)!;
|
||||||
* @param line Line segments
|
const waypoint = this.waypoints.filter(({ ID }) => ID === leg.WptID)[0];
|
||||||
*/
|
|
||||||
const updateLastCourse = (line: LineSegment[]) => {
|
|
||||||
lastCourse = geolib.getGreatCircleBearing(
|
|
||||||
{
|
|
||||||
latitude: line.at(-2)![1],
|
|
||||||
longitude: line.at(-2)![0],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
latitude: line.at(-1)![1],
|
|
||||||
longitude: line.at(-1)![0],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
switch (leg.TrackCode) {
|
||||||
* @param fix New fix
|
case 'AF': {
|
||||||
* @param line New line
|
const [fixToAdd, lineToAdd] = TerminatorsAF(leg as AFTerminalEntry, previousFix, waypoint);
|
||||||
* @param options Options for line rendering
|
update(fixToAdd, lineToAdd);
|
||||||
*/
|
break;
|
||||||
const update = (
|
|
||||||
fix?: NavFix,
|
|
||||||
line?: LineSegment[],
|
|
||||||
options?: Record<string, unknown>
|
|
||||||
) => {
|
|
||||||
if (fix) navFixes.push(fix);
|
|
||||||
if (line) {
|
|
||||||
lineSegments.push({ line, ...options });
|
|
||||||
updateLastCourse(line);
|
|
||||||
}
|
}
|
||||||
};
|
case 'CA': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsCA(leg as CATerminalEntry, previousFix, lastCourse);
|
||||||
// Output variables
|
update(fixToAdd, lineToAdd);
|
||||||
const navFixes: NavFix[] = [];
|
break;
|
||||||
const lineSegments: { line: LineSegment[]; [x: string]: unknown }[] = [];
|
|
||||||
|
|
||||||
// Initials
|
|
||||||
navFixes.push({
|
|
||||||
latitude: runway.Latitude,
|
|
||||||
longitude: runway.Longitude,
|
|
||||||
altitude: runway.Elevation,
|
|
||||||
speed: 0,
|
|
||||||
name: runway.Ident,
|
|
||||||
});
|
|
||||||
let lastCourse = runway.TrueHeading;
|
|
||||||
|
|
||||||
const procedure = procedures.filter(
|
|
||||||
(proc) => proc.Transition === transition
|
|
||||||
);
|
|
||||||
for (let index = 0; index < procedure.length; index++) {
|
|
||||||
const leg = procedure[index];
|
|
||||||
const previousFix = navFixes.at(-1)!;
|
|
||||||
const waypoint = this.waypoints.filter(({ ID }) => ID === leg.WptID)[0];
|
|
||||||
|
|
||||||
switch (leg.TrackCode) {
|
|
||||||
case "AF": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsAF(
|
|
||||||
leg as AFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CA": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCA(
|
|
||||||
leg as CATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CD": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCD(
|
|
||||||
leg as CDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CF": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCF(
|
|
||||||
leg as CFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CI": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCI(
|
|
||||||
leg as CITerminalEntry,
|
|
||||||
procedure[index + 1],
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CR": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsCR(
|
|
||||||
leg as CRTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "DF": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsDF(
|
|
||||||
leg as DFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "FA": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFA(
|
|
||||||
leg as FATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "FC": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFC(
|
|
||||||
leg as FCTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "FD": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFD(
|
|
||||||
leg as FDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "FM": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsFM(
|
|
||||||
leg as FMTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd, { isManual: true });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "HA":
|
|
||||||
case "HF":
|
|
||||||
case "HM":
|
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
|
||||||
break;
|
|
||||||
case "IF": {
|
|
||||||
const fixToAdd = TerminatorsIF(leg as RFTerminalEntry, waypoint);
|
|
||||||
navFixes.length = 0;
|
|
||||||
navFixes.push(fixToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "PI":
|
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
|
||||||
break;
|
|
||||||
case "RF": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsRF(
|
|
||||||
leg as RFTerminalEntry,
|
|
||||||
procedure[index + 1],
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "TF": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsTF(
|
|
||||||
leg as TFTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse,
|
|
||||||
waypoint
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "VA": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVA(
|
|
||||||
leg as VATerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "VD": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVD(
|
|
||||||
leg as VDTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "VI": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVI(
|
|
||||||
leg as VITerminalEntry,
|
|
||||||
procedure[index + 1],
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "VM": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVM(
|
|
||||||
leg as VMTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd, { isManual: true });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "VR": {
|
|
||||||
const [fixToAdd, lineToAdd] = TerminatorsVR(
|
|
||||||
leg as VRTerminalEntry,
|
|
||||||
previousFix,
|
|
||||||
lastCourse
|
|
||||||
);
|
|
||||||
update(fixToAdd, lineToAdd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
console.error("Unknown TrackCode", leg.TrackCode);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
case 'CD': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsCD(leg as CDTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'CF': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsCF(leg as CFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'CI': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsCI(
|
||||||
|
leg as CITerminalEntry,
|
||||||
|
procedure[index + 1],
|
||||||
|
previousFix,
|
||||||
|
lastCourse
|
||||||
|
);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'CR': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsCR(leg as CRTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'DF': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsDF(leg as DFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'FA': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsFA(leg as FATerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'FC': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsFC(leg as FCTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'FD': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsFD(leg as FDTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'FM': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsFM(leg as FMTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'HA':
|
||||||
|
case 'HF':
|
||||||
|
case 'HM':
|
||||||
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
|
break;
|
||||||
|
case 'IF': {
|
||||||
|
const fixToAdd = TerminatorsIF(leg as RFTerminalEntry, waypoint);
|
||||||
|
navFixes.length = 0;
|
||||||
|
navFixes.push(fixToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'PI':
|
||||||
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
|
break;
|
||||||
|
case 'RF': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsRF(
|
||||||
|
leg as RFTerminalEntry,
|
||||||
|
procedure[index + 1],
|
||||||
|
previousFix,
|
||||||
|
lastCourse,
|
||||||
|
waypoint
|
||||||
|
);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'TF': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsTF(leg as TFTerminalEntry, previousFix, lastCourse, waypoint);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'VA': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsVA(leg as VATerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'VD': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsVD(leg as VDTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'VI': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsVI(
|
||||||
|
leg as VITerminalEntry,
|
||||||
|
procedure[index + 1],
|
||||||
|
previousFix,
|
||||||
|
lastCourse
|
||||||
|
);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'VM': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsVM(leg as VMTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd, { isManual: true });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'VR': {
|
||||||
|
const [fixToAdd, lineToAdd] = TerminatorsVR(leg as VRTerminalEntry, previousFix, lastCourse);
|
||||||
|
update(fixToAdd, lineToAdd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
console.error('Unknown TrackCode', leg.TrackCode);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output.push(
|
return geojson.parse([...navFixes, ...lineSegments], {
|
||||||
geojson.parse([...navFixes, ...lineSegments], {
|
LineString: 'line',
|
||||||
LineString: "line",
|
Point: ['latitude', 'longitude'],
|
||||||
Point: ["latitude", "longitude"],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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';
|
||||||
import { computeTurnRate } from "../utils/computeTurnRate.ts";
|
import { computeTurnRate } from '../utils/computeTurnRate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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';
|
||||||
import { generatePerformanceArc } from "./generatePerformanceArc.ts";
|
import { generateTangentArc } from './generateTangentArc';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
// 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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from '../utils/getCourseAndFixForIntercepts';
|
||||||
|
|
||||||
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';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
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,
|
||||||
|
|||||||
@ -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';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import Parser from "../parser.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
import { computeTurnRate } from "../utils/computeTurnRate.ts";
|
import { computeTurnRate } from '../utils/computeTurnRate';
|
||||||
|
|
||||||
// NOTE: Distance not adjusted for altitude in this demo
|
// NOTE: Distance not adjusted for altitude in this demo
|
||||||
export const TerminatorsFC = (
|
export const TerminatorsFC = (
|
||||||
@ -20,22 +20,22 @@ export const TerminatorsFC = (
|
|||||||
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
const line: LineSegment[] = [[previousFix.longitude, previousFix.latitude]];
|
||||||
|
|
||||||
if (previousFix.isFlyOver) {
|
if (previousFix.isFlyOver) {
|
||||||
let crsIntoEndpoint = trackIntoEndpoint;
|
const crsIntoEndpoint = trackIntoEndpoint;
|
||||||
|
|
||||||
// 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';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
// 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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
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';
|
||||||
import { generateRFArc } from "../pathGenerators/generateRFArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { getCourseAndFixForIntercepts } from '../utils/getCourseAndFixForIntercepts';
|
||||||
|
|
||||||
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';
|
||||||
import Parser from "../parser.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { generateOverflyArc } from '../pathGenerators/generateOverflyArc';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
// 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';
|
||||||
import { generatePerformanceArc } from "../pathGenerators/generatePerformanceArc.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
// 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';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
import { getCourseAndFixForIntercepts } from "../utils/getCourseAndFixForIntercepts.ts";
|
import { getCourseAndFixForIntercepts } from '../utils/getCourseAndFixForIntercepts';
|
||||||
|
|
||||||
// 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';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
|
|
||||||
// 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';
|
||||||
import { computeIntersection } from "../utils/computeIntersection.ts";
|
import { computeIntersection } from '../utils/computeIntersection';
|
||||||
import { computeSpeed } from "../utils/computeSpeed.ts";
|
import { computeSpeed } from '../utils/computeSpeed';
|
||||||
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';
|
||||||
|
|
||||||
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,11 +27,16 @@ 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];
|
||||||
}
|
}
|
||||||
|
case 'DF': {
|
||||||
|
const _leg = leg as FMTerminalEntry;
|
||||||
|
const fix = { latitude: _leg.WptLat, longitude: _leg.WptLon };
|
||||||
|
return [-1, fix];
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return [-1, origin];
|
return [-1, origin];
|
||||||
}
|
}
|
||||||
|
|||||||
19
browser/src/parser/utils/prompting.ts
Normal file
19
browser/src/parser/utils/prompting.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import readline from 'readline';
|
||||||
|
|
||||||
|
export const prompting = (message: string) => {
|
||||||
|
return new Promise<string | null>((resolve) => {
|
||||||
|
if (typeof prompt !== 'undefined') {
|
||||||
|
return resolve(prompt(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
const rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout,
|
||||||
|
});
|
||||||
|
rl.question(`${message}: `, (id) => {
|
||||||
|
rl.close();
|
||||||
|
|
||||||
|
resolve(id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
1
browser/src/style.css
Normal file
1
browser/src/style.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
25
browser/src/types/leaflet.d.ts
vendored
25
browser/src/types/leaflet.d.ts
vendored
@ -1,21 +1,20 @@
|
|||||||
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
import 'leaflet';
|
||||||
import * as L from "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;
|
||||||
}
|
}
|
||||||
|
|||||||
63
browser/src/types/types.d.ts
vendored
63
browser/src/types/types.d.ts
vendored
@ -6,6 +6,7 @@ export declare global {
|
|||||||
|
|
||||||
type Runway = {
|
type Runway = {
|
||||||
ID: number;
|
ID: number;
|
||||||
|
AirportID: number;
|
||||||
Latitude: number;
|
Latitude: number;
|
||||||
Longitude: number;
|
Longitude: number;
|
||||||
Elevation: number;
|
Elevation: number;
|
||||||
@ -14,31 +15,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;
|
||||||
@ -70,9 +71,10 @@ export declare global {
|
|||||||
|
|
||||||
type Terminal = {
|
type Terminal = {
|
||||||
ID: number;
|
ID: number;
|
||||||
FullName: string;
|
AirportID: number;
|
||||||
ICAO: string;
|
ICAO: string;
|
||||||
RwyID: number;
|
FullName: string;
|
||||||
|
RwyID?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type NavFix = {
|
type NavFix = {
|
||||||
@ -82,7 +84,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
|
||||||
@ -90,4 +92,11 @@ export declare global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type LineSegment = [number, number];
|
type LineSegment = [number, number];
|
||||||
|
|
||||||
|
type Airport = {
|
||||||
|
ID: number;
|
||||||
|
ICAO: string;
|
||||||
|
Latitude: number;
|
||||||
|
Longitude: number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
13
browser/src/vite-env.d.ts
vendored
13
browser/src/vite-env.d.ts
vendored
@ -1 +1,14 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ViteTypeOptions {
|
||||||
|
strictImportMetaEnv: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_NG_CLIENT_ID: string;
|
||||||
|
readonly VITE_NG_CLIENT_SECRET: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
"sourceMap": true,
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
"files": [],
|
||||||
"references": [
|
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
import { defineConfig } from 'vite'
|
import tailwindcss from '@tailwindcss/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: [tailwindcss(), react()],
|
||||||
})
|
build: {
|
||||||
|
sourcemap: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user