Merge pull request 'Add requirement on non-emptiness of composite trajectory parts list' (!25) from lounres/maps-kt:fix/nonemptiness-check-for-composite-trajectories into dev

Reviewed-on: #25
Reviewed-by: Alexander Nozik <altavir@gmail.com>
This commit is contained in:
Alexander Nozik 2024-07-08 18:12:56 +03:00
commit df800f05f0

View File

@ -179,6 +179,10 @@ public fun CircleTrajectory2D(
@Serializable @Serializable
@SerialName("composite") @SerialName("composite")
public class CompositeTrajectory2D(public val segments: List<Trajectory2D>) : Trajectory2D { public class CompositeTrajectory2D(public val segments: List<Trajectory2D>) : Trajectory2D {
init {
require(segments.isNotEmpty()) { "A composite trajectory cannot consist of an empty list of trajectories" }
}
override val length: Double get() = segments.sumOf { it.length } override val length: Double get() = segments.sumOf { it.length }
override val beginPose: Pose2D get() = segments.first().beginPose override val beginPose: Pose2D get() = segments.first().beginPose