Skip to content

Commit

Permalink
Fix AGL property set to 0 if absent and nil if present
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmab committed Dec 1, 2024
1 parent 9599d3d commit cfb0d10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions pkg/radar/radar.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,19 @@ func (s *scope) handleGarbageCollection() {

// isValidTrack checks if the trackfile is valid. This means the following conditions are met:
// - Last known position is not (0, 0)
// - Speed is above 50 knots
// - If AGL is known, AGL is above 10 meters
// - If AGL is unknown, speed is above 50 knots
func isValidTrack(trackfile *trackfiles.Trackfile) bool {
isValidPosition := !spatial.IsZero(trackfile.LastKnown().Point)
isAboveSpeedFilter := trackfile.Speed() > 50*unit.Knot
if spatial.IsZero(trackfile.LastKnown().Point) {
return false
}

agl := trackfile.LastKnown().AGL
isAboveTerrainFilter := agl != nil && *agl > 10*unit.Meter
if agl != nil {
return isValidPosition && isAboveTerrainFilter
} else {
return isValidPosition && isAboveSpeedFilter
return *agl > 10*unit.Meter
}

return trackfile.Speed() > 50*unit.Knot
}

// isMatch checks:
Expand Down
2 changes: 1 addition & 1 deletion pkg/telemetry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c *client) sendUpdates(updates chan<- sim.Updated) {
if coordinates.Heading != nil {
frame.Heading = *coordinates.Heading
}
if agl, err := object.GetLength(properties.AGL); err != nil {
if agl, err := object.GetLength(properties.AGL); err == nil {
frame.AGL = &agl
}

Expand Down

0 comments on commit cfb0d10

Please sign in to comment.