Skip to content

Commit 2a4cb8e

Browse files
committed
core: remove TravelledPath type alias
Signed-off-by: Eloi Charpentier <[email protected]>
1 parent 2ac5d52 commit 2a4cb8e

File tree

29 files changed

+129
-155
lines changed

29 files changed

+129
-155
lines changed

core/envelope-sim/src/main/kotlin/fr/sncf/osrd/envelope_sim/EnvelopeSimContext.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package fr.sncf.osrd.envelope_sim
22

33
import com.google.common.collect.RangeMap
44
import fr.sncf.osrd.path.interfaces.PhysicsPath
5-
import fr.sncf.osrd.path.interfaces.TravelledPath
5+
import fr.sncf.osrd.path.interfaces.TrainPath
66
import fr.sncf.osrd.utils.DistanceRangeSet
77
import fr.sncf.osrd.utils.units.Offset
88
import fr.sncf.osrd.utils.units.meters
@@ -29,18 +29,18 @@ constructor(
2929
* List of switch and buffer stop offsets on the path, up to the first switch/buffer stop
3030
* *after* the end of the path (or right at the end).
3131
*/
32-
val dangerPointOffsets: List<Offset<TravelledPath>>,
32+
val dangerPointOffsets: List<Offset<TrainPath>>,
3333
/**
3434
* List of block-delimiting detectors (block entry/exit) offsets for every ETCS-block on the
3535
* path. Starts at the start of the path, can end after the end of the path.
3636
*/
37-
val detectorOffsets: List<Offset<TravelledPath>>,
37+
val detectorOffsets: List<Offset<TrainPath>>,
3838
) {
3939
/**
4040
* Returns the next danger point location: next buffer stop or switch, whichever is closest.
4141
* If there is any.
4242
*/
43-
private fun getDangerPoint(offset: Offset<TravelledPath>): Offset<TravelledPath>? {
43+
private fun getDangerPoint(offset: Offset<TrainPath>): Offset<TrainPath>? {
4444
return dangerPointOffsets.firstOrNull { it >= offset }
4545
}
4646

@@ -51,14 +51,14 @@ constructor(
5151
* infrastructure, hence we'll be conservative and place the danger point on the EoA (stop
5252
* location or signal).
5353
*/
54-
fun getMandatoryDangerPoint(signalOffset: Offset<TravelledPath>): Offset<TravelledPath> {
54+
fun getMandatoryDangerPoint(signalOffset: Offset<TrainPath>): Offset<TrainPath> {
5555
val dangerPoint = getDangerPoint(signalOffset)
5656
return if (dangerPoint == null || dangerPoint - signalOffset > 200.meters) signalOffset
5757
else dangerPoint
5858
}
5959

6060
/** Returns the next ETCS detector location. */
61-
fun getNextDetector(offset: Offset<TravelledPath>): Offset<TravelledPath>? {
61+
fun getNextDetector(offset: Offset<TrainPath>): Offset<TrainPath>? {
6262
return detectorOffsets.firstOrNull { it >= offset }
6363
}
6464
}

core/envelope-sim/src/main/kotlin/fr/sncf/osrd/envelope_sim/etcs/ETCSBrakingSimulator.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fr.sncf.osrd.envelope_sim.EnvelopeSimContext
77
import fr.sncf.osrd.envelope_sim.etcs.BrakingType.IND
88
import fr.sncf.osrd.envelope_sim.etcs.BrakingType.PS
99
import fr.sncf.osrd.envelope_sim.pipelines.increase
10-
import fr.sncf.osrd.path.interfaces.TravelledPath
10+
import fr.sncf.osrd.path.interfaces.TrainPath
1111
import fr.sncf.osrd.reporting.exceptions.OSRDError
1212
import fr.sncf.osrd.utils.arePositionsEqual
1313
import fr.sncf.osrd.utils.units.Offset
@@ -71,7 +71,7 @@ interface ETCSBrakingSimulator {
7171
*/
7272
fun computeEoaLocations(
7373
envelope: Envelope,
74-
offsets: List<Offset<TravelledPath>>,
74+
offsets: List<Offset<TrainPath>>,
7575
areSignalsOnOffsetsRestrictive: List<Boolean>,
7676
eoaType: EoaType,
7777
): List<EndOfAuthority>
@@ -85,7 +85,7 @@ typealias EOABrakingCurves = NavigableMap<EndOfAuthority, BrakingCurves>
8585

8686
data class BrakingCurve(val brakingType: BrakingType, val brakingCurve: Envelope)
8787

88-
data class LimitOfAuthority(val offset: Offset<TravelledPath>, val speed: Double) :
88+
data class LimitOfAuthority(val offset: Offset<TrainPath>, val speed: Double) :
8989
Comparable<LimitOfAuthority> {
9090
init {
9191
assert(speed > 0)
@@ -98,8 +98,8 @@ data class LimitOfAuthority(val offset: Offset<TravelledPath>, val speed: Double
9898
}
9999

100100
data class EndOfAuthority(
101-
val offsetEOA: Offset<TravelledPath>,
102-
val offsetSVL: Offset<TravelledPath>?,
101+
val offsetEOA: Offset<TrainPath>,
102+
val offsetSVL: Offset<TrainPath>?,
103103
val usedCurveType: BrakingType,
104104
val eoaType: EoaType = EoaType.STOP,
105105
) : Comparable<EndOfAuthority> {
@@ -211,7 +211,7 @@ class ETCSBrakingSimulatorImpl(override val context: EnvelopeSimContext) : ETCSB
211211
val cursor = EnvelopeCursor.backward(mrsp)
212212
val limitsOfAuthority = mutableListOf<LimitOfAuthority>()
213213
while (cursor.findPartTransition(::increase)) {
214-
val offset = Offset<TravelledPath>(cursor.position.meters)
214+
val offset = Offset<TrainPath>(cursor.position.meters)
215215
if (etcsRanges.contains(offset.distance)) {
216216
limitsOfAuthority.add(LimitOfAuthority(offset, cursor.speed))
217217
}
@@ -222,7 +222,7 @@ class ETCSBrakingSimulatorImpl(override val context: EnvelopeSimContext) : ETCSB
222222

223223
override fun computeEoaLocations(
224224
envelope: Envelope,
225-
offsets: List<Offset<TravelledPath>>,
225+
offsets: List<Offset<TrainPath>>,
226226
areSignalsOnOffsetsRestrictive: List<Boolean>,
227227
eoaType: EoaType,
228228
): List<EndOfAuthority> {
@@ -267,7 +267,7 @@ class ETCSBrakingSimulatorImpl(override val context: EnvelopeSimContext) : ETCSB
267267

268268
/** Compute the EoA for a simple stop. */
269269
private fun computeStopEoA(
270-
stopOffset: Offset<TravelledPath>,
270+
stopOffset: Offset<TrainPath>,
271271
isStopOnClosedSignal: Boolean,
272272
): EndOfAuthority {
273273
return if (isStopOnClosedSignal) {
@@ -291,7 +291,7 @@ class ETCSBrakingSimulatorImpl(override val context: EnvelopeSimContext) : ETCSB
291291

292292
/** Compute the EoA for a spacing conflict on a signal. */
293293
private fun computeSpacingConflictEoa(
294-
signalOffset: Offset<TravelledPath>,
294+
signalOffset: Offset<TrainPath>,
295295
isRouteDelimiter: Boolean,
296296
endPos: Double,
297297
): EndOfAuthority? {
@@ -322,7 +322,7 @@ class ETCSBrakingSimulatorImpl(override val context: EnvelopeSimContext) : ETCSB
322322

323323
/** Compute the EoA for a routing conflict on a signal. */
324324
private fun computeRoutingConflictEoa(
325-
signalOffset: Offset<TravelledPath>,
325+
signalOffset: Offset<TrainPath>,
326326
isRouteDelimiter: Boolean,
327327
): EndOfAuthority? {
328328
return if (isRouteDelimiter) {

core/envelope-sim/src/main/kotlin/fr/sncf/osrd/envelope_sim/pipelines/MaxSpeedEnvelope.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import fr.sncf.osrd.envelope_sim.etcs.ETCSBrakingSimulatorImpl
1515
import fr.sncf.osrd.envelope_sim.etcs.EndOfAuthority
1616
import fr.sncf.osrd.envelope_sim.etcs.EoaType
1717
import fr.sncf.osrd.envelope_sim.overlays.EnvelopeDeceleration
18-
import fr.sncf.osrd.path.interfaces.TravelledPath
18+
import fr.sncf.osrd.path.interfaces.TrainPath
1919
import fr.sncf.osrd.railjson.schema.schedule.RJSTrainStop
2020
import fr.sncf.osrd.utils.units.Distance
2121
import fr.sncf.osrd.utils.units.Offset
@@ -30,7 +30,7 @@ import fr.sncf.osrd.utils.units.Offset
3030
* closed/open signal flag.
3131
*/
3232
data class SimStop(
33-
val offset: Offset<TravelledPath>,
33+
val offset: Offset<TrainPath>,
3434
val rjsReceptionSignal: RJSTrainStop.RJSReceptionSignal,
3535
)
3636

@@ -130,7 +130,7 @@ private fun addStopBrakingCurves(
130130
private fun addConstStopBrakingCurves(
131131
context: EnvelopeSimContext,
132132
curveWithDecelerations: Envelope,
133-
stops: List<Offset<TravelledPath>>,
133+
stops: List<Offset<TrainPath>>,
134134
): Envelope {
135135
var envelope = curveWithDecelerations
136136
for (stop in stops) {

core/kt-osrd-path/src/main/kotlin/fr/sncf/osrd/path/interfaces/PathProperties.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ import fr.sncf.osrd.utils.units.Offset
99

1010
data class TrackLocation(val trackId: TrackSectionId, val offset: Offset<TrackSection>)
1111

12-
/**
13-
* A marker type for Length and Offset. In TravelledPath, start refers to the real start of the head
14-
* of the train.
15-
*/
16-
// TODO path migration: remove TravelledPath entirely
17-
typealias TravelledPath = TrainPath
18-
1912
@Suppress("INAPPLICABLE_JVM_NAME")
2013
interface PathProperties {
2114
fun getSlopes(): DistanceRangeMap<Double>
@@ -43,7 +36,7 @@ interface PathProperties {
4336

4437
fun getLength(): Length<TrainPath>
4538

46-
fun getTrackLocationAtOffset(pathOffset: Offset<TravelledPath>): TrackLocation
39+
fun getTrackLocationAtOffset(pathOffset: Offset<TrainPath>): TrackLocation
4740

4841
fun <T> getRangeMapFromUndirected(
4942
getData: (chunkId: TrackChunkId) -> DistanceRangeMap<T>

core/src/main/kotlin/fr/sncf/osrd/api/CommonSchemas.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package fr.sncf.osrd.api
22

33
import com.squareup.moshi.Json
4-
import fr.sncf.osrd.path.interfaces.TravelledPath
4+
import fr.sncf.osrd.path.interfaces.TrainPath
55
import fr.sncf.osrd.railjson.schema.common.graph.EdgeDirection
66
import fr.sncf.osrd.sim_infra.api.TrackSection
77
import fr.sncf.osrd.utils.DistanceRangeMap
@@ -25,13 +25,13 @@ data class TrackRange(
2525
data class RangeValues<valueT>(
2626
// List of `n` internal boundaries of the ranges along the path (excluding start and end
2727
// bounds).
28-
@Json(name = "boundaries") val internalBoundaries: List<Offset<TravelledPath>> = listOf(),
28+
@Json(name = "boundaries") val internalBoundaries: List<Offset<TrainPath>> = listOf(),
2929
// List of `n+1` values associated to the bounded intervals
3030
val values: List<valueT> = listOf(),
3131
) {
3232
fun toDistanceRangeMap(
33-
beginPos: Offset<TravelledPath>,
34-
endPos: Offset<TravelledPath>,
33+
beginPos: Offset<TrainPath>,
34+
endPos: Offset<TrainPath>,
3535
): DistanceRangeMap<valueT> {
3636
val boundaries = internalBoundaries.toMutableList()
3737
boundaries.add(0, beginPos)
@@ -58,14 +58,14 @@ class TrackLocation(val track: String, val offset: Offset<TrackSection>)
5858
class ZoneUpdate(
5959
val zone: String,
6060
val time: TimeDelta,
61-
val position: Offset<TravelledPath>,
61+
val position: Offset<TrainPath>,
6262
@Json(name = "is_entry") val isEntry: Boolean,
6363
)
6464

6565
class SignalCriticalPosition(
6666
val signal: String,
6767
val time: TimeDelta,
68-
val position: Offset<TravelledPath>,
68+
val position: Offset<TrainPath>,
6969
val state: String,
7070
)
7171

core/src/main/kotlin/fr/sncf/osrd/api/etcs/ETCSBrakingCurvesEndpoint.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import fr.sncf.osrd.envelope_sim.EnvelopeProfile
1515
import fr.sncf.osrd.envelope_sim.EnvelopeSimContext
1616
import fr.sncf.osrd.envelope_sim.etcs.*
1717
import fr.sncf.osrd.path.interfaces.TrainPath
18-
import fr.sncf.osrd.path.interfaces.TravelledPath
1918
import fr.sncf.osrd.signaling.etcs_level2.ETCS_LEVEL2
2019
import fr.sncf.osrd.sim_infra.api.*
2120
import fr.sncf.osrd.standalone_sim.buildSignalingRanges
@@ -139,7 +138,7 @@ class ETCSBrakingCurvesEndpoint(
139138
}
140139

141140
private data class TravelledPathSignal(
142-
val offset: Offset<TravelledPath>,
141+
val offset: Offset<TrainPath>,
143142
val isRouteDelimiter: Boolean,
144143
) : Comparable<TravelledPathSignal> {
145144
override fun compareTo(other: TravelledPathSignal): Int {
@@ -176,8 +175,8 @@ class ETCSBrakingCurvesEndpoint(
176175

177176
private fun parseRawMrsp(
178177
rawMrsp: RangeValues<SpeedLimitProperty>,
179-
endPos: Offset<TravelledPath>,
180-
beginPos: Offset<TravelledPath> = Offset(Distance.ZERO),
178+
endPos: Offset<TrainPath>,
179+
beginPos: Offset<TrainPath> = Offset(Distance.ZERO),
181180
): Envelope {
182181
val speedLimitDistanceRangeMap = rawMrsp.toDistanceRangeMap(beginPos, endPos)
183182
val mrspParts = mutableListOf<EnvelopePart>()

core/src/main/kotlin/fr/sncf/osrd/api/etcs/ETCSBrakingCurvesResponse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.squareup.moshi.JsonAdapter
55
import com.squareup.moshi.Moshi
66
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
77
import fr.sncf.osrd.conflicts.ConflictType
8-
import fr.sncf.osrd.path.interfaces.TravelledPath
8+
import fr.sncf.osrd.path.interfaces.TrainPath
99
import fr.sncf.osrd.utils.json.UnitAdapterFactory
1010
import fr.sncf.osrd.utils.units.Offset
1111
import fr.sncf.osrd.utils.units.TimeDelta
@@ -30,7 +30,7 @@ data class ETCSConflictCurves(
3030
)
3131

3232
data class SimpleEnvelope(
33-
val positions: List<Offset<TravelledPath>>,
33+
val positions: List<Offset<TrainPath>>,
3434
val times: List<TimeDelta>, // Times are compared to the departure time
3535
val speeds: List<Double>,
3636
)

core/src/main/kotlin/fr/sncf/osrd/api/path_properties/PathPropResponse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.squareup.moshi.Moshi
66
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
77
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
88
import fr.sncf.osrd.api.RangeValues
9-
import fr.sncf.osrd.path.interfaces.TravelledPath
9+
import fr.sncf.osrd.path.interfaces.TrainPath
1010
import fr.sncf.osrd.railjson.schema.geom.RJSLineString
1111
import fr.sncf.osrd.utils.json.UnitAdapterFactory
1212
import fr.sncf.osrd.utils.units.Offset
@@ -32,7 +32,7 @@ data class OperationalPointResponse(
3232
val id: String,
3333
val part: OperationalPointPartResponse,
3434
val extensions: OperationalPointExtensions?,
35-
val position: Offset<TravelledPath>,
35+
val position: Offset<TrainPath>,
3636
val weight: Long?,
3737
)
3838

core/src/main/kotlin/fr/sncf/osrd/api/path_properties/PathPropResponseConverter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package fr.sncf.osrd.api.path_properties
33
import com.google.common.collect.Range
44
import fr.sncf.osrd.api.RangeValues
55
import fr.sncf.osrd.path.interfaces.TrainPath
6-
import fr.sncf.osrd.path.interfaces.TravelledPath
76
import fr.sncf.osrd.railjson.schema.geom.RJSLineString
87
import fr.sncf.osrd.sim_infra.api.NeutralSection
98
import fr.sncf.osrd.sim_infra.api.RawSignalingInfra
@@ -118,7 +117,7 @@ private fun <T> makeRangeValues(distanceRangeMap: DistanceRangeMap<T>): RangeVal
118117
}
119118

120119
private fun <T> makeRangeValues(entries: List<DistanceRangeMap.RangeMapEntry<T>>): RangeValues<T> {
121-
val boundaries = mutableListOf<Offset<TravelledPath>>()
120+
val boundaries = mutableListOf<Offset<TrainPath>>()
122121
val values = mutableListOf<T>()
123122
for (entry in entries) {
124123
boundaries.add(Offset(entry.upper))

core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/PathfindingBlockResponse.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
88
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
99
import fr.sncf.osrd.api.DirectionalTrackRange
1010
import fr.sncf.osrd.path.interfaces.JsonTrainPath
11-
import fr.sncf.osrd.path.interfaces.TravelledPath
11+
import fr.sncf.osrd.path.interfaces.TrainPath
1212
import fr.sncf.osrd.pathfinding.Pathfinding
1313
import fr.sncf.osrd.reporting.exceptions.OSRDError
1414
import fr.sncf.osrd.utils.json.UnitAdapterFactory
@@ -20,10 +20,10 @@ interface PathfindingBlockResponse
2020

2121
class PathfindingBlockSuccess(
2222
val path: JsonTrainPath,
23-
val length: Length<TravelledPath>,
23+
val length: Length<TrainPath>,
2424

2525
/** Offsets of the waypoints given as input */
26-
@Json(name = "path_item_positions") val pathItemPositions: List<Offset<TravelledPath>>,
26+
@Json(name = "path_item_positions") val pathItemPositions: List<Offset<TrainPath>>,
2727
) : PathfindingBlockResponse {
2828
override fun equals(other: Any?): Boolean {
2929
if (this === other) return true
@@ -43,12 +43,12 @@ class PathfindingBlockSuccess(
4343

4444
class NotFoundInBlocks(
4545
@Json(name = "track_section_ranges") val trackSectionRanges: List<DirectionalTrackRange>,
46-
val length: Length<TravelledPath>,
46+
val length: Length<TrainPath>,
4747
) : PathfindingBlockResponse
4848

4949
class NotFoundInRoutes(
5050
@Json(name = "track_section_ranges") val trackSectionRanges: List<DirectionalTrackRange>,
51-
val length: Length<TravelledPath>,
51+
val length: Length<TrainPath>,
5252
) : PathfindingBlockResponse
5353

5454
class NotFoundInTracks : PathfindingBlockResponse
@@ -66,9 +66,9 @@ data class IncompatibleConstraints(
6666
val incompatibleSignalingSystemRanges: List<RangeValue<String>>,
6767
)
6868

69-
data class RangeValue<T>(val range: Pathfinding.Range<TravelledPath>, val value: T?) {
69+
data class RangeValue<T>(val range: Pathfinding.Range<TrainPath>, val value: T?) {
7070
@FromJson
71-
fun fromJson(range: Pathfinding.Range<TravelledPath>): RangeValue<T> {
71+
fun fromJson(range: Pathfinding.Range<TrainPath>): RangeValue<T> {
7272
return RangeValue(range, null)
7373
}
7474
}

0 commit comments

Comments
 (0)