/**
  * Set content
  */
 protected function setContent()
 {
     $showElevation = Configuration::ActivityView()->plotMode()->showCollection();
     if (Configuration::ActivityView()->plotMode()->showCollection() && Configuration::ActivityView()->mapFirst()) {
         $this->BoxedValues[] = new Box\Distance($this->Context);
         $this->BoxedValues[] = new BoxedValue($this->Context->dataview()->duration()->string(), '', __('Time'));
     }
     $this->addAveragePace();
     $this->addCalculations();
     $this->addAverageHeartrate();
     $this->addMaximalHeartrate();
     $this->addCaloriesAndTrimp();
     if ($showElevation) {
         $this->addElevation();
     }
     if (Configuration::ActivityView()->plotMode()->showCollection() && Configuration::ActivityView()->mapFirst()) {
         $this->BoxedValues[] = new BoxedValue($this->Context->dataview()->elapsedTime(), '', __('Elapsed time'));
     }
     foreach ($this->BoxedValues as &$Value) {
         $Value->defineAsFloatingBlock('w50');
     }
     if ($showElevation) {
         $this->addCourse();
     }
     $this->addVdotInfoLink();
     if ($showElevation && $this->Context->hasRoute() && $this->Context->route()->hasElevations()) {
         $this->addElevationInfoLink();
     }
 }
 /**
  * Construct collector
  * @param \Runalyze\Model\Trackdata\Entity $trackdata
  * @param int $key
  * @param \Runalyze\Model\Swimdata\Entity $swimdata
  * @throws \InvalidArgumentException
  */
 public function __construct(Trackdata $trackdata, $key, Swimdata $swimdata)
 {
     if (!$swimdata->has($key)) {
         throw new \InvalidArgumentException('Swimdata has no data for "' . $key . '".');
     }
     $this->Key = $key;
     $this->Precision = Configuration::ActivityView()->plotPrecision();
     $this->KnowsDistance = $trackdata->has(Trackdata::DISTANCE);
     $this->init($trackdata);
     $this->LoopSwimdata = new Loop($swimdata);
     $this->collect();
 }
 /**
  * Display
  */
 public final function display()
 {
     if (\Runalyze\Configuration::ActivityView()->showSectionsFullheight()) {
         $this->big = true;
         $this->withShadow = false;
     }
     echo '<div class="training-row">';
     if ($this->withShadow) {
         echo '<div class="training-row-info-shadow"></div>';
     }
     $this->displayInfo();
     $this->displayPlot();
     echo '</div>';
 }
Example #4
0
 /**
  * Convert internal data to correct array for JSON
  */
 private function convertData()
 {
     foreach ($this->Data as $i => $Data) {
         $Points = array();
         foreach ($Data['data'] as $x => $y) {
             $Points[] = array($x, $y);
         }
         $this->Data[$i]['data'] = $Points;
     }
     if (Configuration::ActivityView()->smoothCurves() && !isset($this->Options['series']['curvedLines']['apply'])) {
         $this->Options['series']['curvedLines']['apply'] = true;
     }
     if (empty($this->Data) && strlen($this->ErrorString) == 0) {
         $this->raiseError('Es sind keine Daten vorhanden.');
     }
 }
 /**
  * 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);
     }
 }
 /**
  * All categories
  * @return ConfigurationCategory[]
  */
 private function allCategories()
 {
     return array(Configuration::General(), Configuration::Privacy(), Configuration::ActivityView(), Configuration::ActivityForm(), Configuration::Design(), Configuration::DataBrowser(), Configuration::Vdot(), Configuration::Trimp(), Configuration::BasicEndurance(), Configuration::Misc());
 }
Example #7
0
 /**
  * Get JS
  * @return string
  */
 public function js()
 {
     $scrollOnZoom = Configuration::ActivityView()->mapZoomOnScroll();
     $Code = 'RunalyzeLeaflet.setDefaultLayer("' . Configuration::ActivityView()->mapLayer() . '");';
     $Code .= 'RunalyzeLeaflet.init(\'' . $this->id . '\', { scrollWheelZoom: ' . ($scrollOnZoom ? 'true' : 'false') . '} );';
     foreach ($this->Routes as $Route) {
         $Code .= $Route->js();
     }
     if (!empty($this->Bounds)) {
         $Code .= 'RunalyzeLeaflet.map().fitBounds([[' . $this->Bounds['lat.min'] . ',' . $this->Bounds['lng.min'] . '],[' . $this->Bounds['lat.max'] . ',' . $this->Bounds['lng.max'] . ']]);';
     }
     if (!empty($this->Routes)) {
         $Code .= 'RunalyzeLeaflet.Routes.routeid="' . $this->Routes[0]->id() . '";';
     }
     return '<script>' . $Code . '</script>';
 }
Example #8
0
 /**
  * Get distance
  * @return string
  */
 public function distance($decimals = null)
 {
     if (is_null($decimals)) {
         $decimals = Configuration::ActivityView()->decimals();
     }
     if ($this->Activity->distance() > 0) {
         if ($this->Activity->isTrack()) {
             return (new Distance($this->Activity->distance()))->stringMeter();
         }
         return Distance::format($this->Activity->distance(), true, $decimals);
     }
     return '';
 }
 /**
  * Add: elevation
  */
 protected function addElevation()
 {
     if ($this->Context->activity()->distance() > 0 || $this->Context->activity()->elevation() > 0) {
         if ($this->Context->activity()->distance() > 0 && !(Configuration::ActivityView()->plotMode()->showCollection() && Configuration::ActivityView()->mapFirst())) {
             $this->BoxedValues[] = new Box\Distance($this->Context);
         }
         $this->BoxedValues[] = new Box\Elevation($this->Context);
         // TODO: Calculated elevation?
         if ($this->Context->activity()->elevation() > 0) {
             if ($this->Context->activity()->distance() > 0) {
                 $this->BoxedValues[] = new Box\Gradient($this->Context);
             }
             $this->BoxedValues[] = new Box\ElevationUpDown($this->Context);
         }
     }
 }
Example #10
0
 /**
  * Check for pause
  */
 protected function checkForPause()
 {
     if (!is_null($this->Trackdata) && $this->Trackdata->hasPauses()) {
         if ($this->PauseIndex < $this->Trackdata->pauses()->num() && $this->Trackdata->pauses()->at($this->PauseIndex)->time() <= $this->Trackdata->at($this->TrackdataLoop->index(), Trackdata\Entity::TIME)) {
             $this->addCurrentPauseIcon();
             $this->PathShouldBreak = true;
             $this->PauseIndex++;
         }
     } elseif (!Configuration::ActivityView()->routeBreak()->never() && $this->RouteLoop->calculatedStepDistance() > $this->PauseLimit) {
         $this->addCurrentSegment();
     }
 }
Example #11
0
 /**
  * Constructor
  * 
  * If no options are set, the current configuration settings are used.
  * 
  * @param array $ElevationPoints
  * @param \Runalyze\Parameter\Application\ElevationMethod $Method [optional]
  * @param int $Threshold [optional]
  */
 public function __construct($ElevationPoints, ElevationMethod $Method = null, $Threshold = null)
 {
     $this->ElevationPoints = $ElevationPoints;
     $this->Method = !is_null($Method) ? $Method : Configuration::ActivityView()->elevationMethod();
     $this->Threshold = !is_null($Threshold) ? $Threshold : Configuration::ActivityView()->elevationMinDiff();
 }
 /**
  * Get different algorithms for
  * @param array $array
  * @return string
  */
 protected function getDifferentAlgorithmsFor($array)
 {
     $Method = new ElevationMethod();
     $Calculator = new Elevation\Calculation\Calculator($array);
     $TresholdRange = range(1, 10);
     $Algorithms = array(array(ElevationMethod::NONE, false), array(ElevationMethod::THRESHOLD, true), array(ElevationMethod::DOUGLAS_PEUCKER, true));
     $Code = '<table class="fullwidth zebra-style small">';
     $Code .= '<thead>';
     $Code .= '<tr><th class="r">' . __('Threshold') . ':</th>';
     foreach ($TresholdRange as $t) {
         $Code .= '<th>' . $t . '</th>';
     }
     $Code .= '</tr>';
     $Code .= '</thead>';
     $Code .= '<tbody>';
     foreach ($Algorithms as $Algorithm) {
         $Method->set($Algorithm[0]);
         $Calculator->setMethod($Method);
         $Code .= '<tr><td class="b">' . $Method->valueAsLongString() . '</td>';
         if ($Algorithm[1]) {
             foreach ($TresholdRange as $t) {
                 $highlight = Configuration::ActivityView()->elevationMinDiff() == $t && Configuration::ActivityView()->elevationMethod()->value() == $Algorithm[0] ? ' highlight' : '';
                 $Calculator->setThreshold($t);
                 $Calculator->calculate();
                 $Code .= '<td class="r' . $highlight . '">' . $Calculator->totalElevation() . '&nbsp;m</td>';
             }
         } else {
             $Calculator->calculate();
             $Code .= '<td class="c' . (Configuration::ActivityView()->elevationMethod()->value() == $Algorithm[0] ? ' highlight' : '') . '" colspan="' . count($TresholdRange) . '">' . $Calculator->totalElevation() . '&nbsp;m</td>';
         }
         $Code .= '</tr>';
     }
     $Code .= '</tbody>';
     $Code .= '</table>';
     return $Code;
 }
Example #13
0
 /**
  * Set general info
  */
 protected function setGeneralInfo()
 {
     $this->XML->Folder->name = $this->nameForKml();
     $this->XML->Folder->Placemark->name = $this->nameForKml();
     $this->XML->Folder->Placemark->Style->geomColor = self::rgbToKmlColor(Configuration::ActivityView()->routeColor());
 }
Example #14
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;
 }
Example #15
0
 /**
  * Define x-axis
  * @param \Runalyze\Model\Trackdata\Entity $trackdata
  */
 protected function defineXAxis(Trackdata $trackdata)
 {
     if (Configuration::ActivityView()->usesTimeAsXAxis() && $trackdata->has(Trackdata::TIME) && $trackdata->totalTime() > 0) {
         $this->XAxis = self::X_AXIS_TIME;
     } elseif ($trackdata->has(Trackdata::DISTANCE) && $trackdata->totalDistance() > 0) {
         $this->XAxis = self::X_AXIS_DISTANCE;
     } elseif ($trackdata->has(Trackdata::TIME) && $trackdata->totalTime() > 0) {
         $this->XAxis = self::X_AXIS_TIME;
     } else {
         $this->XAxis = self::X_AXIS_INDEX;
     }
 }
Example #16
0
 /**
  * Add to plot
  * @param \Plot $Plot
  * @param int $yAxis
  * @param boolean $addAnnotations [optional]
  */
 public function addTo(\Plot &$Plot, $yAxis, $addAnnotations = true)
 {
     if (empty($this->Data)) {
         return;
     }
     parent::addTo($Plot, $yAxis, $addAnnotations);
     if (!$this->paceInTime) {
         return;
     }
     $Plot->setYAxisTimeFormat('%M:%S', $yAxis);
     $min = min($this->Data);
     $max = max($this->Data);
     $setLimits = false;
     $autoscale = true;
     if (Configuration::ActivityView()->ignorePaceOutliers() && $max - $min > 2 * 60 * 1000) {
         $setLimits = true;
         $num = count($this->Data);
         $sorted = $this->Data;
         sort($sorted);
         $min = 10 * 1000 * floor($sorted[round(self::$CUT_OUTLIER_PERCENTAGE / 2 / 100 * $num)] / 10 / 1000);
         $max = 10 * 1000 * ceil($sorted[round((1 - self::$CUT_OUTLIER_PERCENTAGE / 2 / 100) * $num) - 1] / 10 / 1000);
     }
     if ($max > 50 * 60 * 1000) {
         $setLimits = true;
         $max = 50 * 60 * 1000;
     }
     if (Configuration::ActivityView()->paceAxisType()->valueAsString() == PaceAxisType::AS_SPEED) {
         $LimitMin = Configuration::ActivityView()->paceYaxisMinimum();
         if (!$LimitMin->automatic()) {
             $min = $LimitMin->value() * 1000;
         }
         $this->setYAxisForReversePace($Plot, $yAxis, $min);
     } else {
         $LimitMin = Configuration::ActivityView()->paceYaxisMinimum();
         $LimitMax = Configuration::ActivityView()->paceYaxisMaximum();
         if (!$LimitMin->automatic() || !$LimitMax->automatic()) {
             $setLimits = true;
             $autoscale = false;
             if (!$LimitMin->automatic() && $min < 1000 * $LimitMin->value()) {
                 $min = 1000 * $LimitMin->value();
             } else {
                 $min = 60 * 1000 * floor($min / 60 / 1000);
             }
             if (!$LimitMax->automatic() && $max > 1000 * $LimitMax->value()) {
                 $max = 1000 * $LimitMax->value();
             } else {
                 $max = 60 * 1000 * floor($max / 60 / 1000);
             }
         }
         if ($setLimits) {
             $Plot->setYLimits($yAxis, $min, $max, $autoscale);
             $Plot->setYAxisLabels($yAxis, null);
         }
     }
     switch (Configuration::ActivityView()->paceAxisType()->valueAsString()) {
         case PaceAxisType::AS_SPEED:
             $Plot->setYAxisPaceReverse($yAxis);
             break;
         case PaceAxisType::REVERSE:
             $Plot->setYAxisReverse($yAxis);
             break;
     }
 }
Example #17
0
<?php

/**
 * File for changing a config-value
 * Call:   ajax.change.Config.php?key=...&value=...[&add]
 */
require_once '../inc/class.Frontend.php';
$Frontend = new Frontend();
switch ($_GET['key']) {
    case 'garmin-ignore':
        \Runalyze\Configuration::ActivityForm()->ignoreActivityID($_GET['value']);
        break;
    case 'leaflet-layer':
        \Runalyze\Configuration::ActivityView()->updateLayer($_GET['value']);
        break;
    default:
        if (substr($_GET['key'], 0, 5) == 'show-') {
            $key = substr($_GET['key'], 5);
            \Runalyze\Configuration::ActivityForm()->update($key, $_GET['value']);
        }
}