Skip to content

Commit

Permalink
removal of repeat objects outside s value range
Browse files Browse the repository at this point in the history
  • Loading branch information
benediktschwab committed Aug 16, 2024
1 parent 17bbaf2 commit fd18146
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import arrow.optics.PPrism
import arrow.optics.Traversal
import io.rtron.model.opendrive.OpendriveModel
import io.rtron.model.opendrive.core.Header
import io.rtron.model.opendrive.core.geoReference
import io.rtron.model.opendrive.core.offset
import io.rtron.model.opendrive.header
import io.rtron.model.opendrive.junction
Expand Down Expand Up @@ -57,6 +58,7 @@ import io.rtron.model.opendrive.signal.RoadSignals
import io.rtron.model.opendrive.signal.signal

val everyHeaderOffset = OpendriveModel.header compose Header.offset compose PPrism.some()
val everyHeaderGeoReference = OpendriveModel.header compose Header.geoReference compose PPrism.some()

// road
val everyRoad = OpendriveModel.road compose Traversal.list()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import io.rtron.io.issues.DefaultIssue
import io.rtron.io.issues.DefaultIssueList
import io.rtron.io.issues.Severity
import io.rtron.model.opendrive.OpendriveModel
import io.rtron.model.opendrive.additions.optics.everyHeaderGeoReference
import io.rtron.model.opendrive.additions.optics.everyHeaderOffset
import io.rtron.model.opendrive.header
import io.rtron.transformer.evaluator.opendrive.OpendriveEvaluatorParameters
Expand Down Expand Up @@ -126,6 +127,24 @@ object CoreEvaluator {
currentHeaderOffset
}

modifiedOpendriveModel =
everyHeaderGeoReference.modify(modifiedOpendriveModel) { currentHeaderGeoReference ->

val contentTrimmed = currentHeaderGeoReference.content.trim()
if (currentHeaderGeoReference.content.length > contentTrimmed.length) {
issueList +=
DefaultIssue(
"GeoReferenceContainsLeadingAndTrailingWhitespace",
"GeoReference element contains leading and trailing whitespace.",
"GeoReference of header element",
Severity.WARNING, wasFixed = true,
)
currentHeaderGeoReference.content = currentHeaderGeoReference.content.trim()
}

currentHeaderGeoReference
}

return modifiedOpendriveModel
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ object RoadObjectsEvaluator {
)
}
currentRoadObjects.roadObject = roadObjectsFiltered

val roadObjectsFilteredRepeat =
currentRoadObjects.roadObject.filter { currentRoadObject ->
currentRoadObject.repeat.isEmpty() ||
currentRoadObject.repeat.all { it.s + it.length <= currentRoad.length + parameters.numberTolerance }
}
if (currentRoadObjects.roadObject.size > roadObjectsFilteredRepeat.size) {
issueList +=
DefaultIssue.of(
"RoadObjectRepeatPositionNotInSValueRange",
"Road object repeats (number of objects affected: ${currentRoadObjects.roadObject.size -
roadObjectsFiltered.size}) were removed since they were positioned outside the " +
"defined length of the road.",
currentRoad.additionalId, Severity.ERROR, wasFixed = true,
)
}
currentRoadObjects.roadObject = roadObjectsFilteredRepeat
}

currentRoad
Expand Down

0 comments on commit fd18146

Please sign in to comment.