private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints)
    {
        foreach ($trackPoints as $trackPoint) {
            $xmlWriter->startElement('trkpt');

            // Location.
            $xmlWriter->writeAttribute('lat', (string)$trackPoint->latitude());
            $xmlWriter->writeAttribute('lon', (string)$trackPoint->longitude());

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

            // Time of position
            $dateTime = clone $trackPoint->dateTime();
            $dateTime->setTimezone(new \DateTimeZone('UTC'));
            $xmlWriter->writeElement('time', $dateTime->format(\DateTime::W3C));

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

            $xmlWriter->endElement();
        }
    }