Skip to content

Replace Historic View with animated CitiBike Trip Playback overlay - #4

Draft
Vaibhav-Hariani with Copilot wants to merge 3 commits into
mainfrom
copilot/remove-historic-mode-add-overlay
Draft

Replace Historic View with animated CitiBike Trip Playback overlay#4
Vaibhav-Hariani with Copilot wants to merge 3 commits into
mainfrom
copilot/remove-historic-mode-add-overlay

Conversation

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown

Removes the Historic View mode entirely and replaces it with a Trip Playback mode that streams real CitiBike trip data as animated Google Maps overlays — always keeping 10 trips active simultaneously.

Data layer (frontend/trip_data.py — new)

  • Dynamically builds month list from Jan 2024 → today; downloads s3.amazonaws.com/tripdata/YYYYMM-citibike-tripdata.csv.zip on demand
  • Caches extracted trips locally as gzip CSVs in processed_data/trips/ (gitignored); skips already-cached months
  • Samples up to 5 000 trips/month, filters to valid durations (1 min–3 hr), returns a started_at-sorted DataFrame

App changes (frontend/app.py)

  • Removed: fetch_timestamps, fetch_artifact, add_historic_view_stations, and all Historic View sidebar/map logic
  • Added: three cached helpers:
    • load_playback_trips() — wraps load_trips with Streamlit cache
    • get_trip_route(slat, slng, elat, elng) — single Google Maps Directions (bicycling) call, cached; coordinates rounded to 4 d.p. (~11 m) to maximise cache hits across trips sharing a station; falls back to straight line on API failure
    • compute_trip_routes(trips_df) — batch-computes routes for the preloaded slice
  • Added: render_trip_playback() — injects a self-contained Google Maps JS animation via st.components.v1.html():
    • Starts 10 trips at t=0; simulation clock advances at speed × real time
    • Spotlight fade: ±15% window around the current dot is bright (opacity 0.9); far-past fades to 0.08; far-future shows faintly at 0.2
    • On trip end, replacement starts within a random [0, 10] simulated-second window to avoid burst restarts
    • HUD overlay shows active count, trip index, and current speed multiplier
  • Sidebar: playback speed slider (1–200×), trips-to-preload slider (20–200), Start/Stop buttons
Original prompt

We need a whole new featureset. I want to completely remove the historic mode altogether. Instead, I want to use existing citibike's historic trip data to create some interesting overlays. https://s3.amazonaws.com/tripdata/index.html

First, download all citibike data from 2024 to latest, dynamically. Then, when users click playback, I want to select 10 trips, grab the google maps fastest path between them, and render them at a given playback speed. When a trip ends, select a random trip that starts (within a ~ 10 second interval of this one ending). This way, we'll always have 10 trips rendered. Trip rendering should use the google maps API to find a path between the stations specified, and then render the trip over time, fading out nodes that should have been passed and fading in new ones.

Created from VS Code.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 26, 2026 16:21
…tiBike data download

Co-authored-by: Vaibhav-Hariani <62775035+Vaibhav-Hariani@users.noreply.github.com>
Co-authored-by: Vaibhav-Hariani <62775035+Vaibhav-Hariani@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove historic mode and add trip overlay feature Replace Historic View with animated CitiBike Trip Playback overlay Feb 26, 2026
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