/** * @param \Runalyze\Model\Activity\Splits\Entity $splits * @param boolean $showInactive */ protected function readDataFromSplits(Splits\Entity $splits, $showInactive) { foreach ($splits->asArray() as $split) { if (($showInactive || $split->isActive()) && $split->distance() > 0) { $this->Labels[] = round((new Distance($split->distance()))->valueInPreferredUnit(), 2); $this->Data[] = $split->time() / $split->distance(); } } }
/** * @param \Runalyze\Model\Activity\Splits\Entity $Splits * @return string * @codeCoverageIgnore */ protected function stringForActiveLaps(Entity $Splits) { $laps = []; $onlyActiveSplits = $Splits->hasActiveAndInactiveLaps(); foreach ($Splits->asArray() as $Split) { if (!$onlyActiveSplits || $Split->isActive()) { $laps[] = Activity\Duration::format($Split->time()); } } return str_replace(' ', ' ', implode(' / ', $laps)); }
/** * Set splits */ private function setSplits() { $i = 0; $seperated = false; $showOnlyActive = $this->Splits->hasActiveAndInactiveLaps() && $this->Splits->hasActiveLaps(2); foreach ($this->Splits->asArray() as $Split) { $PaceObj = $Split->pace($this->PaceUnit); if ($showOnlyActive && !$Split->isActive()) { if (!$seperated && $i > 0) { // && ($i < $num_active)) { $this->Code .= '<tr class="space-line"><td colspan="5"></td></tr>'; $this->Code .= '<tr class="space-line zebra-corrector"><td colspan="5"></td></tr>'; $seperated = true; } continue; } else { $seperated = false; } $this->Code .= '<tr class="r">'; $this->Code .= '<td class="c">' . ++$i . '.</td>'; $this->Code .= '<td>' . Distance::format($Split->distance(), true, 2) . '</td>'; $this->Code .= '<td>' . Duration::format($Split->time()) . '</td>'; $this->Code .= '<td>' . $PaceObj->value() . '<small>' . $PaceObj->appendix() . '</small></td>'; $this->Code .= '<td>' . $this->tdForPaceDifference($PaceObj) . '</td>'; $this->Code .= '</tr>'; } $this->Code .= '</tbody><tbody class="top-spacer">'; }
/** * Complete splits */ public function completeSplits() { $totalDistance = 0; $totalTime = 0; $size = min(count($this->Time), count($this->Distance)); $i = 0; foreach ($this->Splits->asArray() as $split) { if ($this->mode() == self::MODE_DISTANCE) { $s = $split->time(); while ($i < $size - 1 && $s > $this->Time[$i] - $totalTime) { $i++; } $split->setDistance($this->Distance[$i] - $totalDistance); } else { $dist = $split->distance(); while ($i < $size - 1 && $dist > $this->Distance[$i] - $totalDistance) { $i++; } $split->setTime($this->Time[$i] - $totalTime); } $totalTime = $this->Time[$i]; $totalDistance = $this->Distance[$i]; } }
/** * @param \Runalyze\Model\Activity\Splits\Entity $Splits */ public function readFrom(Splits\Entity $Splits) { foreach ($Splits->asArray() as $Split) { $this->Laps->add(new Lap($Split->time(), $Split->distance(), $Split->isActive() ? Lap::MODE_ACTIVE : Lap::MODE_RESTING)); } }