Commit 97a65114 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

Version 3.15.0

See merge request !8
parents 99c8f6a8 5950ea5f
Pipeline #10106 passed with stage
in 3 minutes and 15 seconds
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -34,6 +35,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.FeatureType; ...@@ -34,6 +35,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
*/ */
public class IncludeFilterConfiguration implements Serializable { public class IncludeFilterConfiguration implements Serializable {
@Serial
private static final long serialVersionUID = 1840264505629236113L; private static final long serialVersionUID = 1840264505629236113L;
private List<FeatureType> types; private List<FeatureType> types;
......
...@@ -24,7 +24,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject; ...@@ -24,7 +24,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
public class PatternFilter implements Filter { public class PatternFilter implements Filter {
private Pattern pattern; private final Pattern pattern;
public PatternFilter(String patternString) { public PatternFilter(String patternString) {
pattern = Pattern.compile(patternString); pattern = Pattern.compile(patternString);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -31,6 +32,7 @@ import java.util.Map; ...@@ -31,6 +32,7 @@ import java.util.Map;
*/ */
public class RequirementConfiguration implements Serializable { public class RequirementConfiguration implements Serializable {
@Serial
private static final long serialVersionUID = -1258195428669813888L; private static final long serialVersionUID = -1258195428669813888L;
private boolean enabled; private boolean enabled;
......
...@@ -63,22 +63,22 @@ public class StreamCityGmlConsumer implements CityGmlConsumer { ...@@ -63,22 +63,22 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
private static final Logger logger = LogManager.getLogger(StreamCityGmlConsumer.class); private static final Logger logger = LogManager.getLogger(StreamCityGmlConsumer.class);
private Checker c; private final Checker c;
private XmlStreamReporter xmlReporter; private final XmlStreamReporter xmlReporter;
private PdfStreamReporter pdfReporter; private final PdfStreamReporter pdfReporter;
private SvrlContentHandler handler; private final SvrlContentHandler handler;
private Map<ErrorId, AtomicInteger> errorCount; private final Map<ErrorId, AtomicInteger> errorCount;
private GeometryFactory gmlFactory; private final GeometryFactory gmlFactory;
private ValidationConfiguration config; private final ValidationConfiguration config;
private Statistics statistics; private final Statistics statistics;
private FeatureStatistics buildingStatistics; private final FeatureStatistics buildingStatistics;
private FeatureStatistics bridgeStatistics; private final FeatureStatistics bridgeStatistics;
private FeatureStatistics transportationStatistics; private final FeatureStatistics transportationStatistics;
private FeatureStatistics vegetationStatistics; private final FeatureStatistics vegetationStatistics;
private FeatureStatistics landStatistics; private final FeatureStatistics landStatistics;
private FeatureStatistics waterStatistics; private final FeatureStatistics waterStatistics;
private Validation val; private final Validation val;
private FeatureCheckedListener l; private final FeatureCheckedListener l;
public StreamCityGmlConsumer(Checker c, XmlStreamReporter xmlReporter, PdfStreamReporter pdfReporter, public StreamCityGmlConsumer(Checker c, XmlStreamReporter xmlReporter, PdfStreamReporter pdfReporter,
SvrlContentHandler handler, ValidationConfiguration config, FeatureCheckedListener l) { SvrlContentHandler handler, ValidationConfiguration config, FeatureCheckedListener l) {
...@@ -92,7 +92,7 @@ public class StreamCityGmlConsumer implements CityGmlConsumer { ...@@ -92,7 +92,7 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
gmlFactory = GeometryFactory.newInstance(); gmlFactory = GeometryFactory.newInstance();
val = new Validation(); val = new Validation();
val.setId("CD" + UUID.randomUUID().toString()); val.setId("CD" + UUID.randomUUID());
val.setValidationDate(ZonedDateTime.now()); val.setValidationDate(ZonedDateTime.now());
val.setValidationSoftware("CityDoctor " + Localization.getText(Localization.VERSION)); val.setValidationSoftware("CityDoctor " + Localization.getText(Localization.VERSION));
statistics = new Statistics(); statistics = new Statistics();
...@@ -182,7 +182,7 @@ public class StreamCityGmlConsumer implements CityGmlConsumer { ...@@ -182,7 +182,7 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
} }
val.setStatistics(new StatisticsProperty(statistics)); val.setStatistics(new StatisticsProperty(statistics));
ValidationPlan validationPlan = c.createValidationPlan(); ValidationPlan validationPlan = c.createValidationPlan();
validationPlan.setId("CD_PLAN_" + UUID.randomUUID().toString()); validationPlan.setId("CD_PLAN_" + UUID.randomUUID());
cm.getFeatureMembers().add(new AbstractFeatureProperty(validationPlan)); cm.getFeatureMembers().add(new AbstractFeatureProperty(validationPlan));
val.setValidationPlan(new Reference(validationPlan)); val.setValidationPlan(new Reference(validationPlan));
......
...@@ -21,27 +21,28 @@ package de.hft.stuttgart.citydoctor2.check; ...@@ -21,27 +21,28 @@ package de.hft.stuttgart.citydoctor2.check;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject; import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.FeatureType; import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
/** /**
* Filters the feature type of features * Filters the feature type of features
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class TypeFilter implements Filter { public class TypeFilter implements Filter {
private FeatureType type; private final FeatureType type;
public TypeFilter(FeatureType type) {
this.type = type;
}
@Override
public boolean matches(CityObject co) {
return co.getFeatureType() == type;
}
public TypeFilter(FeatureType type) {
this.type = type;
}
public FeatureType getType() { public FeatureType getType() {
return type; return type;
} }
@Override
public boolean matches(CityObject co) {
return co.getFeatureType() == type;
}
} }
...@@ -18,14 +18,7 @@ ...@@ -18,14 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.BufferedWriter; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -33,6 +26,7 @@ import java.util.Map.Entry; ...@@ -33,6 +26,7 @@ import java.util.Map.Entry;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.nodes.Tag;
...@@ -55,6 +49,7 @@ public class ValidationConfiguration implements Serializable { ...@@ -55,6 +49,7 @@ public class ValidationConfiguration implements Serializable {
public static final String CHECK_FOR_SOLID_XML = "checkForSolid.xml"; public static final String CHECK_FOR_SOLID_XML = "checkForSolid.xml";
private static final String NUMBER_OF_ROUNDING_PLACES_DEFAULT = "8"; private static final String NUMBER_OF_ROUNDING_PLACES_DEFAULT = "8";
private static final String MIN_VERTEX_DISTANCE_DEFAULT = "0.0001"; private static final String MIN_VERTEX_DISTANCE_DEFAULT = "0.0001";
@Serial
private static final long serialVersionUID = -8020055032177740646L; private static final long serialVersionUID = -8020055032177740646L;
private static final Logger logger = LogManager.getLogger(ValidationConfiguration.class); private static final Logger logger = LogManager.getLogger(ValidationConfiguration.class);
...@@ -72,7 +67,7 @@ public class ValidationConfiguration implements Serializable { ...@@ -72,7 +67,7 @@ public class ValidationConfiguration implements Serializable {
} }
public static ValidationConfiguration loadValidationConfig(InputStream stream) { public static ValidationConfiguration loadValidationConfig(InputStream stream) {
Yaml yaml = new Yaml(new Constructor(ValidationConfiguration.class)); Yaml yaml = new Yaml(new Constructor(ValidationConfiguration.class, new LoaderOptions()));
ValidationConfiguration config = yaml.load(stream); ValidationConfiguration config = yaml.load(stream);
config.validateConfiguration(); config.validateConfiguration();
return config; return config;
...@@ -104,9 +99,9 @@ public class ValidationConfiguration implements Serializable { ...@@ -104,9 +99,9 @@ public class ValidationConfiguration implements Serializable {
DumperOptions options = new DumperOptions(); DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true); options.setPrettyFlow(true);
Representer rep = new ValidationConfigurationRepresenter(); Representer rep = new ValidationConfigurationRepresenter(options);
rep.addClassTag(ValidationConfiguration.class, Tag.MAP); rep.addClassTag(ValidationConfiguration.class, Tag.MAP);
Yaml yaml = new Yaml(rep, options); Yaml yaml = new Yaml(rep);
try (BufferedWriter bw = new BufferedWriter(new FileWriter(f))) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(f))) {
yaml.dump(this, bw); yaml.dump(this, bw);
} }
...@@ -178,9 +173,9 @@ public class ValidationConfiguration implements Serializable { ...@@ -178,9 +173,9 @@ public class ValidationConfiguration implements Serializable {
return cConfig; return cConfig;
}); });
} }
globalParameters.computeIfAbsent(GlobalParameters.MIN_VERTEX_DISTANCE, k -> MIN_VERTEX_DISTANCE_DEFAULT); globalParameters.putIfAbsent(GlobalParameters.MIN_VERTEX_DISTANCE, MIN_VERTEX_DISTANCE_DEFAULT);
globalParameters.computeIfAbsent(GlobalParameters.NUMBER_OF_ROUNDING_PLACES, globalParameters.putIfAbsent(GlobalParameters.NUMBER_OF_ROUNDING_PLACES,
k -> NUMBER_OF_ROUNDING_PLACES_DEFAULT); NUMBER_OF_ROUNDING_PLACES_DEFAULT);
} }
public int getNumberOfRoundingPlaces() { public int getNumberOfRoundingPlaces() {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.introspector.Property;
import org.yaml.snakeyaml.nodes.CollectionNode; import org.yaml.snakeyaml.nodes.CollectionNode;
import org.yaml.snakeyaml.nodes.MappingNode; import org.yaml.snakeyaml.nodes.MappingNode;
...@@ -35,7 +36,11 @@ import org.yaml.snakeyaml.representer.Representer; ...@@ -35,7 +36,11 @@ import org.yaml.snakeyaml.representer.Representer;
* *
*/ */
public class ValidationConfigurationRepresenter extends Representer { public class ValidationConfigurationRepresenter extends Representer {
public ValidationConfigurationRepresenter(DumperOptions options) {
super(options);
}
@Override @Override
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue,
Tag customTag) { Tag customTag) {
......
...@@ -38,7 +38,7 @@ import de.hft.stuttgart.citydoctor2.check.RequirementType; ...@@ -38,7 +38,7 @@ import de.hft.stuttgart.citydoctor2.check.RequirementType;
*/ */
public class CheckPrototype { public class CheckPrototype {
private Check c; private final Check c;
public CheckPrototype(Check c) { public CheckPrototype(Check c) {
this.c = c; this.c = c;
......
...@@ -69,12 +69,12 @@ public class Checks { ...@@ -69,12 +69,12 @@ public class Checks {
private static final Logger logger = LogManager.getLogger(Checks.class); private static final Logger logger = LogManager.getLogger(Checks.class);
private static List<CheckPrototype> checkPrototypes; private static final List<CheckPrototype> checkPrototypes;
private static Map<CheckId, CheckPrototype> prototypeMap; private static final Map<CheckId, CheckPrototype> prototypeMap;
private static Map<String, Requirement> availableRequirements; private static Map<String, Requirement> availableRequirements;
private Map<CheckId, Check> checkMap; private final Map<CheckId, Check> checkMap;
static { static {
checkPrototypes = new ArrayList<>(); checkPrototypes = new ArrayList<>();
......
...@@ -45,8 +45,8 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -45,8 +45,8 @@ public class SvrlContentHandler implements ContentHandler {
private StringBuilder buffer; private StringBuilder buffer;
private Map<String, List<SchematronError>> featureErrors; private final Map<String, List<SchematronError>> featureErrors;
private List<SchematronError> generalErrors; private final List<SchematronError> generalErrors;
public SvrlContentHandler() { public SvrlContentHandler() {
featureErrors = new HashMap<>(); featureErrors = new HashMap<>();
...@@ -65,22 +65,23 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -65,22 +65,23 @@ public class SvrlContentHandler implements ContentHandler {
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
// not needed // not needed
} }
@Override @SuppressWarnings("RedundantThrows")
@Override
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void endPrefixMapping(String prefix) throws SAXException { public void endPrefixMapping(String prefix) throws SAXException {
// not needed // not needed
...@@ -132,17 +133,17 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -132,17 +133,17 @@ public class SvrlContentHandler implements ContentHandler {
buffer.append(ch, start, length); buffer.append(ch, start, length);
} }
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void processingInstruction(String target, String data) throws SAXException { public void processingInstruction(String target, String data) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void skippedEntity(String name) throws SAXException { public void skippedEntity(String name) throws SAXException {
// not needed // not needed
......
...@@ -124,9 +124,9 @@ public class RingSelfIntCheck extends Check { ...@@ -124,9 +124,9 @@ public class RingSelfIntCheck extends Check {
Segment3d s1 = new Segment3d(e1.getFrom(), e1.getTo()); Segment3d s1 = new Segment3d(e1.getFrom(), e1.getTo());
Segment3d s2 = new Segment3d(e2.getFrom(), e2.getTo()); Segment3d s2 = new Segment3d(e2.getFrom(), e2.getTo());
DistanceResult dr = s1.getDistanceResult(s2); DistanceResult dr = s1.getDistanceResult(s2);
if (dr.getDistance() < epsilon) { if (dr.distance() < epsilon) {
// intersection // intersection
CheckError err = new RingEdgeIntersectionError(lr, e1, e2, dr.getPoint1()); CheckError err = new RingEdgeIntersectionError(lr, e1, e2, dr.point1());
CheckResult cr = new CheckResult(this, ResultStatus.ERROR, err); CheckResult cr = new CheckResult(this, ResultStatus.ERROR, err);
lr.addCheckResult(cr); lr.addCheckResult(cr);
return; return;
......
...@@ -26,6 +26,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject; ...@@ -26,6 +26,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
* @author Matthias Betz * @author Matthias Betz
* *
*/ */
@FunctionalInterface
public interface FeatureCheckedListener { public interface FeatureCheckedListener {
public void featureChecked(CityObject co); public void featureChecked(CityObject co);
......
...@@ -78,7 +78,7 @@ public class SelfIntersectionUtil { ...@@ -78,7 +78,7 @@ public class SelfIntersectionUtil {
private static final Logger logger = LogManager.getLogger(SelfIntersectionUtil.class); private static final Logger logger = LogManager.getLogger(SelfIntersectionUtil.class);
private static GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING)); private static final GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
private SelfIntersectionUtil() { private SelfIntersectionUtil() {
...@@ -93,7 +93,7 @@ public class SelfIntersectionUtil { ...@@ -93,7 +93,7 @@ public class SelfIntersectionUtil {
List<PolygonIntersection> intersections = new ArrayList<>(); List<PolygonIntersection> intersections = new ArrayList<>();
MeshSurface meshSurface = MeshSurface.of(g); MeshSurface meshSurface = MeshSurface.of(g);
Map<Polygon, EdgePolygon> edgePolyMap = new IdentityHashMap<>(); Map<Polygon, EdgePolygon> edgePolyMap = new IdentityHashMap<>();
for (EdgePolygon poly : meshSurface.getPolygons()) { for (EdgePolygon poly : meshSurface.polygons()) {
edgePolyMap.put(poly.getOriginal(), poly); edgePolyMap.put(poly.getOriginal(), poly);
} }
for (int i = 0; i < polygons.size() - 1; i++) { for (int i = 0; i < polygons.size() - 1; i++) {
...@@ -213,12 +213,10 @@ public class SelfIntersectionUtil { ...@@ -213,12 +213,10 @@ public class SelfIntersectionUtil {
// intersection is only an edge, not a polygon // intersection is only an edge, not a polygon
// edge intersections are allowed // edge intersections are allowed
return PolygonIntersection.none(); return PolygonIntersection.none();
} else if (intersection instanceof GeometryCollection) { } else if (intersection instanceof GeometryCollection col) {
GeometryCollection col = (GeometryCollection) intersection;
for (int i = 0; i < col.getNumGeometries(); i++) { for (int i = 0; i < col.getNumGeometries(); i++) {
org.locationtech.jts.geom.Geometry interGeom = col.getGeometryN(i); org.locationtech.jts.geom.Geometry interGeom = col.getGeometryN(i);
if (interGeom instanceof org.locationtech.jts.geom.Polygon) { if (interGeom instanceof org.locationtech.jts.geom.Polygon intPoly) {
org.locationtech.jts.geom.Polygon intPoly = (org.locationtech.jts.geom.Polygon) interGeom;
ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly); ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly);
return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal()); return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal());
} }
...@@ -226,8 +224,7 @@ public class SelfIntersectionUtil { ...@@ -226,8 +224,7 @@ public class SelfIntersectionUtil {
// no polygon in collection, so no intersection // no polygon in collection, so no intersection
return PolygonIntersection.none(); return PolygonIntersection.none();
} }
if (intersection instanceof org.locationtech.jts.geom.Polygon) { if (intersection instanceof org.locationtech.jts.geom.Polygon intPoly) {
org.locationtech.jts.geom.Polygon intPoly = (org.locationtech.jts.geom.Polygon) intersection;
ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly); ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly);
return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal()); return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal());
} else { } else {
...@@ -412,7 +409,7 @@ public class SelfIntersectionUtil { ...@@ -412,7 +409,7 @@ public class SelfIntersectionUtil {
Triangle3d t2 = p2.getTriangles().get(p2Index); Triangle3d t2 = p2.getTriangles().get(p2Index);
if (t1.doesIntersect(t2)) { if (t1.doesIntersect(t2)) {
logger.trace("{} intersects {}", t1, t2); logger.trace("{} intersects {}", t1, t2);
logger.trace("{} intersects {}", t1.getPartOf().getOriginal().getGmlId(), logger.trace("GML-ID: {} intersects {}", t1.getPartOf().getOriginal().getGmlId(),
t2.getPartOf().getOriginal().getGmlId()); t2.getPartOf().getOriginal().getGmlId());
return new GeometrySelfIntersection(t1.getPartOf().getOriginal(), t2.getPartOf().getOriginal(), t1, return new GeometrySelfIntersection(t1.getPartOf().getOriginal(), t2.getPartOf().getOriginal(), t1,
t2); t2);
......
...@@ -52,22 +52,20 @@ public class ArgumentParser { ...@@ -52,22 +52,20 @@ public class ArgumentParser {
HashMap<String, List<String>> params = new HashMap<>(); HashMap<String, List<String>> params = new HashMap<>();
List<String> options = null; List<String> options = null;
for (int i = 0; i < args.length; i++) { for (final String a : args) {
final String a = args[i]; if (a.charAt(0) == '-') {
if (a.length() < 2) {
if (a.charAt(0) == '-') { ErrorHandler.printHelpAndTerminate("Error while parsing argument " + a);
if (a.length() < 2) { }
ErrorHandler.printHelpAndTerminate("Error while parsing argument " + a); String flag = a.substring(1).toLowerCase();
} options = new ArrayList<>();
String flag = a.substring(1).toLowerCase(); params.put(flag, options);
options = new ArrayList<>(); } else if (options != null) {
params.put(flag, options); options.add(a);
} else if (options != null) { } else {
options.add(a); ErrorHandler.printHelpAndTerminate("Illegal parameter usage at " + a);
} else { }
ErrorHandler.printHelpAndTerminate("Illegal parameter usage at " + a); }
}
}
return params; return params;
} }
......
...@@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public class ErrorStatisticsCollector { public class ErrorStatisticsCollector {
private Map<String, AtomicInteger> errorCounts = new HashMap<>(); private final Map<String, AtomicInteger> errorCounts = new HashMap<>();
public void addError(String errorName) { public void addError(String errorName) {
AtomicInteger numErrors = errorCounts.get(errorName); AtomicInteger numErrors = errorCounts.get(errorName);
......
...@@ -56,8 +56,8 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -56,8 +56,8 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/ */
public class XmlStreamErrorHandler implements ErrorReport { public class XmlStreamErrorHandler implements ErrorReport {
private ErrorDetails details; private final ErrorDetails details;
private BasicCoordinateTransform originalTransform; private final BasicCoordinateTransform originalTransform;
public XmlStreamErrorHandler(ParserConfiguration config) { public XmlStreamErrorHandler(ParserConfiguration config) {
originalTransform = config.getOriginalTransform(); originalTransform = config.getOriginalTransform();
......
...@@ -74,11 +74,11 @@ public class XmlStreamReporter implements StreamReporter { ...@@ -74,11 +74,11 @@ public class XmlStreamReporter implements StreamReporter {
private static final Logger logger = LogManager.getLogger(XmlStreamReporter.class); private static final Logger logger = LogManager.getLogger(XmlStreamReporter.class);
private OutputStream output; private final OutputStream output;
private CheckReport report; private final CheckReport report;
private Map<String, FeatureReport> reportMap; private final Map<String, FeatureReport> reportMap;
private ValidationConfiguration config; private final ValidationConfiguration config;
public XmlStreamReporter(OutputStream output, String fileName, ValidationConfiguration config) { public XmlStreamReporter(OutputStream output, String fileName, ValidationConfiguration config) {
this.output = output; this.output = output;
...@@ -141,18 +141,18 @@ public class XmlStreamReporter implements StreamReporter { ...@@ -141,18 +141,18 @@ public class XmlStreamReporter implements StreamReporter {
@Override @Override
public void report(CityObject co) { public void report(CityObject co) {
if (co instanceof Building) { if (co instanceof Building bu) {
reportBuilding((Building) co); reportBuilding(bu);
} else if (co instanceof Vegetation) { } else if (co instanceof Vegetation ve) {
reportVegetation((Vegetation) co); reportVegetation(ve);
} else if (co instanceof TransportationObject) { } else if (co instanceof TransportationObject to) {
reportTrans((TransportationObject) co); reportTrans(to);
} else if (co instanceof BridgeObject) { } else if (co instanceof BridgeObject bo) {
reportBridge((BridgeObject) co); reportBridge(bo);
} else if (co instanceof WaterObject) { } else if (co instanceof WaterObject wo) {
reportWater((WaterObject) co); reportWater(wo);
} else if (co instanceof LandObject) { } else if (co instanceof LandObject lo) {
reportLand((LandObject) co); reportLand(lo);
} else { } else {
throw new IllegalStateException("Not reportable CityObject found: " + co.getClass().getSimpleName()); throw new IllegalStateException("Not reportable CityObject found: " + co.getClass().getSimpleName());
} }
...@@ -240,26 +240,10 @@ public class XmlStreamReporter implements StreamReporter { ...@@ -240,26 +240,10 @@ public class XmlStreamReporter implements StreamReporter {
@Override @Override
public void finishReport() throws CheckReportWriteException { public void finishReport() throws CheckReportWriteException {
GlobalStatistics stats = new GlobalStatistics(); GlobalStatistics stats = new GlobalStatistics();
GlobalErrorStatistics globErrStats = new GlobalErrorStatistics();
globErrStats
.setNumErrorBridgeObjects(getNumberOfErrorFeatures(report.getValidationResults().getBridgeReports()));
globErrStats.setNumErrorBuildings(getNumberOfErrorFeatures(report.getValidationResults().getBuildingReports()));
globErrStats.setNumErrorLandObjects(getNumberOfErrorFeatures(report.getValidationResults().getLandReports()));
globErrStats.setNumErrorTransportation(
getNumberOfErrorFeatures(report.getValidationResults().getTransportationReports()));
globErrStats
.setNumErrorVegetation(getNumberOfErrorFeatures(report.getValidationResults().getVegetationReports()));
globErrStats.setNumErrorWaterObjects(getNumberOfErrorFeatures(report.getValidationResults().getWaterReports()));
stats.setGlobalErrorStats(globErrStats);
ModelStatistics modelStats = new ModelStatistics(); stats.setGlobalErrorStats(getReportGlobalErrorStatistics());
modelStats.setNumBridgeObjects(report.getValidationResults().getBridgeReports().size());
modelStats.setNumBuildings(report.getValidationResults().getBuildingReports().size()); stats.setModelStats(getReportModelStatistics());
modelStats.setNumLandObjects(report.getValidationResults().getLandReports().size());
modelStats.setNumTransportation(report.getValidationResults().getTransportationReports().size());
modelStats.setNumVegetation(report.getValidationResults().getVegetationReports().size());
modelStats.setNumWaterObjects(report.getValidationResults().getWaterReports().size());
stats.setModelStats(modelStats);
ErrorStatisticsCollector globalErrorCount = new ErrorStatisticsCollector(); ErrorStatisticsCollector globalErrorCount = new ErrorStatisticsCollector();
...@@ -279,6 +263,31 @@ public class XmlStreamReporter implements StreamReporter { ...@@ -279,6 +263,31 @@ public class XmlStreamReporter implements StreamReporter {
report.saveAs(output); report.saveAs(output);
} }
private ModelStatistics getReportModelStatistics() {
ModelStatistics modelStats = new ModelStatistics();
modelStats.setNumBridgeObjects(report.getValidationResults().getBridgeReports().size());
modelStats.setNumBuildings(report.getValidationResults().getBuildingReports().size());
modelStats.setNumLandObjects(report.getValidationResults().getLandReports().size());
modelStats.setNumTransportation(report.getValidationResults().getTransportationReports().size());
modelStats.setNumVegetation(report.getValidationResults().getVegetationReports().size());
modelStats.setNumWaterObjects(report.getValidationResults().getWaterReports().size());
return modelStats;
}
private GlobalErrorStatistics getReportGlobalErrorStatistics() {
GlobalErrorStatistics globErrStats = new GlobalErrorStatistics();
globErrStats
.setNumErrorBridgeObjects(getNumberOfErrorFeatures(report.getValidationResults().getBridgeReports()));
globErrStats.setNumErrorBuildings(getNumberOfErrorFeatures(report.getValidationResults().getBuildingReports()));
globErrStats.setNumErrorLandObjects(getNumberOfErrorFeatures(report.getValidationResults().getLandReports()));
globErrStats.setNumErrorTransportation(
getNumberOfErrorFeatures(report.getValidationResults().getTransportationReports()));
globErrStats
.setNumErrorVegetation(getNumberOfErrorFeatures(report.getValidationResults().getVegetationReports()));
globErrStats.setNumErrorWaterObjects(getNumberOfErrorFeatures(report.getValidationResults().getWaterReports()));
return globErrStats;
}
private void createStatistics(ErrorStatisticsCollector globalErrorCount, List<FeatureReport> reports) { private void createStatistics(ErrorStatisticsCollector globalErrorCount, List<FeatureReport> reports) {
for (FeatureReport fReport : reports) { for (FeatureReport fReport : reports) {
if (fReport.getErrors().isEmpty()) { if (fReport.getErrors().isEmpty()) {
......
...@@ -31,8 +31,8 @@ public class CodeBlock { ...@@ -31,8 +31,8 @@ public class CodeBlock {
private static final String BLOCK = "block"; private static final String BLOCK = "block";
private Element codeBlockContainer; private final Element codeBlockContainer;
private Element codeBlockElement; private final Element codeBlockElement;
private Element currentLine; private Element currentLine;
......
...@@ -48,8 +48,8 @@ public class PdfErrorHandler implements ErrorReport { ...@@ -48,8 +48,8 @@ public class PdfErrorHandler implements ErrorReport {
private static final String ATTRIBUTE_KEY_COLOR = "#7F007F"; private static final String ATTRIBUTE_KEY_COLOR = "#7F007F";
private static final String ATTRIBUTE_VALUE_COLOR = "#2A00FF"; private static final String ATTRIBUTE_VALUE_COLOR = "#2A00FF";
private Section section; private final Section section;
private ParserConfiguration config; private final ParserConfiguration config;
public PdfErrorHandler(Section section, ParserConfiguration config) { public PdfErrorHandler(Section section, ParserConfiguration config) {
this.config = config; this.config = config;
......
...@@ -72,14 +72,14 @@ public class PdfStreamReporter implements StreamReporter { ...@@ -72,14 +72,14 @@ public class PdfStreamReporter implements StreamReporter {
private static final String WARNING_COLOR = "yellow"; private static final String WARNING_COLOR = "yellow";
private static final String OK_COLOR = "green"; private static final String OK_COLOR = "green";
private PdfReport report; private final PdfReport report;
private OutputStream outFile; private final OutputStream outFile;
private Map<ErrorId, AtomicInteger> errorStatistics; private final Map<ErrorId, AtomicInteger> errorStatistics;
private ValidationConfiguration config; private final ValidationConfiguration config;
private Section statistics; private final Section statistics;
private Section vr; private final Section vr;
private Section buildings; private Section buildings;
private int numErrorBuildings; private int numErrorBuildings;
...@@ -107,7 +107,7 @@ public class PdfStreamReporter implements StreamReporter { ...@@ -107,7 +107,7 @@ public class PdfStreamReporter implements StreamReporter {
private Section globalErrors; private Section globalErrors;
private Map<String, Section> sectionMap = new HashMap<>(); private final Map<String, Section> sectionMap = new HashMap<>();
public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config) { public PdfStreamReporter(OutputStream pdfOutputFile, String fileName, ValidationConfiguration config) {
this.config = config; this.config = config;
...@@ -393,21 +393,7 @@ public class PdfStreamReporter implements StreamReporter { ...@@ -393,21 +393,7 @@ public class PdfStreamReporter implements StreamReporter {
@Override @Override
public void finishReport() throws CheckReportWriteException { public void finishReport() throws CheckReportWriteException {
if (buildings != null) { if (buildings != null) {
for (Section s : buildings.getSubSections()) { countFinishedReportBuildings();
if (!s.hasErrors()) {
numOkBuildings++;
// building has no errors, no table
continue;
}
numErrorBuildings++;
Table t = new Table(2);
t.setTableColumnWidth(75, 25);
t.setTitle("Error", "Count");
for (Entry<String, AtomicInteger> e : s.getStats().getErrorCounts().entrySet()) {
t.addRow(e.getKey(), e.getValue().toString());
}
s.addTable(1, t);
}
} }
int numBuildings = numErrorBuildings + numOkBuildings; int numBuildings = numErrorBuildings + numOkBuildings;
if (numBuildings > 0) { if (numBuildings > 0) {
...@@ -446,6 +432,24 @@ public class PdfStreamReporter implements StreamReporter { ...@@ -446,6 +432,24 @@ public class PdfStreamReporter implements StreamReporter {
report.save(outFile); report.save(outFile);
} }
private void countFinishedReportBuildings() {
for (Section s : buildings.getSubSections()) {
if (!s.hasErrors()) {
numOkBuildings++;
// building has no errors, no table
continue;
}
numErrorBuildings++;
Table t = new Table(2);
t.setTableColumnWidth(75, 25);
t.setTitle("Error", "Count");
for (Entry<String, AtomicInteger> e : s.getStats().getErrorCounts().entrySet()) {
t.addRow(e.getKey(), e.getValue().toString());
}
s.addTable(1, t);
}
}
@Override @Override
public void reportGlobalError(CheckError err) { public void reportGlobalError(CheckError err) {
AtomicInteger errorCount = errorStatistics.computeIfAbsent(err.getErrorId(), k -> new AtomicInteger(0)); AtomicInteger errorCount = errorStatistics.computeIfAbsent(err.getErrorId(), k -> new AtomicInteger(0));
......
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