Repository navigation
Conversation
To test ways against a bbox, Bbox_Filter loads the nodes of every
candidate way and checks its segments. It uses a fast path to exclude
ways that must lie outside of the bbox by virtue of their enclosing
tile. Extend the fast path to ways that must lie inside the bbox by
virtue of their enclosing tile.
On a Nova Scotia extract:
[out:csv(::count)]; way[highway](44.60,-63.66,44.70,-63.52); out count;
112 ms -> 74 ms (-34%)
[out:json]; way[highway](44.60,-63.66,44.70,-63.52); out geom;
396 ms -> 333 ms (-16%)
Co-Authored-By: Colin Dellow <cldellow@gmail.com>
cldellow
force-pushed
the
bbox-ways-inside
branch
from
November 30, 2026 15:52
b4e849b to
547cb6e
Compare
Author
|
The CI tests failed due to a flaky race condition in the dispatcher 22 test. I re-ran them, and will submit a separate PR that resolves the race. |
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.
Constraints have the concept of cheap and expensive filters.
Bbox_Filter's cheap filter currently removes things that can be excluded by the filter without needing to analyze their geometry.
For ways, this includes ways whose tile index lies entirely outside of the bbox, like
Din this Claude-generated image:The expensive filter then runs to exactly test all the other ways.
This PR speeds up bbox filters by skipping exact geometry tests for ways that are provably inside the bbox by virtue of their tile index, as
AandBare.Then, only ways whose tile index spans the bbox's boundary need to be analyzed in the expensive filter for their exact geometry.
On a Nova Scotia extract:
Bboxes that cross the antimeridian or which are 180 or more degrees wide are explicitly excluded from the fast path, since the expensive filter has special handling for them.
This can likely be extended to relations, but that will be a separate PR.
Caveat/question for reviewers: this PR changes the behaviour for some ways that have a missing node. Previously, the expensive filter would call
make_geometryfor short ways, which returns an empty geometry if a way has a missing node. Thus, that way would be excluded by the bbox filter, even if one of its nodes did fall within the bbox. This PR will now include ways with missing nodes if their tile index falls entirely within the bbox. This is a change in behaviour, so I'm flagging it, but IMO, it's a good change in behaviour, and it's unlikely to be hit by most people if their databases are built from the planet or from well-formed extracts that maintain way integrity.