Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ssks: Fix distance between neighbor track
Browse files Browse the repository at this point in the history
TruongQuangSB committed Nov 22, 2024
1 parent ee33cef commit fe4ee92
Showing 3 changed files with 58 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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,53 +951,65 @@ 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)
}
val distanceBetweenTracks = opposideSideDistance > 0
? 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)
}

0 comments on commit fe4ee92

Please sign in to comment.