diff --git a/CityDoctorParent/CityDoctorCheckResult/pom.xml b/CityDoctorParent/CityDoctorCheckResult/pom.xml index 0fffb0ae9f9a28da449fea142860892de0a14469..1267661a563430afbd5078f62ef68624ee3d1268 100644 --- a/CityDoctorParent/CityDoctorCheckResult/pom.xml +++ b/CityDoctorParent/CityDoctorCheckResult/pom.xml @@ -5,7 +5,7 @@ de.hft.stuttgart CityDoctorParent - 3.10.1-SNAPSHOT + 3.10.1 CityDoctorCheckResult diff --git a/CityDoctorParent/CityDoctorEdge/pom.xml b/CityDoctorParent/CityDoctorEdge/pom.xml index 7037b33501da6a9e7cf387ae490b48e69e4d58f8..263419095c9ca7be3daded035fd6da82c4924192 100644 --- a/CityDoctorParent/CityDoctorEdge/pom.xml +++ b/CityDoctorParent/CityDoctorEdge/pom.xml @@ -5,7 +5,7 @@ de.hft.stuttgart CityDoctorParent - 3.10.1-SNAPSHOT + 3.10.1 CityDoctorEdge diff --git a/CityDoctorParent/CityDoctorModel/pom.xml b/CityDoctorParent/CityDoctorModel/pom.xml index 668ddb2869f18f848f3dd3e48836b65829a0e406..0364527e62b8ab031f066ce0b6ae8b4e7482d81b 100644 --- a/CityDoctorParent/CityDoctorModel/pom.xml +++ b/CityDoctorParent/CityDoctorModel/pom.xml @@ -5,7 +5,7 @@ de.hft.stuttgart CityDoctorParent - 3.10.1-SNAPSHOT + 3.10.1 diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/UnknownCheckError.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/UnknownCheckError.java index e583cc5fc738d6dabda33ff85bbbe4bfcf5069b3..b3702d9c58c69934b852aa63a1ff900c2987b8c5 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/UnknownCheckError.java +++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/UnknownCheckError.java @@ -49,6 +49,12 @@ public class UnknownCheckError implements CheckError { this.e = e; checkId = check.getCheckId(); } + + public UnknownCheckError(Checkable c, Exception e, CheckId checkId) { + this.c = c; + this.e = e; + this.checkId = checkId; + } public CheckId getCheck() { return checkId; diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModel.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModel.java index 0619e893d1b61986a6390663232b451606a07005..a9cc1c89f3a6b51f1a1675be5c0013a0ff9fa3a5 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModel.java +++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModel.java @@ -288,7 +288,12 @@ public class CityDoctorModel { for (Entry e : errorCount.entrySet()) { ErrorStatistics stats = new ErrorStatistics(); stats.setAmount(e.getValue().get()); - stats.setName(QualityADEUtils.mapErrorIdToAdeId(e.getKey())); + de.hft.stuttgart.quality.model.jaxb.ErrorId adeId = QualityADEUtils.mapErrorIdToAdeId(e.getKey()); + if (adeId == null) { + // error that is not part of the ade standard + continue; + } + stats.setName(adeId); statistics.getErrorStatistics().add(stats); } statistics.setNumErrorBuildings(countValidatedCityObjects(buildings)); diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtils.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtils.java index ff60c50202285d9e94fa313ddf5dff2fe5b06740..474234c06ddefca02e6e08e9c2a72c7dc50e5cc2 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtils.java +++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtils.java @@ -29,6 +29,7 @@ import org.citygml4j.model.gml.geometry.primitives.DirectPosition; import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.ErrorId; +import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError; import de.hft.stuttgart.citydoctor2.datastructure.CityObject; import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.quality.model.Edge; @@ -69,7 +70,13 @@ public class QualityADEUtils { res.setResult(ResultType.ERROR); Set errorSet = new HashSet<>(errors); for (CheckError e : errorSet) { - e.convertToQualityAdeDatastructure().ifPresent(res.getErrors()::add); + if (e instanceof UnknownCheckError) { + // an error happened while checking + // set to not checked + res.setResult(ResultType.NOT_CHECKED); + } else { + e.convertToQualityAdeDatastructure().ifPresent(res.getErrors()::add); + } } } } else { @@ -141,7 +148,8 @@ public class QualityADEUtils { case "SE_ATTRIBUTE_MISSING": return de.hft.stuttgart.quality.model.jaxb.ErrorId.SE_ATTRIBUTE_MISSING; default: - throw new IllegalStateException("Cannot map " + key + " to ADE Error Id"); + return null; +// throw new IllegalStateException("Cannot map " + key + " to ADE Error Id"); } } diff --git a/CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtilsTest.java b/CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtilsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..087099e7336b09f65a0b65e51f7a7895e9a487f5 --- /dev/null +++ b/CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/utils/QualityADEUtilsTest.java @@ -0,0 +1,57 @@ +/*- + * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart + * + * This file is part of CityDoctor2. + * + * CityDoctor2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CityDoctor2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with CityDoctor2. If not, see . + */ +package de.hft.stuttgart.citydoctor2.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.citygml4j.model.citygml.ade.ADEComponent; +import org.junit.Test; + +import de.hft.stuttgart.citydoctor2.check.CheckId; +import de.hft.stuttgart.citydoctor2.check.CheckResult; +import de.hft.stuttgart.citydoctor2.check.ResultStatus; +import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError; +import de.hft.stuttgart.citydoctor2.datastructure.Building; +import de.hft.stuttgart.quality.model.ValidationResult; +import de.hft.stuttgart.quality.model.jaxb.ResultType; + +public class QualityADEUtilsTest { + + @Test + public void testWriteQualityADE() { + Building b = new Building(); + org.citygml4j.model.citygml.building.Building gmlB = new org.citygml4j.model.citygml.building.Building(); + b.setGmlObject(gmlB); + List coADE = gmlB.getGenericApplicationPropertyOfCityObject(); + assertTrue(coADE.isEmpty()); + b.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, new UnknownCheckError(b, new NullPointerException(), CheckId.C_GE_P_HOLE_OUTSIDE))); + QualityADEUtils.writeQualityAde(b); + coADE = gmlB.getGenericApplicationPropertyOfCityObject(); + assertFalse(coADE.isEmpty()); + assertEquals(1, coADE.size()); + ADEComponent adeComponent = coADE.get(0); + ValidationResult valResult = (ValidationResult) adeComponent; + assertEquals(ResultType.NOT_CHECKED, valResult.getResult()); + } + +} diff --git a/CityDoctorParent/CityDoctorValidation/pom.xml b/CityDoctorParent/CityDoctorValidation/pom.xml index d843a8b094b27ed1fe8d90638cab40b35a63438b..21682985ebdb1450aeb382f7cf82742bea370caa 100644 --- a/CityDoctorParent/CityDoctorValidation/pom.xml +++ b/CityDoctorParent/CityDoctorValidation/pom.xml @@ -5,7 +5,7 @@ de.hft.stuttgart CityDoctorParent - 3.10.1-SNAPSHOT + 3.10.1 CityDoctorValidation CityDoctorValidation diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java index a78eaddb1ec552130c389522b1d8429af5582fc8..107adbf8952fca802107f9f541271b9ce14e6675 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java @@ -158,7 +158,7 @@ public class Checker { if (pdfFile.getParentFile() != null) { pdfFile.getParentFile().mkdirs(); } - Reporter reporter = new PdfReporter("assets/Logo.png"); + Reporter reporter = new PdfReporter(); try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pdfFile.getAbsolutePath()))) { reporter.writeReport(checkConfig, bos, model, config); } catch (IOException | CheckReportWriteException e) { @@ -721,7 +721,7 @@ public class Checker { } if (layer.isEmpty()) { throw new IllegalStateException( - "There are checks that have dependencies that are not executed or are unknown"); + "There are checks that have dependencies that are not executed or are unknown, aborting"); } result.add(layer); for (Check c : layer) { @@ -744,12 +744,11 @@ public class Checker { public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException { - streamCheck(inputFile, xmlOutput, pdfOutput, config, "assets/Logo.png", null, outputFile); + streamCheck(inputFile, xmlOutput, pdfOutput, config, null, outputFile); } public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config, - String logoLocation, FeatureCheckedListener l, String outputFile) - throws IOException, CityGmlParseException { + FeatureCheckedListener l, String outputFile) throws IOException, CityGmlParseException { try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput); BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) { Checker c = new Checker(config, null); @@ -757,7 +756,7 @@ public class Checker { // create reporter if available XmlStreamReporter xmlReporter = getXmlReporter(config, xmlBos, fileName); - PdfStreamReporter pdfReporter = getPdfReporter(config, logoLocation, pdfBos, fileName); + PdfStreamReporter pdfReporter = getPdfReporter(config, pdfBos, fileName); // execute schematron first SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, inputFile); @@ -784,11 +783,11 @@ public class Checker { return xmlReporter; } - private static PdfStreamReporter getPdfReporter(ValidationConfiguration config, String logoLocation, - BufferedOutputStream pdfBos, String fileName) { + private static PdfStreamReporter getPdfReporter(ValidationConfiguration config, BufferedOutputStream pdfBos, + String fileName) { PdfStreamReporter pdfReporter; if (pdfBos != null) { - pdfReporter = new PdfStreamReporter(pdfBos, fileName, config, logoLocation); + pdfReporter = new PdfStreamReporter(pdfBos, fileName, config); } else { pdfReporter = null; } diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/StreamCityGmlConsumer.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/StreamCityGmlConsumer.java index 1e4753128f6585797f6c9abaeb6d59e59d6690c0..bb550dba9a1296770e4cd769ab2aeb288c566bda 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/StreamCityGmlConsumer.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/StreamCityGmlConsumer.java @@ -168,7 +168,11 @@ public class StreamCityGmlConsumer implements CityGmlConsumer { for (Entry e : errorCount.entrySet()) { ErrorStatistics stats = new ErrorStatistics(); stats.setAmount(e.getValue().get()); - stats.setName(QualityADEUtils.mapErrorIdToAdeId(e.getKey())); + de.hft.stuttgart.quality.model.jaxb.ErrorId adeId = QualityADEUtils.mapErrorIdToAdeId(e.getKey()); + if (adeId == null) { + // error that is not part of the ade standard + continue; + } statistics.getErrorStatistics().add(stats); } val.setStatistics(statistics); diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfErrorHandler.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfErrorHandler.java index e60fec839a47c3212054cfac03ca5605b2728ce3..41cf9b2223147fc8a81dba3b3f22b6870b2d79a9 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfErrorHandler.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfErrorHandler.java @@ -73,25 +73,26 @@ public class PdfErrorHandler implements ErrorReport { } block.newLine(10); block.addText("", TAG_COLOR); - if (p.getInnerRings().isEmpty()) { - return; - } - block.newLine(10); - block.addText("", TAG_COLOR); - for (LinearRing ring : p.getInnerRings()) { - block.newLine(20); - block.addText("", TAG_COLOR); - for (Vertex v : p.getExteriorRing().getVertices()) { - block.newLine(30); - addVertexToBlock(block, v); + if (!p.getInnerRings().isEmpty()) { + block.newLine(10); + block.addText("", TAG_COLOR); + for (LinearRing ring : p.getInnerRings()) { + block.newLine(20); + block.addText("", TAG_COLOR); + for (Vertex v : p.getExteriorRing().getVertices()) { + block.newLine(30); + addVertexToBlock(block, v); + } + block.newLine(20); + block.addText("", TAG_COLOR); } - block.newLine(20); - block.addText("", TAG_COLOR); + block.newLine(10); + block.addText("", TAG_COLOR); } - block.newLine(10); - block.addText("", TAG_COLOR); + block.newLine(0); + block.addText("", TAG_COLOR); } diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfReporter.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfReporter.java index b1d35b06e933002a8c839788e42e698ed4ca64ff..ebb2a1ac2a8f5bfe0af92d169a964e4a1178ea32 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfReporter.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfReporter.java @@ -19,7 +19,6 @@ package de.hft.stuttgart.citydoctor2.reporting.pdf; import java.io.OutputStream; -import java.util.Objects; import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration; import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException; @@ -35,17 +34,10 @@ import de.hft.stuttgart.citydoctor2.reporting.Reporter; */ public class PdfReporter implements Reporter { - private String logoPath; - - public PdfReporter(String logoPath) { - Objects.requireNonNull(logoPath); - this.logoPath = logoPath; - } - @Override public void writeReport(Checks checks, OutputStream outFile, CityDoctorModel model, ValidationConfiguration config) throws CheckReportWriteException { - PdfStreamReporter reporter = new PdfStreamReporter(outFile, model.getFileName(), config, logoPath); + PdfStreamReporter reporter = new PdfStreamReporter(outFile, model.getFileName(), config); model.createFeatureStream().forEach(reporter::report); reporter.finishReport(); } diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java index 97ec89a41ff5b98ccdcb8ae85258d88e12ac7e4b..b5ac9cdc4eb6f55027197a5ee0d8f1a3b2b5a8e6 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java @@ -108,8 +108,7 @@ public class PdfStreamReporter implements StreamReporter { private Map sectionMap = new HashMap<>(); - public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config, - String logoPath) { + public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config) { this.config = config; errorStatistics = new HashMap<>(); outFile = pdfOutputFile; diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfUtils.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfUtils.java index af2ffe95e884b6c8d0822a440049a904083a799b..632ee819f7f12a754364f3d89ccb110a8560917a 100644 --- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfUtils.java +++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfUtils.java @@ -85,7 +85,7 @@ public class PdfUtils { Element val2Text = new Element("text", svgNs); svgElement.addContent(val2Text); String val2String = "" + val2; - val2Text.setAttribute("x", "" + (WIDTH - val2String.length() * 10)); + val2Text.setAttribute("x", "" + (WIDTH - val2String.length() * 13)); val2Text.setAttribute("y", "20"); val2Text.setAttribute("font-size", "18pt"); diff --git a/CityDoctorParent/pom.xml b/CityDoctorParent/pom.xml index 2958da24bd71d2619055b9fc8ef367b728b5da39..51a71fc48246ec3e7de179a78c8047dc44bbeb50 100644 --- a/CityDoctorParent/pom.xml +++ b/CityDoctorParent/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.hft.stuttgart CityDoctorParent - 3.10.1-SNAPSHOT + 3.10.1 pom CityDoctorParent @@ -144,12 +144,13 @@ org.apache.logging.log4j log4j-api - 2.11.2 + 2.15.0 + org.apache.logging.log4j log4j-core - 2.11.2 + 2.15.0 org.yaml