@@ -27,7 +27,6 @@ import arrow.core.nonEmptyListOf
27
27
import arrow.core.raise.either
28
28
import arrow.core.right
29
29
import arrow.core.toNonEmptyListOrNull
30
- import arrow.optics.copy
31
30
import io.rtron.math.analysis.function.univariate.UnivariateFunction
32
31
import io.rtron.math.analysis.function.univariate.combination.SectionedUnivariateFunction
33
32
import io.rtron.math.analysis.function.univariate.combination.StackedFunction
@@ -646,19 +645,24 @@ class Road(
646
645
roadMarking : RoadMarking ,
647
646
step : Double ,
648
647
): AbstractGeometry3D {
649
- if (roadMarking.width.value < geometricalTolerance) {
648
+ require(roadMarking.domain.length >= geometricalTolerance) { " Domain must be above tolerance threshold." }
649
+ if (roadMarking.width.isNone()) {
650
650
return getCurveOnLaneSectionSurface(centerLane.id.laneSectionIdentifier, centerLane.level)
651
651
.getOrElse { throw it }
652
652
}
653
653
654
- val leftOffsetFunction = roadMarking.width timesValue 0.5
654
+ val leftOffsetFunction =
655
+ roadMarking.getLeftOffsetFunction()
656
+ .getOrElse { throw IllegalStateException (" Case without width must have already been handled." ) }
655
657
val leftRoadMarkingBoundary =
656
658
getCurveOnLaneSectionSurface(centerLane.id.laneSectionIdentifier, centerLane.level, leftOffsetFunction)
657
659
.getOrElse { throw it }
658
660
.calculatePointListGlobalCS(step)
659
661
.mapLeft { it.toIllegalStateException() }
660
662
.getOrElse { throw it }
661
- val rightOffsetFunction = roadMarking.width timesValue - 0.5
663
+ val rightOffsetFunction =
664
+ roadMarking.getRightOffsetFunction()
665
+ .getOrElse { throw IllegalStateException (" Case without width must have already been handled." ) }
662
666
val rightRoadMarkingBoundary =
663
667
getCurveOnLaneSectionSurface(centerLane.id.laneSectionIdentifier, centerLane.level, rightOffsetFunction)
664
668
.getOrElse { throw it }
@@ -711,27 +715,24 @@ class Road(
711
715
roadMarking : RoadMarking ,
712
716
step : Double ,
713
717
): Either <Exception , AbstractGeometry3D > {
714
- if (roadMarking.width.domain.length < geometricalTolerance) {
715
- return Either .Left (
716
- IllegalStateException (
717
- " ${laneIdentifier.toIdentifierText()} : Road marking's length is zero (or below tolerance threshold) and " +
718
- " thus no surface can be constructed." ,
719
- ),
720
- )
721
- }
718
+ require(roadMarking.domain.length >= geometricalTolerance) { " Domain must be above tolerance threshold." }
722
719
723
- if (roadMarking.width.value < geometricalTolerance ) {
724
- return getCurveOnLane(laneIdentifier, 1.0 , roadMarking.width )
720
+ if (roadMarking.width.isNone() ) {
721
+ return getCurveOnLane(laneIdentifier, 1.0 , roadMarking.lateralOffsetFunction )
725
722
}
726
723
727
- val leftOffsetFunction = roadMarking.width timesValue 0.5
724
+ val leftOffsetFunction =
725
+ roadMarking.getLeftOffsetFunction()
726
+ .getOrElse { throw IllegalStateException (" Case without width must have already been handled." ) }
728
727
val leftRoadMarkBoundary =
729
728
getCurveOnLane(laneIdentifier, 1.0 , leftOffsetFunction)
730
729
.getOrElse { throw it }
731
730
.calculatePointListGlobalCS(step)
732
731
.mapLeft { it.toIllegalStateException() }
733
732
.getOrElse { throw it }
734
- val rightOffsetFunction = roadMarking.width timesValue - 0.5
733
+ val rightOffsetFunction =
734
+ roadMarking.getRightOffsetFunction()
735
+ .getOrElse { throw IllegalStateException (" Case without width must have already been handled." ) }
735
736
val rightRoadMarkBoundary =
736
737
getCurveOnLane(laneIdentifier, 1.0 , rightOffsetFunction)
737
738
.getOrElse { throw it }
0 commit comments