src/Workout/Dumper/TCX.php
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints)
    {
        $previousTrackPoint = null;
        foreach ($trackPoints as $trackPoint) {
            $xmlWriter->startElement('Trackpoint');

            // Time of position
            $dateTime = clone $trackPoint->dateTime();
            $dateTime->setTimezone(new \DateTimeZone('UTC'));
            $xmlWriter->writeElement('Time', $this->formatDateTime($dateTime));

            // Position.
            $xmlWriter->startElement('Position');
            $xmlWriter->writeElement('LatitudeDegrees', (string)$trackPoint->latitude());
            $xmlWriter->writeElement('LongitudeDegrees', (string)$trackPoint->longitude());
            $xmlWriter->endElement();

            // Elevation.
            $xmlWriter->writeElement('AltitudeMeters', (string)$trackPoint->elevation());

            // Distance.
            if ($previousTrackPoint !== null) {
                $xmlWriter->writeElement('DistanceMeters', (string)$trackPoint->distanceFromPoint($previousTrackPoint));
            } else {
                $xmlWriter->writeElement('DistanceMeters', '0');
            }

            // Extensions.
            $this->writeExtensions($xmlWriter, $trackPoint->extensions());

            $xmlWriter->endElement();

            $previousTrackPoint = $trackPoint;
        }
    }
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints)
    {
        $previousTrackPoint = null;
        foreach ($trackPoints as $trackPoint) {
            $xmlWriter->startElement('Trackpoint');

            // Time of position
            $dateTime = clone $trackPoint->dateTime();
            $dateTime->setTimezone(new \DateTimeZone('UTC'));
            $xmlWriter->writeElement('Time', $this->formatDateTime($dateTime));

            // Position.
            $xmlWriter->startElement('Position');
            $xmlWriter->writeElement('LatitudeDegrees', (string)$trackPoint->latitude());
            $xmlWriter->writeElement('LongitudeDegrees', (string)$trackPoint->longitude());
            $xmlWriter->endElement();

            // Elevation.
            $xmlWriter->writeElement('AltitudeMeters', (string)$trackPoint->elevation());

            // Distance.
            if ($previousTrackPoint !== null) {
                $xmlWriter->writeElement('DistanceMeters', (string)$trackPoint->distanceFromPoint($previousTrackPoint));
            } else {
                $xmlWriter->writeElement('DistanceMeters', '0');
            }

            // Extensions.
            $this->writeExtensions($xmlWriter, $trackPoint->extensions());

            $xmlWriter->endElement();

            $previousTrackPoint = $trackPoint;
        }
    }
private function writeTrackPoints ( \ XMLWriter $ xmlWriter , array $ trackPoints ) { $ previousTrackPoint = null ; foreach ( $ trackPoints as $ trackPoint ) { $ xmlWriter -> startElement ( 'Trackpoint' ) ; // Time of position $ dateTime = clone $ trackPoint -> dateTime ( ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ xmlWriter -> writeElement ( 'Time' , $ this -> formatDateTime ( $ dateTime ) ) ; // Position. $ xmlWriter -> startElement ( 'Position' ) ; $ xmlWriter -> writeElement ( 'LatitudeDegrees' , ( string ) $ trackPoint -> latitude ( ) ) ; $ xmlWriter -> writeElement ( 'LongitudeDegrees' , ( string ) $ trackPoint -> longitude ( ) ) ; $ xmlWriter -> endElement ( ) ; // Elevation. $ xmlWriter -> writeElement ( 'AltitudeMeters' , ( string ) $ trackPoint -> elevation ( ) ) ; // Distance. if ( $ previousTrackPoint !== null ) { $ xmlWriter -> writeElement ( 'DistanceMeters' , ( string ) $ trackPoint -> distanceFromPoint ( $ previousTrackPoint ) ) ; } else { $ xmlWriter -> writeElement ( 'DistanceMeters' , '0' ) ; } // Extensions. $ this -> writeExtensions ( $ xmlWriter , $ trackPoint -> extensions ( ) ) ; $ xmlWriter -> endElement ( ) ; $ previousTrackPoint = $ trackPoint ; } }
Write the track points to the TCX.

@param \XMLWriter $xmlWriter The XML writer.
@param TrackPoint[] $trackPoints The track points to write.
Write the track points to the TCX .