feat(api): add OpenStreetMap as a 2nd open station source - #53
Merged
Conversation
Multi-source ingest. OSM (ODbL) is fetched per-viewport via Overpass and merged into the same stations table alongside Open Charge Map, increasing coverage everywhere OSM has data (location-only chargers are first-class). - app/ingest.py: source-neutral StationRow (now with `source`), shared UPSERT (writes source), upsert_stations, and osm_station_id() namespacing OSM ids into a BIGINT range disjoint from OCM (+ between node/way/relation) so the single-column PK + reports FK are untouched. - app/ocm.py: map_poi sets source="ocm"; imports shared StationRow. - app/osm.py: fetch_osm_elements (Overpass GET + User-Agent) + pure map_osm_element → OCM-compatible connectors JSON (socket:* → titles, power parsing); source="osm". - app/stations.py: generic guarded _sync_source per source (independent tile guards); cold viewport gathers OCM+OSM, warm refreshes both in background; `source` added to the query + StationOut. - geo.tile_key(source); config OSM_OVERPASS_URL / OSM_SYNC_TTL_SECONDS. - migration 004_station_source.sql (source column). - frontend: Station.source; StationDetail shows the data source. - ATTRIBUTION: OSM station data (ODbL, © OpenStreetMap contributors). - tests: map_osm_element + osm_station_id; map_poi source assertion. Verified: ruff + mypy strict + pure tests; frontend lint/test/build/svelte-check. End-to-end against Supabase: central London now 9 OCM + 40 OSM stations.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What (PR-1 of "more stations")
Adds OpenStreetMap (ODbL) as a second open station source alongside Open Charge Map. OSM is fetched per-viewport via the Overpass API and merged into the same
stationstable, so coverage grows everywhere OSM has data. Location-only chargers are first-class (still render; missing fields handled).How
app/ingest.py(new) — source-neutralStationRow(now withsource), sharedUPSERT(writessource),upsert_stations, andosm_station_id()that namespaces OSM ids into a BIGINT range disjoint from OCM + between node/way/relation → single-column PK +reportsFK untouched.app/osm.py(new) —fetch_osm_elements(Overpass GET + User-Agent) + puremap_osm_elementmapping OSM tags into the same OCM-compatible connectors JSON (socket:*→titles, kW parsing);source="osm".app/ocm.py—map_poisetssource="ocm"; uses sharedStationRow.app/stations.py— generic guarded_sync_sourceper source (independent tile guards); cold viewportgathers OCM+OSM then re-queries, warm refreshes both in background;sourceadded to query +StationOut.geo.tile_key(source), configOSM_OVERPASS_URL/OSM_SYNC_TTL_SECONDS, migration004_station_source.sql.Station.source+ detail panel shows the source.ATTRIBUTION.md: OSM/ODbL.Verification
ruff+ruff format+mypy app(strict) + pure tests (test_osm,test_ocm) ✓. Frontendlint/test(27)/build/svelte-check✓.Rollout
Migration 004 already applied to Supabase ✓. On merge, Render auto-deploys the multi-source backend. (No cross-source dedup yet → possible duplicate markers; tracked as a follow-up.)