ground-dashboard/ground/tool/summerizers/origin.go
2022-12-05 22:25:36 +00:00

37 lines
750 B
Go

package summerizers
import (
"errors"
"fmt"
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
)
type OriginSummerizer struct {
origin core.Coordinate
originSet bool
}
func (s *OriginSummerizer) Generate(fd []core.DataSegment) error {
s.origin = core.Coordinate{}
s.originSet = false
for _, d := range fd {
if !s.originSet && d.Computed.FlightMode == core.ModeAscentPowered {
s.origin = d.Raw.Coordinate
s.originSet = true
}
}
if !s.originSet {
return errors.New("cannot determine origin")
}
return nil
}
func (s *OriginSummerizer) Value() string {
return fmt.Sprintf("%f/%f", s.origin.Lat, s.origin.Lon)
}
func (s *OriginSummerizer) Name() string {
return "Origin"
}