-
Notifications
You must be signed in to change notification settings - Fork 2
/
tcx.php
63 lines (50 loc) · 2.78 KB
/
tcx.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/* Copyright (C) 2014 Salvatore Santagati <[email protected]>
*/
class tcx {
private $tcx;
function __construct ( $act) {
$this->tcx = new SimpleXMLElement("<TrainingCenterDatabase></TrainingCenterDatabase>");
/* Namespace */
$this->tcx->addAttribute('xmlns', 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2');
$this->tcx->addAttribute('xmlns:xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->tcx->addAttribute('xmlns:xsi:schemaLocation', 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd');
$Activities = $this->tcx->addChild( 'Activities' );
$Activity = $Activities->addChild( 'Activity' );
$Activity->addAttribute( 'Sport', $act->getActivitySport() );
$Id = $Activity->addChild( 'Id', $act->getId() );
$Lap = $Activity->addChild('Lap');
$Lap->addAttribute( 'StartTime', $act->getStarttime() );
$TotalTimeSeconds = $Lap->addChild( 'TotalTimeSeconds', $act->getTotalTimeSeconds() );
$DistanceMeters = $Lap->addChild ( 'DistanceMeters', $act->getDistanceMeters() );
$Calories = $Lap->addChild ( 'Calories', $act->getCalories() );
$AverageHeartRateBpm = $Lap->addChild ( 'AverageHeartRateBpm' );
$AverageHeartRateBpm->addAttribute ('xmlns:xsi:type', 'HeartRateInBeatsPerMinute_t' );
$Value = $AverageHeartRateBpm->addChild ( 'Value', $act->getAverageHeartRateBpm() );
$MaximumHeartRateBpm = $Lap->addChild ('MaximumHeartRateBpm' );
$MaximumHeartRateBpm->addAttribute ('xmlns:xsi:type', 'HeartRateInBeatsPerMinute_t' );
$Value = $MaximumHeartRateBpm->addChild ( 'Value', $act->getMaxHearRate() );
$Cadence = $Lap->addChild ('Cadence', $act->getAvgCadence() );
$Track = $Lap->addChild ('Track');
for ( $i = 0; $i < $act->getTracks(); $i++ ) {
$Trackpoint = $Track->addChild('Trackpoint');
$Time = $Trackpoint->addChild('Time', $act->getTimeTrack( $i ) );
$Position = $Trackpoint->addChild('Position');
$LatitudeDegrees = $Position->addChild('LatitudeDegrees', $act->getLatitude($i) );
$LongitudeDegrees = $Position->addChild('LongitudeDegrees', $act->getLongitude($i) );
$AltitudeMeters = $Trackpoint->addChild('AltitudeMeters', $act->getAltitude($i) );
$DistanceMeters = $Trackpoint->addchild('DistanceMeters', $act->getDistance($i) );
$HeartRateBpm = $Trackpoint->addChild('HeartRateBpm');
$HeartRateBpm->addAttribute('xmlns:xsi:type','HeartRateInBeatsPerMinute_t');
$Value = $HeartRateBpm->addChild('Value', $act->getHeartRate($i) );
$Cadence = $Trackpoint->addChild('Cadence', $act->getCadenceTrack($i) );
}
$Creator = $Activity->addChild ('Creator');
$Creator->addAttribute('xmlns:xsi:type', 'Device_t');
$Name = $Creator->addChild ('Name', $act->getDeviceName());
}
function GetTcx ( ) {
return $this->tcx;
}
}
?>