Geohash implementation - #24
Merged
Merged
Conversation
ZipFile is real persnickety about formatting, and will fail on duplicate entries. some downloaded gtfs feeds do have duplicate entries - SF Bay Area has 2x "Attribution" entries for some reason, which is harmless, but causes the whole extraction to fail. ZipInputStream is less efficient but it works.
There was a problem hiding this comment.
Pull request overview
Implements a local GTFS-backed nearby-stops lookup (using a simple geohash cell index in SQLite/Room) and wires it into the existing Nearby Stops flow, while also refactoring GTFS-related code into browse/, sources/, and local/ subpackages. It also adds developer-facing controls to clear GTFS caches/downloads and updates the zip-entry extraction approach to be more tolerant of imperfect GTFS zips.
Changes:
- Add a Room database for imported
stops.txt, a geohash implementation for indexed bounding-box queries, and aNearbyStopsProviderthat returns locally-imported stops. - Merge live API nearby stops with locally-imported GTFS stops in
NearbyStopsViewModel. - Refactor GTFS code into clearer subpackages and add Developer Settings UI + cache-reset plumbing.
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tool/src/main/kotlin/dev/garado/transit/settings/DeveloperSettingsScreen.kt | Adds a dev action to clear GTFS cache/downloads via a confirm screen. |
| tool/src/main/kotlin/dev/garado/transit/map/NearbyStopsViewModel.kt | Merges Transit API results with local GTFS stop results; departures remain API-only. |
| tool/src/main/kotlin/dev/garado/transit/HomeScreen.kt | Updates import path for moved GtfsManagerScreen. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsSourceStore.kt | New store that persists sources, downloads zips, and imports stops into the local DB. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsSourceDatabase.kt | Moves package; adds DAO method to reset all download states. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsSource.kt | Moves package; refines download state messaging / retry semantics. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsManagerViewModel.kt | Updates store wiring to include stops DAO (local import support). |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsManagerSourceListScreen.kt | Updates package/imports and store initialization with stops DAO. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsManagerScreen.kt | Updates package/imports for refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsManagerRegionListScreen.kt | Updates package/imports and store initialization with stops DAO. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsDownloader.kt | Moves package; downloader streams response to disk (used by new source store). |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsClearCacheConfirmScreen.kt | New confirmation screen for clearing GTFS cache/downloads. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/sources/GtfsCacheReset.kt | New cache reset function clearing DB state and downloaded zips. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/local/GtfsZipExtractor.kt | New zip entry reader using ZipInputStream for more tolerant extraction. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/local/GtfsStopsTxtParser.kt | New minimal CSV parser for stops.txt into DB entities. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/local/GtfsStopsDatabase.kt | New Room DB schema + geohash index/query helpers + Geohash implementation. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/local/GtfsLocalNearbyStopsProvider.kt | New provider that queries the local DB and returns nearby TripStops. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/GtfsSourceStore.kt | Removes old store (replaced by gtfs/sources/GtfsSourceStore). |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/TransitousFeedFetcher.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsRegionListScreen.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsDatasetListScreen.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsCountryListScreen.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsCatalogDatabase.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsBulkAddConfirmScreen.kt | Moves package/imports for browse refactor. |
| tool/src/main/kotlin/dev/garado/transit/gtfs/browse/GtfsBrowserViewModel.kt | Moves package/imports for browse refactor. |
| .gitignore | Stops ignoring local/. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Closed
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.
Implements basic geohashing scheme for efficient nearby stops lookups. It is working!!!
The initial design decision was rtree, but then I found out it's not included in the available sqlite build, sigh.
Also adds workarounds in ZipExtractor to sidestep ZipInput being unnecessarily picky and causing failures with certain harmlessly slightly-incorrectly-formatted zip files. (Switch to ZipInputStream instead.)
I... also slipped in splitting gtfs dir into subdirectories, inflating the diff.