/** * 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() . ' m</td>'; } } else { $Calculator->calculate(); $Code .= '<td class="c' . (Configuration::ActivityView()->elevationMethod()->value() == $Algorithm[0] ? ' highlight' : '') . '" colspan="' . count($TresholdRange) . '">' . $Calculator->totalElevation() . ' m</td>'; } $Code .= '</tr>'; } $Code .= '</tbody>'; $Code .= '</table>'; return $Code; }
/** * 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; }