Skip to content

Commit

Permalink
['record']['timestamp'] and fix_data() enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangibbons committed Aug 12, 2015
1 parent d8bed5c commit dcb61a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions php-FIT-File-Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ private function read_data_records() {
if(isset($tmp_record_array['timestamp'])) {
$timestamp = $tmp_record_array['timestamp'];
unset($tmp_record_array['timestamp']);
$this->data_mesgs['record']['timestamp'][] = $timestamp;

foreach($tmp_record_array as $key => $value) {
if($value !== null) {
Expand All @@ -760,7 +761,12 @@ private function fix_data($options) {
array_walk($options['fix_data'], function(&$value) { $value = strtolower($value); } ); // Make all lower-case.
$bCadence = $bDistance = $bHeartRate = $bLatitudeLongitude = $bSpeed = $bPower = false;
if(in_array('all', $options['fix_data'])) {
$bCadence = $bDistance = $bHeartRate = $bLatitudeLongitude = $bSpeed = $bPower = true;
$bCadence = isset($this->data_mesgs['record']['cadence']);
$bDistance = isset($this->data_mesgs['record']['distance']);
$bHeartRate = isset($this->data_mesgs['record']['heart_rate']);
$bLatitudeLongitude = isset($this->data_mesgs['record']['position_lat']) && isset($this->data_mesgs['record']['position_long']);
$bSpeed = isset($this->data_mesgs['record']['speed']);
$bPower = isset($this->data_mesgs['record']['power']);
}
else {
if(isset($this->data_mesgs['record']['timestamp'])) {
Expand All @@ -780,10 +786,10 @@ private function fix_data($options) {
$bPower = (count($this->data_mesgs['record']['power']) === $count_timestamp) ? false : in_array('power', $options['fix_data']);
}
}

$missing_distance_keys = [];
$missing_hr_keys = [];
$missing_lat_keys = [];

$missing_lon_keys = [];
$missing_speed_keys = [];
$missing_power_keys = [];
Expand Down

0 comments on commit dcb61a2

Please sign in to comment.