Back to Projects

Vehicle Traffic Management and Analysis

Semester Project, rebuilt in 2026 2019
PythonFlaskJavaScriptLeaflet / OpenStreetMappytestGitHub ActionsPTV VissimData Collection

Fixed-timing traffic lights at busy Kathmandu Valley intersections cause delays, deadlocks and higher fuel consumption. The original project collected traffic counts and tested timing in PTV Vissim. The rebuild turns those counts into signal plans that run, are visible on a dashboard and can be checked by tests.

// Overview

Webster's method sets each junction's green split by hour and weekday from the 2020 traffic counts, and all three junctions share one cycle, with offsets based on travel time at 30 km/h. A junction's state is calculated from the clock, so there are no background threads or shared variables: every server process gives the same answer and tests can check any moment with a fake clock. Cycle lengths divide 3600 s, so a change of plan never cuts a phase short.

// Gallery

// Features

Home overview and live maps

Every junction on one screen, each with a camera, a live OpenStreetMap view (movements coloured by phase, signal poles T1-T3), the phase countdown and a cycle bar. Movement routes are traced along OpenStreetMap's one-way carriageways.

Home page showing three junction cards with camera, map and countdown
Junction page and charts

A larger map and camera, the signal table, and charts for the day's cycle length, green split and load, next to the 2020 traffic counts. A clear warning appears if the connection drops.

Junction page with map, camera and signal tableCharts of cycle length, green split and load
Safe override, accounts and hardware feed

An admin can end a green early, but yellow and all-red always run in full, the junction stays in sync and every press is recorded in an admin activity log with the time, junction, user and result (including refused presses). View-only and admin roles, password reset links and an admin page manage access. A token-protected endpoint serves the fixed-width message the signal controller reads.

Admin activity log listing every press of Next with time, junction, user and result
Camera relay

Each junction can relay a real IP camera (for example a phone running an IP-camera app) or show a simulated CCTV view.

Easy to extend: add a junction

A new junction needs no Python changes. Copy a commented YAML file in config/junctions, fill in its traffic counts, signal poles and traced routes, and list it in settings.yaml. The Home page, junction page, charts and corridor timing offsets then include it, and a step-by-step guide covers the process.

Original data collection and simulation

Videos of traffic flow were processed to find vehicle density and stoppage times, and timing sequences were tested in PTV Vissim.