mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-12 15:33:45 +08:00
1ce9f73ae2
Add navigation and map matching providers with the vendored map service sources.
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())
|
|
}
|