public function testSimpleExample() { $Splits = new Splits\Object(); $Splits->add(new Splits\Split(3.0, 1000, false)); $Splits->add(new Splits\Split(0.4, 72, true)); $Splits->add(new Splits\Split(0.2, 62, false)); $Splits->add(new Splits\Split(0.4, 69, true)); $Splits->add(new Splits\Split(0.2, 63, false)); $Splits->add(new Splits\Split(2.0, 600, false)); $this->object->readFrom($Splits); $this->assertEquals(6, $this->Laps->num()); $this->checkAgainst(array(array(1000, 3.0, false), array(72, 0.4, true), array(62, 0.2, false), array(69, 0.4, true), array(63, 0.2, false), array(600, 2.0, false))); }
/** * @see https://github.com/Runalyze/Runalyze/issues/1308 */ public function testSpareData() { $this->object->setDistances(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); $this->object->calculateFrom(new Trackdata\Object(array(Trackdata\Object::TIME => array(0, 150, 300, 450, 600, 800, 1200, 2200, 2750), Trackdata\Object::DISTANCE => array(0.0, 0.5, 1.0, 1.6, 2.1, 2.8, 4.1, 7.3, 8.9), Trackdata\Object::HEARTRATE => array(150, 150, 150, 150, 150, 150, 150, 150, 150)))); $this->assertEquals(10, $this->Laps->num()); $this->checkAgainst(array(array(300, 1.0, 300, 1.0, 150, 150, 0, 0), array(300, 1.1, 600, 2.1, 150, 150, 0, 0), array(600, 2.0, 1200, 4.1, 150, 150, 0, 0), array(0, 0.0, 1200, 4.1, 0, 0, 0, 0), array(1000, 3.2, 2200, 7.3, 150, 150, 0, 0), array(0, 0.0, 2200, 7.3, 0, 0, 0, 0), array(0, 0.0, 2200, 7.3, 0, 0, 0, 0), array(550, 1.6, 2750, 8.9, 150, 150, 0, 0), array(0, 0.0, 2750, 8.9, 0, 0, 0, 0), array(0, 0.0, 2750, 8.9, 0, 0, 0, 0))); }
/** * Read lap */ protected function readLap() { $Lap = new Lap($this->TrackdataLoop->difference(Trackdata\Object::TIME), $this->TrackdataLoop->difference(Trackdata\Object::DISTANCE)); $Lap->setTrackDuration($this->TrackdataLoop->time()); $Lap->setTrackDistance($this->TrackdataLoop->distance()); $Lap->setHR($this->TrackdataLoop->average(Trackdata\Object::HEARTRATE), $this->TrackdataLoop->max(Trackdata\Object::HEARTRATE)); $this->addElevationFor($Lap); $this->Laps->add($Lap); }
/** * Construct laps from trackdata by distances */ protected function constructLapsFromTrackdataByDistances() { $Distances = $this->ManualDistances; if (empty($Distances)) { if ($this->LapDistance == 0) { $this->LapDistance = 1; } $LastStep = $this->LapDistance * floor($this->Context->trackdata()->totalDistance() / $this->LapDistance); if ($LastStep <= $this->LapDistance) { $Distances = array($this->LapDistance); } else { $Distances = range($this->LapDistance, $LastStep, $this->LapDistance); } } $this->Laps->calculateFrom($Distances, $this->Context->trackdata(), $this->Context->route()); }
/** * @param int $i * @return string */ protected function tableRowFor($i) { $Lap = $this->Laps->at($i); $Lap->pace()->setUnit($this->DemandedPace->unit()); return '<tr class="c ' . ($Lap->isActive() ? '' : 'unimportant') . '">' . '<td class="small">' . ($Lap->isActive() ? $this->IndexActive++ . '.' : '(' . $this->IndexResting++ . '.)') . '</td>' . '<td>' . ($Lap->hasTrackValues() ? $Lap->trackDistance()->string() : '-') . '</td>' . '<td>' . ($Lap->hasTrackValues() ? $Lap->trackDuration()->string() : '-') . '</td>' . '<td>' . $Lap->distance()->string() . '</td>' . '<td>' . $Lap->duration()->string() . '</td>' . ($this->DemandedTime->isZero() ? '' : '<td>' . $Lap->duration()->compareTo($this->DemandedTime, true) . '</td>') . '<td>' . $Lap->pace()->valueWithAppendix() . '</td>' . ($this->DemandedPace->isEmpty() ? '' : '<td>' . $Lap->pace()->compareTo($this->DemandedPace) . '</td>') . '<td>' . ($Lap->hasHR() ? Helper::Unknown($Lap->HRavg()->string(), '-') : '-') . '</td>' . '<td>' . ($Lap->hasHR() ? Helper::Unknown($Lap->HRmax()->string(), '-') : '-') . '</td>' . '<td>' . ($Lap->hasElevation() ? '+' . Elevation::format($Lap->elevationUp(), false) . '/-' . Elevation::format($Lap->elevationDown(), false) : '-') . '</td>' . $this->additionalTableCellsFor($Lap) . '</tr>'; }
/** * @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)); } }