src/Workout/Dumper/JSON.php
private function writeTrackPoints(array $trackPoints)
    {
        $points = array();
        $previousPoint = null;
        foreach ($trackPoints as $trackPoint) {
            $dateTime = clone $trackPoint->dateTime();
            $dateTime->setTimezone(new \DateTimeZone('UTC'));

            $distance = 0;
            if ($previousPoint !== null) {
                $distance = $trackPoint->distanceFromPoint($previousPoint);
            }

            $point = array(
                'time' => $dateTime->format(\DateTime::W3C),
                'latitude' => $trackPoint->latitude(),
                'longitude' => $trackPoint->longitude(),
                'elevation' => $trackPoint->elevation(),
                'distance' => $distance,
                'extensions' => $this->writeExtensions($trackPoint->extensions())
            );
            $previousPoint = $trackPoint;

            $points[] = $point;
        }

        return $points;
    }
private function writeTrackPoints(array $trackPoints)
    {
        $points = array();
        $previousPoint = null;
        foreach ($trackPoints as $trackPoint) {
            $dateTime = clone $trackPoint->dateTime();
            $dateTime->setTimezone(new \DateTimeZone('UTC'));

            $distance = 0;
            if ($previousPoint !== null) {
                $distance = $trackPoint->distanceFromPoint($previousPoint);
            }

            $point = array(
                'time' => $dateTime->format(\DateTime::W3C),
                'latitude' => $trackPoint->latitude(),
                'longitude' => $trackPoint->longitude(),
                'elevation' => $trackPoint->elevation(),
                'distance' => $distance,
                'extensions' => $this->writeExtensions($trackPoint->extensions())
            );
            $previousPoint = $trackPoint;

            $points[] = $point;
        }

        return $points;
    }
private function writeTrackPoints ( array $ trackPoints ) { $ points = array ( ) ; $ previousPoint = null ; foreach ( $ trackPoints as $ trackPoint ) { $ dateTime = clone $ trackPoint -> dateTime ( ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ distance = 0 ; if ( $ previousPoint !== null ) { $ distance = $ trackPoint -> distanceFromPoint ( $ previousPoint ) ; } $ point = array ( 'time' => $ dateTime -> format ( \ DateTime :: W3C ) , 'latitude' => $ trackPoint -> latitude ( ) , 'longitude' => $ trackPoint -> longitude ( ) , 'elevation' => $ trackPoint -> elevation ( ) , 'distance' => $ distance , 'extensions' => $ this -> writeExtensions ( $ trackPoint -> extensions ( ) ) ) ; $ previousPoint = $ trackPoint ; $ points [ ] = $ point ; } return $ points ; }
Write the track points into an array.

@param TrackPoint[] $trackPoints The track points to write.
@return array
Write the track points into an array .