Skip to content

Commit

Permalink
display arrow, if airport outside range
Browse files Browse the repository at this point in the history
  • Loading branch information
flogross89 committed Apr 24, 2024
1 parent f1eb495 commit 810666e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
4 changes: 3 additions & 1 deletion fbw-a32nx/src/systems/instruments/src/ND/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"@tcas/*": ["./tcas/src/*"],
"@typings/*": ["../../../fbw-common/src/typings/*"],
"@flybywiresim/fbw-sdk": ["../../../fbw-common/src/systems/index-no-react.ts"],
"@flybywiresim/navigation-display": ["../../../fbw-common/src/systems/instruments/src/ND/index.ts"]
"@flybywiresim/navigation-display": ["../../../fbw-common/src/systems/instruments/src/ND/index.ts"],
"@flybywiresim/oanc": ["../../../fbw-common/src/systems/instruments/src/OANC/index.ts"],
"@flybywiresim/msfs-avionics-common": ["../../../fbw-common/src/systems/instruments/src/MsfsAvionicsCommon/index.ts"]
}
}
}
18 changes: 16 additions & 2 deletions fbw-common/src/systems/instruments/src/OANC/Oanc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
BBox, bbox, bboxPolygon, booleanPointInPolygon, centroid, Feature, featureCollection, FeatureCollection, Geometry, LineString, Point, Polygon,
Position,
} from '@turf/turf';
import { clampAngle, Coordinates, placeBearingDistance } from 'msfs-geo';
import { bearingTo, clampAngle, Coordinates, distanceTo, placeBearingDistance } from 'msfs-geo';

import { OansControlEvents } from 'instruments/src/OANC/OansControlEventPublisher';
import { reciprocal } from '@fmgc/guidance/lnav/CommonGeometry';
Expand Down Expand Up @@ -245,6 +245,10 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {

public readonly aircraftWithinAirport = Subject.create(false);

private readonly airportWithinRange = Subject.create(false);

private readonly airportBearing = Subject.create(0);

public readonly projectedPpos: Position = [0, 0];

private readonly aircraftOnGround = Subject.create(true);
Expand Down Expand Up @@ -478,7 +482,6 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {
this.dataAirportIata.set(wgs84ReferencePoint.properties.iata);

// Figure out the boundaries of the map data

const dataBbox = bbox(airportMap);

this.updatePosition();
Expand Down Expand Up @@ -788,6 +791,11 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {

this.aircraftOnGround.set(![5, 6, 7].includes(SimVar.GetSimVarValue('L:A32NX_FWC_FLIGHT_PHASE', SimVarValueType.Number)));

if (this.arpCoordinates) {
this.airportWithinRange.set(distanceTo(this.ppos, this.arpCoordinates) < (this.props.zoomValues[this.zoomLevelIndex.get()] + 1)); // Add 1nm for airport dimension
this.airportBearing.set(bearingTo(this.ppos, this.arpCoordinates));
}

if (this.usingPposAsReference.get() || !this.arpCoordinates) {
this.referencePos.lat = this.ppos.lat;
this.referencePos.long = this.ppos.long;
Expand Down Expand Up @@ -1207,6 +1215,9 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {
ndMode={this.overlayNDModeSub}
rotation={this.interpolatedMapHeading}
isMapPanned={this.isMapPanned}
airportWithinRange={this.airportWithinRange}
airportBearing={this.airportBearing}
airportIcao={this.dataAirportIcao}
/>
</div>
</div>
Expand All @@ -1229,6 +1240,9 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {
ndMode={this.overlayNDModeSub}
rotation={this.interpolatedMapHeading}
isMapPanned={this.isMapPanned}
airportWithinRange={this.airportWithinRange}
airportBearing={this.airportBearing}
airportIcao={this.dataAirportIcao}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: GPL-3.0

import { Arinc429WordData, MathUtils } from '@flybywiresim/fbw-sdk';
import { DisplayComponent, EventBus, FSComponent, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { DisplayComponent, EventBus, FSComponent, MappedSubject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Layer } from '../MsfsAvionicsCommon/Layer';

export interface ArcModeOverlayProps {
Expand All @@ -13,11 +13,16 @@ export interface ArcModeOverlayProps {
oansRange: Subscribable<number>,
doClip: boolean,
yOffset: number,
airportWithinRange: Subscribable<boolean>,
airportBearing: Subscribable<number>,
airportIcao: Subscribable<string>,
}

export class ArcModeUnderlay extends DisplayComponent<ArcModeOverlayProps> {
private readonly rotationValid = this.props.rotation.map((it) => it.isNormalOperation());

private readonly rotationToAirport = MappedSubject.create(([bearing, rot]) => MathUtils.diffAngle(rot.value, bearing).toFixed(2), this.props.airportBearing, this.props.rotation)

render(): VNode | null {
return (
<Layer x={384} y={384 - this.props.yOffset} visible={this.props.visible}>
Expand Down Expand Up @@ -53,6 +58,20 @@ export class ArcModeUnderlay extends DisplayComponent<ArcModeOverlayProps> {
clip-path="url(#arc-mode-overlay-clip-2)"
/>
</g>

<g
transform={this.rotationToAirport.map((it) => `translate(369 250) rotate(-90) rotate(${it} -370 0)`)}
class="White"
fill="none"
stroke-width={3}
stroke-linecap="round"
visibility={this.props.airportWithinRange.map((it) => (it ? 'hidden' : 'inherit'))}
>
<path id="svg_5" d="m21,15l-17.33333,-13l60,0l31.66667,12l-31.66667,13l-60.33333,0l17.66667,-12z" />
<g transform={this.rotationToAirport.map((it) => `translate(60 60) rotate(${-it + 90})`)}>
<text text-anchor="middle" font-size={20}>{this.props.airportIcao}</text>
</g>
</g>
</Layer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export interface OancMapOverlayProps {
ndMode: Subscribable<EfisNdMode>,

isMapPanned: Subscribable<boolean>,

airportWithinRange: Subscribable<boolean>,

airportBearing: Subscribable<number>,

airportIcao: Subscribable<string>,
}

export class OancMovingModeOverlay extends DisplayComponent<OancMapOverlayProps> {
Expand Down Expand Up @@ -63,6 +69,9 @@ export class OancMovingModeOverlay extends DisplayComponent<OancMapOverlayProps>
oansRange={this.props.oansRange}
doClip={false}
yOffset={620 - 384}
airportWithinRange={this.props.airportWithinRange}
airportBearing={this.props.airportBearing}
airportIcao={this.props.airportIcao}
/>
</svg>
);
Expand Down Expand Up @@ -110,6 +119,9 @@ export class OancStaticModeOverlay extends DisplayComponent<OancMapOverlayProps>
oansRange={this.props.oansRange}
doClip
yOffset={0}
airportWithinRange={this.props.airportWithinRange}
airportBearing={this.props.airportBearing}
airportIcao={this.props.airportIcao}
/>

<OancPlanModeCompass
Expand Down

0 comments on commit 810666e

Please sign in to comment.