Repository navigation
Fix numerical errors - #3520
Closed
jdries wants to merge 5 commits into
Closed
Fix numerical errors#3520jdries wants to merge 5 commits into
jdries wants to merge 5 commits into
Conversation
values like 4.9999999999 were actually floored to 4, whereas it should be 5, caused pixel shifts in output
Contributor
Author
|
Found a simple test that exposes the issue. It's all about gridextents that are in fact aligned, but due to very small numerical differences, things go wrong. Still have to figure out where and how to integrate this as part of geotrellis unit tests. |
Member
|
@jdries a nice find! Could you add this unit test? |
pomadchin
requested changes
Sep 13, 2023
pomadchin
left a comment
Member
There was a problem hiding this comment.
🔥 Thx for a nice PR, but tests don't compile! Once the CI is green, I'll merge it.
Comment on lines
+194
to
+195
| targetBounds.height should be resultingBounds.height | ||
| targetBounds.width should be resultingBounds.width |
Member
There was a problem hiding this comment.
Tests don't compile!
Suggested change
| targetBounds.height should be resultingBounds.height | |
| targetBounds.width should be resultingBounds.width | |
| targetBounds.height shouldBe resultingBounds.height | |
| targetBounds.width shouldBe resultingBounds.width |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
When working in epsg:4326 coordinates, I recently observed separate bugs caused by the same problem. Basically transformations between geographical coordinates and grid coordinates where wrong due to floating point imprecision.
In both cases, grid coordinates were calculated as doubles and resulted in e.g. 4.9999999 but were done floored (toLong) resulting in 4.
This resulted in an actual pixel shift in one case, and in another case a missing row of pixels at the bottom of a saved geotiff.
Checklist
Notes
Optional. Ancillary topics, caveats, alternative strategies that didn't work out, anything else.
Closes #XXX