Skip to content

Commit

Permalink
Merge pull request #14 from adriangibbons/endianness
Browse files Browse the repository at this point in the history
interpolate_missing_data() typo
  • Loading branch information
adriangibbons committed Aug 15, 2015
2 parents 4f0405e + fb25b27 commit 353cdbc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions php-FIT-File-Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -936,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);
Expand Down

0 comments on commit 353cdbc

Please sign in to comment.