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

Better default coordinate constant #24

Open
brandonjpierce opened this issue Sep 25, 2024 · 2 comments
Open

Better default coordinate constant #24

brandonjpierce opened this issue Sep 25, 2024 · 2 comments
Labels
fix A bug fix

Comments

@brandonjpierce
Copy link
Contributor

@brandonjpierce brandonjpierce changed the title TODO: better coordinate constant TODO: better default coordinate constant Sep 25, 2024
@brandonjpierce
Copy link
Contributor Author

brandonjpierce commented Sep 25, 2024

Super contrived port of GLSL function taken from: https://github.com/mattdesl/number-util/blob/master/index.js:

Reference: https://registry.khronos.org/OpenGL-Refpages/gl4/html/intBitsToFloat.xhtml

const int8 = new Int8Array(4);
const int32 = new Int32Array(int8.buffer, 0, 1);
const float32 = new Float32Array(int8.buffer, 0, 1);

function intBitsToFloat(value: number) {
  int32[0] = value;
  return float32[0];
}

@brandonjpierce brandonjpierce changed the title TODO: better default coordinate constant Refactor: better default coordinate constant Oct 23, 2024
@brandonjpierce
Copy link
Contributor Author

Verified the above snippet, doing intBitsToFloat(-1) like how it is done in the deckgl shader correctly returns NaN. This calls into question another thought:

This "default coordinate" constant is primarily used as a fallback when no lon/lat is provided in the data. However, this is also a little contextualized to geojson data format specifically as other formats such as Arrow already give you a dict of null values for any given column. One could argue that if we needed to pass "empty" coordinates to a shader you may still run into this issue given that the return value of intBitsToFloat(-1) (in the function above, not in a shader) still returns NaN. Thus, you would still be passing NaN to the shader itself vs. deriving inside by checking if the attribute is falsy to begin with.

@brandonjpierce brandonjpierce added the fix A bug fix label Oct 23, 2024
@brandonjpierce brandonjpierce changed the title Refactor: better default coordinate constant Better default coordinate constant Oct 23, 2024
@belsrc belsrc removed the dev label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A bug fix
Projects
None yet
Development

No branches or pull requests

2 participants