/**
  * Get the speed between this point and another point in km/h.
  *
  * @param TrackPoint $trackPoint The other point.
  * @return float
  */
 public function speed(TrackPoint $trackPoint)
 {
     $start = $this->getDateTime();
     $end = $trackPoint->getDateTime();
     $dateDiff = $start->diff($end);
     $secondsDifference = $dateDiff->days * 86400 + $dateDiff->h * 3600 + $dateDiff->i * 60 + $dateDiff->s;
     if ($secondsDifference === 0) {
         return 0;
     }
     if ($this->hasDistance() === true && $trackPoint->hasDistance()) {
         $distance = abs($this->getDistance() - $trackPoint->getDistance());
     } else {
         $distance = $this->distance($trackPoint);
     }
     return $distance / $secondsDifference * 3.6;
 }
 /**
  * Flatten a track point to be posted on endomondo.
  *
  * @param TrackPoint $trackPoint The track point to flatten.
  * @param float $distance The total distance the point in meters.
  * @param float $speed The speed the point in km/h from the previous point.
  * @return string
  */
 private function flattenTrackPoint(TrackPoint $trackPoint, $distance, $speed)
 {
     $dateTime = clone $trackPoint->getDateTime();
     $dateTime->setTimezone(new \DateTimeZone('UTC'));
     return $this->formatEndomondoTrackPoint($dateTime, self::INSTRUCTION_START, $trackPoint->getLatitude(), $trackPoint->getLongitude(), $distance, $speed, $trackPoint->getElevation(), $trackPoint->hasExtension(HR::ID) ? $trackPoint->getExtension(HR::ID)->getValue() : '');
 }