tcx

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tcx reads garmin XML format files (.tcx file extension) and converts them into .fit format Go structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CvtToFitLaps

func CvtToFitLaps(db *TCXDB) (runLaps []fit.Lap)

CvtToFitLaps converts lap-specific values (elapsed time, distance, calories) from the TCXDB structure to the fit.Lap structure.

func CvtToFitRecs

func CvtToFitRecs(db *TCXDB) (runRecs []fit.Record)

CvtToFitRecs converts timestamp, position (latitude/longitude), altitude, distance, speed and cadence (e.g. tracks) from the TCXDB structure to the fit.Record structure.

func DeviceInfo

func DeviceInfo(db *TCXDB) (DevName string, DevUnitId string, DevProdID string)

DeviceInfo converts GPS device information from the TCXDB structure to strings.

func Distance

func Distance(lat1, lon1, lat2, lon2 float64) float64

Distance returns the distance (in meters) between two points of a given longitude and latitude relatively accurately (using a spherical approximation of the Earth) through the Haversin Distance Formula for great arc distance on a sphere with accuracy for small distances.

Point coordinates are supplied in degrees and converted into rad. in the function.

distance returned is METERS!!!!!! http://en.wikipedia.org/wiki/Haversine_formula

Types

type Activities

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

Activities represents an array of Activity.

func ReadActivities

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

ReadActivities converts an array of activities values from XML.

type Activity

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

Activity represents an individual sporting activity undertaken at a specific time, the device it was captured with and the associated raw summary (lap) information.

func ReadActivity

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

ReadActivity converts an individual activity value from XML.

type Author

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

Author represents the software used on a Device to capture information.

func (Author) String

func (a Author) String() string

Function to retrieve information about the software.

type Build

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

Build is meta-information about the Garmin software.

type BuildVersion

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

BuildVersion is meta-information about the Garmin software version.

type Device

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

Device respresents the hardware used to capture information.

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>Value,omitempty"`
	MaxHr         float64 `xml:"MaximumHeartRateBpm>Value,omitempty"`
	Intensity     string  `xml:",omitempty"`
	TriggerMethod string  `xml:",omitempty"`
	Trk           *Track  `xml:"Track"`
}

Lap represents summary values for GPS and activity related information.

func ReadLap

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

ReadLap converts the lap values from XML.

type TCXDB

type TCXDB struct {
	XMLName xml.Name    `xml:"TrainingCenterDatabase"`
	Acts    *Activities `xml:"Activities"`
	Auth    Author      `xml:"Author"`
}

TCXDB is the top level file structure containing Activities.

func ReadTCXFile

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

ReadTCXFile converts an entire TCX file from XML.

type Track

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

Track represents an array of Trackpoint.

func ReadTpts

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

ReadTpts converts the GPS track points from XML.

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"`
}

Trackpoint represents an individual GPS track and associated measured values at a particular time.

Jump to

Keyboard shortcuts

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