Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset and scale are not fixed values #87

Open
jovandeginste opened this issue Mar 1, 2024 · 2 comments
Open

Offset and scale are not fixed values #87

jovandeginste opened this issue Mar 1, 2024 · 2 comments

Comments

@jovandeginste
Copy link

I'm running into issues decoding fit-files downloaded from Garmin Connect. Specifically, the elevations are wrong. I believe the documentation says the elevation (like any numeric value) may have a scale and offset (those may be 1 and 0 respectively), and those are specified in the record message. In the code, I see those are fixed values.

Could you check my logic here?

The snippet from the documentation:

Scale/Offset

The FIT SDK supports applying a scale or offset to binary fields. This allows efficient representation of values within a particular range and provides a convenient method for representing floating point values in integer systems. A scale or offset may be specified in the FIT profile for binary fields (sint/uint etc.) only. When specified, the binary quantity is divided by the scale factor and then the offset is subtracted, yielding a floating point quantity. The field access functions within the SDK automatically handle this conversion. If no scale and offset are specified, the field is interpreted as the underlying type and no extra conversion is necessary.

...

Scale and offset must be specified for all components even if these are 1 and 0. However, scale and offset will not be applied to destination fields with types of string or enum.

@jovandeginste
Copy link
Author

To be clear, I believe the values (5 and 500) in the documentation are meant as examples or maybe defaults, not as the definitive values:

image

@tormoder
Copy link
Owner

tormoder commented Mar 4, 2024

I believe the documentation says the elevation (like any numeric value) may have a scale and offset (those may be 1 and 0 respectively),

It is my understanding that the scale and offset values for a specific FIT profile field is fixed and defined "statically" in the global profile. There is no way to encode that information for a field "dynamically".

Scale and offset must be specified for all components even if these are 1 and 0. However, scale and offset will not be applied to destination fields with types of string or enum.

I think this is refering to that componments must expliclity have a scale of 1 and offset of 0 in the profile, even if they have no scale and offset. Every "regular" field without a scale and offset implicitly have 1 and 0 as scale and offset.

It's been a while since it looked at this, so I will be more than happy to be corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants