/**
  * Constructor
  * @param \Runalyze\View\Activity\Context $context
  */
 public function __construct(Context $context)
 {
     $this->Context = $context;
     if ($this->Context->trackdata()->has(Runalyze\Model\Trackdata\Entity::TIME)) {
         $this->initData();
         $this->convertData();
     }
 }
示例#2
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::GROUNDCONTACT_BALANCE);
     $this->setManualAverage($context->activity()->groundContactBalance() / 100);
     $this->manipulateData();
 }
示例#3
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->setManipulationFactor();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::HEARTRATE, true);
     $this->manipulateData();
 }
示例#4
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata());
     $this->manipulateData();
     $this->setManualAverage($context->activity()->strideLength());
 }
示例#5
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::VERTICAL_OSCILLATION);
     $this->manipulateData();
     $this->setManualAverage($context->activity()->verticalOscillation() * 0.1);
 }
示例#6
0
 /**
  * Construct plot data
  * @param enum $algorithm
  * @param int $treshold
  * @return array
  */
 protected function constructPlotDataFor($algorithm, $treshold = false)
 {
     $Method = new ElevationMethod();
     $Method->set($algorithm);
     if ($treshold === false) {
         $treshold = Configuration::ActivityView()->elevationMinDiff();
     }
     $Calculator = new Data\Elevation\Calculation\Calculator($this->Context->route()->elevations());
     $Calculator->setMethod($Method);
     $Calculator->setThreshold($treshold);
     $Calculator->calculate();
     $i = 0;
     $Data = array();
     $Points = $Calculator->strategy()->smoothedData();
     $Indices = $Calculator->strategy()->smoothingIndices();
     $hasDistances = $this->Context->trackdata()->get(Trackdata\Entity::DISTANCE);
     $Distances = $this->Context->trackdata()->get(Trackdata\Entity::DISTANCE);
     $Times = $this->Context->trackdata()->get(Trackdata\Entity::TIME);
     $num = $this->Context->trackdata()->num();
     foreach ($Indices as $i => $index) {
         if ($index >= $num) {
             $index = $num - 1;
         }
         if ($hasDistances) {
             $Data[(string) $Distances[$index]] = $Points[$i];
         } else {
             $Data[(string) $Times[$index] . '000'] = $Points[$i];
         }
     }
     $this->manipulateData($Data);
     return $Data;
 }
示例#7
0
文件: Heartrate.php 项目: 9x/Runalyze
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->setManipulationFactor();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::HEARTRATE, true);
     $this->manipulateData();
     $this->setManualAverage(round(100 * $context->activity()->hrAvg() / $this->HRmax));
 }
示例#8
0
文件: Pace.php 项目: guancio/Runalyze
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->paceUnit = $context->sport()->paceUnit();
     $this->paceUnitEnum = $context->sport()->paceUnitEnum();
     $this->isRunning = $context->sport()->id() == Configuration::General()->runningSport();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::PACE);
     $this->manipulateData();
 }
示例#9
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->paceUnit = $context->sport()->paceUnit();
     $this->paceInTime = $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_KM || $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_100M || $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_500M;
     $this->isRunning = $context->sport()->id() == Configuration::General()->runningSport();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::PACE);
     $this->manipulateData();
 }
示例#10
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->isRunning = $context->activity()->sportid() == Configuration::General()->runningSport();
     $cadence = $this->isRunning ? new CadenceUnitRunning(0) : new CadenceUnit(0);
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::CADENCE);
     $this->initStrings($cadence);
     $this->manipulateData($cadence);
 }
示例#11
0
 /**
  * @param \Runalyze\View\Activity\Context $context
  * @return array
  */
 protected function computeRounds(Activity\Context $context)
 {
     $Loop = new Trackdata\Loop($context->trackdata());
     $Rounds = array();
     do {
         $Loop->nextDistance();
         $Rounds[] = array('km' => $Loop->difference(Trackdata\Object::DISTANCE), 's' => $Loop->difference(Trackdata\Object::TIME));
     } while (!$Loop->isAtEnd());
     return $Rounds;
 }
示例#12
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->isRunning = $context->activity()->sportid() == Configuration::General()->runningSport();
     $cadence = $this->isRunning ? new Data\Cadence\Running() : new Data\Cadence\General(0);
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::CADENCE);
     $this->initStrings($cadence);
     $this->manipulateData($cadence);
     $this->setManualAverage($cadence->useFactor($context->activity()->cadence()));
 }
示例#13
0
 /**
  * Display rounds
  */
 protected function displayTable()
 {
     $this->DemandedPace->setUnit($this->Context->sport()->paceUnit());
     $Table = new Table($this->Laps, $this->DemandedTime, $this->DemandedPace, $this->Context->sport()->id() == Configuration::General()->runningSport());
     if ($this->LapDistance > 0) {
         $Table->setAverage($this->Context->dataview()->pace(), new Duration($this->Context->trackdata()->totalTime() / $this->Context->trackdata()->totalDistance() * $this->LapDistance));
     } else {
         $Table->setAverage($this->Context->dataview()->pace());
     }
     $Table->display();
 }
示例#14
0
 /**
  * Determine correct x axis
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function determineXAxis(Activity\Context $context)
 {
     if ($context->hasTrackdata()) {
         $totalTime = 1000 * $context->trackdata()->totalTime();
         if ($context->hrv()->num() == $context->trackdata()->num()) {
             $this->XAxisData = array_map(function ($value) {
                 return 1000 * $value;
             }, $context->trackdata()->time());
         } else {
             $correctTime = abs(array_sum($context->hrv()->data()) - $totalTime) > 0.005 * $totalTime;
             $time = 0;
             foreach ($context->hrv()->data() as $ms) {
                 $time += $correctTime && $ms < 1000 ? 1000 : $ms;
                 $this->XAxisData[] = $time;
             }
             if ($correctTime && abs($time - $totalTime) > 0.01 * $totalTime) {
                 $this->XAxisData = array();
             }
         }
     }
 }
示例#15
0
 /**
  * Init sections
  */
 protected function initSections()
 {
     if (Configuration::ActivityView()->mapFirst() && Configuration::ActivityView()->plotMode()->showCollection()) {
         $this->Sections[] = new SectionComposite($this->Context);
         $this->Sections[] = new SectionLaps($this->Context);
     } else {
         $this->Sections[] = new SectionOverview($this->Context);
         if (Configuration::ActivityView()->mapFirst()) {
             $this->Sections[] = new SectionRouteOnlyMap($this->Context);
         } else {
             $this->Sections[] = new SectionLaps($this->Context);
         }
         $this->Sections[] = new SectionSwimLane($this->Context);
         if (Configuration::ActivityView()->plotMode()->showSeperated()) {
             $this->Sections[] = new SectionHeartrate($this->Context);
             $this->Sections[] = new SectionPace($this->Context);
             if (Configuration::ActivityView()->mapFirst()) {
                 $this->Sections[] = new SectionRouteOnlyElevation($this->Context);
             } else {
                 $this->Sections[] = new SectionRoute($this->Context);
             }
         } else {
             $this->Sections[] = new SectionComposite($this->Context);
             if (Configuration::ActivityView()->plotMode()->showPaceAndHR()) {
                 if (Configuration::ActivityView()->mapFirst()) {
                     $this->Sections[] = new SectionRouteOnlyElevation($this->Context);
                 } else {
                     $this->Sections[] = new SectionRoute($this->Context);
                 }
             } else {
                 if (!Configuration::ActivityView()->mapFirst()) {
                     $this->Sections[] = new SectionRouteOnlyMap($this->Context);
                 }
             }
         }
         if (Configuration::ActivityView()->mapFirst()) {
             $this->Sections[] = new SectionLaps($this->Context);
         }
     }
     if ($this->Context->trackdata()->has(\Runalyze\Model\Trackdata\Object::CADENCE) && $this->Context->sport()->id() == Configuration::General()->runningSport() || $this->Context->trackdata()->has(\Runalyze\Model\Trackdata\Object::GROUNDCONTACT) || $this->Context->trackdata()->has(\Runalyze\Model\Trackdata\Object::VERTICAL_OSCILLATION)) {
         $this->Sections[] = new SectionRunningDynamics($this->Context);
         $this->Sections[] = new SectionMiscellaneous($this->Context, false);
     } else {
         $this->Sections[] = new SectionMiscellaneous($this->Context, true);
     }
     if ($this->Context->hasHRV()) {
         $this->Sections[] = new SectionHRV($this->Context);
     }
 }
示例#16
0
 /**
  * Init data
  * @var \Runalyze\View\Activity\Context $context
  * @var boolean $forceOriginal
  */
 protected function initDataWithSwimdata(Activity\Context $context)
 {
     if (!$context->hasSwimdata()) {
         $this->Data = array();
         return;
     }
     $key = Swimdata::SWOLFCYCLES;
     if (!$context->swimdata()->has($key)) {
         $this->Data = array();
         return;
     }
     $Collector = new DataCollectorWithSwimdata($context->trackdata(), $key, $context->swimdata());
     $this->Data = $Collector->data();
     $this->XAxis = $Collector->xAxis();
 }
示例#17
0
 /**
  * Init data
  * @var \Runalyze\View\Activity\Context $context
  * @var boolean $forceOriginal
  */
 protected function initDataWithRoute(Activity\Context $context, $forceOriginal)
 {
     if (!$context->hasRoute()) {
         $this->Data = array();
         return;
     }
     $key = $context->route()->hasCorrectedElevations() && !$forceOriginal ? Route::ELEVATIONS_CORRECTED : Route::ELEVATIONS_ORIGINAL;
     if (!$context->route()->has($key)) {
         $this->Data = array();
         return;
     }
     $Collector = new DataCollectorWithRoute($context->trackdata(), $key, $context->route());
     $this->Data = $Collector->data();
     $this->XAxis = $Collector->xAxis();
 }
 /**
  * Display course
  */
 public function displayCourse()
 {
     $this->Context = new Context(Request::sendId(), Request::param('account'));
     if (!$this->activityIsValid() || !$this->Context->hasRoute() || !$this->Context->route()->hasPositionData()) {
         die('Don\'t do that!');
     }
     $Linker = new Linker($this->Context->activity());
     echo '<meta property="og:type" content="metadata">' . NL;
     echo '<link rel="origin" href="' . $Linker->publicUrl() . '">' . NL;
     $this->RouteLoop = new Model\Route\Loop($this->Context->route());
     $this->RouteLoop->setStepSize(self::STEP_SIZE);
     $this->TrackdataLoop = new Model\Trackdata\Loop($this->Context->trackdata());
     $this->TrackdataLoop->setStepSize(self::STEP_SIZE);
     do {
         $this->displayActivityDataPoint();
     } while ($this->RouteLoop->nextStep() && $this->TrackdataLoop->nextStep());
 }
示例#19
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::GROUNDCONTACT);
     $this->setManualAverage($context->activity()->groundcontact());
 }
示例#20
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::TIME);
 }
示例#21
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::POWER);
     $this->setManualAverage($context->activity()->power());
 }
示例#22
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata());
     $this->manipulateData();
 }
示例#23
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::VERTICAL_OSCILLATION);
     $this->manipulateData();
 }