-
-
Notifications
You must be signed in to change notification settings - Fork 2
Added R-Tree spatial indexing to DB to massively speed up nearest_* functions #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds R-Tree spatial indexing to the SQLite database to significantly improve the performance of nearest_addr() and nearest_placenames() functions. R-Tree indexes enable efficient bounding box queries, replacing the previous brute-force approach that scanned all records. The implementation creates virtual R-Tree tables (stadfong_rtree and ornefni_rtree) and uses an expanding search radius strategy to find nearby candidates before computing precise distances.
Key Changes:
- Added R-Tree virtual tables for spatial indexing of addresses and placenames
- Refactored nearest_* functions to use R-Tree queries with expanding bounding box search
- Added
max_distparameter to allow filtering results by maximum distance - Removed coordinate-based regular indexes that are now superseded by R-Tree
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_iceaddr.py | Added test coverage for new max_dist parameter and refactored existing test for clarity |
| src/iceaddr/placenames.py | Refactored nearest_placenames() to use R-Tree with expanding bounding box search and added max_dist parameter |
| src/iceaddr/addresses.py | Refactored nearest_addr() to use R-Tree with expanding bounding box search and added max_dist parameter |
| build_db.py | Added R-Tree virtual table creation and population for address data |
| add_placename_data.py | Added R-Tree virtual table creation and population for placename data; commented out interactive file fetch prompt |
| README.md | Updated license link for IS 50V Örnefni data source |
Comments suppressed due to low confidence (3)
add_placename_data.py:48
- This comment appears to contain commented-out code.
# if input(f"{GPKG_FILE} exists, fetch newer version? (y/n): ").lower().startswith("y"):
# Path(GPKG_FILE).unlink()
# else:
src/iceaddr/addresses.py:15
- Import of 'math' is not used.
import math
src/iceaddr/placenames.py:13
- Import of 'math' is not used.
import math
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s + updated CI co action to latest version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…th the search box + optimized by removing redundant repeated dist calc when max_dist specified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.