Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit f6427a0

Browse files
committed
Add getJSONLap() method
1 parent c04b532 commit f6427a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/phpFITFileAnalysis.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,30 @@ public function getJSON($crank_length = null, $ftp = null, $data_required = ['al
26152615
return json_encode($for_json);
26162616
}
26172617

2618+
/**
2619+
* Create a JSON object that contains available lap message information.
2620+
*/
2621+
public function getJSONLap()
2622+
{
2623+
$for_json = [];
2624+
$for_json['fix_data'] = isset($this->options['fix_data']) ? $this->options['fix_data'] : null;
2625+
$for_json['units'] = isset($this->options['units']) ? $this->options['units'] : null;
2626+
$for_json['pace'] = isset($this->options['pace']) ? $this->options['pace'] : null;
2627+
$for_json['num_laps'] = count($this->data_mesgs['lap']['timestamp']);
2628+
$data = [];
2629+
2630+
for ($i=0; $i<$for_json['num_laps']; $i++) {
2631+
$data[$i]['lap'] = $i;
2632+
foreach ($this->data_mesgs['lap'] as $key => $value) {
2633+
$data[$i][$key] = $value[$i];
2634+
}
2635+
}
2636+
2637+
$for_json['data'] = $data;
2638+
2639+
return json_encode($for_json);
2640+
}
2641+
26182642
/**
26192643
* Outputs tables of information being listened for and found within the processed FIT file.
26202644
*/

0 commit comments

Comments
 (0)