Skip to content

Commit

Permalink
core: prevents path from taking the same track section twice
Browse files Browse the repository at this point in the history
This check was already there but not for opposite direction.
  • Loading branch information
flomonster authored and younesschrifi committed Jun 21, 2024
1 parent c57458e commit 39f7837
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import fr.sncf.osrd.api.api_v2.TrackLocation
import fr.sncf.osrd.api.pathfinding.constraints.*
import fr.sncf.osrd.graph.*
import fr.sncf.osrd.graph.Pathfinding.EdgeLocation
import fr.sncf.osrd.railjson.schema.common.graph.EdgeDirection
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
Expand Down Expand Up @@ -308,9 +307,9 @@ fun validatePathfindingResponse(
}
}

val dirTracks = HashSet<Pair<String, EdgeDirection>>()
for (track in res.trackSectionRanges) dirTracks.add(Pair(track.trackSection, track.direction))
if (dirTracks.size != res.trackSectionRanges.size)
val trackSet = HashSet<String>()
for (track in res.trackSectionRanges) trackSet.add(track.trackSection)
if (trackSet.size != res.trackSectionRanges.size)
throw OSRDError(ErrorType.PathWithRepeatedTracks)

if (res.pathItemPositions.size != req.pathItems.size)
Expand Down

0 comments on commit 39f7837

Please sign in to comment.