Commit d4f107f2 authored by Clouard Regis's avatar Clouard Regis
Browse files

Added route statistics (refactoring).

parent af8972af
......@@ -57,7 +57,6 @@ function renderTimeSheet(distances) {
} else if (index === timeSheetData[0][1].length - 1) {
controlCell.innerHTML = "Arrivée";
lengthCell.innerHTML = distances[$i] + " m";
lengthCell.innerHTML = distances[$i];
} else {
controlCell.innerHTML = index;
lengthCell.innerHTML = distances[$i] + " m";
......
......@@ -23,15 +23,16 @@ class TrackStatistics
{
$splitTimes = array();
$splitTimes[] = "";
$lastTime = $controlPoints[0]->punchTime + 1; // +1 to avoid == 0.
for ($i = 1; $i < count($controlPoints); $i++) {
$lastTime = 0;
$lastIndex = $i;
while ($lastTime === 0 && $lastIndex > 0) {
$lastIndex--;
$lastTime = $controlPoints[$lastIndex]->punchTime;
$time = $controlPoints[$i]->punchTime;
if ($lastTime > 0 && $time > 0) {
$elapsedTime = $time - $lastTime;
$splitTimes[] = $this->convertTimetoString($elapsedTime); // TODO A faire en Javascript (c'est de l'affichage, peut dépendre de la langue).
} else {
$splitTimes[] = $this->convertTimetoString(0); // TODO A faire en Javascript (c'est de l'affichage, peut dépendre de la langue).
}
$time = $controlPoints[$i]->punchTime - $lastTime;
$splitTimes[] = $this->convertTimetoString($time);
$lastTime = $controlPoints[$i]->punchTime;
}
return $splitTimes;
......@@ -73,7 +74,7 @@ class TrackStatistics
if (is_numeric($lengths[$i]) && intval($lengths[$i]) > 0) {
$time = $this->convertStringToTimeInMs($splitTimes[$i]);
$length = intval($lengths[$i]);
$pace = $this->convertTimetoString($time * 1000 / $length);
$pace = $this->convertTimetoString($time * 1000 / $length); // TODO EN Javascript
$paces[] = $pace;
} else {
$paces[] = "--:--";
......@@ -83,7 +84,7 @@ class TrackStatistics
return $paces;
}
private function convertTimetoString(int $time): string
private function convertTimetoString(int $time): string // TODO A supprimer.
{
$timeInS = $time / 1000.0;
$hrs = floor($timeInS / 3600);
......@@ -101,7 +102,7 @@ class TrackStatistics
}
}
private function convertStringToTimeInMs(string $formattedTime): int
private function convertStringToTimeInMs(string $formattedTime): int // TODO On devrait plus en avoir besoin quand convertTimeToString sera supprimée.
{
list($min, $sec) = sscanf($formattedTime, "%d:%d");
......
......@@ -20,6 +20,7 @@
cursor: pointer;
color: var(--primary);
}
.table th, td {
text-align: center;
}
......@@ -111,7 +112,9 @@
const element = event.target;
if (!gpxDictionary[element.value]) {
gpxDictionary[element.value] = addTrack(event, map, gpxTrace);
addTimeSheet(element.innerHTML, punchedPoints, splitTimes, distances, paces);
if (courseFormat === 0) {
addTimeSheet(element.innerHTML, punchedPoints, splitTimes, distances, paces);
}
buttonDictionary[element.value] = addDownloadButton(event, element.innerHTML, gpxTrace, document.getElementById("files-tab"));
} else {
let gpxLayer = gpxDictionary[element.value];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment