Documentation
¶
Overview ¶
Package tcx reads garmin XML format files (.tcx file extension) and converts them into .fit format Go structures.
Index ¶
- func CvtToFitLaps(db *TCXDB) (runLaps []fit.Lap)
- func CvtToFitRecs(db *TCXDB) (runRecs []fit.Record)
- func DeviceInfo(db *TCXDB) (DevName string, DevUnitId string, DevProdID string)
- func Distance(lat1, lon1, lat2, lon2 float64) float64
- type Activities
- type Activity
- type Author
- type Build
- type BuildVersion
- type Device
- type Lap
- type TCXDB
- type Track
- type Trackpoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CvtToFitLaps ¶
CvtToFitLaps converts lap-specific values (elapsed time, distance, calories) from the TCXDB structure to the fit.Lap structure.
func CvtToFitRecs ¶
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 ¶
DeviceInfo converts GPS device information from the TCXDB structure to strings.
func Distance ¶
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 ¶
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.
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.
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 ¶
ReadTCXFile converts an entire TCX file from XML.
type Track ¶
type Track struct {
Pt []Trackpoint `xml:"Trackpoint"`
}
Track represents an array of Trackpoint.
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.