Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ public class GeoKanteGeometryServiceImpl
public static class GeoKanteGeometrySessionData {
private final Map<GEO_Kante, LineString> edgeGeometry;
private final Map<String, List<GEOKanteMetadata>> geoKanteMetadas;
private final Map<GEO_Knoten, Coordinate> geoNodeCoordinates;

/**
* COnstructor
*/
public GeoKanteGeometrySessionData() {
edgeGeometry = new ConcurrentHashMap<>();
geoKanteMetadas = new ConcurrentHashMap<>();
geoNodeCoordinates = new ConcurrentHashMap<>();
}

/**
Expand All @@ -128,6 +130,23 @@ public Map<GEO_Kante, LineString> getEdgeGeometry() {
public Map<String, List<GEOKanteMetadata>> getGeoKanteMetadas() {
return geoKanteMetadas;
}

/**
* @return the geometry coordinate of {@link GEO_Knoten}
*/
public Map<GEO_Knoten, Coordinate> getGeoNodeCoordinates() {
return geoNodeCoordinates;
}

/**
* Clear data
*/
public void clear() {
edgeGeometry.clear();
geoKanteMetadas.clear();
geoNodeCoordinates.clear();

}
}

private Thread findGeometryThread;
Expand Down Expand Up @@ -166,8 +185,7 @@ public void handleEvent(final Event event) {
// Only clear geometry data when main session change
final GeoKanteGeometrySessionData sessionData = getSessionData(
schnitstelle);
sessionData.getEdgeGeometry().clear();
sessionData.getGeoKanteMetadas().clear();
sessionData.clear();

findGeometryThread = new Thread(() -> {
try {
Expand Down Expand Up @@ -379,14 +397,12 @@ public GEOKanteCoordinate getCoordinate(final GEOKanteMetadata md,
RoundingMode.HALF_UP)
: BigDecimal.ZERO;
final SegmentPosition position = Geometries.getSegmentPosition(
md.getGeometry(),
GeoKnotenExtensions.getCoordinate(md.getGeoKnoten()),
md.getGeometry(), getGeoNodeCoordinate(md.getGeoKnoten()),
scaledDistance);
final LineSegment tangent = getTangent(md.getGeoKante(), position);
final GeoPosition coordinate = GeoKanteExtensions.getCoordinate(tangent,
position, lateralDistance, wirkrichtung);
return new GEOKanteCoordinate(coordinate, md,
getCRS(md.getGeoKnoten()));
return new GEOKanteCoordinate(coordinate, md);
}

@Override
Expand Down Expand Up @@ -505,9 +521,7 @@ private Pair<GEOKanteCoordinate, BigDecimal> getProjectionCoordinate(
if (relevantSegments == null) {
throw new IllegalArgumentException();
}
return new Pair<>(
new GEOKanteCoordinate(projectionCoor, metadata,
getCRS(metadata.getGeoKnoten())),
return new Pair<>(new GEOKanteCoordinate(projectionCoor, metadata),
projectionDistance);
} catch (final IllegalArgumentException | NullPointerException e) {
logger.error(
Expand Down Expand Up @@ -661,9 +675,9 @@ private List<GEOKanteMetadata> getGeoKantenMetadata(
final GEOKanteMetadata metadata = switch (geoArt) {
case final TOP_Kante topKante -> new GEOKanteMetadata(geoKante,
distance, geoKanteLength, bereichObjekte, topKante,
geoKnoten, geometry);
geoKnoten, geometry, getCRS(geoKnoten));
case final Strecke streck -> new GEOKanteMetadata(geoKante,
distance, geoKnoten, geometry);
distance, geoKnoten, geometry, getCRS(geoKnoten));
default -> throw new IllegalArgumentException(
"Unexpected value: " + geoArt); //$NON-NLS-1$
};
Expand All @@ -675,4 +689,10 @@ private List<GEOKanteMetadata> getGeoKantenMetadata(
geoKnoten = getOpposite(geoKante, geoKnoten);
}
}

private Coordinate getGeoNodeCoordinate(final GEO_Knoten node) {
final GeoKanteGeometrySessionData sessionData = getSessionData(node);
return sessionData.getGeoNodeCoordinates()
.computeIfAbsent(node, GeoKnotenExtensions::getCoordinate);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store coordinate of GEO_Knoten instead of find the coordinate each call

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ public class GEOKanteCoordinate {
* the {@link GeoPosition}
* @param geoKante
* the {@link GEOKanteMetadata}
* @param crs
* the coordinate system
*/
public GEOKanteCoordinate(final GeoPosition position,
final GEOKanteMetadata geoKante,
final ENUMGEOKoordinatensystem crs) {
final GEOKanteMetadata geoKante) {
this.position = position;
this.geoKante = geoKante;
this.crs = crs;
this.crs = geoKante.getGeoCRS();
this.topDistance = determineTopDistance(position.getCoordinate(),
geoKante);
}
Expand All @@ -60,15 +57,12 @@ public GEOKanteCoordinate(final GeoPosition position,
* the coordinate
* @param geoKante
* the {@link Bereich_Objekt}
* @param crs
* the coordinate system
*/
public GEOKanteCoordinate(final Coordinate coordinate,
final GEOKanteMetadata geoKante,
final ENUMGEOKoordinatensystem crs) {
final GEOKanteMetadata geoKante) {
this.position = new GeoPosition(coordinate, 0, 0);
this.geoKante = geoKante;
this.crs = crs;
this.crs = geoKante.getGeoCRS();
this.topDistance = determineTopDistance(coordinate, geoKante);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.function.Function;

import org.eclipse.set.model.planpro.Basisobjekte.Bereich_Objekt;
import org.eclipse.set.model.planpro.Geodaten.ENUMGEOKoordinatensystem;
import org.eclipse.set.model.planpro.Geodaten.GEO_Kante;
import org.eclipse.set.model.planpro.Geodaten.GEO_Knoten;
import org.eclipse.set.model.planpro.Geodaten.TOP_Kante;
Expand Down Expand Up @@ -57,6 +58,18 @@ public class GEOKanteMetadata {
*/
final BigDecimal length;

/**
* The coordinate system
*/
final ENUMGEOKoordinatensystem geoCRS;

/**
* @return the geometry coordinate system
*/
public ENUMGEOKoordinatensystem getGeoCRS() {
return geoCRS;
}

/**
* @return the GEO_Kante
*/
Expand Down Expand Up @@ -121,17 +134,20 @@ public BigDecimal getLength() {
* the start {@link GEO_Knoten} of this GEO_Kante
* @param geometry
* the geometry of this GEO_Kante
* @param geoCRS
* the geometry coordinate system
*
*/
public GEOKanteMetadata(final GEO_Kante geoKante, final BigDecimal start,
final BigDecimal length, final List<Bereich_Objekt> bereichObjekt,
final TOP_Kante topKante, final GEO_Knoten geoKnoten,
final LineString geometry) {
final LineString geometry, final ENUMGEOKoordinatensystem geoCRS) {
this.geoKante = geoKante;
this.start = start;
this.length = length;
this.geometry = geometry;
this.geoKnoten = geoKnoten;
this.geoCRS = geoCRS;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storage CRS direct in GEOKanteMetaData instead of find by each call

determineSegments(topKante, bereichObjekt);
}

Expand All @@ -144,14 +160,18 @@ public GEOKanteMetadata(final GEO_Kante geoKante, final BigDecimal start,
* the start {@link GEO_Knoten} of this GEO_Kante
* @param geometry
* the geometry of this GEO_Kante
* @param geoCRS
* the geometry coordinate system
*/
public GEOKanteMetadata(final GEO_Kante geoKante, final BigDecimal start,
final GEO_Knoten geoKnoten, final LineString geometry) {
final GEO_Knoten geoKnoten, final LineString geometry,
final ENUMGEOKoordinatensystem geoCRS) {
this.geoKante = geoKante;
this.start = start;
this.length = dermineLength().apply(geoKante);
this.geometry = geometry;
this.geoKnoten = geoKnoten;
this.geoCRS = geoCRS;
// As there is final no segmenting information, only use one segment
segments.add(new GEOKanteSegment(start, length));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
import org.eclipse.set.ppmodel.extensions.container.MultiContainer_AttributeGroup;
import org.eclipse.set.ppmodel.extensions.geometry.GEOKanteGeometryExtensions;
import org.eclipse.set.ppmodel.extensions.utils.IterableExtensions;
import org.eclipse.set.utils.geometry.GeometryOptionsBuilder;
import org.eclipse.set.utils.geometry.GeometryCalculationOptions.GeometryCalculationOptionsBuilder;
import org.eclipse.set.utils.geometry.GeometryOptionsBuilder;
import org.eclipse.xtext.xbase.lib.Pair;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.LineSegment;
Expand Down Expand Up @@ -411,8 +411,7 @@ private static GEOKanteCoordinate calculateCoordinate(
final LineSegment tangent = getTangent(md.getGeoKante(), position);
final GeoPosition geoPosition = getCoordinate(tangent, position,
lateralDistance, wirkrichtung);
return new GEOKanteCoordinate(geoPosition, md,
getCRS(md.getGeoKnoten()));
return new GEOKanteCoordinate(geoPosition, md);
}

private static GEOKanteMetadata getGeoKanteMetaData(
Expand Down Expand Up @@ -446,7 +445,8 @@ private static GEOKanteMetadata getGeoKanteMetaData(
return new GEOKanteMetadata(geoKante,
relevantGeoKnotenRange.startDistance(), geoKanteLength,
bereichObjekts, topkante,
relevantGeoKnotenRange.startNode(), geometry);
relevantGeoKnotenRange.startNode(), geometry,
getCRS(relevantGeoKnotenRange.startNode()));
} catch (final NullPointerException | IllegalArgumentException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.locationtech.jts.geom.Coordinate;
import org.osgi.service.component.annotations.Component;

import com.google.common.collect.Lists;
import com.google.common.collect.Streams;

/**
Expand Down Expand Up @@ -101,8 +102,10 @@ protected List<PlazError> run(
return;
}
try {
final List<GEO_Punkt> geoPunkteA = getGeoPunkte(geoKnotenA);
final List<GEO_Punkt> geoPunkteB = getGeoPunkte(geoKnotenB);
final List<GEO_Punkt> geoPunkteA = Lists
.newArrayList(getGeoPunkte(geoKnotenA));
final List<GEO_Punkt> geoPunkteB = Lists
.newArrayList(getGeoPunkte(geoKnotenB));
geoPunkteA.addAll(geoPunkteB);
final Map<ENUMGEOKoordinatensystem, List<GEO_Punkt>> geoPunktGroupByCRS = geoPunkteA
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class RouteTransformator extends BaseTransformator<Strecke> {
geoKante = geoKanten.get(0)
// Find the metadata for the current GEO_Kante
val metadata = new GEOKanteMetadata(geoKante, geoDistance,
geoKnoten, geometryService.getGeometry(geoKante))
geoKnoten, geometryService.getGeometry(geoKante), geoKnoten.CRS)

// For every 100m on this GEO_Kante, determine the point
while (offset <= metadata.end.doubleValue) {
Expand All @@ -153,7 +153,8 @@ class RouteTransformator extends BaseTransformator<Strecke> {
// Add the point to the result
try {
result.add(
geometryService.getCoordinate(metadata, BigDecimal.valueOf(offset), BigDecimal.ZERO,
geometryService.getCoordinate(metadata,
BigDecimal.valueOf(offset), BigDecimal.ZERO,
ENUMWirkrichtung.ENUM_WIRKRICHTUNG_IN) -> offset)
offset += STRECKE_KM_SPACING
} catch (GeometryException exc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.math.BigDecimal
import java.math.RoundingMode
import java.util.List
import java.util.Set
import java.util.function.Supplier
import org.eclipse.e4.core.services.events.IEventBroker
import org.eclipse.set.basis.IModelSession
import org.eclipse.set.basis.constants.ContainerType
Expand All @@ -21,6 +22,7 @@ import org.eclipse.set.basis.constants.ToolboxConstants
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.basis.geometry.GeoPosition
import org.eclipse.set.core.services.geometry.GeoKanteGeometryService
import org.eclipse.set.feature.siteplan.SiteplanConstants
import org.eclipse.set.feature.siteplan.positionservice.PositionService
Expand Down Expand Up @@ -265,19 +267,23 @@ class TrackTransformator extends BaseTransformator<TOP_Kante> implements EventHa
])
result.type.addAll(segment.getTrackType(md))
val geoKnotenA = geoKante.geoKnotenA
// Record an error if there is not exactly one track type defined for the segment
val center = geoKante.getCoordinate(geoKnotenA,
geoKante.GEOKanteAllg.GEOLaenge.wert.divide(BigDecimal.valueOf(2),
ToolboxConstants.ROUNDING_TO_PLACE, RoundingMode.HALF_UP),
BigDecimal.ZERO, ENUMWirkrichtung.ENUM_WIRKRICHTUNG_IN)
// Record an error if there is not exactly one track type defined for the segment
// Calculate center coordinate only by necessary
val Supplier<GeoPosition> getCenterSupplier = [
geoKante.getCoordinate(geoKnotenA,
geoKante.GEOKanteAllg?.GEOLaenge?.wert?.divide(
BigDecimal.valueOf(2), ToolboxConstants.ROUNDING_TO_PLACE,
RoundingMode.HALF_UP) ?: BigDecimal.ZERO, BigDecimal.ZERO,
ENUMWirkrichtung.ENUM_WIRKRICHTUNG_IN)
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculate Center coordinate only by exist error

val guid = geoKante.identitaet.wert
if (result.type.length > 1 && existsTrackType) {
recordError(guid, String.format(ERROR_MULTIPLE_GLEIS_ART, guid),
positionService.transformCoordinate(center.getCoordinate,
positionService.transformCoordinate(getCenterSupplier.get.getCoordinate,
geoKnotenA.CRS))
} else if (result.type.length == 0 && existsTrackType) {
recordError(guid, String.format(ERROR_NO_GLEIS_ART, guid),
positionService.transformCoordinate(center.getCoordinate,
positionService.transformCoordinate(getCenterSupplier.get.getCoordinate,
geoKnotenA.CRS))
}

Expand Down Expand Up @@ -410,13 +416,9 @@ class TrackTransformator extends BaseTransformator<TOP_Kante> implements EventHa
return result;
} else {
if (result.empty) {
result.add(
new GEOKanteCoordinate(lastCoordinate, geoKante,
geoKante.geoKnoten.CRS))
result.add(new GEOKanteCoordinate(lastCoordinate, geoKante))
}
result.add(
new GEOKanteCoordinate(coordinate, geoKante,
geoKante.geoKnoten.CRS))
result.add(new GEOKanteCoordinate(coordinate, geoKante))
distance +=
BigDecimal.valueOf(lastCoordinate.distance(coordinate))
lastCoordinate = coordinate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class GeoKnotenExtensions extends BasisObjektExtensions {
*
* @returns the GEO-Punkte for this GEO-Knoten
*/
def static List<GEO_Punkt> getGeoPunkte(
def static Iterable<GEO_Punkt> getGeoPunkte(
GEO_Knoten knoten
) {
return knoten.container.GEOPunkt.filter [
IDGEOKnoten !== null && IDGEOKnoten?.wert == knoten.identitaet.wert
].toList
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need transform to list each call

]
}

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ class GeoKnotenExtensions extends BasisObjektExtensions {
* @returns the coordinate of this GEO Knoten
*/
def static Coordinate getCoordinate(GEO_Knoten geoKnoten) {
val List<GEO_Punkt> geoPunkte = geoKnoten.geoPunkte
val geoPunkte = geoKnoten.geoPunkte
val GEO_Punkt geoPunkt = geoPunkte.getGeoPunkt(geoKnoten)
return geoPunkt.coordinate
}
Expand All @@ -102,14 +102,15 @@ class GeoKnotenExtensions extends BasisObjektExtensions {
val crs = geoKnoten.geoPunkte.map [
GEOPunktAllg?.GEOKoordinatensystem?.wert
].toSet.uniqueOrNull
return crs !== null ? crs : ENUMGEOKoordinatensystem.
ENUMGEO_KOORDINATENSYSTEM_SONSTIGE
return crs !== null
? crs
: ENUMGEOKoordinatensystem.ENUMGEO_KOORDINATENSYSTEM_SONSTIGE
}

def static GEO_Punkt getGeoPunkt(List<GEO_Punkt> geoPunkte,
def static GEO_Punkt getGeoPunkt(Iterable<GEO_Punkt> geoPunkte,
GEO_Knoten geoKnoten) {
if (geoPunkte.size === 1) {
return geoPunkte.first
return geoPunkte.get(0)
}
val crs = geoPunkte.map[GEOPunktAllg?.GEOKoordinatensystem?.wert].toSet
// A Geo_Knoten reference to two Geo_Punkt only when the Geo_Knoten have 2 Coordinatensystem
Expand All @@ -119,7 +120,7 @@ class GeoKnotenExtensions extends BasisObjektExtensions {
Integer.valueOf(geoPunkte.size()),
geoKnoten.getIdentitaet().getWert()))
}

return geoPunkte.firstOrNull
}

Expand Down
Loading