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 @@ -33,7 +33,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.StreamSupport;

import org.eclipse.e4.core.services.events.IEventBroker;
Expand Down Expand Up @@ -100,55 +99,6 @@
GeoKanteGeometryService.class, EventHandler.class })
public class GeoKanteGeometryServiceImpl
implements GeoKanteGeometryService, EventHandler {
/**
* Helper class for storage geometry and metadata of Geo_Kante each sessions
*/
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<>();
}

/**
* @return the geometry data
*/
public Map<GEO_Kante, LineString> getEdgeGeometry() {
return edgeGeometry;
}

/**
* @return the geokante metada
*/
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;
// Acceptable tolerance between the length of all GEO_Kante on a TOP_Kante
// and the length of the TOP_Kante
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2025 DB InfraGO AG and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
*/
package org.eclipse.set.application.geometry;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.set.basis.geometry.GEOKanteMetadata;
import org.eclipse.set.model.planpro.Geodaten.GEO_Kante;
import org.eclipse.set.model.planpro.Geodaten.GEO_Knoten;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.LineString;

/**
* Store GeoKanteGeometry information for each session
*/
public 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<>();
}

/**
* @return the already found geometry
*/
public Map<GEO_Kante, LineString> getEdgeGeometry() {
return edgeGeometry;
}

/**
* @return the already found {@link GEOKanteMetadata}k
*/
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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25908
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Import-Package: org.apache.commons.csv;version="[1.9.0,2.0.0)",
org.eclipse.set.ppmodel.extensions.container,
org.eclipse.set.unittest.utils,
org.junit;version="[4.13.0,5.0.0)",
org.junit.jupiter.api,
org.junit.jupiter.api.function,
org.junit.jupiter.params;version="[5.12.0,6.0.0)",
org.junit.jupiter.params.provider;version="[5.12.0,6.0.0)",
org.junit.platform.commons.annotation;version="[1.12.0,2.0.0)"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.eclipse.set</groupId>
<artifactId>org.eclipse.set.feature.plazmodel.test</artifactId>
<version>2.6.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<packaging>eclipse-test-plugin</packaging>

<parent>
<relativePath>../../../</relativePath>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/
package org.eclipse.set.feature.plazmodel.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -34,8 +34,8 @@
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.eclipse.set.application.geometry.GeoKanteGeometryServiceImpl;
import org.eclipse.set.application.geometry.GeoKanteGeometrySessionData;
import org.eclipse.set.application.geometry.PointObjectPositionServiceImpl;
import org.eclipse.set.application.geometry.GeoKanteGeometryServiceImpl.GeoKanteGeometrySessionData;
import org.eclipse.set.basis.Pair;
import org.eclipse.set.basis.constants.ContainerType;
import org.eclipse.set.basis.geometry.GEOKanteMetadata;
Expand Down Expand Up @@ -97,13 +97,17 @@ private void thenExpectAllCoordinateAreEqualReference() {
case INITIAL -> "Start";
default -> "Alleinstehend";
};
String guid = coord.po().getIdentitaet().getWert();
String poGuid = coord.po().getIdentitaet().getWert();
String topKanteGuid = coord.potk().getIDTOPKante().getWert();
List<CSVRecord> csvEntries = csvRecords.stream()
.filter(entry -> entry.get(3).equals(guid)
&& entry.get(1).equals(state))
.filter(entry -> entry.get(1).equals(state))
.filter(entry -> entry.get(3).equals(poGuid))
.filter(entry -> entry.get(4).equals(topKanteGuid))
.toList();
assertFalse(csvEntries.isEmpty());
assertEquals(1, csvEntries.size());
assertEquals(1, csvEntries.size(), () -> {
return "Test";
});
CSVRecord csvEntry = csvEntries.getFirst();
String[] coordStrArry = getCoordinateString(EObjectExtensions
.getNullableObject(coord,
Expand All @@ -115,8 +119,8 @@ private void thenExpectAllCoordinateAreEqualReference() {
.orElse("Fehler bei der Berechnung");

// No need to compare State and GUID here. It is already valid
Map<Integer, String> valueToCompare = Map.of(4, crs, 5,
coordStrArry[0], 6, coordStrArry[1]);
Map<Integer, String> valueToCompare = Map.of(5, crs, 6,
coordStrArry[0], 7, coordStrArry[1]);
assertTrue(isSame(csvEntry, valueToCompare));
});
}
Expand Down Expand Up @@ -186,19 +190,18 @@ private void givenTopologicalCoordinaten(String testFile)
builder.build())) {
csvRecords = parser.getRecords();
// Remove CSV header info
csvRecords = csvRecords.subList(5, csvRecords.size());
csvRecords = csvRecords.subList(4, csvRecords.size());
}
}

private void givenGeoCoordinateValid() throws IllegalAccessException {
testee = new GeoCoordinateValid();
FieldUtils.writeField(testee, "topologischeCoordinaten",
FieldUtils.writeField(testee, "topologicalCoordinates",
Optional.empty(), true);
FieldUtils.writeField(testee, "alreadyFoundMetaData",
new ArrayList<GEOKanteMetadata>(), true);
FieldUtils.writeField(testee, "pointObjectPositionService",
new PointObjectPositionServiceImpl(), true);
FieldUtils.writeField(testee, "geometryService", geometryService, true);
}

private void givenGeoKanteGeometryService() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ public GEOKanteCoordinate calculateCoordinate(final ContainerType state,
}
final Optional<TopologicalCoordinate> target = alreadyCalulatedCoordinates
.stream()
.filter(ele -> ele.state() == state && ele.po() == po
&& ele.potk() == potk)
.filter(ele -> ele.state() == state)
.filter(ele -> ele.po()
.getIdentitaet()
.getWert()
.equals(po.getIdentitaet().getWert()))
.filter(ele -> ele.potk() == potk)
.findFirst();
if (target.isPresent()) {
return target.get().coordinate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
Expand All @@ -29,6 +31,7 @@
import org.eclipse.set.feature.plazmodel.Messages;
import org.eclipse.set.feature.plazmodel.check.GeoCoordinateValid;
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.Ortung.FMA_Komponente;
import org.eclipse.set.model.planpro.PZB.PZB_Element;
import org.eclipse.set.model.planpro.PlanPro.PlanPro_Schnittstelle;
Expand Down Expand Up @@ -73,7 +76,7 @@ public class ExportTopologicalCoordinatePart extends BasePart {
Prüfungszeit: %s
"Lfd. Nr.";"Zustand";"Objektart";"Guid";"Koordinatensystem";"x";"y"
"Lfd. Nr.";"Zustand";"Objektart";"Punkt_Objekt";"TopKante";"Koordinatensystem";"x";"y"
""";

ExportToCSV<String> csvExport;
Expand Down Expand Up @@ -166,8 +169,9 @@ private List<TopologicalCoordinate> getTopologicalCoordiante() {

final PlanPro_Schnittstelle planProSchnittstelle = getModelSession()
.getPlanProSchnittstelle();
List.of(ContainerType.FINAL, ContainerType.INITIAL,
ContainerType.SINGLE)
final List<Punkt_Objekt> pos = List
.of(ContainerType.FINAL, ContainerType.INITIAL,
ContainerType.SINGLE)
.stream()
.map(type -> PlanProSchnittstelleExtensions
.getContainer(planProSchnittstelle, type))
Expand All @@ -177,14 +181,21 @@ private List<TopologicalCoordinate> getTopologicalCoordiante() {
.filter(po -> PunktObjektExtensions.existLateralDistance(po)
|| po instanceof FMA_Komponente
|| po instanceof PZB_Element)
.forEach(po -> po.getPunktObjektTOPKante().forEach(potk -> {
final MultiContainer_AttributeGroup container = BasisAttributExtensions
.getContainer(po);
final ContainerType containerType = MultiContainer_AttributeGroupExtensions
.getContainerType(container);
geoCoordinateValid.calculateCoordinate(containerType, po,
potk);
}));
.toList();
final List<Entry<Punkt_Objekt, Punkt_Objekt_TOP_Kante_AttributeGroup>> entries = pos
.stream()
.flatMap(po -> po.getPunktObjektTOPKante()
.stream()
.map(potk -> Map.entry(po, potk)))
.toList();
entries.forEach(entry -> {
final MultiContainer_AttributeGroup container = BasisAttributExtensions
.getContainer(entry.getKey());
final ContainerType containerType = MultiContainer_AttributeGroupExtensions
.getContainerType(container);
geoCoordinateValid.calculateCoordinate(containerType,
entry.getKey(), entry.getValue());
});
return geoCoordinateValid.getTopologischeCoordinaten();
}

Expand All @@ -210,7 +221,8 @@ private static String transformToCsv(final int index,
.of(String.valueOf(index), state,
instanceClassName.substring(
instanceClassName.lastIndexOf(".") + 1),
topCoor.po().getIdentitaet().getWert(), crs,
topCoor.po().getIdentitaet().getWert(),
topCoor.potk().getIDTOPKante().getWert(), crs,
coord == null ? "Fehler bei der Berechnung"
: String.valueOf(coord.x).replace(".", ","),
coord == null ? "Fehler bei der Berechnung"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ Import-Package: org.apache.commons.lang3.reflect,
org.eclipse.emf.ecore.resource,
org.eclipse.emf.ecore.resource.impl,
org.eclipse.jdt.internal.junit.runner,
org.eclipse.set.application.geometry,
org.eclipse.set.model.siteplan,
org.eclipse.set.ppmodel.extensions.container,
org.eclipse.set.unittest.utils,
org.junit.jupiter.api;version="5.6.0",
org.junit.jupiter.api.function;version="5.6.0",
org.junit.jupiter.params;version="5.6.0",
org.junit.jupiter.params.provider;version="5.6.0"
org.junit.jupiter.params.provider;version="5.6.0",
org.osgi.service.event;version="[1.4.0,2.0.0)"
Bundle-ActivationPolicy: lazy
2 changes: 1 addition & 1 deletion java/bundles/org.eclipse.set.feature.siteplan.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.eclipse.set</groupId>
<artifactId>org.eclipse.set.feature.siteplan.test</artifactId>
<version>2.6.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<packaging>eclipse-test-plugin</packaging>

<parent>
<relativePath>../../../</relativePath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import java.io.IOException;

import org.eclipse.set.feature.siteplan.transform.utils.SiteplanTest;
import org.eclipse.set.model.siteplan.Siteplan;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -27,11 +25,11 @@ public class SiteplanTransformatorTest extends SiteplanTest {

@ParameterizedTest
@MethodSource("getSiteplanReferenceFiles")
void testSiteplanTransformSuccessful(final String file) throws IOException {
givenSiteplanTransformator();
void testSiteplanTransformSuccessful(final String file) throws Exception {
givenPlanProFile(file);

assertDoesNotThrow(() -> whenTransformingToSiteplanModel());
givenGeoKanteGeometryService();
givenSiteplanTransformator();
assertDoesNotThrow(this::whenTransformingToSiteplanModel);
// then no exception occurs
}

Expand Down
Loading
Loading