Skip to content

Cover the whole distance circle in the lon/lat search window - #499

Open
Andy2003 wants to merge 2 commits into
masterfrom
fix/orthodromic-search-window
Open

Andy2003 wants to merge 2 commits into
masterfrom
fix/orthodromic-search-window

Conversation

@Andy2003

@Andy2003 Andy2003 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

spatial.withinDistance (and, after #498, spatial.closest) found candidates in a lon/lat search window that could miss points within the distance:

  • At high latitudes the window was too narrow in longitude. Searching 1000 km from (0, 60) missed a point 994 km away.
  • It didn't wrap at ±180°. Searching 50 km from (179.9, 0) missed (-179.9, 0), which is 22 km away.
  • Near the poles it grew past ±90/±180 instead of covering every longitude.

The window now uses the exact great-circle width, and spans every longitude when the circle reaches a pole or crosses ±180°.

Longitudes are expected in -180..180; values stored in a 0..360 range are not found across the antimeridian.

Out of scope

  • The distance to lines and polygons is measured in flat degrees, also wrong across ±180°: pre-existing, fixed in Measure the great-circle distance to lines and polygons #500.
  • Near ±180° and the poles the window covers every longitude instead of two smaller windows. Results are correct; only the search area is larger.

The longitude half-width r / cos(lat) is too narrow away from the equator,
so spatial.withinDistance missed points near the edge of the distance. The
window also never wrapped at the antimeridian and grew past the poles; it
now spans all longitudes in those cases.
@Andy2003 Andy2003 self-assigned this Nov 18, 2026
@Andy2003 Andy2003 added the fix Bugfix label Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Test Results

446 tests  +11   424 ✅ +11   3m 2s ⏱️ -13s
 33 suites ± 0    22 💤 ± 0 
 33 files   ± 0     0 ❌ ± 0 

Results for commit 48fd45b. ± Comparison against base commit e390381.

@Andy2003
Andy2003 requested a lite review from Copilot November 18, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants