Skip to content

Commit

Permalink
core: fix v2 path_with_repeated_tracks by checking track with directi…
Browse files Browse the repository at this point in the history
…on duplicates in path
  • Loading branch information
Erashin committed May 22, 2024
1 parent afc1c50 commit d7c30b0
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,16 @@ fun validatePathfindingResponse(
}
}

val tracks = HashSet<String>()
for (track in res.trackSectionRanges) tracks.add(track.trackSection)
if (tracks.size != res.trackSectionRanges.size)
throw OSRDError(ErrorType.PathWithRepeatedTracks)
val dirTrackDuplicates =
res.trackSectionRanges.filter { trackSectionRange ->
res.trackSectionRanges
.filter {
trackSectionRange.trackSection == it.trackSection &&
trackSectionRange.direction == it.direction
}
.size > 1
}
if (dirTrackDuplicates.isNotEmpty()) throw OSRDError(ErrorType.PathWithRepeatedTracks)

if (res.pathItemPositions.size != req.pathItems.size)
throw OSRDError(ErrorType.PathHasInvalidItemPositions)
Expand Down

0 comments on commit d7c30b0

Please sign in to comment.