Skip to content

Commit

Permalink
introduced cli argument for skipping bounding box transformation of r…
Browse files Browse the repository at this point in the history
…oad objects
  • Loading branch information
benediktschwab committed Apr 1, 2024
1 parent f311c91 commit d576158
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ class SubcommandOpendriveToCitygml : CliktCommand(name = "opendrive-to-citygml",
.default(Opendrive2RoadspacesParameters.DEFAULT_CRS_EPSG)
private val addOffset by option(help = "offset values by which the model is translated along the x, y, and z axis").double().triple()
.default(Triple(OpendriveOffsetAdderParameters.DEFAULT_OFFSET_X, OpendriveOffsetAdderParameters.DEFAULT_OFFSET_Y, OpendriveOffsetAdderParameters.DEFAULT_OFFSET_Z))
private val cropPolygon by option(help = "2D polygon outline for cropping the OpenDRIVE dataset (experimental)").double().pair().multiple(default = emptyList())
private val cropPolygon by option(help = "2D polygon outline for cropping the OpenDRIVE dataset").double().pair().multiple()
private val removeRoadObjectOfType by option(help = "Remove road object of a specific type").enum<EObjectType>().multiple().unique()

private val skipRoadObjectBoundingBoxTransformation by option(help = "skip the transformation of the road object's bounding box").flag()
private val discretizationStepSize by option(help = "distance between each discretization step for curves and surfaces").double()
.default(Roadspaces2CitygmlParameters.DEFAULT_DISCRETIZATION_STEP_SIZE)
private val sweepDiscretizationStepSize by option(help = "distance between each discretization step for solid geometries of ParametricSweep3D").double()
Expand Down Expand Up @@ -109,6 +110,7 @@ class SubcommandOpendriveToCitygml : CliktCommand(name = "opendrive-to-citygml",
cropPolygonY = cropPolygon.map { it.second },
removeRoadObjectsOfTypes = removeRoadObjectOfType,

skipRoadObjectBoundingBoxTransformation = skipRoadObjectBoundingBoxTransformation,
discretizationStepSize = discretizationStepSize,
sweepDiscretizationStepSize = sweepDiscretizationStepSize,
circleSlices = circleSlices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ data class OpendriveToCitygmlParameters(
val cropPolygonY: List<Double> = OpendriveCropperParameters.DEFAULT_CROP_POLYGON_Y,
val removeRoadObjectsOfTypes: Set<EObjectType> = OpendriveObjectRemoverParameters.DEFAULT_REMOVE_ROAD_OBJECTS_OF_TYPES,

val skipRoadObjectBoundingBoxTransformation: Boolean = Opendrive2RoadspacesParameters.DEFAULT_SKIP_ROAD_OBJECT_BOUNDING_BOX_TRANSFORMATION,
val discretizationStepSize: Double = Roadspaces2CitygmlParameters.DEFAULT_DISCRETIZATION_STEP_SIZE,
val sweepDiscretizationStepSize: Double = Roadspaces2CitygmlParameters.DEFAULT_SWEEP_DISCRETIZATION_STEP_SIZE,
val circleSlices: Int = Roadspaces2CitygmlParameters.DEFAULT_CIRCLE_SLICES,
Expand Down Expand Up @@ -116,7 +117,8 @@ data class OpendriveToCitygmlParameters(
attributesPrefix = Opendrive2RoadspacesParameters.DEFAULT_ATTRIBUTES_PREFIX,
deriveCrsEpsgAutomatically = true,
crsEpsg = crsEpsg,
extrapolateLateralRoadShapes = Opendrive2RoadspacesParameters.DEFAULT_EXTRAPOLATE_LATERAL_ROAD_SHAPES
extrapolateLateralRoadShapes = Opendrive2RoadspacesParameters.DEFAULT_EXTRAPOLATE_LATERAL_ROAD_SHAPES,
skipRoadObjectBoundingBoxTransformation = skipRoadObjectBoundingBoxTransformation
)

fun deriveRoadspacesEvaluatorParameters() = RoadspacesEvaluatorParameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ data class ValidateOpendriveParameters(
attributesPrefix = Opendrive2RoadspacesParameters.DEFAULT_ATTRIBUTES_PREFIX,
deriveCrsEpsgAutomatically = false,
crsEpsg = Opendrive2RoadspacesParameters.DEFAULT_CRS_EPSG,
extrapolateLateralRoadShapes = Opendrive2RoadspacesParameters.DEFAULT_EXTRAPOLATE_LATERAL_ROAD_SHAPES
extrapolateLateralRoadShapes = Opendrive2RoadspacesParameters.DEFAULT_EXTRAPOLATE_LATERAL_ROAD_SHAPES,
skipRoadObjectBoundingBoxTransformation = Opendrive2RoadspacesParameters.DEFAULT_SKIP_ROAD_OBJECT_BOUNDING_BOX_TRANSFORMATION
)

fun deriveRoadspacesEvaluatorParameters() = RoadspacesEvaluatorParameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ data class Opendrive2RoadspacesParameters(
/** [EPSG code](https://en.wikipedia.org/wiki/EPSG_Geodetic_Parameter_Dataset) of the coordinate reference system (obligatory for working with GIS applications) */
val crsEpsg: Int,
/** linear extrapolation of lateral road shapes if they are not defined at the position (otherwise errors are thrown) */
val extrapolateLateralRoadShapes: Boolean
val extrapolateLateralRoadShapes: Boolean,
/** skip the transformation of bounding box geometries of road objects */
val skipRoadObjectBoundingBoxTransformation: Boolean
) {

companion object {
Expand All @@ -50,5 +52,6 @@ data class Opendrive2RoadspacesParameters(
const val DEFAULT_DERIVE_CRS_EPSG_AUTOMATICALLY = false
const val DEFAULT_CRS_EPSG = 0
const val DEFAULT_EXTRAPOLATE_LATERAL_ROAD_SHAPES = false
const val DEFAULT_SKIP_ROAD_OBJECT_BOUNDING_BOX_TRANSFORMATION = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ class RoadspaceObjectBuilder(
RoadspaceObjectIdentifier(roadObject.id, repeatIdentifier.repeatIndex.some(), roadObject.name, id)

val pointGeometry = buildPointGeometry(currentRoadObjectRepeat, roadReferenceLine)
val boundingBoxGeometry = buildBoundingBoxGeometry(roadObject, roadReferenceLine)
val boundingBoxGeometry =
if (parameters.skipRoadObjectBoundingBoxTransformation) {
None
} else {
buildBoundingBoxGeometry(roadObject, roadReferenceLine)
}
val complexGeometry = buildComplexGeometry(
roadObject,
currentRoadObjectRepeat.some(),
Expand All @@ -135,7 +140,12 @@ class RoadspaceObjectBuilder(
val roadObjects = if (roadObjectsFromRepeat.isEmpty()) {
val roadspaceObjectId = RoadspaceObjectIdentifier(roadObject.id, None, roadObject.name, id)
val pointGeometry = buildPointGeometry(roadObject, roadReferenceLine)
val boundingBoxGeometry = buildBoundingBoxGeometry(roadObject, roadReferenceLine)
val boundingBoxGeometry =
if (parameters.skipRoadObjectBoundingBoxTransformation) {
None
} else {
buildBoundingBoxGeometry(roadObject, roadReferenceLine)
}
val complexGeometry =
buildComplexGeometry(roadObject, None, roadReferenceLine).handleIssueList { issueList += it }
nonEmptyListOf(
Expand Down

0 comments on commit d576158

Please sign in to comment.