예제 #1
0
파일: Laps.php 프로젝트: 9x/Runalyze
 /**
  * @param array $times
  * @param \Runalyze\Model\Trackdata\Object $trackdata
  * @param \Runalyze\Model\Route\Object $route
  */
 public function calculateFromTimes(array $times, Trackdata\Object $trackdata, Route\Object $route = null)
 {
     $Calculator = new Calculator($this);
     $Calculator->calculateAdditionalValues($this->CalculateAdditionalValues);
     $Calculator->setTimes($times);
     $Calculator->calculateFrom($trackdata, $route);
 }
예제 #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)));
 }
예제 #3
0
파일: Window.php 프로젝트: guancio/Runalyze
 /**
  * Read request
  */
 protected function readPropertiesFromRequest()
 {
     if ((double) Request::param('distance') > 0) {
         $this->LapDistance = min($this->Context->trackdata()->totalDistance(), (double) Request::param('distance'));
     }
     if (strlen(Request::param('time')) > 0) {
         $Time = new Duration(Request::param('time'));
         $this->LapTime = min($this->Context->trackdata()->totalTime(), $Time->seconds());
     }
     if (strlen(Request::param('demanded-time')) > 0) {
         $this->DemandedTime->fromString(Request::param('demanded-time'));
         if ($this->LapDistance > 0) {
             $this->DemandedPace->setTime($this->DemandedTime->seconds() / $this->LapDistance);
         }
     } elseif ($this->LapDistance > 0) {
         $this->DemandedTime->fromSeconds($this->Context->trackdata()->totalTime() / $this->Context->trackdata()->totalDistance() * $this->LapDistance);
         $this->DemandedPace->setTime($this->DemandedTime->seconds() / $this->LapDistance);
     }
     if (strlen(Request::param('demanded-pace')) > 0) {
         $this->DemandedPace->fromMinPerKm(Request::param('demanded-pace'));
         $this->DemandedTime->fromSeconds($this->LapDistance * $this->DemandedPace->secondsPerKm());
     } elseif ($this->DemandedPace->secondsPerKm() == 0) {
         $this->DemandedPace = $this->Context->dataview()->pace();
     }
     if (strlen(Request::param('manual-distances')) > 0) {
         $this->ManualDistances = Calculator::getDistancesFromString(Request::param('manual-distances'));
     }
     if (strlen(Request::param('manual-times')) > 0) {
         $this->ManualTimes = Calculator::getTimesFromString(Request::param('manual-times'));
     }
 }
예제 #4
0
 public function testTimesFromStringWithShortNotationForMinutes()
 {
     $this->assertEquals(array(5 * 60, 15 * 60, 20 * 60), Calculator::getTimesFromString('+5\', 10\', 5\''));
 }
예제 #5
0
파일: Laps.php 프로젝트: n0rthface/Runalyze
 /**
  * @param array $distances
  * @param \Runalyze\Model\Trackdata\Object $trackdata
  * @param \Runalyze\Model\Route\Object $route
  */
 public function calculateFrom(array $distances, Trackdata\Object $trackdata, Route\Object $route = null)
 {
     $Calculator = new Calculator($this);
     $Calculator->setDistances($distances);
     $Calculator->calculateFrom($trackdata, $route);
 }