Skip to content

Commit 47a7d31

Browse files
authored
Merge pull request #25 from FireController1847/1.10.15
Turn On Red (Previously Right On Red)
2 parents 2757da2 + 8a33f75 commit 47a7d31

31 files changed

+705
-368
lines changed

TLM/TLM/Geometry/Impl/SegmentGeometry.cs

+24-7
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,30 @@ public bool IsIncomingStraightSegment(ushort toSegmentId, bool startNode) {
898898
return contains;
899899
}
900900

901-
/// <summary>
902-
/// Determines if, according to the stored geometry data, the managed segment is only connected to highways at the given node.
903-
///
904-
/// A segment geometry verification is not performed.
905-
/// </summary>
906-
/// <returns>true, if, according to the stored geometry data, the managed segment is only connected to highways at the given node, false otherwise</returns>
907-
public bool HasOnlyHighways(bool startNode) {
901+
/// <summary>
902+
/// Determines if, according to the stored geometry data, the segment is eligible for turn-on-red.
903+
///
904+
/// A segment geometry verification is not performed.
905+
/// </summary>
906+
/// <returns>true, if eligible for turn-on-red</returns>
907+
public bool HasValidTurnOnRedOutgoingSegment(SegmentEndGeometry segmentEndGeometry) {
908+
if (Constants.ServiceFactory.SimulationService.LeftHandDrive) {
909+
return (segmentEndGeometry.NumOutgoingLeftSegments > 0 ||
910+
(IsOneWay() && (segmentEndGeometry.NumOutgoingLeftSegments > 0 || segmentEndGeometry.NumOutgoingRightSegments > 0 && segmentEndGeometry.OutgoingOneWay)));
911+
} else {
912+
return (segmentEndGeometry.NumOutgoingRightSegments > 0 ||
913+
(IsOneWay() && (segmentEndGeometry.NumOutgoingLeftSegments > 0 && segmentEndGeometry.OutgoingOneWay || segmentEndGeometry.NumOutgoingRightSegments > 0)));
914+
}
915+
}
916+
917+
918+
/// <summary>
919+
/// Determines if, according to the stored geometry data, the managed segment is only connected to highways at the given node.
920+
///
921+
/// A segment geometry verification is not performed.
922+
/// </summary>
923+
/// <returns>true, if, according to the stored geometry data, the managed segment is only connected to highways at the given node, false otherwise</returns>
924+
public bool HasOnlyHighways(bool startNode) {
908925
SegmentEndGeometry endGeometry = startNode ? startNodeGeometry : endNodeGeometry;
909926
return endGeometry.OnlyHighways;
910927
}

TLM/TLM/Manager/IJunctionRestrictionsManager.cs

+31-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
@@ -14,14 +14,23 @@ public interface IJunctionRestrictionsManager {
1414
/// <returns><code>true</code> if u-turns may be customized, <code>false</code> otherwise</returns>
1515
bool IsUturnAllowedConfigurable(ushort segmentId, bool startNode, ref NetNode node);
1616

17-
/// <summary>
18-
/// Determines if lane changing behavior may be controlled at the given segment end.
17+
/// <summary>
18+
/// Determines if turn-on-red behavior may be controlled at the given segment end.
1919
/// </summary>
2020
/// <param name="segmentId">segment id</param>
2121
/// <param name="startNode">at start node?</param>
2222
/// <param name="node">node data</param>
23-
/// <returns><code>true</code> if lane changing may be customized, <code>false</code> otherwise</returns>
24-
bool IsLaneChangingAllowedWhenGoingStraightConfigurable(ushort segmentId, bool startNode, ref NetNode node);
23+
/// <returns><code>true</code> if turn-on-red may be customized, <code>false</code> otherwise</returns>
24+
bool IsTurnOnRedAllowedConfigurable(ushort segmentId, bool startNode, ref NetNode node);
25+
26+
/// <summary>
27+
/// Determines if lane changing behavior may be controlled at the given segment end.
28+
/// </summary>
29+
/// <param name="segmentId">segment id</param>
30+
/// <param name="startNode">at start node?</param>
31+
/// <param name="node">node data</param>
32+
/// <returns><code>true</code> if lane changing may be customized, <code>false</code> otherwise</returns>
33+
bool IsLaneChangingAllowedWhenGoingStraightConfigurable(ushort segmentId, bool startNode, ref NetNode node);
2534

2635
/// <summary>
2736
/// Determines if entering blocked junctions may be controlled at the given segment end.
@@ -50,14 +59,23 @@ public interface IJunctionRestrictionsManager {
5059
/// <returns><code>true</code> if u-turns are allowed by default, <code>false</code> otherwise</returns>
5160
bool GetDefaultUturnAllowed(ushort segmentId, bool startNode, ref NetNode node);
5261

53-
/// <summary>
54-
/// Determines the default setting for straight lane changes at the given segment end.
55-
/// </summary>
56-
/// <param name="segmentId">segment id</param>
57-
/// <param name="startNode">at start node?</param>
58-
/// <param name="node">node data</param>
59-
/// <returns><code>true</code> if straight lane changes are allowed by default, <code>false</code> otherwise</returns>
60-
bool GetDefaultLaneChangingAllowedWhenGoingStraight(ushort segmentId, bool startNode, ref NetNode node);
62+
/// <summary>
63+
/// Determines the default setting for turn-on-red at the given segment end.
64+
/// </summary>
65+
/// <param name="segmentId">segment id</param>
66+
/// <param name="startNode">at start node?</param>
67+
/// <param name="node">node data</param>
68+
/// <returns><code>true</code> if turn-on-red is allowed by default, <code>false</code> otherwise</returns>
69+
bool GetDefaultTurnOnRedAllowed(ushort segmentId, bool startNode, ref NetNode node);
70+
71+
/// <summary>
72+
/// Determines the default setting for straight lane changes at the given segment end.
73+
/// </summary>
74+
/// <param name="segmentId">segment id</param>
75+
/// <param name="startNode">at start node?</param>
76+
/// <param name="node">node data</param>
77+
/// <returns><code>true</code> if straight lane changes are allowed by default, <code>false</code> otherwise</returns>
78+
bool GetDefaultLaneChangingAllowedWhenGoingStraight(ushort segmentId, bool startNode, ref NetNode node);
6179

6280
/// <summary>
6381
/// Determines the default setting for entering a blocked junction at the given segment end.

0 commit comments

Comments
 (0)