@@ -737,9 +737,11 @@ def image_to_base64(image_path):
737737 🟡 DELAYS DETECTED
738738 </div>
739739 <div style="color: #ffcc88; font-size: 0.85em; margin-top: 8px;">
740- {% if detection.delays_segments %}{{ detection.delays_segments|length }} track section(s) disabled{% endif %}
741- {% if detection.delays_segments and detection.delays_platforms|length >= 2 %}, {% endif %}
742- {% if detection.delays_platforms|length >= 2 %}{{ detection.delays_platforms|length }} platforms in hold{% endif %}
740+ {% set reasons = [] %}
741+ {% if detection.delays_segments %}{% set _ = reasons.append(detection.delays_segments|length ~ ' track section(s) disabled') %}{% endif %}
742+ {% if detection.delays_platforms|length >= 2 %}{% set _ = reasons.append(detection.delays_platforms|length ~ ' platforms in hold') %}{% endif %}
743+ {% if detection.delays_bunching %}{% set _ = reasons.append('train bunching detected') %}{% endif %}
744+ {{ reasons|join(', ') }}
743745 </div>
744746 {% else %}
745747 <div style="background: #208020; color: white; padding: 15px; border-radius: 8px; font-size: 1.3em; font-weight: bold;">
@@ -756,7 +758,7 @@ def image_to_base64(image_path):
756758 <div class="info-section">
757759 <h3>Delays Detected</h3>
758760 <div id="delaysInfo">
759- {% if detection.delays_segments or detection.delays_platforms %}
761+ {% if detection.delays_segments or detection.delays_platforms or detection.delays_bunching %}
760762 {% for d in detection.delays_segments %}
761763 <div class="delay-item delay-red" onclick="showSegment('{{ d.key }}')">
762764 Track Off: {{ d.from }} → {{ d.to }} ({{ d.direction }})
@@ -767,6 +769,11 @@ def image_to_base64(image_path):
767769 Hold: {{ d.name }} ({{ d.direction }})
768770 </div>
769771 {% endfor %}
772+ {% for b in detection.delays_bunching %}
773+ <div class="delay-item delay-yellow" onclick="showBunching('{{ b.station }}', '{{ b.direction }}', {{ b.train_count }})">
774+ Bunching: {{ b.train_count }} trains at {{ b.station }} ({{ b.direction }})
775+ </div>
776+ {% endfor %}
770777 {% else %}
771778 <div class="no-delays">No delays detected</div>
772779 {% endif %}
@@ -985,6 +992,18 @@ def image_to_base64(image_path):
985992 }
986993 }
987994
995+ function showBunching(station, direction, trainCount) {
996+ const stationData = detection.stations.find(s => s.code === station);
997+ const stationName = stationData ? stationData.name : station;
998+ document.getElementById('clickInfo').innerHTML = `
999+ <strong>Train Bunching</strong><br>
1000+ Station: ${stationName} (${station})<br>
1001+ Direction: ${direction}<br>
1002+ Trains bunched: <span style="color:#ffcc00">${trainCount}</span><br>
1003+ <span style="color:#888;font-size:0.85em">Multiple trains queued close together, indicating delays</span>
1004+ `;
1005+ }
1006+
9881007 function showTrain(id, x, y, track, confidence) {
9891008 // Parse train ID: route letter + 4-digit number + suffix
9901009 let content = `<strong>Train: ${id}</strong><br>`;
0 commit comments