Repository navigation
Fix precision loss in cagnoli for edges crossing the antimeridian - #13
Merged
Merged
Conversation
For an edge whose endpoints lie on opposite sides of +-180 degrees the raw longitude difference is close to +-2*pi, and the true tiny step between the vertices is lost to the ulp of 2*pi before sin and cos are applied. Nothing cancels the error, so cells straddling the antimeridian at resolutions 12 and above come out up to 7.8% too small (res 15). Shift both longitudes to the same side of the antimeridian before subtracting, so the difference is between two nearby values. sin and cos are 2*pi-periodic, so the result is unchanged mathematically. Global area sums at res 0-3 still equal 4*pi to within 5e-13. Regression from v4.5.0 (uber#1101), reported in ClickHouse/ClickHouse#124447 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Konstantin Bogdanov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
clickgapai
pushed a commit
to clickgapai/ClickHouse
that referenced
this pull request
Oct 19, 2026
Bump the h3 fork to pick up ClickHouse/h3#13: in h3 4.5.0 cellAreaRads2 sums Cagnoli terms over the cell edges, and for an edge crossing the antimeridian the raw longitude difference is close to 2*pi, losing the tiny true step to its ulp. Cells straddling the antimeridian at resolutions >= 12 came out up to 7.8% smaller than their neighbours at res 15. Closes: ClickHouse#124447 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
For an edge whose endpoints lie on opposite sides of ±180° the raw longitude difference in
cagnoliis close to ±2π, and the true tiny step between the vertices is lost to the ulp of 2π beforesinandcosare applied. Nothing cancels the error, so cells straddling the antimeridian at resolutions 12 and above come out too small: 0.07% at res 13, 0.4% at res 14, 2.5% at res 15 (cellAreaRads2of the straddling cell vs. its neighbour).The fix shifts both longitudes to the same side of the antimeridian before subtracting, so the difference is between two nearby values.
sinandcosare 2π-periodic, so the result is unchanged mathematically. Global area sums at res 0–3 still equal 4π to within 5e-13. Of the cells used by the ClickHouse area tests only two antimeridian cells at res 0/1 change, in the 15th digit.Adds a
cell_area_antimeridiantest with three straddling/neighbour cell pairs; it fails on the unpatched code and passes with the fix.testH3CellAreaandtestH3CellAreaExhaustivepass.Regression from v4.5.0 (uber#1101), not present in v4.4.1 which used a different formula. To be reported upstream.
Closes: ClickHouse/ClickHouse#124447
Related: uber#1101
Related: uber#1108
🤖 Generated with Claude Code