Example #1
0
 /**
  * Compare
  * Both pace objects must have the same unit and the unit must be comparable.
  * @param \Runalyze\Activity\Pace $other
  * @param boolean $raw [optional]
  * @throws \InvalidArgumentException
  * @return string
  */
 public function compareTo(Pace $other, $raw = false)
 {
     if ($this->unitEnum() != $other->unitEnum()) {
         throw new \InvalidArgumentException('Pace objects must have the same unit.');
     }
     if ($this->secondsPerKm() == 0 || $other->secondsPerKm() == 0) {
         return '';
     }
     $comparisonInSecondsPerKm = $this->UnitObject->compare($this->secondsPerKm(), $other->secondsPerKm());
     $isPositive = $comparisonInSecondsPerKm >= 0;
     if ($comparisonInSecondsPerKm == 0 && $this->UnitObject->isTimeFormat()) {
         return $this->formatComparison('0:00', $isPositive, $raw);
     }
     return $this->formatComparison($this->UnitObject->format(abs($comparisonInSecondsPerKm)), $isPositive, $raw);
 }
Example #2
0
 /**
  * Add annotations
  */
 protected function addAnnotations()
 {
     if ($this->demandedPace > 0) {
         $demandedPace = $this->PaceUnit->rawValue($this->demandedPace);
         if ($this->PaceUnit->isTimeFormat()) {
             $demandedPace *= 1000;
         }
         $this->Plot->addThreshold("y", round($demandedPace), 'rgb(180,0,0)');
         //$this->Plot->addAnnotation(count($Data)-1, round($demandedPace), 'Soll: '.$this->PaceUnit->format($this->demandedPace), -10, -7);
     }
     if ($this->achievedPace > 0) {
         $achievedPace = $this->PaceUnit->rawValue($this->achievedPace);
         if ($this->PaceUnit->isTimeFormat()) {
             $achievedPace *= 1000;
         }
         $this->Plot->addThreshold("y", round($achievedPace), 'rgb(0,180,0)');
         $this->Plot->addAnnotation(0, round($achievedPace), 'ø ' . $this->PaceUnit->format($this->achievedPace), -40, -7);
     }
 }
Example #3
0
 /**
  * @param \Runalyze\Activity\PaceUnit\AbstractUnit $Unit
  * @return string
  */
 public function asUnit(PaceUnit\AbstractUnit $Unit)
 {
     return $Unit->format($this->secondsPerKm());
 }