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

Rational arrays not read correctly #437

Open
sam6321 opened this issue Sep 6, 2024 · 0 comments
Open

Rational arrays not read correctly #437

sam6321 opened this issue Sep 6, 2024 · 0 comments

Comments

@sam6321
Copy link

sam6321 commented Sep 6, 2024

for (let i = 0; i < count; i += 2) {

When reading arrays of rational numbers (for example, when reading a GPSLatitude or GPSLongitude field) the reader does not index the output Uint32Array correctly, resulting in it skipping values on output.

A GPSLatitude array containing [71, 1, 25, 1, 47289959, 1000000] is currently being read as [71, 1, 47289959, 1000000, 0, 0]

The reading loop:

for (let i = 0; i < count; i += 2) {
  values[i] = readMethod.call(
    dataSlice, offset + (i * fieldTypeLength),
  );
  values[i + 1] = readMethod.call(
    dataSlice, offset + ((i * fieldTypeLength) + 4),
  );
}

Should instead be:

for (let i = 0; i < count; i++) {
  values[i * 2] = readMethod.call(
    dataSlice, offset + (i * fieldTypeLength),
  );
  values[i * 2 + 1] = readMethod.call(
    dataSlice, offset + ((i * fieldTypeLength) + 4),
  );
}
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

1 participant