mirror of
https://codeberg.org/portospaceteam/ground-dashboard.git
synced 2024-11-29 01:56:59 +00:00
37 lines
750 B
Go
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"
|
|
}
|