Commit 2c4afc20 authored by Matthias Betz's avatar Matthias Betz
Browse files

version 3.10.1

fix pdf report polygon ending
fix pdf report statistics being cut with large numbers
fix gml not written when unknown error occured now set to not checked
parent 30792585
Pipeline #5711 passed with stage
in 3 minutes and 17 seconds
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
<version>3.10.1-SNAPSHOT</version> <version>3.10.1</version>
</parent> </parent>
<artifactId>CityDoctorCheckResult</artifactId> <artifactId>CityDoctorCheckResult</artifactId>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
<version>3.10.1-SNAPSHOT</version> <version>3.10.1</version>
</parent> </parent>
<artifactId>CityDoctorEdge</artifactId> <artifactId>CityDoctorEdge</artifactId>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
<version>3.10.1-SNAPSHOT</version> <version>3.10.1</version>
</parent> </parent>
<properties> <properties>
......
...@@ -49,6 +49,12 @@ public class UnknownCheckError implements CheckError { ...@@ -49,6 +49,12 @@ public class UnknownCheckError implements CheckError {
this.e = e; this.e = e;
checkId = check.getCheckId(); checkId = check.getCheckId();
} }
public UnknownCheckError(Checkable c, Exception e, CheckId checkId) {
this.c = c;
this.e = e;
this.checkId = checkId;
}
public CheckId getCheck() { public CheckId getCheck() {
return checkId; return checkId;
......
...@@ -288,7 +288,12 @@ public class CityDoctorModel { ...@@ -288,7 +288,12 @@ public class CityDoctorModel {
for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) { for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) {
ErrorStatistics stats = new ErrorStatistics(); ErrorStatistics stats = new ErrorStatistics();
stats.setAmount(e.getValue().get()); 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.getErrorStatistics().add(stats);
} }
statistics.setNumErrorBuildings(countValidatedCityObjects(buildings)); statistics.setNumErrorBuildings(countValidatedCityObjects(buildings));
......
...@@ -29,6 +29,7 @@ import org.citygml4j.model.gml.geometry.primitives.DirectPosition; ...@@ -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.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorId; 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.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.quality.model.Edge; import de.hft.stuttgart.quality.model.Edge;
...@@ -69,7 +70,13 @@ public class QualityADEUtils { ...@@ -69,7 +70,13 @@ public class QualityADEUtils {
res.setResult(ResultType.ERROR); res.setResult(ResultType.ERROR);
Set<CheckError> errorSet = new HashSet<>(errors); Set<CheckError> errorSet = new HashSet<>(errors);
for (CheckError e : errorSet) { 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 { } else {
...@@ -141,7 +148,8 @@ public class QualityADEUtils { ...@@ -141,7 +148,8 @@ public class QualityADEUtils {
case "SE_ATTRIBUTE_MISSING": case "SE_ATTRIBUTE_MISSING":
return de.hft.stuttgart.quality.model.jaxb.ErrorId.SE_ATTRIBUTE_MISSING; return de.hft.stuttgart.quality.model.jaxb.ErrorId.SE_ATTRIBUTE_MISSING;
default: default:
throw new IllegalStateException("Cannot map " + key + " to ADE Error Id"); return null;
// throw new IllegalStateException("Cannot map " + key + " to ADE Error Id");
} }
} }
......
/*-
* 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 <https://www.gnu.org/licenses/>.
*/
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<ADEComponent> 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());
}
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
<version>3.10.1-SNAPSHOT</version> <version>3.10.1</version>
</parent> </parent>
<artifactId>CityDoctorValidation</artifactId> <artifactId>CityDoctorValidation</artifactId>
<name>CityDoctorValidation</name> <name>CityDoctorValidation</name>
......
...@@ -158,7 +158,7 @@ public class Checker { ...@@ -158,7 +158,7 @@ public class Checker {
if (pdfFile.getParentFile() != null) { if (pdfFile.getParentFile() != null) {
pdfFile.getParentFile().mkdirs(); pdfFile.getParentFile().mkdirs();
} }
Reporter reporter = new PdfReporter("assets/Logo.png"); Reporter reporter = new PdfReporter();
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pdfFile.getAbsolutePath()))) { try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pdfFile.getAbsolutePath()))) {
reporter.writeReport(checkConfig, bos, model, config); reporter.writeReport(checkConfig, bos, model, config);
} catch (IOException | CheckReportWriteException e) { } catch (IOException | CheckReportWriteException e) {
...@@ -721,7 +721,7 @@ public class Checker { ...@@ -721,7 +721,7 @@ public class Checker {
} }
if (layer.isEmpty()) { if (layer.isEmpty()) {
throw new IllegalStateException( 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); result.add(layer);
for (Check c : layer) { for (Check c : layer) {
...@@ -744,12 +744,11 @@ public class Checker { ...@@ -744,12 +744,11 @@ public class Checker {
public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config, public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config,
String outputFile) throws IOException, CityGmlParseException { 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, public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config,
String logoLocation, FeatureCheckedListener l, String outputFile) FeatureCheckedListener l, String outputFile) throws IOException, CityGmlParseException {
throws IOException, CityGmlParseException {
try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput); try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput);
BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) { BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) {
Checker c = new Checker(config, null); Checker c = new Checker(config, null);
...@@ -757,7 +756,7 @@ public class Checker { ...@@ -757,7 +756,7 @@ public class Checker {
// create reporter if available // create reporter if available
XmlStreamReporter xmlReporter = getXmlReporter(config, xmlBos, fileName); XmlStreamReporter xmlReporter = getXmlReporter(config, xmlBos, fileName);
PdfStreamReporter pdfReporter = getPdfReporter(config, logoLocation, pdfBos, fileName); PdfStreamReporter pdfReporter = getPdfReporter(config, pdfBos, fileName);
// execute schematron first // execute schematron first
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, inputFile); SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, inputFile);
...@@ -784,11 +783,11 @@ public class Checker { ...@@ -784,11 +783,11 @@ public class Checker {
return xmlReporter; return xmlReporter;
} }
private static PdfStreamReporter getPdfReporter(ValidationConfiguration config, String logoLocation, private static PdfStreamReporter getPdfReporter(ValidationConfiguration config, BufferedOutputStream pdfBos,
BufferedOutputStream pdfBos, String fileName) { String fileName) {
PdfStreamReporter pdfReporter; PdfStreamReporter pdfReporter;
if (pdfBos != null) { if (pdfBos != null) {
pdfReporter = new PdfStreamReporter(pdfBos, fileName, config, logoLocation); pdfReporter = new PdfStreamReporter(pdfBos, fileName, config);
} else { } else {
pdfReporter = null; pdfReporter = null;
} }
......
...@@ -168,7 +168,11 @@ public class StreamCityGmlConsumer implements CityGmlConsumer { ...@@ -168,7 +168,11 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) { for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) {
ErrorStatistics stats = new ErrorStatistics(); ErrorStatistics stats = new ErrorStatistics();
stats.setAmount(e.getValue().get()); 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); statistics.getErrorStatistics().add(stats);
} }
val.setStatistics(statistics); val.setStatistics(statistics);
......
...@@ -73,25 +73,26 @@ public class PdfErrorHandler implements ErrorReport { ...@@ -73,25 +73,26 @@ public class PdfErrorHandler implements ErrorReport {
} }
block.newLine(10); block.newLine(10);
block.addText("</Exterior Ring>", TAG_COLOR); block.addText("</Exterior Ring>", TAG_COLOR);
if (p.getInnerRings().isEmpty()) { if (!p.getInnerRings().isEmpty()) {
return; block.newLine(10);
} block.addText("<Interior Rings>", TAG_COLOR);
block.newLine(10); for (LinearRing ring : p.getInnerRings()) {
block.addText("<Interior Rings>", TAG_COLOR); block.newLine(20);
for (LinearRing ring : p.getInnerRings()) { block.addText("<Interior Ring", TAG_COLOR);
block.newLine(20); addGmlId(ring, block);
block.addText("<Interior Ring", TAG_COLOR); block.addText(">", TAG_COLOR);
addGmlId(ring, block); for (Vertex v : p.getExteriorRing().getVertices()) {
block.addText(">", TAG_COLOR); block.newLine(30);
for (Vertex v : p.getExteriorRing().getVertices()) { addVertexToBlock(block, v);
block.newLine(30); }
addVertexToBlock(block, v); block.newLine(20);
block.addText("</Interior Ring>", TAG_COLOR);
} }
block.newLine(20); block.newLine(10);
block.addText("</Interior Ring>", TAG_COLOR); block.addText("</Interior Rings>", TAG_COLOR);
} }
block.newLine(10); block.newLine(0);
block.addText("</Interior Rings>", TAG_COLOR); block.addText("</Polygon>", TAG_COLOR);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package de.hft.stuttgart.citydoctor2.reporting.pdf; package de.hft.stuttgart.citydoctor2.reporting.pdf;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Objects;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration; import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException; import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException;
...@@ -35,17 +34,10 @@ import de.hft.stuttgart.citydoctor2.reporting.Reporter; ...@@ -35,17 +34,10 @@ import de.hft.stuttgart.citydoctor2.reporting.Reporter;
*/ */
public class PdfReporter implements Reporter { public class PdfReporter implements Reporter {
private String logoPath;
public PdfReporter(String logoPath) {
Objects.requireNonNull(logoPath);
this.logoPath = logoPath;
}
@Override @Override
public void writeReport(Checks checks, OutputStream outFile, CityDoctorModel model, ValidationConfiguration config) public void writeReport(Checks checks, OutputStream outFile, CityDoctorModel model, ValidationConfiguration config)
throws CheckReportWriteException { throws CheckReportWriteException {
PdfStreamReporter reporter = new PdfStreamReporter(outFile, model.getFileName(), config, logoPath); PdfStreamReporter reporter = new PdfStreamReporter(outFile, model.getFileName(), config);
model.createFeatureStream().forEach(reporter::report); model.createFeatureStream().forEach(reporter::report);
reporter.finishReport(); reporter.finishReport();
} }
......
...@@ -108,8 +108,7 @@ public class PdfStreamReporter implements StreamReporter { ...@@ -108,8 +108,7 @@ public class PdfStreamReporter implements StreamReporter {
private Map<String, Section> sectionMap = new HashMap<>(); private Map<String, Section> sectionMap = new HashMap<>();
public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config, public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config) {
String logoPath) {
this.config = config; this.config = config;
errorStatistics = new HashMap<>(); errorStatistics = new HashMap<>();
outFile = pdfOutputFile; outFile = pdfOutputFile;
......
...@@ -85,7 +85,7 @@ public class PdfUtils { ...@@ -85,7 +85,7 @@ public class PdfUtils {
Element val2Text = new Element("text", svgNs); Element val2Text = new Element("text", svgNs);
svgElement.addContent(val2Text); svgElement.addContent(val2Text);
String val2String = "" + val2; String val2String = "" + val2;
val2Text.setAttribute("x", "" + (WIDTH - val2String.length() * 10)); val2Text.setAttribute("x", "" + (WIDTH - val2String.length() * 13));
val2Text.setAttribute("y", "20"); val2Text.setAttribute("y", "20");
val2Text.setAttribute("font-size", "18pt"); val2Text.setAttribute("font-size", "18pt");
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
<version>3.10.1-SNAPSHOT</version> <version>3.10.1</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>CityDoctorParent</name> <name>CityDoctorParent</name>
...@@ -144,12 +144,13 @@ ...@@ -144,12 +144,13 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId> <artifactId>log4j-api</artifactId>
<version>2.11.2</version> <version>2.15.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.11.2</version> <version>2.15.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>
......
Markdown is supported
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