Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssks: Find route km throught projection of signal on route #1134

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Eclipse Signalling Engineering Toolbox

The main purpose of this project is the ongoing development and maintainance of
the Eclipse Signalling Engineering Toolbox (in the following simply called
toolbox). The toolbox, as aforementioned, provides means for initialization,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.math.BigDecimal;
import java.util.List;

import org.eclipse.set.basis.Pair;
import org.eclipse.set.basis.geometry.GEOKanteCoordinate;
import org.eclipse.set.basis.geometry.GEOKanteMetadata;
import org.eclipse.set.basis.geometry.GEOKanteSegment;
Expand All @@ -25,6 +26,7 @@
import org.eclipse.set.model.planpro.BasisTypen.ENUMWirkrichtung;
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt;
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt_TOP_Kante_AttributeGroup;
import org.eclipse.set.model.planpro.Geodaten.Strecke;
import org.eclipse.set.model.planpro.Geodaten.TOP_Kante;
import org.eclipse.set.model.planpro.Geodaten.TOP_Knoten;
import org.eclipse.set.model.planpro.Gleis.ENUMGleisart;
Expand All @@ -51,7 +53,7 @@ public class PointObjectPositionServiceImpl
* Default constructor
*/
public PointObjectPositionServiceImpl() {
Services.setPointObjectService(this);
Services.setPointObjectPositionService(this);
}

/*
Expand Down Expand Up @@ -140,8 +142,7 @@ private static BigDecimal getLateralDistance(
&& singlePoint.getSeitlicherAbstand().getWert() != null) {
return singlePoint.getSeitlicherAbstand().getWert();
}
final BigDecimal distance = singlePoint.getSeitlicherAbstand()
.getWert();
final BigDecimal distance = singlePoint.getAbstand().getWert();
// Determine the track type
final GEOKanteSegment segment = geoKante.getContainingSegment(distance);
final List<ENUMGleisart> trackType = segment.getBereichObjekte()
Expand All @@ -165,4 +166,12 @@ private static BigDecimal getLateralDistance(
}
return BigDecimal.valueOf(lateralDistance);
}

@Override
public Pair<GEOKanteCoordinate, BigDecimal> getProjectionOnStreck(
final Punkt_Objekt punktObjekt, final Strecke strecke) {
final GEOKanteCoordinate coordinate = getCoordinate(punktObjekt);
return geometryService.getProjectionCoordinateOnStrecke(
coordinate.getCoordinate(), strecke);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,147 @@
*/
package org.eclipse.set.basis.geometry;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.set.model.planpro.Basisobjekte.Bereich_Objekt;
import org.eclipse.set.model.planpro.Geodaten.ENUMGEOKoordinatensystem;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.Point;

/**
* A coordinate on a GEO_Kante including information of Bereich_Objekte covering
* the coordinate
* A coordinate on a GEO_Kante including information of this GEO_Kante
*
* @author Stuecker
*
*/
public class GEOKanteCoordinate {
private final Set<Bereich_Objekt> bereichObjekte;
private static final double GEOMETRY_TOLERANCE = 1e-9;
private final GEOKanteMetadata geoKante;
private final GeoPosition position;
private final ENUMGEOKoordinatensystem crs;

private final Optional<BigDecimal> topDistance;

private Set<Bereich_Objekt> bereichObjekt = null;

/**
* @param position
* the {@link GeoPosition}
* @param bereichObjekte
* the {@link Bereich_Objekt}
* @param geoKante
* the {@link GEOKanteMetadata}
* @param crs
* the coordinate system
*/
public GEOKanteCoordinate(final GeoPosition position,
final Set<Bereich_Objekt> bereichObjekte,
final GEOKanteMetadata geoKante,
final ENUMGEOKoordinatensystem crs) {
this.position = position;
this.bereichObjekte = bereichObjekte;
this.geoKante = geoKante;
this.crs = crs;
this.topDistance = determineTopDistance(position.getCoordinate(),
geoKante);
}

/**
* @param coordinate
* the coordinate
* @param geoKante
* the {@link Bereich_Objekt}
* @param crs
* the coordinate system
*/
public GEOKanteCoordinate(final Coordinate coordinate,
final GEOKanteMetadata geoKante,
final ENUMGEOKoordinatensystem crs) {
this.position = new GeoPosition(coordinate, 0, 0);
this.geoKante = geoKante;
this.crs = crs;
this.topDistance = determineTopDistance(coordinate, geoKante);
}

/**
* @param coordinate
* the coordinate
* @param bereichObjekte
* @param geoKante
* the {@link Bereich_Objekt}
* @param topDistance
* the topological distance
* @param crs
* the coordinate system
*/
public GEOKanteCoordinate(final Coordinate coordinate,
final Set<Bereich_Objekt> bereichObjekte,
final GEOKanteMetadata geoKante, final BigDecimal topDistance,
final ENUMGEOKoordinatensystem crs) {
this.position = new GeoPosition(coordinate, 0, 0);
this.bereichObjekte = bereichObjekte;
this.geoKante = geoKante;
this.crs = crs;
this.topDistance = Optional.of(topDistance);
}

private static Optional<BigDecimal> determineTopDistance(
final Coordinate coordinate, final GEOKanteMetadata metadata) {
final GeometryFactory geometryFactory = new GeometryFactory();
final LineString geometry = metadata.getGeometry();
// Determine the distance only when the coordinate lie on the GEO_Kante
if (!geometry.isWithinDistance(geometryFactory.createPoint(coordinate),
GEOMETRY_TOLERANCE)) {
return Optional.empty();
}
BigDecimal distance = metadata.getStart();
Coordinate currentCoordinate = null;
for (final Coordinate nextCoordinate : geometry.getCoordinates()) {
if (currentCoordinate == null) {
currentCoordinate = nextCoordinate;
continue;
}

final double distanceToNextCoord = currentCoordinate
.distance(currentCoordinate);
final double distanceToTargetCoord = currentCoordinate
.distance(coordinate);
if (isOnLine(coordinate, currentCoordinate, nextCoordinate)
&& distanceToNextCoord >= distanceToTargetCoord) {
return Optional.of(distance
.add(BigDecimal.valueOf(distanceToTargetCoord)));
}
distance = distance.add(BigDecimal.valueOf(distanceToTargetCoord));
currentCoordinate = nextCoordinate;
}
return Optional.empty();
}

private static boolean isOnLine(final Coordinate coordinate,
final Coordinate coordinateA, final Coordinate coordianteB) {
final GeometryFactory geometryFactory = new GeometryFactory();
final LineString line = geometryFactory.createLineString(
new Coordinate[] { coordinateA, coordianteB });
final Point point = geometryFactory.createPoint(coordinate);
return line.isWithinDistance(point, GEOMETRY_TOLERANCE);
}

/**
* @return a list of Bereich_Objekte which affect the coordinate
*/
public Set<Bereich_Objekt> getBereichObjekte() {
return bereichObjekte;
if (bereichObjekt != null) {
return bereichObjekt;
}

if (topDistance.isEmpty()) {
return Collections.emptySet();
}
bereichObjekt = geoKante.segments.stream().filter(
segment -> topDistance.get().compareTo(segment.getStart()) >= 0
&& topDistance.get().compareTo(segment.getEnd()) <= 0)
.flatMap(segment -> segment.getBereichObjekte().stream())
.collect(Collectors.toSet());
return bereichObjekt;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Services {
private static UserConfigurationService userConfigurationService;

private static TopologicalGraphService topGraphService;
private static PointObjectPositionService pointObjectService;
private static PointObjectPositionService pointObjectPositionService;

/**
* @return the siteplan service
Expand Down Expand Up @@ -169,13 +169,19 @@ public static void setTopGraphService(
Services.topGraphService = topGraphService;
}

public static void setPointObjectService(
final PointObjectPositionService pointObjectPositionService) {
Services.pointObjectService = pointObjectPositionService;

/**
* @return the {@link PointObjectPositionService}
*/
public static PointObjectPositionService getPointObjectPositionService() {
return pointObjectPositionService;
}

public static PointObjectPositionService getPointObjectService() {
return pointObjectService;
/**
* @param pointObjectPositionService
* the {@link PointObjectPositionService}
*/
public static void setPointObjectPositionService(
final PointObjectPositionService pointObjectPositionService) {
Services.pointObjectPositionService = pointObjectPositionService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.set.model.planpro.BasisTypen.ENUMWirkrichtung;
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt;
import org.eclipse.set.model.planpro.Geodaten.GEO_Kante;
import org.eclipse.set.model.planpro.Geodaten.Strecke;
import org.eclipse.set.model.planpro.Geodaten.TOP_Kante;
import org.eclipse.set.model.planpro.Geodaten.TOP_Knoten;
import org.locationtech.jts.geom.Coordinate;
Expand Down Expand Up @@ -91,6 +92,14 @@ GEOKanteCoordinate getCoordinate(GEOKanteMetadata geoKante,
BigDecimal distance, BigDecimal lateralDistance,
ENUMWirkrichtung wirkrichtung);

/**
*
* @param geoKante
* the GEO_Kante
* @return the reference GEOKanteMetadata of this GEO_Kante
*/
GEOKanteMetadata getGeoKanteMetaData(GEO_Kante geoKante);

/**
* @param topKante
* the TOP_Kante to consider
Expand All @@ -108,7 +117,14 @@ GEOKanteMetadata getGeoKanteAt(TOP_Kante topKante, TOP_Knoten topKnoten,
* the TOP_Kante to consider
* @return a list of GEO_Kanten with metadata for the given TOP_Kante
*/
List<GEOKanteMetadata> getGeoKanten(TOP_Kante topKante);
List<GEOKanteMetadata> getTopKantenMetaData(TOP_Kante topKante);

/**
* @param strecke
* the Strecke
* @return a list of GEO_Kanten with metadata for the given Strecke
*/
List<GEOKanteMetadata> getStreckeMetaData(Strecke strecke);

/**
*
Expand All @@ -117,15 +133,30 @@ GEOKanteMetadata getGeoKanteAt(TOP_Kante topKante, TOP_Knoten topKnoten,
boolean isFindGeometryComplete();

/**
* Determine the projection coordinate of a Point on the Top_Kante and the
* distance of this coordinate to start node of the Top_Kante
* Determine the projection coordinate of a Point on the {@link TOP_Kante}
* and the topological distance of this coordinate to start node of the
* {@link TOP_Kante}
*
* @param coordinate
* the target coordinate
* @param topKante
* the {@link TOP_Kante}
* @return Pair<GEOKanteCoordinate, BigDecimal>
*/
Pair<GEOKanteCoordinate, BigDecimal> getProjectionCoordinateOnTopKante(
Coordinate coordinate, TOP_Kante topKante);

/**
* Determine the projection coordinate of a Point on the {@link Strecke} and
* the topological distance of this coordinate to start node of the
* {@link Strecke}
*
* @param coor
* @param coordinate
* the target coordinate
* @param topEdge
* the TOP_Kante
* @param strecke
* the {@link Strecke}
* @return Pair<GEOKanteCoordinate, BigDecimal>
*/
Pair<GEOKanteCoordinate, BigDecimal> getProjectionCoordinate(
Coordinate coor, TOP_Kante topEdge);
Pair<GEOKanteCoordinate, BigDecimal> getProjectionCoordinateOnStrecke(
Coordinate coordinate, Strecke strecke);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

import java.math.BigDecimal;

import org.eclipse.set.basis.Pair;
import org.eclipse.set.basis.geometry.GEOKanteCoordinate;
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt;
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt_TOP_Kante_AttributeGroup;
import org.eclipse.set.model.planpro.Geodaten.Strecke;

/**
*
Expand Down Expand Up @@ -45,4 +47,15 @@ GEOKanteCoordinate getCoordinate(
*/
GEOKanteCoordinate getCoordinate(Punkt_Objekt_TOP_Kante_AttributeGroup potk,
BigDecimal lateralDistance);

/**
* @param punktObjekt
* the punkt objekt
* @param strecke
* the strecke
* @return the coordinate of projection on Strecke and topological distance
* to start of Strecke
*/
Pair<GEOKanteCoordinate, BigDecimal> getProjectionOnStreck(
Punkt_Objekt punktObjekt, Strecke strecke);
}
Loading
Loading