tcx

package module
v0.0.0-...-142b73f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 6 Imported by: 0

README

Garmin *.tcx parsing for Go

Some basic utilities for marshaling and unmarshaling Garmin *.tcx (xml) in to and out of Go structs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBytes

func ToBytes(file TCXDB) ([]byte, error)

Types

type Activities

type Activities struct {
	Act []Activity `xml:"Activity"`
}

func ReadActivities

func ReadActivities(path string) (acts *Activities, err error)

type Activity

type Activity struct {
	Sport   string `xml:"Sport,attr,omitempty"`
	Id      time.Time
	Laps    []Lap   `xml:"Lap,omitempty"`
	Creator *Device `xml:"Creator,omitempty"`
	Notes   string  `xml:",omitempty"`
}

func ReadActivity

func ReadActivity(path string) (act *Activity, err error)

type Author

type Author struct {
	Name       string `xml:",omitempty"`
	Build      Build  `xml:",omitempty"`
	LangID     string `xml:",omitempty"`
	PartNumber string `xml:",omitempty"`
}

func (Author) String

func (a Author) String() string

type Build

type Build struct {
	Version BuildVersion `xml:"Version,omitempty"`
	Type    string       `xml:",omitempty"`
	Time    string       `xml:",omitempty"`
	Builder string       `xml:",omitempty"`
}

type BuildVersion

type BuildVersion struct {
	VersionMajor int `xml:",omitempty"`
	VersionMinor int `xml:",omitempty"`
	BuildMajor   int `xml:",omitempty"`
	BuildMinor   int `xml:",omitempty"`
}

type Device

type Device struct {
	Name      string       `xml:",omitempty"`
	UnitID    int          `xml:"UnitId,omitempty"`
	ProductID string       `xml:",omitempty"`
	Version   BuildVersion `xml:",omitempty"`
}

type Lap

type Lap struct {
	Start         string  `xml:"StartTime,attr"`
	TotalTime     float64 `xml:"TotalTimeSeconds,omitempty"`
	Dist          float64 `xml:"DistanceMeters,omitempty"`
	Calories      float64 `xml:",omitempty"`
	MaxSpeed      float64 `xml:"MaximumSpeed,omitempty"`
	AvgHr         float64 `xml:"AverageHeartRateBpm,omitempty"`
	MaxHr         float64 `xml:"MaximumHeartRateBpm,omitempty"`
	Intensity     string  `xml:",omitempty"`
	TriggerMethod string  `xml:",omitempty"`
	Trk           *Track  `xml:"Track"`
}

func ReadLap

func ReadLap(path string) (lap *Lap, err error)

func (Lap) MatchTime

func (lap Lap) MatchTime(sec float64) error

Match lap time to "sec" (in-place)

type LapZeroDistError

type LapZeroDistError struct{}

func (*LapZeroDistError) Error

func (l *LapZeroDistError) Error() string

type LapZeroTimeError

type LapZeroTimeError struct{}

func (*LapZeroTimeError) Error

func (l *LapZeroTimeError) Error() string

type TCXDB

type TCXDB struct {
	XMLName xml.Name    `xml:"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 TrainingCenterDatabase"`
	Acts    *Activities `xml:"Activities"`
	Auth    *Author     `xml:"Author,omitempty"`
}

func ReadFile

func ReadFile(path string) (db *TCXDB, err error)

type Track

type Track struct {
	Pt []Trackpoint `xml:"Trackpoint"`
}

func ReadTpts

func ReadTpts(path string) (track *Track, err error)

type TrackSpline

type TrackSpline struct {
	// contains filtered or unexported fields
}

func Spline

func Spline(trk *Track) *TrackSpline

func (*TrackSpline) Alt

func (t *TrackSpline) Alt(dist float64) float64

func (*TrackSpline) Lat

func (t *TrackSpline) Lat(dist float64) float64

func (*TrackSpline) Long

func (t *TrackSpline) Long(dist float64) float64

func (*TrackSpline) Speed

func (t *TrackSpline) Speed(dist float64) float64

type Trackpoint

type Trackpoint struct {
	Time  time.Time
	Lat   float64 `xml:"Position>LatitudeDegrees"`
	Long  float64 `xml:"Position>LongitudeDegrees"`
	Alt   float64 `xml:"AltitudeMeters,omitempty"`
	Dist  float64 `xml:"DistanceMeters,omitempty"`
	HR    float64 `xml:"HeartRateBpm>Value,omitempty"`
	Cad   float64 `xml:"Cadence,omitempty"`
	Speed float64 `xml:"Extensions>TPX>Speed,omitempty"`
	Power float64 `xml:"Extensions>TPX>Watts,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL