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;
    }