Skip to content

Commit

Permalink
Diverting flight state (#699)
Browse files Browse the repository at this point in the history
* Diversion Detection

* Fixed diversion detection

* Final fix

* Change it entirely because I'm tired of it

* For real fix

* Diversion Detection

Update version

Fix rare callsign fail

Improve ATC scroll pilot

Update default.json

chore(deps): Update dependency nuxt to v3.15.3

chore(deps): Update devDependency stylelint to ^16.14.1

chore(deps): Lockfile Maintenance

1.0.2-alpha.01 Initial Upload

Update CHANGELOG.md

Update package.json

VG Fix

Version bump

Fixed diversion detection

Update average utilization

Temp layers update

(cherry picked from commit 75a4bc3)

chore(deps): Update dependency nuxt to v3.15.4

chore(deps): Update all non-major dependencies

Final fix

Change it entirely because I'm tired of it

1.0.1-2

1.0.1-2

Removed debug

Update deps

Version bump

Temp layers update

Update airlines

chore(deps): Update devDependency @nuxt/eslint to v1

Add update popup

chore(deps): Lockfile Maintenance

Update version

chore(deps): Update dependency idb to ^8.0.2

chore(deps): Update devDependency @types/node to ^22.13.0

Fix METAR

(cherry picked from commit 2d7144c)

Update version

Fix METAR

Fixed overlapping labels

Update version

Update metar fetch stability

Stats Page & Sigmets WIP (#653)

* Init table

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

WIP

Finish sigmets

Version bump

Fix sigmets expiration display

For real fix

* Optimized Diversion Detection

* Finished Diverted Flight Detection

* Diverted Icon

* Placed diverted icon

* Expected "rotate" to come before "fill"

* Requested change + linter request

* Renaming and removing of memory leak :D

* Lint fix

---------

Co-authored-by: Danila Rodichkin <[email protected]>
  • Loading branch information
MindCollaps and daniluk4000 authored Feb 16, 2025
1 parent 8e777f7 commit c002665
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/assets/icons/kit/diverted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 87 additions & 17 deletions src/components/common/vatsim/CommonPilotDestination.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
<template>
<div
v-if="pilot.departure && pilot.arrival"
class="destination"
class="destination_wrap"
>
<common-info-block
:bottom-items="[depAirport?.name]"
class="destination_card"
:is-button="!!depAirport"
text-align="center"
:top-items="[pilot.departure]"
@click="mapStore.addAirportOverlay(depAirport?.icao ?? '')"
/>
<div class="destination_aircraft-icon">
<aircraft-icon/>
<div class="destination">
<common-info-block
:bottom-items="[depAirport?.name]"
class="destination_card"
:is-button="!!depAirport"
text-align="center"
:top-items="[depAirport?.icao]"
@click="mapStore.addAirportOverlay(depAirport?.icao ?? '')"
/>
<div
class="destination_aircraft-icon"
>
<aircraft-icon/>
</div>
<div
v-if="pilot.diverted"
class="diverted_icon"
>
<diverted-icon/>
</div>
<common-info-block
v-if="!pilot.diverted"
:bottom-items="[arrAirport?.name]"
class='destination_card'
:is-button="!!arrAirport"
text-align="center"
:top-items="[arrAirport?.icao]"
@click="mapStore.addAirportOverlay(arrAirport?.icao ?? '')"
/>
<common-info-block
v-if="pilot.diverted"
:bottom-items="[divOrgAirport?.name]"
class='destination_diverted'
:is-button="!!divOrgAirport"
text-align="center"
:top-items="[divOrgAirport?.icao]"
@click="mapStore.addAirportOverlay(divOrgAirport?.icao ?? '')"
/>
</div>
<common-info-block
:bottom-items="[arrAirport?.name]"
class="destination_card"
:is-button="!!arrAirport"
v-if="pilot.diverted"
:bottom-items="['Diverted to ' + divArrAirport?.name]"
class="diverted"
:is-button="!!divArrAirport"
text-align="center"
:top-items="[pilot.arrival]"
@click="mapStore.addAirportOverlay(arrAirport?.icao ?? '')"
:top-items="[divArrAirport?.icao]"
@click="mapStore.addAirportOverlay(divArrAirport?.icao ?? '')"
/>
</div>
</template>
Expand All @@ -29,6 +58,7 @@
import CommonInfoBlock from '~/components/common/blocks/CommonInfoBlock.vue';
import type { VatsimShortenedAircraft } from '~/types/data/vatsim';
import AircraftIcon from '@/assets/icons/kit/aircraft.svg?component';
import DivertedIcon from '@/assets/icons/kit/diverted.svg?component';
import { useMapStore } from '~/store/map';
const props = defineProps({
Expand All @@ -41,10 +71,12 @@ const props = defineProps({
const dataStore = useDataStore();
const mapStore = useMapStore();
const airports = computed(() => dataStore.vatspy.value?.data.airports.filter(x => x.icao === props.pilot.departure || x.icao === props.pilot.arrival) ?? []);
const airports = computed(() => dataStore.vatspy.value?.data.airports.filter(x => x.icao === props.pilot.departure || x.icao === props.pilot.arrival || x.icao === props.pilot.diverted_arrival || x.icao === props.pilot.diverted_origin) ?? []);
const depAirport = computed(() => airports.value.find(x => x.icao === props.pilot.departure));
const arrAirport = computed(() => airports.value.find(x => x.icao === props.pilot.arrival));
const divArrAirport = computed(() => airports.value.find(x => x.icao === props.pilot.diverted_arrival));
const divOrgAirport = computed(() => airports.value.find(x => x.icao === props.pilot.diverted_origin));
</script>

<style scoped lang="scss">
Expand Down Expand Up @@ -87,5 +119,43 @@ const arrAirport = computed(() => airports.value.find(x => x.icao === props.pilo
width: 16px;
}
}
&_diverted {
color: $divertedTextColor;
}
&_wrap {
display: flex;
flex-direction: column;
gap: 4px;
justify-content: center;
}
}
.diverted {
display: flex;
justify-content: center;
padding: 4px;
background: $divertedBackground;
&_icon {
position: absolute;
z-index: 1;
bottom: -13px;
display: flex;
flex: none;
align-items: center;
justify-content: center;
width: auto;
padding: 0 4px;
svg {
rotate: 90deg;
width: 30px;
fill: currentColor;
}
}
}
</style>
3 changes: 3 additions & 0 deletions src/components/map/popups/MapPopupFlightPlan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
:pilot="{
departure: flightPlan.departure,
arrival: flightPlan.arrival,
diverted: flightPlan.diverted,
diverted_arrival: flightPlan.diverted_arrival,
diverted_origin: flightPlan.diverted_origin,
}"
/>
<div
Expand Down
5 changes: 4 additions & 1 deletion src/types/data/vatsim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export type VatsimPilotFlightPlan = Partial<{
revision_id: number;
assigned_transponder: string;
locked?: boolean;
diverted?: boolean;
diverted_arrival?: string;
diverted_origin?: string;
}>;

export interface VatsimController {
Expand Down Expand Up @@ -141,7 +144,7 @@ export type VatsimShortenedData = {
general: VatsimGeneral;
pilots: Array<
Omit<VatsimPilot, 'server' | 'qnh_i_hg' | 'flight_plan' | 'last_updated'> &
Partial<Pick<NonNullable<VatsimPilot['flight_plan']>, 'aircraft_faa' | 'aircraft_short' | 'departure' | 'arrival'>> &
Partial<Pick<NonNullable<VatsimPilot['flight_plan']>, 'aircraft_faa' | 'aircraft_short' | 'departure' | 'arrival' | 'diverted' | 'diverted_arrival' | 'diverted_origin'>> &
Partial<Pick<VatsimExtendedPilot, 'status' | 'depDist' | 'toGoDist'>> & {
filteredColor?: UserMapSettingsColor;
filteredOpacity?: number;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/backend/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export interface RadarStorage {
navigraph: typeof cycles | null;
patreonInfo: PatreonInfo | null;
airlines: RadarDataAirlinesAllList;
extendedPilotsMap: { [key: string]: VatsimExtendedPilot };
}

export const radarStorage: RadarStorage = {
Expand Down Expand Up @@ -232,6 +233,7 @@ export const radarStorage: RadarStorage = {
virtual: {},
all: {},
},
extendedPilotsMap: {},
};

export function getRadarStorage() {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/backend/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { PartialRecord } from '~/types';

export const colorsList = {
mapSectorBorder: '#2d2d30',
divertedBackground: '#de5656',
divertedTextColor: '#97979d',

lightgray0: '#F7F7FA',
lightgray50: '#F2F2F7',
Expand Down
52 changes: 52 additions & 0 deletions src/utils/backend/vatsim/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export async function updateVatsimExtendedPilots() {
})).filter(x => x.controllers.length);

radarStorage.vatsim.extendedPilots = [];
const updatePilots: { [key: string]: VatsimExtendedPilot } = {};

const pilotsToProcess: {
pilot: VatsimExtendedPilot;
Expand Down Expand Up @@ -244,11 +245,62 @@ export async function updateVatsimExtendedPilots() {
extendedPilot.status = 'enroute';
}

// Diversion Detection
if (extendedPilot.status === 'departed' || extendedPilot.status === 'climbing' ||
extendedPilot.status === 'cruising' || extendedPilot.status === 'enroute' ||
extendedPilot.status === 'descending' || extendedPilot.status === 'arriving') {
const oldPilot = radarStorage.extendedPilotsMap[extendedPilot.cid];
const arrival = extendedPilot.flight_plan?.arrival;
const oldFlightPlan = oldPilot?.flight_plan;

if (arrival && oldFlightPlan) {
if (oldFlightPlan.diverted) {
extendedPilot.flight_plan ??= {};

if (oldFlightPlan.diverted_arrival !== arrival) {
if (oldFlightPlan.diverted_origin === arrival || arrival === 'ZZZZ') {
extendedPilot.flight_plan.diverted = false;
}
else {
extendedPilot.flight_plan.diverted_arrival = arrival;
extendedPilot.flight_plan.diverted_origin = oldFlightPlan.diverted_origin;
extendedPilot.flight_plan.diverted = true;
}
}
else {
extendedPilot.flight_plan = {
...extendedPilot.flight_plan,
diverted_arrival: oldFlightPlan.diverted_arrival,
diverted_origin: oldFlightPlan.diverted_origin,
diverted: true,
};
}
}
else if (arrival !== 'ZZZZ' && oldFlightPlan.arrival !== 'ZZZZ' &&
oldFlightPlan.arrival && oldFlightPlan.arrival !== arrival && extendedPilot.flight_plan?.flight_rules !== 'V') {
extendedPilot.flight_plan = {
...extendedPilot.flight_plan,
diverted: true,
diverted_arrival: arrival,
diverted_origin: oldFlightPlan.arrival,
};
}
}
}

origPilot.status = extendedPilot.status;
origPilot.toGoDist = extendedPilot.toGoDist;
origPilot.depDist = extendedPilot.depDist;
origPilot.arrival = extendedPilot.flight_plan?.arrival;
origPilot.diverted = extendedPilot.flight_plan?.diverted;
origPilot.diverted_arrival = extendedPilot.flight_plan?.diverted_arrival;
origPilot.diverted_origin = extendedPilot.flight_plan?.diverted_origin;

updatePilots[extendedPilot.cid] = extendedPilot;
radarStorage.vatsim.extendedPilots.push(extendedPilot);
}

radarStorage.extendedPilotsMap = updatePilots;
}

const xmlParser = new XMLParser({
Expand Down
44 changes: 44 additions & 0 deletions src/utils/backend/worker/data-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,50 @@ defineCronJob('* * * * * *', async () => {
console.error(e);
}

/* data?.pilots.push({
cid: 10000,
name: "Dummy",
callsign: "DELTA",
server: "Nah ah",
pilot_rating: 1,
military_rating: 0,
latitude: 48.137154,
longitude: 11.576124,
altitude: 10000,
groundspeed: 100,
transponder: "7700",
heading: 360,
qnh_i_hg: 100,
qnh_mb: 100,
flight_plan: {
flight_rules: 'I',
aircraft: "C170",
aircraft_faa: "",
aircraft_short: "",
departure: "EDDM",
cruise_tas: "",
altitude: "10000",
arrival: "EDDH",
alternate: "EDDK",
deptime: "",
enroute_time: "",
fuel_time: "",
remarks: "DUMMY",
route: "",
revision_id: 1,
assigned_transponder: "7700",
locked: false,
diverted: true,
diverted_arrival: "EDDV",
diverted_origin: "EDDH",
},
logon_time: "",
last_updated: "",
frequencies: ["122.800"],
sim: "MSFS",
icon: "c17"
});*/

dataInProgress = false;
dataLatestFinished = Date.now();
});
Expand Down

0 comments on commit c002665

Please sign in to comment.