Skip to content

Claude/create gtfs sqljs module 011 c up nn k ltuvz d dz xyz fy rm - #12

Merged
chtitux merged 4 commits into
mainfrom
claude/create-gtfs-sqljs-module-011CUpNnKLtuvzDDzXYZFyRm
Nov 5, 2025
Merged

chtitux merged 4 commits into
mainfrom
claude/create-gtfs-sqljs-module-011CUpNnKLtuvzDDzXYZFyRm

Conversation

@chtitux

@chtitux chtitux commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

No description provided.

…tions

Implements comprehensive GTFS-RT integration supporting:
- Service alerts
- Trip updates with stop time updates
- Vehicle positions

Features:
- Configurable feed URLs (array of endpoints)
- Staleness threshold (default 120s) to exclude old data
- Manual refresh via fetchRealtimeData()
- Query methods: getAlerts(), getVehiclePositions()
- Enhanced getStopTimes() with includeRealtime option
- Enhanced getTrips() with includeRealtime option (includes vehicle position + trip update)
- Realtime data stored in SQLite and included in exports

Implementation details:
- Uses protobufjs for parsing GTFS-RT protobuf feeds
- RT tables: rt_alerts, rt_vehicle_positions, rt_trip_updates, rt_stop_time_updates
- Each row tracks rt_last_updated timestamp for staleness filtering
- Alert active period checking (assume active if no period defined)
- Entity-based alert filtering (route, stop, trip)
- Nested realtime data in query results (Option A per requirements)
- Fetch uses native fetch API (Node.js 18+ required)
- TypeScript types for all RT entities and enums

Alert filtering:
- activeOnly: checks active_period start/end against current time
- Affected entity filters: routeId, stopId, tripId
- Always applies staleness threshold

Vehicle position filtering:
- By tripId, routeId, vehicleId
- Always applies staleness threshold

Trip realtime merging:
- Returns vehiclePosition: null if no RT data
- Includes trip update data (delay, schedule relationship)

Stop time realtime merging:
- Nested realtime object with arrival/departure delays
- Schedule relationship included

Configuration:
- Set via constructor options or setRealtimeFeedUrls()
- Configurable staleness threshold via constructor or setStalenessThreshold()

Dependencies:
- Added protobufjs ^7.2.5 for protobuf parsing

Breaking changes: None (pure addition)
- test-realtime.ts: Full test with real network URLs (for production testing)
- test-realtime-local.ts: Local test demonstrating RT API functionality
- Shows all RT methods, data structures, and usage examples
- Validates RT configuration, queries, and data merging
- Add camelCase to snake_case conversion for protobuf fields
- Fix insertAlerts, insertVehiclePositions, and insertTripUpdates to properly map protobuf field names
- Add conversion helper functions (camelToSnake, convertKeysToSnakeCase)
- Add test-realtime-local-file.ts for testing with downloaded RT feed
- Verify alerts load correctly with French text and all metadata
@chtitux
chtitux merged commit 5cc575d into main Nov 5, 2025
0 of 3 checks passed
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