Add local reverse-geocode database for better performance#87
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds optional local reverse-geocoding support for navigation features, using an RGC database to reduce reliance on online Photon/Komoot lookups.
Changes:
- Adds RGC configuration paths and default navigation config options.
- Initializes/downloads a local RGC database in
NavigationModule. - Uses local RGC lookups in
OpenStreetMapAPI, with country-code fallback handling for warp creation/editing. - Adds the
alpslib-geodependency and repository resolution changes.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/resources/modules/navigation/config.yml |
Adds local reverse-geocode database configuration. |
src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigPaths.java |
Adds config path constants for RGC settings. |
src/main/java/net/buildtheearth/buildteamtools/modules/network/api/OpenStreetMapAPI.java |
Adds local RGC lookup path before online fallback. |
src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavUtils.java |
Adds helper for resolving CCA2 from region names. |
src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavigationModule.java |
Adds RGC database file setup, download, and handler initialization. |
src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/WarpsComponent.java |
Uses fallback CCA2 lookup when reverse geocode returns no code. |
src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpEditMenu.java |
Uses fallback CCA2 lookup when changing warp location. |
settings.gradle.kts |
Enables mavenLocal() repository resolution. |
gradle/libs.versions.toml |
Adds alpslib-geo version catalog entries. |
build.gradle.kts |
Adds alpslib-geo as an implementation dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Qodana for JVM2 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
68868a8 to
a531451
Compare
…load and thread-safety fixes - Add optional offline country/region lookup using alpslib-geo RgcHandler - Automatically download and cache RGC database on first run from configured URL - Fall back to online Photon/Komoot API if local database disabled or unavailable - Mark rgcHandler field as volatile to guarantee cross-thread visibility - Mark Module.enabled as volatile to ensure reliable isEnabled() checks across threads - Schedule RgcHandler creation and all method calls on main thread to prevent concurrent access - Create parent directories before FileOutputStream to handle first-run download - Use try-with-resources for download streams to prevent resource leaks - Schedule RGC lookups on main thread when called from worker threads in OpenStreetMapAPI - Add getCCA2FromCountryName() fallback helper for country code lookup - Add RGC configuration options: enabled, url, path under reverse-geocode.local-database - Handle download failures gracefully with logging and fallback to API Dependencies: - Add com.alpsbte.alpslib:alpslib-geo:1.0.0 Files: - build.gradle.kts: add alpslib-geo dependency - gradle/libs.versions.toml: define alpslib-geo version - settings.gradle.kts: enable mavenLocal() (TEMPORARY - disable before merge) - NavigationModule.java: add RGC initialization with auto-download - Module.java: mark enabled field volatile - OpenStreetMapAPI.java: schedule RGC lookups on main thread - NavUtils.java: add getCCA2FromCountryName() helper - ConfigPaths.java: add RGC_LOCAL_DB_* constants - WarpsComponent.java, WarpEditMenu.java: use fallback country code lookup - config.yml: document RGC local-database settings
a531451 to
4ed6464
Compare
Address PR review by splitting RGC setup, region lookup, and OpenStreetMap country resolution into focused methods and switch-based flows.
Jasupa
left a comment
There was a problem hiding this comment.
The code is way more clean now; good job. Maybe we can create a second version for things like the disputed areas or multiple languages later, but again, this is out of scope for now and otherwise we would make things unneccesarily complicated for now.
Dependencies:
Files: