This project is a Windows Forms-based public transport route planning application that visualizes bus and tram stops on an interactive map and calculates optimal routes based on distance, time, and cost. The application uses a graph-based shortest path algorithm over a predefined transport network loaded from a JSON dataset.
The UI is built on GMap.NET, allowing the user to see stops, planned routes, and a direct taxi route on a real map.
-
Interactive map (GMap.NET)
- Displays bus and tram stops on a Google Map.
- Shows two different public transport routes and one direct taxi route.
-
Shortest path calculation
- Graph 1: edges weighted by fare (ucret).
- Graph 2: edges weighted by travel time (sure).
- Uses a Dijkstra-like algorithm to compute the shortest path between stops.
-
Nearest stop detection
- Given:
- Current coordinates (
startLat,startLon) - Target coordinates (
targetLat,targetLon)
- Current coordinates (
- Finds:
- Closest start stop to the user
- Closest target stop to the destination
- Given:
-
Taxi fare calculation
- Taxi parameters (
openingFee,costPerKm) are read fromdataset/bedirhan.json. - Taxi is used:
- From user location to nearest public transport stop (if distance > 3 km).
- Optional direct taxi route from start to target.
- Visualizes the direct taxi route on the map.
- Taxi parameters (
-
Passenger types & discounts
- Student (
Ogrenci): 50% discount - Elderly (
Yasli): 30% discount - General (
Genel): no discount - Passenger type affects the base public transport fare.
- Student (
-
Payment methods
- Cash (
Nakit): no discount, no commission - KentKart: 20% discount
- Credit card (
KrediKarti): +1.5% commission - Final payable amount is computed based on both passenger type and payment method.
- Cash (
-
Terminal-like log panel
- Route details and pricing steps are logged into a
RichTextBoxat the top of the main form.
- Route details and pricing steps are logged into a
- Language: C#
- Framework: .NET (Windows Forms)
- UI: WinForms (
System.Windows.Forms) - Map Library: GMap.NET
- JSON Handling:
System.Text.Json - Core Concepts:
- Object-oriented modeling of vehicles, passengers, payment methods
- Graph data structure for the transport network
- Dijkstra-like shortest path algorithm
-
main.cs- Entry point (
Mainmethod,[STAThread]). - Reads
dataset/bedirhan.jsonusingjsonreader/json. - Creates:
- Bus stops (
Otobus) and tram stops (Tramvay) - Two graphs:
Graph graph(weighted by fare)Graph graph2(weighted by time)
- Bus stops (
- Adds nodes and edges for:
- Buses (
Otobus) based onNextStops - Trams (
Tramvay) based onNextStops
- Buses (
- Starts the main form (
Form1) and, after user enters coordinates, callsyakinDurakBul.EnYakinDuragiBul(...).
- Entry point (
-
Graph.csGraphclass with:AdjacencyList<Arac, List<(Arac, double)>>AddNode,AddEdge(bidirectional)GetShortestPath(start, end)(Dijkstra-like)GetEdgeWeight(from, to)for fare/time summation.
-
NextStop.csNextStopdata model (StopId, distance, time, fare) – conceptual representation of a connection between stops.
-
Models/Arac/Arac.cs- Abstract base class for all vehicles:
id,name,type,lat,lon,sonDurak.
- Abstract base class for all vehicles:
-
Models/Arac/Otobus.csOtobus : Arac- Has
List<string> NextStops(raw next stop info likestopId(distance, time, fare)).
-
Models/Arac/Tramvay.csTramvay : Arac- Has
List<string> NextStops(same concept as forOtobus).
-
Models/Arac/Taksi.csTaksi : Durak, Mesafe, Ucret- Reads taxi configuration from
dataset/bedirhan.json(openingFee,costPerKm). - Calculates distance between coordinates and fee for the taxi ride.
-
Models/Durak.cs- Interfaces:
Durak(stop information)Mesafe(distance calculation)Ucret(fare calculation).
- Interfaces:
-
Models/Yolcu/Yolcu.cs- Abstract
YolcuwithindirimOraniand virtualUcretHesapla(double ucret).
- Abstract
-
Models/Yolcu/Ogrenci.cs,Yasli.cs,Genel.cs- Implement different discount ratios for passenger types.
-
Models/Odeme/Odeme.cs- Abstract base class for payment methods with
indirimOrani,komisyonOraniandHesapla(double toplamMaliyet).
- Abstract base class for payment methods with
-
Models/Odeme/KentKart.cs,KrediKarti.cs,Nakit.cs- Implement payment-specific discount or commission logic.
-
Form1.cs(inHaritaUygulamasinamespace insidemain.cs)- Main visual form:
GMapControlfor map- Textboxes for coordinates input
- Buttons:
Rota Hesapla(Calculate route)Ödeme Yöntemi Seç(Select payment method)Yolcu Türü Seç(Select passenger type)
DrawRoutes(...):- Draws public transport routes (Graph/Graph2) on the map.
- Draws the direct taxi route.
- Computes and logs the final fare based on passenger type & payment method.
- Main visual form:
The project expects a JSON file at:
dataset/bedirhan.jsonExample structure (simplified):
{
"duraklar": [
{
"lat": 40.0,
"lon": 29.0,
"id": "STOP1",
"sonDurak": false,
"type": "Otobus",
"name": "Otogar",
"nextStops": [
{
"stopId": "STOP2",
"mesafe": 2.5,
"sure": 10,
"ucret": 5.0
}
],
"transfer": {
"transferStopId": "TRAM1",
"transferSure": 5,
"transferUcret": 2.0
}
}
],
"taxi": {
"openingFee": 10.0,
"costPerKm": 15.0
}
}> Note: The actual JSON file used in the project (bedirhan.json) must match the properties accessed in main.cs and Taksi.cs.
- Windows OS
- .NET (Windows Forms support) – e.g.:
- .NET Framework with WinForms, or
- .NET 6/7 Windows Desktop (depending on how the project is configured in
UlasimRotaPlanlama.csproj)
- Visual Studio or any IDE that supports WinForms development.
- GMap.NET references must be correctly added to the project:
GMap.NET.CoreGMap.NET.WindowsForms
-
Clone / Copy the project
git clone cd UlasimRotaPlanlama 2. Place the dataset
- Ensure
dataset/bedirhan.jsonexists and follows the expected structure.
- Ensure
-
Open the solution
- Open
UlasimRotaPlanlama.slnin Visual Studio.
- Open
-
Restore NuGet packages
- Right-click on the solution →
Restore NuGet Packages, make sure GMap.NET is installed.
- Right-click on the solution →
-
Build the project
- Build the solution in
DebugorReleasemode.
- Build the solution in
-
Run
- Set
UlasimRotaPlanlamaas startup project (if not already). - Run the application (F5).
- Set
-
Start the application.
-
Inspect the map
- Bus and tram stops are drawn on the map automatically on form load.
-
Enter coordinates
- Fill in:
Mevcut Enlem (lat)Mevcut Boylam (lon)Hedef Enlem (lat)Hedef Boylam (lon)
- Click "Rota Hesapla".
- These coordinates are used to find the nearest start and target stops.
- Fill in:
-
Select passenger type
- Click "Yolcu Türü Seç".
- Choose:
- 1 – Student
- 2 – Elderly
- 3 – General
-
Select payment method
- Click "Ödeme Yöntemi Seç".
- Choose:
- 1 – Cash
- 2 – KentKart (20% discount)
- 3 – Credit Card (+1.5% commission)
-
View results
- Two public transport routes and one taxi route are drawn.
- The terminal area displays:
- Route details (stop names, coordinates)
- Total base fare
- Discounted / adjusted fare based on passenger and payment type
- Direct taxi route fare
- Add validation and error handling for missing/invalid JSON data.
- Allow dynamic loading and editing of stops and routes from the UI.
- Introduce multi-criteria optimization (time vs. cost vs. transfers).
- Support localization (English/UI translations).
- Persist user preferences (default passenger type, default payment method).
This project does not currently specify a license.
If you plan to publish or share it, consider adding a suitable open-source license (MIT, Apache-2.0, etc.).