Skip to content

Commit

Permalink
added lane identifier range
Browse files Browse the repository at this point in the history
  • Loading branch information
beneschwab committed Jul 11, 2023
1 parent 7bc5e33 commit cdf35aa
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.poly2tri.geometry.polygon.PolygonPoint as P2TPolygonPoint
class Poly2TriTriangulationAlgorithm : TriangulationAlgorithm() {

override fun triangulate(vertices: NonEmptyList<Vector3D>, tolerance: Double): Either<TriangulatorException, List<Polygon3D>> = either.eager {
val polygon = P2TPolygon(vertices.map { P2TPolygonPoint(it.x, it.y, it.z) })
val polygon = P2TPolygon(vertices.toList().map { P2TPolygonPoint(it.x, it.y, it.z) })

poly2TriTriangulation(polygon).bind()
val triangles = polygonBackConversion(polygon, tolerance).bind()
Expand Down
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)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@

package io.rtron.model.roadspaces.roadspace.objects

import arrow.core.Option
import io.rtron.math.geometry.euclidean.threed.AbstractGeometry3D
import io.rtron.model.roadspaces.identifier.LaneIdentifierRange
import io.rtron.model.roadspaces.identifier.RoadspaceObjectIdentifier
import io.rtron.model.roadspaces.roadspace.attribute.AttributeList

/**
* Represents an object within the road space.
*
* @param geometry geometry of the road space object
* @param laneRelations object relations to road lanes
* @param attributes attributes containing information about the road space object
*/
data class RoadspaceObject(
val id: RoadspaceObjectIdentifier,
val type: RoadObjectType = RoadObjectType.NONE,
val geometry: AbstractGeometry3D,
val laneRelations: Option<LaneIdentifierRange>,
val attributes: AttributeList
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ class RoadspaceObjectBuilder(

val roadspaceObjectId = RoadspaceObjectIdentifier("${roadObject.id}_${repeatIdentifier.repeatIndex}", roadObject.name, id)
val geometry = buildGeometries(roadObject, currentRoadObjectRepeat.some(), roadReferenceLine).handleMessageList { messageList += it }
RoadspaceObject(roadspaceObjectId, type, geometry, attributes)
RoadspaceObject(roadspaceObjectId, type, geometry, None, attributes)
}

val roadObjects = if (roadObjectsFromRepeat.isEmpty()) {
val roadspaceObjectId = RoadspaceObjectIdentifier(roadObject.id, roadObject.name, id)
val geometry = buildGeometries(roadObject, None, roadReferenceLine).handleMessageList { messageList += it }
nonEmptyListOf(RoadspaceObject(roadspaceObjectId, type, geometry, attributes))
nonEmptyListOf(RoadspaceObject(roadspaceObjectId, type, geometry, None, attributes))
} else {
roadObjectsFromRepeat.toNonEmptyListOrNull()!!
}
Expand Down Expand Up @@ -234,7 +234,7 @@ class RoadspaceObjectBuilder(
buildAttributes(roadSignal.curveRelativePosition) +
buildAttributes(roadSignal.referenceLinePointRelativeRotation)

return RoadspaceObject(objectId, RoadObjectType.SIGNAL, geometry, attributes)
return RoadspaceObject(objectId, RoadObjectType.SIGNAL, geometry, None, attributes)
}

private fun buildAttributes(signal: RoadSignalsSignal): AttributeList =
Expand Down

0 comments on commit cdf35aa

Please sign in to comment.