Skip to content

Geohash implementation - #24

Merged
garado merged 8 commits into
devfrom
feat/geohash-implementation
Aug 12, 2026
Merged

Geohash implementation#24
garado merged 8 commits into
devfrom
feat/geohash-implementation

Conversation

@garado

@garado garado commented Aug 12, 2026

Copy link
Copy Markdown
Owner

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.

garado added 8 commits August 11, 2026 04:41
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 a NearbyStopsProvider that 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.

@garado
garado merged commit 4029e5b into dev Aug 12, 2026
2 checks passed
@garado garado mentioned this pull request Aug 12, 2026
@garado
garado deleted the feat/geohash-implementation branch August 12, 2026 08:28
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.

2 participants