Commit d7629865 authored by Numanoglu's avatar Numanoglu
Browse files

debugging sweep on real gml wip

parent aeae0705
Pipeline #12499 passed with stage
in 2 minutes and 39 seconds
package de.hft.stuttgart.citydoctor2.healing; package de.hft.stuttgart.citydoctor2.healing;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
...@@ -13,6 +12,13 @@ import java.util.LinkedHashMap; ...@@ -13,6 +12,13 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
...@@ -57,6 +63,41 @@ public class SweepUtilitiesRealGmlTest { ...@@ -57,6 +63,41 @@ public class SweepUtilitiesRealGmlTest {
private static final String PLANAR_DISTANCE_TOLERANCE = "0.01"; private static final String PLANAR_DISTANCE_TOLERANCE = "0.01";
private static final String PLANAR_CHECK_TYPE = PlanarCheck.DISTANCE; private static final String PLANAR_CHECK_TYPE = PlanarCheck.DISTANCE;
private static final boolean PRINT_EACH_RELEVANT_SWEEP_VERTEX = true; private static final boolean PRINT_EACH_RELEVANT_SWEEP_VERTEX = true;
private static final int MAX_HEAL_ITERATIONS = 30;
private static final String[] QUIET_LOGGERS = { "de.hft.stuttgart.citydoctor2.check.Checker",
"de.hft.stuttgart.citydoctor2.check.Checkable",
"de.hft.stuttgart.citydoctor2.parser.ImplicitGeometryHolder", "com.zaxxer.hikari" };
private static final Map<String, LoggerConfig> ORIGINAL_LOGGER_CONFIGS = new HashMap<>();
@BeforeClass
public static void quietNoisyRealGmlLoggers() {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration configuration = context.getConfiguration();
for (String loggerName : QUIET_LOGGERS) {
LoggerConfig ownConfig = configuration.getLoggers().get(loggerName);
if (ownConfig != null) {
ORIGINAL_LOGGER_CONFIGS.put(loggerName, ownConfig);
}
LoggerConfig quietConfig = new LoggerConfig(loggerName, Level.WARN, true);
configuration.addLogger(loggerName, quietConfig);
}
context.updateLoggers();
}
@AfterClass
public static void restoreNoisyRealGmlLoggers() {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration configuration = context.getConfiguration();
for (String loggerName : QUIET_LOGGERS) {
LoggerConfig originalConfig = ORIGINAL_LOGGER_CONFIGS.get(loggerName);
if (originalConfig != null) {
configuration.addLogger(loggerName, originalConfig);
} else {
configuration.removeLogger(loggerName);
}
}
context.updateLoggers();
}
/** /**
* Reales ganzes CityGML:NpR1 . Der Test lädt die Datei über den * Reales ganzes CityGML:NpR1 . Der Test lädt die Datei über den
...@@ -68,6 +109,13 @@ public class SweepUtilitiesRealGmlTest { ...@@ -68,6 +109,13 @@ public class SweepUtilitiesRealGmlTest {
checkRealGmlAndTrySweepHealing("src/test/resources/sweep/non-planar-distance-plane/NP_R_1.gml"); checkRealGmlAndTrySweepHealing("src/test/resources/sweep/non-planar-distance-plane/NP_R_1.gml");
} }
@Test
public void reportsAndTriesSweepForLoD21005WithVal3dityErrors()
throws CityGmlParseException, IOException, InvalidGmlFileException {
checkRealGmlAndTrySweepHealing(
"src/test/resources/sweep/non-planar-distance-plane/LoD2_10_05_mit_val3dity_volumenfehlern.gml");
}
private void checkRealGmlAndTrySweepHealing(String path) private void checkRealGmlAndTrySweepHealing(String path)
throws CityGmlParseException, IOException, InvalidGmlFileException { throws CityGmlParseException, IOException, InvalidGmlFileException {
String fileName = Path.of(path).getFileName().toString(); String fileName = Path.of(path).getFileName().toString();
...@@ -101,34 +149,54 @@ public class SweepUtilitiesRealGmlTest { ...@@ -101,34 +149,54 @@ public class SweepUtilitiesRealGmlTest {
int healedCount = 0; int healedCount = 0;
int unhealedCount = 0; int unhealedCount = 0;
for (int i = 0; i < errors.size(); i++) { for (int i = 0; i < MAX_HEAL_ITERATIONS; i++) {
NonPlanarPolygonDistancePlaneError error = errors.get(i); List<CheckError> currentRawErrors = collectErrors(model);
SweepUtilities utilities = new SweepUtilities(error, POINT_ON_PLANE_TOLERANCE, List<NonPlanarPolygonDistancePlaneError> currentDistancePlaneErrors = collectUniqueDistancePlaneErrors(
SWEEP_EDGE_AND_ANGLE_TOLERANCE); currentRawErrors);
if (currentDistancePlaneErrors.isEmpty()) {
break;
}
NonPlanarPolygonDistancePlaneError error = currentDistancePlaneErrors.get(0);
int distancePlaneBefore = currentDistancePlaneErrors.size();
System.out.println(); System.out.println();
System.out.println("Fehler " + (i + 1) + " von " + errors.size() + " in Datei " + fileName); System.out.println("Heiliteration " + (i + 1) + " in Datei " + fileName);
System.out.println("DistancePlane-Fazetten vor der Heilung: " + distancePlaneBefore);
printErrorSummary(error); printErrorSummary(error);
SweepUtilities utilities = new SweepUtilities(error, POINT_ON_PLANE_TOLERANCE,
SWEEP_EDGE_AND_ANGLE_TOLERANCE);
utilities.initialize(); utilities.initialize();
printSweepVertexSummary(utilities.getSweepVertices()); printSweepVertexSummary(utilities.getSweepVertices());
boolean calculated = utilities.calculate(); boolean calculated = utilities.calculate();
System.out.println("calculate(): " + calculated); System.out.println("calculate(): " + calculated);
String healingMethod;
boolean methodSucceeded;
if (calculated) { if (calculated) {
utilities.doHeal(); utilities.doHeal();
boolean polygonPlanarAfterHealing = isPolygonPlanar(error.getPolygon()); healingMethod = "SweepUtilities";
System.out.println("PlanarCheck nach doHeal() für diese Fazette: " + polygonPlanarAfterHealing); methodSucceeded = true;
assertTrue("Die aktuell geheilte Fazette muss nach doHeal() planar sein.", polygonPlanarAfterHealing); } else {
recheckWholeModel(checker, model); HealPlanarPolygonError fallback = new HealPlanarPolygonError();
int remainingDistancePlaneFacets = printModelErrorSummaryAfterHealing(model); methodSucceeded = fallback.visit(error, null);
assertEquals("Nach doHeal() und erneutem Checker-Lauf dürfen keine DistancePlane-Fazetten übrig sein.", healingMethod = "Alte Heal-Methode als Fallback";
0, remainingDistancePlaneFacets); }
if (polygonPlanarAfterHealing) {
healedCount++; System.out.println("Erfolgreiche Heilmethode: " + (methodSucceeded ? healingMethod : "keine"));
} else { if (!methodSucceeded) {
unhealedCount++; unhealedCount++;
} break;
}
boolean polygonPlanarAfterHealing = isPolygonPlanar(error.getPolygon());
System.out.println("PlanarCheck nach Heilmethode für diese Fazette: " + polygonPlanarAfterHealing);
recheckWholeModel(checker, model);
int distancePlaneAfter = printModelErrorSummaryAfterHealing(model);
System.out.println("DistancePlane-Fazetten vorher -> nachher: " + distancePlaneBefore + " -> "
+ distancePlaneAfter);
if (distancePlaneAfter <= distancePlaneBefore) {
healedCount++;
} else { } else {
unhealedCount++; unhealedCount++;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment