feat(substations): add join query API endpoints (PR 8/9)#196
Closed
texture-coding-agent wants to merge 5 commits intomainfrom
Closed
feat(substations): add join query API endpoints (PR 8/9)#196texture-coding-agent wants to merge 5 commits intomainfrom
texture-coding-agent wants to merge 5 commits intomainfrom
Conversation
- /substations — list page with filtering, search, pagination - /substations/[slug] — detail page with ownership, voltage, connectivity info, ODbL attribution - /api/tiles/substations/:z/:x/:y — vector tile endpoint for map rendering - Pre-generated tiles from substations.geojson via tippecanoe (future automation in CI) - Follows existing power-plants and transmission-lines UI patterns
Implements /api/cron/sync-substations endpoint that triggers the substations
data sync (OSM + EIA hybrid) on a weekly schedule.
**What's included:**
- Cron endpoint with internal auth (CRON_SECRET)
- Spawns the sync script via tsx
- Captures output and file stats
- 30-minute timeout for full US sweep
- Logs progress and errors
**Integration:**
- Wire to Vercel Cron (or equivalent scheduler)
- Recommend schedule: Weekly (e.g., Mondays 00:00 UTC)
- Outputs updated data/substations.{json,geojson}
**Next:**
- PR #6: transmission_line_endpoints join + sync
- PR #7: power_plant_interconnections join + sync
- PR #8: Join query API endpoints
- PR #9: Docs + catalog
---
*Part of CommonGrid 9th entry point milestone (substations) — PR 5 of 9*
…c (PR 6/9) Implements transmission_line_endpoints join table to replace fuzzy sub1/sub2 string references with formal foreign keys. Includes fuzzy matching sync script with confidence scoring for community review workflow. **What's included:** - Schema: transmission_line_endpoints table with role (from|to) and match_confidence - Migration: 0005_transmission_line_endpoints.sql with indexes - Sync script: fuzzy-matches transmission_lines.sub1/sub2 against substation names - Levenshtein + suffix-variation matching for reliability - Match confidence (0..1) for high/medium/low confidence filtering **Features:** - Auto-matches high-confidence pairs (≥0.85) - Flags lower-confidence for community review - Handles common suffix variations (SUBSTATION/STATION/SUB) - Batch insert with upsert support **Next:** - PR #7: power_plant_interconnections join + sync - PR #8: Join query API endpoints - PR #9: Docs + catalog --- *Part of CommonGrid 9th entry point milestone (substations) — PR 6 of 9*
…nc (PR 7/9) Implements power_plant_interconnections join table to link power plants to their nearest substation(s) for grid interconnection analysis. Uses PostGIS ST_Distance to compute spatial relationships. **What's included:** - Schema: power_plant_interconnections table with distance_meters and isPrimary - Migration: 0006_power_plant_interconnections.sql with optimized indexes - Sync script: ST_Distance-based spatial matching via PostGIS - Configurable search radius (default: 50 km via SEARCH_RADIUS_KM env var) - Primary + secondary interconnection candidates **Features:** - Efficiently computes nearest substation per power plant - Marks closest match as isPrimary=true - Stores all candidates within search radius - Distance in meters for precise filtering - Batch insert with upsert support **Next:** - PR #8: Join query API endpoints - PR #9: Docs + catalog --- *Part of CommonGrid 9th entry point milestone (substations) — PR 7 of 9*
Adds API endpoints to query the join tables: - GET /api/v1/substations/[slug]/transmission-lines - GET /api/v1/power-plants/[slug]/substations **What's included:** - Substation → transmission lines endpoint (lists connected lines + confidence) - Power plant → interconnected substations endpoint (primary + secondaries) - Distance metrics in km for power plant interconnections - Confidence distribution statistics for transmission line matches - Cache headers (3600s public) **Features:** - Groups transmission lines by role (from/to) - Separates primary interconnection from secondaries - Includes match confidence for community review - Efficient queries with proper joins **Next:** - PR #9: Docs + catalog update --- *Part of CommonGrid 9th entry point milestone (substations) — PR 8 of 9*
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Closing as zombie — commits in this PR are already on main via the meridian/* branch merges (#198 merged PR 5/9 content, #191 merged PR 4/9, #201 merged PR 8/9). This branch is stale from an earlier stacked-rebase attempt. Fresh PRs for the remaining work (PR 6/9 transmission joins, PR 9/9 docs) will be opened against current main. No action needed. |
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.
Adds API endpoints for querying join relationships. Depends on #193.