A high-performance C++ simulation built with Qt 6 that parses OpenStreetMap (OSM) data to simulate an urban environment where connected vehicles interact in real-time.
| City Infrastructure | Connected Vehicle Logic |
|---|---|
![]() |
![]() |
| Rendering of OSM ways and nodes | V2V connection via frequency proximity |
The core challenge of this project was rendering complex geographic data while maintaining a high frame rate for car movements.
Initially, I used a standard QWidget and overloaded the paintEvent. This proved inefficient because any movement required a full screen refresh, causing significant lag even with small .osm files.
Parsing large XML files on every launch was slow. I implemented a Database-First approach:
- Parsing:
.osmfiles (Nodes, Ways, Tags) are parsed once and stored in a MySQL database. - Retrieval: The app queries
QSqltables for faster data access during rendering.
To optimize the UI, I migrated to the QGraphicsView and QGraphicsScene framework. Unlike the paint event, this framework only redraws modified elements (the moving cars), leaving the static city map cached in the background.
To display an entire city without freezing the UI, I utilized Qt Concurrency. Roads (Ways) are drawn independently in parallel, using QApplication::processEvents() to keep the interface responsive during the initial load.
- V2V Connectivity: Each car is assigned a random frequency. A visual circle represents the signal range; when two cars' circles overlap, they are marked as "Connected."
- Geospatial Mapping: A
BoundsCalculatortranslates real-world Latitude and Longitude into optimized screen coordinates. - Network Grids: A hexagonal grid system (
Maille) is overlaid to represent network coverage areas. - Traffic Logic: Cars follow specific road "Ways" and respect speed limit tags extracted from the OSM data.
| Class | Description |
|---|---|
ConfigManager |
Manages screen scaling and window dimensions. |
Car |
Logic for movement, speed limits, and connectivity range. |
DatabaseManager |
Handles MySQL connections and initial OSM XML parsing. |
CustomScene/View |
Custom rendering engine for the optimized GraphicsView. |
BoundsCalculator |
Normalizes GPS coordinates to local pixel coordinates. |
Maille |
Generates the hexagonal network grid logic. |
Node / Way |
Object representations of OpenStreetMap elements. |
- Qt 6 (Core, Sql, Gui, Widgets)
- MySQL Server
- CMake 3.28+
mkdir build && cd build
cmake ..
make
./GraphicsInQt

