From fe4ee92e42ec522e25424303808282cbaabc25e5 Mon Sep 17 00:00:00 2001 From: Quang Truong Date: Fri, 22 Nov 2024 15:12:24 +0100 Subject: [PATCH] Ssks: Fix distance between neighbor track --- .../PointObjectPositionServiceImpl.java | 8 +++ .../eclipse/set/core/services/Services.java | 12 ++++ .../table/pt1/ssks/SsksTransformator.xtend | 63 +++++++++++-------- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/geometry/PointObjectPositionServiceImpl.java b/java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/geometry/PointObjectPositionServiceImpl.java index dfa0f3e92..efc9af7f3 100644 --- a/java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/geometry/PointObjectPositionServiceImpl.java +++ b/java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/geometry/PointObjectPositionServiceImpl.java @@ -18,6 +18,7 @@ import org.eclipse.set.basis.geometry.GEOKanteCoordinate; import org.eclipse.set.basis.geometry.GEOKanteMetadata; import org.eclipse.set.basis.geometry.GEOKanteSegment; +import org.eclipse.set.core.services.Services; import org.eclipse.set.core.services.geometry.GeoKanteGeometryService; import org.eclipse.set.core.services.geometry.PointObjectPositionService; import org.eclipse.set.model.planpro.BasisTypen.ENUMLinksRechts; @@ -46,6 +47,13 @@ public class PointObjectPositionServiceImpl @Reference GeoKanteGeometryService geometryService; + /** + * Default constructor + */ + public PointObjectPositionServiceImpl() { + Services.setPointObjectService(this); + } + /* * Special case for signals: The lateral position may be given indirectly * via local track types diff --git a/java/bundles/org.eclipse.set.core.services/src/org/eclipse/set/core/services/Services.java b/java/bundles/org.eclipse.set.core.services/src/org/eclipse/set/core/services/Services.java index d3dbfd555..e5af6c550 100644 --- a/java/bundles/org.eclipse.set.core.services/src/org/eclipse/set/core/services/Services.java +++ b/java/bundles/org.eclipse.set.core.services/src/org/eclipse/set/core/services/Services.java @@ -12,6 +12,7 @@ import org.eclipse.set.core.services.cache.NoCacheService; import org.eclipse.set.core.services.configurationservice.UserConfigurationService; import org.eclipse.set.core.services.geometry.GeoKanteGeometryService; +import org.eclipse.set.core.services.geometry.PointObjectPositionService; import org.eclipse.set.core.services.graph.TopologicalGraphService; import org.eclipse.set.core.services.planningaccess.PlanningAccessService; import org.eclipse.set.core.services.siteplan.SiteplanService; @@ -32,6 +33,7 @@ public class Services { private static UserConfigurationService userConfigurationService; private static TopologicalGraphService topGraphService; + private static PointObjectPositionService pointObjectService; /** * @return the siteplan service @@ -166,4 +168,14 @@ public static void setTopGraphService( final TopologicalGraphService topGraphService) { Services.topGraphService = topGraphService; } + + public static void setPointObjectService( + final PointObjectPositionService pointObjectPositionService) { + Services.pointObjectService = pointObjectPositionService; + + } + + public static PointObjectPositionService getPointObjectService() { + return pointObjectService; + } } diff --git a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend index 8a44bd9ec..d9762d096 100644 --- a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend +++ b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend @@ -134,6 +134,7 @@ import static extension org.eclipse.set.ppmodel.extensions.utils.CacheUtils.* import static extension org.eclipse.set.ppmodel.extensions.utils.IterableExtensions.* import static extension org.eclipse.set.utils.math.BigDecimalExtensions.* import static extension org.eclipse.set.utils.math.DoubleExtensions.* +import org.eclipse.set.core.services.Services /** * Table transformation for a Signaltabelle (Ssks). @@ -950,17 +951,28 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) ].filterNull.map[singlePoints].flatten.toSet.forEach [ p | val seitlicherAbstand = Math.round( p.seitlicherAbstand.wert.doubleValue * 1000) - val wirkrichtung = signal.getWirkrichtung(p.topKante) - + val wirkrichtung = p.wirkrichtung.wert val distanceFromPoint = MAX_OPOSIDE_DISTANCE - Math.abs(seitlicherAbstand) - val perpendicularRotation = wirkrichtung == ENUM_WIRKRICHTUNG_IN && - seitlicherAbstand > 0 ? 90 : -90 + var perpendicularRotation = 0 + + switch (wirkrichtung) { + case ENUM_WIRKRICHTUNG_IN, + case ENUM_WIRKRICHTUNG_BEIDE: + perpendicularRotation = seitlicherAbstand >= 0 ? 90 : -90 + case ENUM_WIRKRICHTUNG_GEGEN: + perpendicularRotation = seitlicherAbstand < 0 ? 90 : 9 - 0 + default: { + LOGGER.error("Illegal Wirkrichtung") + return + } + } var opposideSideDistance = 0.0 + val geoPosition = Services.pointObjectService.getCoordinate(p). + geoPosition try { - opposideSideDistance = p.opposideSideDistance( - p.coordinate.effectiveRotation + perpendicularRotation, - distanceFromPoint / 1000) + opposideSideDistance = p.opposideSideDistance(geoPosition, + perpendicularRotation, distanceFromPoint / 1000) } catch (Exception e) { LOGGER.error(e.message) } @@ -968,35 +980,36 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) ? Math.abs(seitlicherAbstand) + Math.round(opposideSideDistance * 1000) : 0 - if ((wirkrichtung == ENUM_WIRKRICHTUNG_IN && - seitlicherAbstand > 0) || - (wirkrichtung == ENUM_WIRKRICHTUNG_GEGEN && - seitlicherAbstand < 0)) { - abstandMastmitteLinks.add(Math.abs(seitlicherAbstand) -> - distanceBetweenTracks) - } - if ((wirkrichtung == ENUM_WIRKRICHTUNG_IN && - seitlicherAbstand < 0) || - (wirkrichtung == ENUM_WIRKRICHTUNG_GEGEN && - seitlicherAbstand > 0)) { - abstandMastmitteRechts.add(Math.abs(seitlicherAbstand) -> - distanceBetweenTracks) + + switch (wirkrichtung) { + case ENUM_WIRKRICHTUNG_IN, + case ENUM_WIRKRICHTUNG_BEIDE: + seitlicherAbstand >= 0 + ? abstandMastmitteLinks.add( + Math.abs(seitlicherAbstand) -> distanceBetweenTracks) + : abstandMastmitteRechts.add( + Math.abs(seitlicherAbstand) -> distanceBetweenTracks) + case ENUM_WIRKRICHTUNG_GEGEN: + seitlicherAbstand < 0 + ? abstandMastmitteLinks.add( + Math.abs(seitlicherAbstand) -> distanceBetweenTracks) + : abstandMastmitteRechts.add( + Math.abs(seitlicherAbstand) -> distanceBetweenTracks) } ] } private def Double opposideSideDistance( - Punkt_Objekt_TOP_Kante_AttributeGroup potk, double angle, - double distance) { - val position = potk.coordinate - val rad = angle * Math.PI / 180 + Punkt_Objekt_TOP_Kante_AttributeGroup potk, GeoPosition position, + double angle, double distance) { + val rad = (angle + position.effectiveRotation) * Math.PI / 180 val transformX = Math.sin(rad) * distance + position.coordinate.x val transformY = Math.cos(rad) * distance + position.coordinate.y val geometryFactory = new GeometryFactory() val perpendicularLine = geometryFactory.createLineString( #[position.coordinate, new Coordinate(transformX, transformY)]) val relevantGeoKante = potk.container.GEOKante.filter [ - geoArt instanceof TOP_Kante && geoArt !== potk.IDTOPKante + geoArt instanceof TOP_Kante && geoArt !== potk.IDTOPKante.value ].map[getGeometry].filterNull.toList return relevantGeoKante.getDistanceOpposide(perpendicularLine, position) }