How aspekts/urban-ev-pathfinding works
Project Type and Purpose
• This is a standalone Python‐based pathfinding engine with a GUI front end. It reads geospatial and tabular datasets, builds a graph representation of an urban road network, applies search algorithms (A*, BFS, UCS) considering traffic and charging station data, and visualizes results via a Tkinter GUI.
• The primary goal is to optimize EV routes in urban environments by modeling congestion, energy usage, and charging stops.
File Structure Analysis
• Top-Level “data/” directory: raw inputs (shapefiles for nodes, links, junctions; CSV for traffic counts and charging stations).
• Root Python modules:
• data_processing.py – loading & cleaning geospatial and CSV data
• graph.py – graph construction logic using NetworkX
• main.py – orchestrates the end-to-end workflow
• test_data.py / dataset_test.py – sample scenarios, unit tests, visualization helpers
• example/ – any sample inputs or usage demos
• Config/dependency file: requirements.txt
• No deployment scripts – runs locally as a Python application.
Key Components
A. Data Ingestion Layer
• Data sources:
• Road network shapefiles (RoadNode, RoadLink, MotorwayJunction)
• Traffic CSV (AADF)
• Charging station CSV (NCR)
• Modules: data_processing.py functions
B. Data Processing & Enrichment
• Shapefile parsers → DataFrames/GeoDataFrames
• Traffic join → congestion metrics
• Charging filter → station metadata
C. Graph Construction
• build_graph() in graph.py
• Directed NetworkX graph with nodes (intersections, chargers) and weighted edges (distance + congestion cost)
D. Pathfinding Engine
• a_star_search(), BFS, UCS implementations
• Heuristic module: geodesic distance + charging proximity
E. Calculation Module
• calculate_total_distance_and_time()
F. Visualization & GUI
• test_and_visualize() for plots via matplotlib
• PathfindingApp (Tkinter) for user input and real‐time rendering
G. Orchestration
• main.py: calls ingestion → graph build → search → visualization
Relationships & Data Flows
• main.py sits at the top of the flow, invoking each stage in sequence.
• Test modules wrap around the graph and search components for validation.
Architectural Patterns & Principles
• Pipeline architecture: distinct phases for ingestion, transformation, analysis, visualization.
• Single Responsibility: each module handles one concern.
• Modularity and extensibility: easy to swap in new algorithms or data sources.
• Layered design: Data Layer → Business Logic (graph & algorithms) → Presentation Layer (GUI/plots).