-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bc5e33
commit cdf35aa
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
rtron-model/src/main/kotlin/io/rtron/model/roadspaces/identifier/LaneIdentifierRange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019-2023 Chair of Geoinformatics, Technical University of Munich | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.rtron.model.roadspaces.identifier | ||
|
||
import io.rtron.math.range.Range | ||
|
||
/** | ||
* Identifier of a range of lanes within a lane section. | ||
* | ||
* @param laneIdRange range of lane ids which must have a lower and upper bound | ||
* @param laneSectionIdentifier identifier of the lane section | ||
*/ | ||
data class LaneIdentifierRange( | ||
val laneIdRange: Range<Int>, | ||
val laneSectionIdentifier: LaneSectionIdentifier | ||
) : AbstractRoadspacesIdentifier(), LaneSectionIdentifierInterface by laneSectionIdentifier { | ||
// Properties and Initializers | ||
init { | ||
require(laneIdRange.hasLowerBound()) { "laneIdRange must have a lower bound." } | ||
require(laneIdRange.hasUpperBound()) { "laneIdRange must have a upper bound." } | ||
} | ||
|
||
val lowerLaneId get() = LaneIdentifier(laneIdRange.lowerEndpointOrNull()!!, laneSectionIdentifier) | ||
val upperLaneId get() = LaneIdentifier(laneIdRange.upperEndpointOrNull()!!, laneSectionIdentifier) | ||
|
||
// Conversions | ||
override fun toStringMap(): Map<String, String> = | ||
mapOf("lowerLaneId" to laneIdRange.lowerEndpointOrNull()!!.toString(), "upperLaneId" to laneIdRange.upperEndpointOrNull()!!.toString()) + laneSectionIdentifier.toStringMap() | ||
|
||
override fun toIdentifierText() = "LaneIdentifierRange(lowerLaneId=${laneIdRange.lowerEndpointOrNull()!!}, upperLaneId=${laneIdRange.upperEndpointOrNull()!!}, laneSectionId=$laneSectionId, roadId=$roadspaceId)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters