diff --git a/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLine.java b/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLine.java index dff20ee2f6e4f8c0d0efc3ffe6ce35b6d18ac92f..5cea520a3e2673e08e3b537611f8977d7dc7e05f 100644 --- a/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLine.java +++ b/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLine.java @@ -78,21 +78,21 @@ public class PolyLine extends BaseEntity { return mpLast; } - public Boolean isNullLine() { + public boolean isNullLine() { return isNullLine(0.00); } - public Boolean isNullLine(Double tolerance) { + public boolean isNullLine(double tolerance) { // If either start or end Segment is null, return immediately if (mpFirst == null || mpLast == null) { return true; } PolyLineSegment currentSegment = mpFirst; - Double length = 0.00; + double length = 0.00; // Add length of all segments, starting from mpFirst do { - Double segmentLength = currentSegment.getLengthVector().getLength(); + double segmentLength = currentSegment.getLengthVector().getLength(); if (segmentLength > tolerance) { length += segmentLength; } @@ -103,15 +103,13 @@ public class PolyLine extends BaseEntity { } while (currentSegment.getNext() != null); // Since mpLast will be missed due to loop condition add its length afterwards - Double segmentLength = mpLast.getLengthVector().getLength(); + double segmentLength = mpLast.getLengthVector().getLength(); if (segmentLength > tolerance) { length += segmentLength; } // Check if total length is less than the set tolerance - if (length <= tolerance) { - return true; - } - return false; + return length <= tolerance; + } diff --git a/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLineSegment.java b/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLineSegment.java index 5af8039ab56e4abaf8b4f862b1984fb02887d0a8..fd69514259e2a9cf5845526e8e625a2a9fe0058f 100644 --- a/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLineSegment.java +++ b/CityDoctorParent/CityDoctorEdge/src/main/java/de/hft/stuttgart/citydoctor2/edge/PolyLineSegment.java @@ -59,8 +59,7 @@ public class PolyLineSegment extends BaseEntity { } public Vector3d getLengthVector() { - Vector3d representation = mpEnd.getPoint().minus(mpStart.getPoint()); - return representation; + return mpEnd.getPoint().minus(mpStart.getPoint()); } @Override diff --git a/CityDoctorParent/CityDoctorValidation/src/test/java/de/hft/stuttgart/citydoctor2/checks/geometry/SolidSelfIntCheckTest.java b/CityDoctorParent/CityDoctorValidation/src/test/java/de/hft/stuttgart/citydoctor2/checks/geometry/SolidSelfIntCheckTest.java index f4b3a2155a7f1856688c6b3d75b2d7a87bf4e4d6..e6cff8ebc9bd37a7ed77c1f1edef0ce0afe1e43a 100644 --- a/CityDoctorParent/CityDoctorValidation/src/test/java/de/hft/stuttgart/citydoctor2/checks/geometry/SolidSelfIntCheckTest.java +++ b/CityDoctorParent/CityDoctorValidation/src/test/java/de/hft/stuttgart/citydoctor2/checks/geometry/SolidSelfIntCheckTest.java @@ -21,14 +21,8 @@ package de.hft.stuttgart.citydoctor2.checks.geometry; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.List; - -import org.apache.logging.log4j.core.util.internal.Status; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import de.hft.stuttgart.citydoctor2.check.CheckResult; @@ -84,16 +78,20 @@ public class SolidSelfIntCheckTest { assertFalse(m.getBuildings().get(0).containsAnyError()); } - @Test - public void testKnownFalsePositiveExample1() throws CityGmlParseException, InvalidGmlFileException { + + private void testFalsePositiveExample(String gml_filepath) throws CityGmlParseException, InvalidGmlFileException { ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); config.setSchematronFilePathInGlobalParameters(null); - CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest-known_false_positive1.gml", config.getParserConfiguration()); + CityDoctorModel m = CityGmlParser.parseCityGmlFile(gml_filepath, config.getParserConfiguration()); Checker c = new Checker(config, m); c.runChecks(); Building building = m.getBuildings().get(0); System.out.println(building.containsAnyError()); - // Example1 Building has some BuildingInstallations, which throw semantic errors + /* + * The examples have no actual self-intersections, but can contain other actual model defects. + * If an error is detected, it is thus required to check if the + * False-Positive self-intersection triggered it. + */ if (building.containsAnyError()) { Geometry buildingGeom = building.getGeometry(GeometryType.SOLID, Lod.LOD2); buildingGeom.clearCheckResults(); @@ -101,83 +99,22 @@ public class SolidSelfIntCheckTest { check.check(buildingGeom); CheckResult cr = buildingGeom.getCheckResult(check); assertNotNull(cr); - //Ensure that checker did not find a self intersection + //Ensure that the found error is not a self-intersection error assertEquals("Known False-Positive self-intersection was detected as error", ResultStatus.OK, cr.getResultStatus()); } - - } @Test - public void testKnownFalsePositiveExample2() throws CityGmlParseException, InvalidGmlFileException { - ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); - config.setSchematronFilePathInGlobalParameters(null); - CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest-known_false_positive2.gml", config.getParserConfiguration()); - Checker c = new Checker(config, m); - c.runChecks(); - Building building = m.getBuildings().get(0); - // If an error was found, check if error is SolidSelfInt - if (building.containsAnyError()) { - Geometry buildingGeom = building.getGeometry(GeometryType.SOLID, Lod.LOD2); - buildingGeom.clearCheckResults(); - SolidSelfIntCheck check = new SolidSelfIntCheck(); - check.check(buildingGeom); - CheckResult cr = buildingGeom.getCheckResult(check); - assertNotNull(cr); - //Ensure that checker did not find the false-positive self intersection - assertEquals("Known False-Positive self-intersection was detected as error", ResultStatus.OK, cr.getResultStatus()); - } - - + public void testKnownFalsePositiveExample1() throws CityGmlParseException, InvalidGmlFileException { + testFalsePositiveExample("src/test/resources/SolidSelfIntTest-known_false_positive1.gml"); } - @Ignore("Only run this test locally. The big mesh causes the CI/CD-Runner to crash due to running out of RAM") @Test - public void testKnownFalsePositiveExample_BigMesh1() throws CityGmlParseException, InvalidGmlFileException { - ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); - config.setSchematronFilePathInGlobalParameters(null); - CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest-known_false_positive_Big_Mesh1.gml", config.getParserConfiguration()); - Checker c = new Checker(config, m); - c.runChecks(); - Building building = m.getBuildings().get(0); - // If an error was found, check if error is SolidSelfInt - if (building.containsAnyError()) { - Geometry buildingGeom = building.getGeometry(GeometryType.SOLID, Lod.LOD2); - buildingGeom.clearCheckResults(); - SolidSelfIntCheck check = new SolidSelfIntCheck(); - check.check(buildingGeom); - CheckResult cr = buildingGeom.getCheckResult(check); - assertNotNull(cr); - assertEquals("Known False-Positive self-intersection was detected as error", ResultStatus.OK, cr.getResultStatus()); - } - - + public void testKnownFalsePositiveExample2() throws CityGmlParseException, InvalidGmlFileException { + testFalsePositiveExample("src/test/resources/SolidSelfIntTest-known_false_positive2.gml"); } - - @Ignore("Only run this test locally. The big mesh causes the CI/CD-Runner to crash due to running out of RAM") - @Test - public void testKnownFalsePositiveExample_BigMesh2() throws CityGmlParseException, InvalidGmlFileException { - ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); - config.setSchematronFilePathInGlobalParameters(null); - CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest-known_false_positive_Big_Mesh2.gml", config.getParserConfiguration()); - Checker c = new Checker(config, m); - c.runChecks(); - Building building = m.getBuildings().get(0); - // If an error was found, check if error is SolidSelfInt - if (building.containsAnyError()) { - Geometry buildingGeom = building.getGeometry(GeometryType.SOLID, Lod.LOD2); - buildingGeom.clearCheckResults(); - SolidSelfIntCheck check = new SolidSelfIntCheck(); - check.check(buildingGeom); - CheckResult cr = buildingGeom.getCheckResult(check); - assertNotNull(cr); - //Ensure that checker did not find the false-positive self intersection - assertEquals("Known False-Positive self-intersection was detected as error", ResultStatus.OK, cr.getResultStatus()); - } + - - } - - } +