mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-07 04:53:47 +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
409 B
Go
26 lines
409 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
|
|
m "pfeifer.dev/mapd/math"
|
|
)
|
|
|
|
type UpdateTracker struct {
|
|
LastTime time.Time
|
|
Time time.Time
|
|
DiffMA m.MovingAverage
|
|
}
|
|
|
|
func (u *UpdateTracker) Init(maLength int) {
|
|
u.LastTime = time.Now()
|
|
u.Time = time.Now()
|
|
u.DiffMA.Init(maLength)
|
|
}
|
|
|
|
func (u *UpdateTracker) Update() {
|
|
u.LastTime = u.Time
|
|
u.Time = time.Now()
|
|
u.DiffMA.Update(u.Time.Sub(u.LastTime).Seconds())
|
|
}
|