Skip to content

Fix incorrect open linestring distance computation#1499

Merged
michaelkirk merged 2 commits intogeorust:mainfrom
wherobots:fix-linestring-linestring-dist
Feb 4, 2026
Merged

Fix incorrect open linestring distance computation#1499
michaelkirk merged 2 commits intogeorust:mainfrom
wherobots:fix-linestring-linestring-dist

Conversation

@Kontinuation
Copy link
Contributor

@Kontinuation Kontinuation commented Feb 4, 2026

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

The Euclidean distance computation method for linestrings produce incorrect results for disjoint, non-closed linestrings. This is because of a bug in the fast path for computing distances where the bboxes of linestrings are disjoint. We always drop the last coordinate when computing the projected coordinate, this will miss the end point when the projected linestring is not closed. This patch fixes the problem by only dropping the last coordinate for closed linestrings.

This problem was originally found when upgrading geo from 0.31.0 to 0.32.0 in apache/sedona-db#566.

@urschrei
Copy link
Member

urschrei commented Feb 4, 2026

Oof, thanks for catching this. Mea culpa.

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

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

Thank you finding and fixing this bug! Your code changes make sense, but I'm confused by the test case.

@michaelkirk michaelkirk added this pull request to the merge queue Feb 4, 2026
Merged via the queue into georust:main with commit 1d30142 Feb 4, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants