Example #1
0
 public function testSimpleArray()
 {
     $Calculator = new Calculator(new Trackdata\Object(array(Trackdata\Object::TIME => array(30, 60, 90, 120, 150), Trackdata\Object::DISTANCE => array(0.09, 0.18, 0.3, 0.48, 0.55), Trackdata\Object::CADENCE => array(90, 100, 100, 90, 70))));
     $Calculator->calculate();
     $this->assertEquals(122, $Calculator->average());
     $this->assertEquals(array(100, 90, 120, 200, 100), $Calculator->stridesData());
 }
Example #2
0
 /**
  * Update stride length
  */
 protected function updateStrideLength()
 {
     if ($this->hasChanged(Entity::SPORTID) || $this->hasChanged(Entity::VERTICAL_OSCILLATION) || $this->hasChanged(Entity::STRIDE_LENGTH)) {
         if ($this->NewObject->sportid() == Configuration::General()->runningSport()) {
             $this->NewObject->set(Entity::STRIDE_LENGTH, \Runalyze\Calculation\StrideLength\Calculator::forActivity($this->NewObject));
         } else {
             $this->NewObject->set(Entity::STRIDE_LENGTH, 0);
         }
     }
 }
Example #3
0
 /**
  * Calculate stride length
  */
 protected function calculateStrideLength()
 {
     if ($this->Object->sportid() == Configuration::General()->runningSport()) {
         if (null !== $this->Trackdata && $this->Trackdata->has(Model\Trackdata\Object::CADENCE)) {
             $Calculator = new \Runalyze\Calculation\StrideLength\Calculator($this->Trackdata);
             $Calculator->calculate();
             $this->Object->set(Object::STRIDE_LENGTH, $Calculator->average());
         } elseif ($this->Object->cadence() > 0) {
             $this->Object->set(Object::STRIDE_LENGTH, \Runalyze\Calculation\StrideLength\Calculator::forActivity($this->Object));
         }
     }
 }
Example #4
0
 protected function calculateStrideLengthArray()
 {
     if (!$this->has(self::STRIDE_LENGTH)) {
         $StridesCalculator = new StrideLength\Calculator($this);
         $StridesCalculator->calculate();
         $this->set(self::STRIDE_LENGTH, $StridesCalculator->stridesData());
     }
 }
Example #5
0
 /**
  * Calculate stride length
  */
 protected function calculateStrideLength()
 {
     if ($this->Object->sportid() == Configuration::General()->runningSport()) {
         $this->Object->set(Entity::STRIDE_LENGTH, \Runalyze\Calculation\StrideLength\Calculator::forActivity($this->Object));
     }
 }
Example #6
0
 /**
  * @param \Runalyze\Model\Trackdata\Object $Object
  * @param array $AdditionalData
  */
 protected function addStrideLengthToDataFrom(Trackdata\Object $Object, array &$AdditionalData)
 {
     $StrideCalculator = new Calculation\StrideLength\Calculator($Object);
     $StrideCalculator->calculate();
     if ($StrideCalculator->average() > 0) {
         $AdditionalData[Activity\Object::STRIDE_LENGTH] = $StrideCalculator->average();
     }
 }