From b334d8859cb172096c88943e1c025f673e4e27bd Mon Sep 17 00:00:00 2001 From: Benedikt Schwab Date: Tue, 19 Sep 2023 13:06:58 +0200 Subject: [PATCH] fixes #36 --- .../roadspaces2citygml/module/RelationAdder.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rtron-transformer/src/main/kotlin/io/rtron/transformer/converter/roadspaces2citygml/module/RelationAdder.kt b/rtron-transformer/src/main/kotlin/io/rtron/transformer/converter/roadspaces2citygml/module/RelationAdder.kt index e135178c..b3460f24 100644 --- a/rtron-transformer/src/main/kotlin/io/rtron/transformer/converter/roadspaces2citygml/module/RelationAdder.kt +++ b/rtron-transformer/src/main/kotlin/io/rtron/transformer/converter/roadspaces2citygml/module/RelationAdder.kt @@ -17,7 +17,6 @@ package io.rtron.transformer.converter.roadspaces2citygml.module import io.rtron.model.roadspaces.identifier.AbstractRoadspacesIdentifier -import io.rtron.model.roadspaces.identifier.LaneIdentifier import io.rtron.model.roadspaces.identifier.RoadSide import io.rtron.model.roadspaces.roadspace.objects.RoadspaceObject import io.rtron.model.roadspaces.roadspace.road.Lane @@ -41,7 +40,7 @@ class RelationAdder( private val attributesAdder = AttributesAdder(parameters) // Methods - fun addRelatedToRelation(roadspaceObject: RoadspaceObject, dstCityObject: AbstractCityObject) { + fun addRelatedToRelation(roadspaceObject: RoadspaceObject, dstTrafficSpace: TrafficSpace) { val relationType = "related" + when (RoadspaceObjectRouter.route(roadspaceObject)) { RoadspaceObjectRouter.CitygmlTargetFeatureType.BUILDING_BUILDING -> "Building" RoadspaceObjectRouter.CitygmlTargetFeatureType.CITYFURNITURE_CITYFURNITURE -> "Furniture" @@ -52,12 +51,16 @@ class RelationAdder( RoadspaceObjectRouter.CitygmlTargetFeatureType.VEGETATION_SOLITARYVEGETATIONOBJECT -> "Vegetation" } - val relations: HashSet = roadspaceObject.laneRelations.flatMap { it.getAllLeftRightLaneIdentifiers() }.toHashSet() - dstCityObject.relatedTo = relations.map { createCityObjectRelation(roadspaceObject.id.deriveGmlIdentifier(parameters.gmlIdPrefix), relationType, it) } + val relation = createCityObjectRelation(roadspaceObject.id.deriveGmlIdentifier(parameters.gmlIdPrefix), relationType, roadspaceObject.id) + dstTrafficSpace.relatedTo.add(relation) } fun addBelongToRelations(roadspaceObject: RoadspaceObject, dstCityObject: AbstractCityObject) { - dstCityObject.relatedTo = roadspaceObject.laneRelations.flatMap { it.getAllLeftRightLaneIdentifiers() }.map { createCityObjectRelation(it.deriveTrafficSpaceOrAuxiliaryTrafficSpaceGmlIdentifier(parameters.gmlIdPrefix), "belongsTo", it) } + val relations = roadspaceObject.laneRelations + .flatMap { it.getAllLeftRightLaneIdentifiers() } + .map { createCityObjectRelation(it.deriveTrafficSpaceOrAuxiliaryTrafficSpaceGmlIdentifier(parameters.gmlIdPrefix), "belongsTo", it) } + + dstCityObject.relatedTo.addAll(relations) } /**