Exemplo n.º 1
0
 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)));
 }
Exemplo n.º 2
0
 /**
  * @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)));
 }
Exemplo n.º 3
0
 /**
  * @return string
  */
 protected function tableBody()
 {
     $Code = '<tbody class="top-and-bottom-border">';
     for ($i = 0, $num = $this->Laps->num(); $i < $num; ++$i) {
         $Code .= $this->tableRowFor($i);
     }
     $Code .= '</tbody>';
     return $Code;
 }
Exemplo n.º 4
0
 /**
  * Construct laps from splits object
  */
 protected function constructLapsFromSplits()
 {
     if ($this->handmadeLapsDiffer() && !Request::param('calculate-for-splits')) {
         $this->Laps->readFrom($this->Context->activity()->splits());
         return;
     }
     if ($this->handmadeLapsTimeDiffers()) {
         $this->constructLapsFromSplitsDistances();
     } else {
         $this->constructLapsFromSplitsTimes();
     }
     $num = $this->Laps->num();
     foreach ($this->Context->activity()->splits()->asArray() as $i => $split) {
         if ($i < $num) {
             $this->Laps->at($i)->setMode($split->isActive() ? Lap::MODE_ACTIVE : Lap::MODE_RESTING);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Construct laps from splits object
  */
 protected function constructLapsFromSplits()
 {
     if ($this->handmadeLapsDiffer() && !Request::param('calculate-for-splits')) {
         $this->Laps->readFrom($this->Context->activity()->splits());
         return;
     }
     $Distances = array();
     $sum = 0;
     foreach ($this->Context->activity()->splits()->asArray() as $split) {
         $Distances[] = $split->distance() + $sum;
         $sum += $split->distance();
     }
     $this->Laps->calculateFrom($Distances, $this->Context->trackdata(), $this->Context->route());
     $num = $this->Laps->num();
     foreach ($this->Context->activity()->splits()->asArray() as $i => $split) {
         if ($i < $num) {
             $this->Laps->at($i)->setMode($split->isActive() ? Lap::MODE_ACTIVE : Lap::MODE_RESTING);
         }
     }
 }