Skip to content

Commit

Permalink
force mlat if no other position
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Feb 6, 2025
1 parent ff6b71a commit 8bc10fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions track.c
Original file line number Diff line number Diff line change
Expand Up @@ -2539,13 +2539,19 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) {
}
}
int usePosition = 0;
if (mm->source == SOURCE_MLAT && now - a->seenPosReliable > TRACK_STALE) {
if (mm->source == SOURCE_MLAT && (
now - a->seenPosReliable > TRACK_STALE
|| (now - a->lastMlatForce > 30 * SECONDS && greatcircle(a->latReliable, a->lonReliable, mm->decoded_lat, mm->decoded_lon, 1) > 50e3)
)
) {
a->lastMlatForce = now;
usePosition = 1;

// pretend it's been very long since we updated the position to guarantee accept_data to update position_valid
a->position_valid.updated = 0;
// force accept_data
accept_data(&a->position_valid, mm->source, mm, a, REDUCE_OFTEN);
incrementReliable(a, mm, now, 3); // force reliable
} else if (!speed_check(a, mm->source, mm->decoded_lat, mm->decoded_lon, mm, CPR_NONE)) {
mm->pos_bad = 1;
// speed check failed, do nothing
Expand Down Expand Up @@ -3735,11 +3741,14 @@ static void incrementReliable(struct aircraft *a, struct modesMessage *mm, int64
if (mm->pos_receiver_range_exceeded) {
increment = 0.25f;
}
if (odd == 3) {
increment = Modes.json_reliable;
}

if (odd)
a->pos_reliable_odd = fminf(a->pos_reliable_odd + increment, Modes.position_persistence);

if (!odd || odd == 2)
if (!odd || odd == 2 || odd == 3)
a->pos_reliable_even = fminf(a->pos_reliable_even + increment, Modes.position_persistence);

if (a->pos_reliable_odd < increment) {
Expand Down
2 changes: 1 addition & 1 deletion track.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ struct aircraft
data_validity acas_ra_valid;
float gs_reliable;
float track_reliable;
uint64_t canary1;
uint64_t lastMlatForce;
int64_t squawkTentativeChanged;
double magneticDeclination;
int64_t updatedDeclination;
Expand Down

0 comments on commit 8bc10fd

Please sign in to comment.