Skip to content

Commit

Permalink
Ssks: Fix distance between neighbor track (#1083)
Browse files Browse the repository at this point in the history
* Ssks: Fix distance between neighbor track

* Update SsksTransformator.xtend

* both direction is a illegal direction

* Revert change by CellContentExtensions
  • Loading branch information
TruongQuangSB authored Dec 10, 2024
1 parent 56679c9 commit 381d4bd
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +33,7 @@ public class Services {
private static UserConfigurationService userConfigurationService;

private static TopologicalGraphService topGraphService;
private static PointObjectPositionService pointObjectService;

/**
* @return the siteplan service
Expand Down Expand Up @@ -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
Expand Up @@ -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).
Expand Down Expand Up @@ -351,8 +352,8 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
]
waitingFileSideDistanceSignal.put(row, signal)
} else {
val abstandMastmitteLinks = new HashSet<Pair<Long, Long>>
val abstandMastmitteRechts = new HashSet<Pair<Long, Long>>
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>

signal.initAbstandMastmitte(signal.signalRahmen,
abstandMastmitteLinks, abstandMastmitteRechts);
Expand All @@ -363,7 +364,7 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
signal,
[
abstandMastmitteLinks.map [
'''«key»«IF value > 0» («value»)«ENDIF»'''
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
Expand All @@ -376,11 +377,10 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
signal,
[
abstandMastmitteRechts.map [
'''«key»«IF value > 0» («value»)«ENDIF»'''
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
[toString]
null
)
}

Expand Down Expand Up @@ -917,28 +917,28 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)

private def void refillSideDistance(TableRow row, Signal signal,
List<Pt1TableChangeProperties> changeProperties) {
val abstandMastmitteLinks = new HashSet<Pair<Long, Long>>
val abstandMastmitteRechts = new HashSet<Pair<Long, Long>>
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>
val containerType = signal.container.containerType
signal.initAbstandMastmitte(signal.signalRahmen, abstandMastmitteLinks,
abstandMastmitteRechts);
val leftDistance = new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Links), abstandMastmitteLinks.map [
'''«key» «IF value > 0»(«value»)«ENDIF»'''
'''«key» «IF value !== null»(«value»)«ENDIF»'''
].toList, ITERABLE_FILLING_SEPARATOR)
changeProperties.add(leftDistance)
val rightDistance = new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Rechts), abstandMastmitteRechts.map [
'''«key» «IF value > 0»(«value»)«ENDIF»'''
'''«key» «IF value !== null»(«value»)«ENDIF»'''
].toList, ITERABLE_FILLING_SEPARATOR)
changeProperties.add(rightDistance)
}

private def void initAbstandMastmitte(
Signal signal,
List<Signal_Rahmen> signalRahmen,
Set<Pair<Long, Long>> abstandMastmitteLinks,
Set<Pair<Long, Long>> abstandMastmitteRechts
Set<Pair<String, String>> abstandMastmitteLinks,
Set<Pair<String, String>> abstandMastmitteRechts
) {
signalRahmen.map [
signalBefestigungIterator.findFirst [
Expand All @@ -948,55 +948,69 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
ENUM_BEFESTIGUNG_ART_REGELANORDNUNG_MAST_NIEDRIG
]
].filterNull.map[singlePoints].flatten.toSet.forEach [ p |
val seitlicherAbstand = Math.round(
p.seitlicherAbstand.wert.doubleValue * 1000)
val wirkrichtung = signal.getWirkrichtung(p.topKante)

if (p?.seitlicherAbstand?.wert === null) {
val exception = new NullPointerException(
"The Signal_Befestigung haven't seitlicherAbstand")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
}
val seitlicherAbstand = Math.round(p.seitlicherAbstand.wert.doubleValue * 1000)
val wirkrichtung = p.wirkrichtung.wert
val distanceFromPoint = MAX_OPOSIDE_DISTANCE -
Math.abs(seitlicherAbstand)
val perpendicularRotation = wirkrichtung == ENUM_WIRKRICHTUNG_IN &&
seitlicherAbstand > 0 ? 90 : -90
if (wirkrichtung !== ENUM_WIRKRICHTUNG_IN &&
wirkrichtung !== ENUM_WIRKRICHTUNG_GEGEN) {
val exception = new IllegalArgumentException(
"The Signal_Befestigung have Illegal Wirkrichtung")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
}
val isLeftsideOfTrack = (wirkrichtung === ENUM_WIRKRICHTUNG_IN) ===
(seitlicherAbstand >= 0)
val perpendicularRotation = isLeftsideOfTrack ? 90 : -90
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)
? (Math.abs(seitlicherAbstand) +
Math.round(opposideSideDistance * 1000)).toString
: null

if (isLeftsideOfTrack) {
abstandMastmitteLinks.add(
Math.abs(seitlicherAbstand).toString ->
distanceBetweenTracks)
} else {
abstandMastmitteRechts.add(
Math.abs(seitlicherAbstand).toString ->
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell,
configRegistry)
: 0;

switch (getCellEdge()) {
switch (super.getCellEdge()) {
case LEFT:
return new Rectangle(adjustedCellBounds.x, adjustedCellBounds.y,
preferredDecoratorWidth, preferredDecoratorHeight)
Expand All @@ -90,7 +90,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell,
case RIGHT:
return new Rectangle(adjustedCellBounds.x,
adjustedCellBounds.y + preferredBaseHeight
- preferredDecoratorHeight,
- getSpacing(),
preferredDecoratorWidth, preferredDecoratorHeight)
.intersection(adjustedCellBounds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator;
import org.eclipse.swt.graphics.Image;

import org.eclipse.set.model.tablemodel.extensions.CellContentExtensions;
import org.eclipse.swt.graphics.Image;

/**
* Painter used to draw PlanPro table cells.
Expand All @@ -30,27 +29,27 @@ public class PlanProTableCellPainter extends BackgroundPainter {
/**
* @param interiorPainter
* the interior painter
* @param leftWarningImage
* the left warning image
* @param rightWarningImage
* the right warning image
* @param yellowWarningImage
* the yellow warning image
* @param redWarningImage
* the red warning image
* @param blackWarningImage
* the black warning image
*/
public PlanProTableCellPainter(final ICellPainter interiorPainter,
final Image leftWarningImage, final Image rightWarningImage,
final Image yellowWarningImage, final Image redWarningImage,
final Image blackWarningImage) {
super(new PaddingDecorator(new BasePainterDecorator(
new BasePainterDecorator(new BasePainterDecorator(
interiorPainter, BaseEdgeEnum.BEFORE,
new WarningPainter(redWarningImage,
CellContentExtensions.WARNING_MARK_RED)),
BaseEdgeEnum.BEFORE,
new WarningPainter(blackWarningImage,
CellContentExtensions.WARNING_MARK_BLACK)),
BaseEdgeEnum.BEFORE,
new WarningPainter(leftWarningImage,
CellContentExtensions.WARNING_MARK_YELLOW)),
BaseEdgeEnum.AFTER,
new WarningPainter(rightWarningImage,
CellContentExtensions.WARNING_MARK_RED)),
new WarningPainter(yellowWarningImage,
CellContentExtensions.WARNING_MARK_YELLOW)),
TOP_PADDING, RIGHT_PADDING, BOTTOM_PADDING, LEFT_PADDING,
false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ public void createPainterInstances() {
final boolean calculateByTextLength = false;
final boolean calculateByTextHeight = true;

final Image leftWarningImage = createImage(resourceManager,
final Image yellowWarningImage = createImage(resourceManager,
SetImages.WARNING_YELLOW);
final Image rightWarningImage = createImage(resourceManager,
final Image redWarningImage = createImage(resourceManager,
SetImages.WARNING_RED);
final Image blackWarningImage = createImage(resourceManager,
SetImages.IC_WARNING_BLACK_18DP_1X);

this.defaultCellPainter = new PlanProTableCellPainter(
new PlanProRichTextCellPainter(wraptext, calculateByTextLength,
calculateByTextHeight),
leftWarningImage, rightWarningImage, blackWarningImage);
yellowWarningImage, redWarningImage, blackWarningImage);
this.filterRowCellPainter = new PaddingDecorator(
new FilterRowPainter(
new FilterIconPainter(GUIHelper.getImage("filter"))), //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory
import static extension com.google.common.base.Throwables.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.*
import static extension org.eclipse.set.ppmodel.extensions.utils.Debug.*
import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt

/**
* Provides common functions for table transformations.
Expand Down Expand Up @@ -543,7 +544,7 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
) {
var guid = row.group.leadingObject?.identitaet?.wert
var leadingObject = getLeadingObjectIdentifier(row, guid)
var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObject»"'''
var errorMsg = e.createErrorMsg(row)

tableErrors.add(
new TableError(guid, leadingObject, "",
Expand All @@ -552,6 +553,24 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
logger.
error('''«e.class.simpleName» in column "«column.debugString»" for leading object "«leadingObject»" («guid»). «e.message»«System.lineSeparator»«e.stackTraceAsString»''')
}

def String createErrorMsg(
Exception e,
TableRow row
) {
var guid = row.group.leadingObject?.identitaet?.wert
var leadingObject = getLeadingObjectIdentifier(row, guid)
return e.createErrorMsg(leadingObject)
}

def String createErrorMsg(
Exception e,
String leadingObjectGuid
) {
var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObjectGuid»"'''
return '''«ERROR_PREFIX»«errorMsg»'''
}


/**
* Evaluates the given function with the given value for use in sorting.
Expand Down

0 comments on commit 381d4bd

Please sign in to comment.