This system demonstrates real-time spatial data visualization using two main applications sharing a database.
flowchart LR
RoverSim["🤖 RoverSimulator<br/>Console App"]
DB[("💾 Database<br/>PostgreSQL/GeoPackage")]
Frontend["🌐 FrontendLeaflet<br/>Blazor Server"]
Browser["🖥️ Browser<br/>Leaflet Map"]
RoverSim -->|"Writes rover data<br/>(every 1s)"| DB
DB -->|"Reads rover data<br/>(every 8s)"| Frontend
Frontend -.->|"SignalR WebSocket"| Browser
style RoverSim fill:#ff9999,color:#000000
style DB fill:#ffcc99,color:#000000,stroke:#333
style Frontend fill:#99ccff,color:#000000
style Browser fill:#cc99ff,color:#000000
RoverSimulator generates simulated rover data (position, wind measurements) and writes to the database every second.
FrontendLeaflet is a Blazor Server application that polls the database every 8 seconds, calculates coverage polygons, and displays everything in real-time on an interactive map.
Database can be either PostgreSQL/PostGIS (production) or GeoPackage files (local development).
This diagram shows how data flows from the database to the browser through the Blazor Server application:
sequenceDiagram
participant DB
participant Repo
participant Blazor
participant SignalR
participant Browser
Note over DB,Browser: Every 8 seconds
Blazor->>Repo: GetNewSinceSequenceAsync()
Repo->>DB: SQL Query
DB-->>Repo: New measurements
Repo-->>Blazor: RoverMeasurement[]
Blazor->>Blazor: Calculate polygons
Blazor->>Blazor: StateHasChanged()
Blazor->>SignalR: DOM diff
SignalR->>Browser: WebSocket push
Browser->>Browser: Update UI
The Blazor Server component polls the database every 8 seconds for new measurements, calculates coverage polygons, and pushes updates to the browser via SignalR WebSocket.
This diagram shows how the Leaflet map is updated through JavaScript interop:
sequenceDiagram
participant Repo
participant Blazor
participant SignalR
participant Browser
participant Leaflet
Note over Repo,Leaflet: Initial Load
Blazor->>SignalR: initMap() call
SignalR->>Browser: WebSocket
Browser->>Leaflet: L.map()
Leaflet-->>Browser: Map ready
Note over Repo,Leaflet: Every 8s: Update
Blazor->>Repo: GetNewSinceSequenceAsync()
Repo-->>Blazor: New measurements
loop Each rover
Blazor->>SignalR: appendRoverTrail(coords)
SignalR->>Browser: WebSocket
Browser->>Leaflet: Update polyline
Blazor->>SignalR: updateRoverPosition(lat,lon)
SignalR->>Browser: WebSocket
Browser->>Leaflet: Update marker
end
Blazor->>SignalR: updateCoverageGeoJson()
SignalR->>Browser: WebSocket
Browser->>Leaflet: Render polygon
Blazor Server uses JavaScript interop to control the Leaflet map. Map initialization and all updates are sent through SignalR WebSocket to the browser where Leaflet renders the visualization.
Generates simulated rover data with position and wind measurements. Supports multiple rovers and sessions. Writes measurements to database every second using IRoverDataRepository.
Configuration: Session name, rover ID, and rover name via command-line arguments or appsettings.json.
Stores rover measurements with spatial data. Supports session isolation where multiple rovers can share the same session.
- PostgreSQL: Production database with
rover_sessionsandrover_pointstables - GeoPackage: File-based SQLite spatial database for local development
Unified interface with two implementations:
PostgresRoverDataRepository- PostgreSQL/PostGIS access via NpgsqlGeoPackageRoverDataRepository- GeoPackage file access
Key methods: InitializeAsync(), InsertAsync(), GetAllAsync(), GetNewSinceSequenceAsync()
Calculates coverage polygons from rover measurements and wind data. Uses IMemoryCache with 1-second TTL to optimize performance.
Key methods: GetUnifiedPolygonAsync(), GetRoverUnifiedPolygonsAsync(), GetForestIntersectionAreasAsync()
Web application that visualizes rover data on an interactive Leaflet map. Polls database every 8 seconds and pushes updates to the browser via SignalR WebSocket.
Main components:
Index.razor- Main page with polling timer and data managementScentMap.razor- Leaflet map with JavaScript interop for visualizationForestCoveragePie.razor- Statistics display
- RoverSimulator writes measurements to database (every 1s per rover)
- FrontendLeaflet polls for new data using
GetNewSinceSequenceAsync()(every 8s) - ScentPolygonGenerator calculates coverage polygons with memory caching (1s TTL)
- SignalR pushes UI updates to browser via WebSocket
- Leaflet renders the visualization in the browser
- Blazor Server: Server-side rendering with direct dependency injection access to repositories (no REST API)
- Session-aware: All components filter data per session using
ISessionContext - Multiple rovers: Each rover has unique ID, name, and visual identity on the map
- Database agnostic: Supports both PostgreSQL and GeoPackage through unified repository interface
- On-demand processing: Polygon generation happens only on request, not as a background service