mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 00:53:45 +08:00
ab81464bd1
Add navigation and map matching providers with the vendored map service sources. Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
26 lines
455 B
Go
26 lines
455 B
Go
package utils
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
)
|
|
|
|
type Float32Tracker struct {
|
|
LastValue float32
|
|
Value float32
|
|
UpdatedTime time.Time
|
|
AllowNullLastValue bool
|
|
}
|
|
|
|
func (t *Float32Tracker) Update(val float32) (updated bool) {
|
|
if t.Value != val {
|
|
if t.AllowNullLastValue || !(math.IsNaN(float64(t.Value)) || t.Value == 0) {
|
|
t.LastValue = t.Value
|
|
}
|
|
t.UpdatedTime = time.Now()
|
|
t.Value = val
|
|
return true
|
|
}
|
|
return false
|
|
}
|