src/Workout/Dumper/TCX.php
protected function writeLapHeartRateDate(\XMLWriter $xmlWriter, Track $track)
    {
        $averageHeartRate = array();
        $maxHearRate = null;
        foreach ($track->trackPoints() as $trackPoint) {
            if ($trackPoint->hasExtension(HR::ID()) === true) {
                $pointHearRate = $trackPoint->extension(HR::ID())->value();

                $maxHearRate = max($maxHearRate, $pointHearRate);
                $averageHeartRate[] = $pointHearRate;
            }
        }

        if ($averageHeartRate !== array()) {
            $xmlWriter->startElement('AverageHeartRateBpm');
            $xmlWriter->writeAttributeNS('xsi', 'type', null, 'HeartRateInBeatsPerMinute_t');
            $hearRateValue = array_sum($averageHeartRate) / count($averageHeartRate);
            $xmlWriter->writeElement('Value', (string)$hearRateValue);
            $xmlWriter->endElement();
        }

        if ($maxHearRate !== null) {
            $xmlWriter->startElement('MaximumHeartRateBpm');
            $xmlWriter->writeAttributeNS('xsi', 'type', null, 'HeartRateInBeatsPerMinute_t');
            $xmlWriter->writeElement('Value', (string)$maxHearRate);
            $xmlWriter->endElement();
        }
    }
protected function writeLapHeartRateDate(\XMLWriter $xmlWriter, Track $track)
    {
        $averageHeartRate = array();
        $maxHearRate = null;
        foreach ($track->trackPoints() as $trackPoint) {
            if ($trackPoint->hasExtension(HR::ID()) === true) {
                $pointHearRate = $trackPoint->extension(HR::ID())->value();

                $maxHearRate = max($maxHearRate, $pointHearRate);
                $averageHeartRate[] = $pointHearRate;
            }
        }

        if ($averageHeartRate !== array()) {
            $xmlWriter->startElement('AverageHeartRateBpm');
            $xmlWriter->writeAttributeNS('xsi', 'type', null, 'HeartRateInBeatsPerMinute_t');
            $hearRateValue = array_sum($averageHeartRate) / count($averageHeartRate);
            $xmlWriter->writeElement('Value', (string)$hearRateValue);
            $xmlWriter->endElement();
        }

        if ($maxHearRate !== null) {
            $xmlWriter->startElement('MaximumHeartRateBpm');
            $xmlWriter->writeAttributeNS('xsi', 'type', null, 'HeartRateInBeatsPerMinute_t');
            $xmlWriter->writeElement('Value', (string)$maxHearRate);
            $xmlWriter->endElement();
        }
    }
protected function writeLapHeartRateDate ( \ XMLWriter $ xmlWriter , Track $ track ) { $ averageHeartRate = array ( ) ; $ maxHearRate = null ; foreach ( $ track -> trackPoints ( ) as $ trackPoint ) { if ( $ trackPoint -> hasExtension ( HR :: ID ( ) ) === true ) { $ pointHearRate = $ trackPoint -> extension ( HR :: ID ( ) ) -> value ( ) ; $ maxHearRate = max ( $ maxHearRate , $ pointHearRate ) ; $ averageHeartRate [ ] = $ pointHearRate ; } } if ( $ averageHeartRate !== array ( ) ) { $ xmlWriter -> startElement ( 'AverageHeartRateBpm' ) ; $ xmlWriter -> writeAttributeNS ( 'xsi' , 'type' , null , 'HeartRateInBeatsPerMinute_t' ) ; $ hearRateValue = array_sum ( $ averageHeartRate ) / count ( $ averageHeartRate ) ; $ xmlWriter -> writeElement ( 'Value' , ( string ) $ hearRateValue ) ; $ xmlWriter -> endElement ( ) ; } if ( $ maxHearRate !== null ) { $ xmlWriter -> startElement ( 'MaximumHeartRateBpm' ) ; $ xmlWriter -> writeAttributeNS ( 'xsi' , 'type' , null , 'HeartRateInBeatsPerMinute_t' ) ; $ xmlWriter -> writeElement ( 'Value' , ( string ) $ maxHearRate ) ; $ xmlWriter -> endElement ( ) ; } }
Write the heart rate data for a lap.

@param \XMLWriter $xmlWriter The XML writer.
@param Track $track The track to write.
Write the heart rate data for a lap .