@@ -21,6 +21,7 @@ import arrow.core.None
21
21
import arrow.core.Some
22
22
import arrow.core.flattenOption
23
23
import arrow.core.getOrElse
24
+ import arrow.core.some
24
25
import arrow.core.toNonEmptyListOrNone
25
26
import io.rtron.io.issues.ContextIssueList
26
27
import io.rtron.io.issues.DefaultIssue
@@ -228,6 +229,56 @@ class RoadMarkingBuilder(
228
229
}
229
230
}
230
231
232
+ private fun buildRoadMarkings (
233
+ roadMarkingCurvePositionStart : Double ,
234
+ typeLines : NonEmptyList <RoadLanesLaneSectionLCRLaneRoadMarkTypeLine >,
235
+ domain : Range <Double >,
236
+ laneChange : LaneChange ,
237
+ generalAttributeList : AttributeList ,
238
+ ): List <RoadMarking > {
239
+ require(domain.hasUpperBound()) { " Domain must have an upper bound." }
240
+
241
+ return typeLines.withIndex()
242
+ .flatMap { (currentIndex, currentTypeLine) ->
243
+ val typeLineAttributes =
244
+ attributes(" ${parameters.attributesPrefix} roadMarking_typeLine_" ) {
245
+ attribute(" index" , currentIndex)
246
+ attribute(" width" , currentTypeLine.width)
247
+ }
248
+ val currentTypeLineCurvePositionStart = roadMarkingCurvePositionStart + currentTypeLine.sOffset
249
+ val lateralOffset =
250
+ if (currentTypeLine.tOffset < parameters.numberTolerance) None else Some (currentTypeLine.tOffset)
251
+
252
+ val step = currentTypeLine.length + currentTypeLine.space
253
+ (0 .. floor((domain.upperEndpointOrNull()!! - currentTypeLineCurvePositionStart) / step).toInt())
254
+ .map { currentRegularIndex ->
255
+ val start = currentTypeLineCurvePositionStart + currentRegularIndex * step
256
+ val end =
257
+ if (start + currentTypeLine.length < domain.upperEndpointOrNull()!! ) {
258
+ start + currentTypeLine.length
259
+ } else {
260
+ domain.upperEndpointOrNull()!!
261
+ }
262
+ if (end - start < parameters.numberTolerance) return @map None
263
+
264
+ val attributes =
265
+ attributes(" ${parameters.attributesPrefix} roadMarking_typeLine_regular_" ) {
266
+ attribute(" index" , currentIndex)
267
+ attribute(" curvePositionStart" , start)
268
+ attribute(" curvePositionEnd" , end)
269
+ }
270
+
271
+ RoadMarking (
272
+ Range .closed(start, end),
273
+ currentTypeLine.width,
274
+ lateralOffset,
275
+ laneChange,
276
+ generalAttributeList + typeLineAttributes + attributes,
277
+ ).some()
278
+ }.flattenOption()
279
+ }
280
+ }
281
+
231
282
private fun buildRoadMarkings (
232
283
roadMarkingCurvePositionStart : Double ,
233
284
explicitLines : NonEmptyList <RoadLanesLaneSectionLCRLaneRoadMarkExplicitLine >,
@@ -252,52 +303,4 @@ class RoadMarkingBuilder(
252
303
)
253
304
RoadMarking (currentEntryDomain, currentExplicitLine.width, lateralOffset, laneChange, generalAttributeList + attributes)
254
305
}.toNonEmptyListOrNone().getOrElse { throw IllegalArgumentException (" Explicit road markings must contain at least one entry." ) }
255
-
256
- private fun buildRoadMarkings (
257
- roadMarkingCurvePositionStart : Double ,
258
- typeLines : NonEmptyList <RoadLanesLaneSectionLCRLaneRoadMarkTypeLine >,
259
- domain : Range <Double >,
260
- laneChange : LaneChange ,
261
- generalAttributeList : AttributeList ,
262
- ): List <RoadMarking > {
263
- require(domain.hasUpperBound()) { " Domain must have an upper bound." }
264
-
265
- return typeLines.withIndex().flatMap { (currentIndex, currentTypeLine) ->
266
- val typeLineAttributes =
267
- attributes(" ${parameters.attributesPrefix} roadMarking_typeLine_" ) {
268
- attribute(" index" , currentIndex)
269
- attribute(" width" , currentTypeLine.width)
270
- }
271
- val currentTypeLineCurvePositionStart = roadMarkingCurvePositionStart + currentTypeLine.sOffset
272
- val lateralOffset =
273
- if (currentTypeLine.tOffset < parameters.numberTolerance) None else Some (currentTypeLine.tOffset)
274
-
275
- val step = currentTypeLine.length + currentTypeLine.space
276
- (0 .. floor((domain.upperEndpointOrNull()!! - currentTypeLineCurvePositionStart) / step).toInt())
277
- .map { currentRegularIndex ->
278
- val start = currentTypeLineCurvePositionStart + currentRegularIndex * step
279
- val end =
280
- if (start + currentTypeLine.length < domain.upperEndpointOrNull()!! ) {
281
- start + currentTypeLine.length
282
- } else {
283
- domain.upperEndpointOrNull()!!
284
- }
285
-
286
- val attributes =
287
- attributes(" ${parameters.attributesPrefix} roadMarking_typeLine_regular_" ) {
288
- attribute(" index" , currentIndex)
289
- attribute(" curvePositionStart" , start)
290
- attribute(" curvePositionEnd" , end)
291
- }
292
-
293
- RoadMarking (
294
- Range .closed(start, end),
295
- currentTypeLine.width,
296
- lateralOffset,
297
- laneChange,
298
- generalAttributeList + typeLineAttributes + attributes,
299
- )
300
- }
301
- }
302
- }
303
306
}
0 commit comments