From 3a0e5525ad898d229e26e8ff03f65c8bcda6ec0c Mon Sep 17 00:00:00 2001 From: Adrian Gibbons Date: Sat, 15 Aug 2015 12:51:06 +0800 Subject: [PATCH 1/2] fix_data() endianness isset(field_name) --- php-FIT-File-Analysis.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/php-FIT-File-Analysis.php b/php-FIT-File-Analysis.php index 334f01f..5d5107d 100644 --- a/php-FIT-File-Analysis.php +++ b/php-FIT-File-Analysis.php @@ -787,7 +787,8 @@ private function fix_data($options) { $mesg_name = $this->data_mesg_info[$mesg['global_mesg_num']]['mesg_name']; foreach($mesg['field_defns'] as $field) { - if($field['base_type'] === 131) { // Convert uint16 to sint16 + // Convert uint16 to sint16 + if($field['base_type'] === 131 && isset($this->data_mesg_info[$mesg['global_mesg_num']]['field_defns'][$field['field_definition_number']]['field_name'])) { $field_name = $this->data_mesg_info[$mesg['global_mesg_num']]['field_defns'][$field['field_definition_number']]['field_name']; if(is_array($this->data_mesgs[$mesg_name][$field_name])) { foreach($this->data_mesgs[$mesg_name][$field_name] as &$v) { @@ -800,7 +801,8 @@ private function fix_data($options) { $this->data_mesgs[$mesg_name][$field_name] = -1 * ($this->data_mesgs[$mesg_name][$field_name] - 0x7FFF); } } - else if($field['base_type'] === 133) { // Convert uint32 to sint32 + // Convert uint32 to sint32 + else if($field['base_type'] === 133 && isset($this->data_mesg_info[$mesg['global_mesg_num']]['field_defns'][$field['field_definition_number']]['field_name'])) { $field_name = $this->data_mesg_info[$mesg['global_mesg_num']]['field_defns'][$field['field_definition_number']]['field_name']; if(is_array($this->data_mesgs[$mesg_name][$field_name])) { foreach($this->data_mesgs[$mesg_name][$field_name] as &$v) { From fb25b2744931ef1fa0b5b6e7ae922e64ddc18eff Mon Sep 17 00:00:00 2001 From: Adrian Gibbons Date: Sat, 15 Aug 2015 12:51:55 +0800 Subject: [PATCH 2/2] interpolate_missing_data() typo --- php-FIT-File-Analysis.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/php-FIT-File-Analysis.php b/php-FIT-File-Analysis.php index 5d5107d..1a774c2 100644 --- a/php-FIT-File-Analysis.php +++ b/php-FIT-File-Analysis.php @@ -938,11 +938,13 @@ private function interpolate_missing_data(&$missing_keys, &$array){ if ($missing_keys[$i] > $max_key) { $array[$missing_keys[$i]] = $array[$max_key]; continue; - } else if ($missing_keys[$i] < $max_key) { + } else if ($missing_keys[$i] < $min_key) { $array[$missing_keys[$i]] = $array[$min_key]; continue; } + reset($array); + while($missing_keys[$i] > key($array)) { $prev_value = current($array); next($array);