@@ -30,6 +30,8 @@ import kotlin.math.min
30
30
* @param addRollingStockLength whether the rolling stock length should be taken into account in the
31
31
* computation.
32
32
* @param trainTag corresponding train.
33
+ * @param useInfraSpeedLimits whether the speed limits coming from the infrastructure should be
34
+ * taken into account in the computation
33
35
* @return the corresponding MRSP as an Envelope.
34
36
*/
35
37
fun computeMRSP (
@@ -39,7 +41,7 @@ fun computeMRSP(
39
41
trainTag : String? ,
40
42
temporarySpeedLimitManager : TemporarySpeedLimitManager ? ,
41
43
safetySpeedRanges : DistanceRangeMap <Speed >? = null,
42
- ignoreInfraSpeedLimits : Boolean = false ,
44
+ useInfraSpeedLimits : Boolean = true ,
43
45
): Envelope {
44
46
return computeMRSP(
45
47
path,
@@ -49,7 +51,7 @@ fun computeMRSP(
49
51
trainTag,
50
52
temporarySpeedLimitManager,
51
53
safetySpeedRanges,
52
- ignoreInfraSpeedLimits ,
54
+ useInfraSpeedLimits ,
53
55
)
54
56
}
55
57
@@ -61,11 +63,11 @@ fun computeMRSP(
61
63
* @param rsLength length of the rolling stock (m)
62
64
* @param addRollingStockLength whether the rolling stock length should be taken into account in the
63
65
* computation.
64
- * @param ignoreInfraSpeedLimits whether the speed limits coming from the infrastructure should be ignored in the
65
- * computaion
66
66
* @param trainTag corresponding train.
67
67
* @param safetySpeedRanges Extra speed ranges, used for safety speeds. Note: rolling stock length
68
68
* is *not* added at the end of these ranges.
69
+ * @param useInfraSpeedLimits whether the speed limits coming from the infrastructure should be
70
+ * taken into account in the computation
69
71
* @return the corresponding MRSP as an Envelope.
70
72
*/
71
73
fun computeMRSP (
@@ -76,39 +78,39 @@ fun computeMRSP(
76
78
trainTag : String? ,
77
79
temporarySpeedLimitManager : TemporarySpeedLimitManager ? ,
78
80
safetySpeedRanges : DistanceRangeMap <Speed >? = null,
79
- ignoreInfraSpeedLimits : Boolean = false ,
81
+ useInfraSpeedLimits : Boolean = true ,
80
82
): Envelope {
81
83
val builder = MRSPEnvelopeBuilder ()
82
84
val pathLength = toMeters(path.getLength())
83
85
84
86
val offset = if (addRollingStockLength) rsLength else 0.0
85
- val speedLimitProperties = path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
86
- if ( ! ignoreInfraSpeedLimits) { // if we take into account speedlimits coming from the infrastructure
87
- for (speedLimitPropertyRange in speedLimitProperties) {
88
- // Compute where this limit is active from and to
89
- val start = toMeters(speedLimitPropertyRange.lower)
90
- val end = min(pathLength, offset + toMeters(speedLimitPropertyRange.upper) )
91
- val speedLimitProp = rangeMapEntryToSpeedLimitProperty (speedLimitPropertyRange)
92
- val speed = toMetersPerSecond(speedLimitProp.speed )
93
- val attrs =
94
- mutableListOf< SelfTypeHolder ?>(
95
- EnvelopeProfile . CONSTANT_SPEED ,
96
- MRSPEnvelopeBuilder . LimitKind . SPEED_LIMIT
97
- )
98
- if (speedLimitProp.source != null ) {
99
- attrs.add (speedLimitProp.source)
100
- }
101
- if (attrs.any { it is UnknownTag }) attrs.add( HasMissingSpeedTag )
102
- if (speed != 0.0 ) {
103
- // Add the envelope part corresponding to the restricted speed section
104
- builder.addPart(
105
- EnvelopePart .generateTimes (
106
- attrs,
107
- doubleArrayOf(start, end) ,
108
- doubleArrayOf(speed, speed)
109
- )
87
+ val speedLimitProperties =
88
+ if (useInfraSpeedLimits) path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
89
+ else distanceRangeMapOf< SpeedLimitProperty >()
90
+ for (speedLimitPropertyRange in speedLimitProperties) {
91
+ // Compute where this limit is active from and to
92
+ val start = toMeters(speedLimitPropertyRange.lower )
93
+ val end = min(pathLength, offset + toMeters (speedLimitPropertyRange.upper) )
94
+ val speedLimitProp = rangeMapEntryToSpeedLimitProperty(speedLimitPropertyRange )
95
+ val speed = toMetersPerSecond(speedLimitProp.speed)
96
+ val attrs =
97
+ mutableListOf< SelfTypeHolder ?>(
98
+ EnvelopeProfile . CONSTANT_SPEED ,
99
+ MRSPEnvelopeBuilder . LimitKind . SPEED_LIMIT
100
+ )
101
+ if (speedLimitProp.source != null ) {
102
+ attrs.add(speedLimitProp.source)
103
+ }
104
+ if (attrs.any { it is UnknownTag }) attrs.add( HasMissingSpeedTag )
105
+ if (speed != 0.0 ) {
106
+ // Add the envelope part corresponding to the restricted speed section
107
+ builder.addPart (
108
+ EnvelopePart .generateTimes(
109
+ attrs ,
110
+ doubleArrayOf(start, end),
111
+ doubleArrayOf(speed, speed )
110
112
)
111
- }
113
+ )
112
114
}
113
115
}
114
116
@@ -124,7 +126,7 @@ fun computeMRSP(
124
126
)
125
127
126
128
// Add safety speeds
127
- if (! ignoreInfraSpeedLimits && safetySpeedRanges != null ) {
129
+ if (useInfraSpeedLimits && safetySpeedRanges != null ) {
128
130
for (range in safetySpeedRanges) {
129
131
val speed = range.value
130
132
val newAttrs =
0 commit comments