55// Transfer (FIT) Protocol License.
66/////////////////////////////////////////////////////////////////////////////////////////////
77// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8- // Profile Version = 21.169 .0Release
9- // Tag = production/release/21.169 .0-0-g7105132
8+ // Profile Version = 21.170 .0Release
9+ // Tag = production/release/21.170 .0-0-g5991e72
1010/////////////////////////////////////////////////////////////////////////////////////////////
1111
1212
@@ -20,6 +20,9 @@ import Utils from "./utils.js";
2020const HEADER_WITH_CRC_SIZE = 14 ;
2121const HEADER_WITHOUT_CRC_SIZE = 12 ;
2222
23+ const FIELD_DEFAULT_SCALE = 1 ;
24+ const FIELD_DEFAULT_OFFSET = 0 ;
25+
2326/**
2427 * A class for encoding FIT files.
2528 * @class
@@ -212,10 +215,17 @@ class Encoder {
212215 throw new Error ( ) ;
213216 }
214217
215- const scale = fieldDefinition . components . length > 1 ? 1 : fieldDefinition . scale ;
216- const offset = fieldDefinition . components . length > 1 ? 0 : fieldDefinition . offset ;
218+ const scale = fieldDefinition . components . length > 1 ? FIELD_DEFAULT_SCALE : fieldDefinition . scale ;
219+ const offset = fieldDefinition . components . length > 1 ? FIELD_DEFAULT_OFFSET : fieldDefinition . offset ;
220+ const hasScaleOrOffset = ( scale != FIELD_DEFAULT_SCALE || offset != FIELD_DEFAULT_OFFSET ) ;
221+
222+ if ( hasScaleOrOffset ) {
223+ const scaledValue = ( value + offset ) * scale ;
217224
218- return ( value + offset ) * scale ;
225+ return FIT . FloatingPointFieldTypes . includes ( fieldDefinition . type ) ? scaledValue : Math . round ( scaledValue ) ;
226+ }
227+
228+ return value ;
219229 }
220230
221231 // Is this a date_time field?
0 commit comments