Skip unnecessary longitude normalization on antimeridian-crossing box#1456
Open
tinko92 wants to merge 1 commit intoboostorg:developfrom
Open
Skip unnecessary longitude normalization on antimeridian-crossing box#1456tinko92 wants to merge 1 commit intoboostorg:developfrom
tinko92 wants to merge 1 commit intoboostorg:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Addresses a rounding-error edge case where expanding a spheroidal box that crosses the antimeridian can unexpectedly shrink due to unnecessary longitude normalization.
Changes:
- Adds an “allow antimeridian crossing” path to longitude normalization to avoid lossy normalize-then-shift behavior.
- Updates spheroidal box normalization to pass the new flag when appropriate.
- Adds a regression test for the shrink-on-expand scenario and tightens box equality checks to respect the provided tolerance.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/algorithms/envelope_expand/test_envelope_expand_on_spheroid.hpp | Adjusts box equality logic for longitude comparisons under tolerance. |
| test/algorithms/envelope_expand/expand_on_spheroid.cpp | Adds a regression test for antimeridian-crossing box expansion stability. |
| include/boost/geometry/util/normalize_spheroidal_coordinates.hpp | Extends longitude normalization with an option to skip normalization for antimeridian-crossing representation. |
| include/boost/geometry/util/normalize_spheroidal_box_coordinates.hpp | Detects the special antimeridian-crossing representation and forwards the skip-normalization flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ec1dc3e to
3f36811
Compare
…ridian-crossing box.
3f36811 to
7e9a531
Compare
barendgehrels
approved these changes
Apr 14, 2026
Collaborator
barendgehrels
left a comment
There was a problem hiding this comment.
Thanks for the fix! I'm OK
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.
The program in issue #1452 triggers some cases in which a box shrinks when being expanded with a point that is already within it, due to rounding errors introduced unnecessarily in coordinate normalization. When a box crosses the antimeridian, the longitude of its max point is first normalized to be within [-180, 180], then increased by half_period() again, which can introduce rounding error, including shrinking the box. the shrinking then seems to produce unstable behaviour in the rtree when the computed area difference between a boxes expansion and itself is negative. This is only a small part of the tree instability in #1452 and does not resolve most of the issue but isolated enough from the other issues to be treated in a separated PR.
This PR contains the following changes: