Commit a66db57b authored by Matthias Betz's avatar Matthias Betz
Browse files

renamed tiny edge error to degenerated edge error

parent 2f04eb81
Pipeline #1972 failed with stage
in 40 seconds
...@@ -48,7 +48,7 @@ import de.hft.stuttgart.citydoctor2.check.error.SchematronError; ...@@ -48,7 +48,7 @@ import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError; import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError; import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
import de.hft.stuttgart.citydoctor2.check.error.SurfaceUnfragmentedError; import de.hft.stuttgart.citydoctor2.check.error.SurfaceUnfragmentedError;
import de.hft.stuttgart.citydoctor2.check.error.TinyEdgeError; import de.hft.stuttgart.citydoctor2.check.error.DegeneratedPolygonError;
import de.hft.stuttgart.citydoctor2.check.error.TooFewPolygonsError; import de.hft.stuttgart.citydoctor2.check.error.TooFewPolygonsError;
import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError; import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError;
...@@ -123,7 +123,7 @@ public interface ErrorVisitor { ...@@ -123,7 +123,7 @@ public interface ErrorVisitor {
public void visit(SurfaceUnfragmentedError err); public void visit(SurfaceUnfragmentedError err);
public void visit(TinyEdgeError err); public void visit(DegeneratedPolygonError err);
public void visit(AttributeMissingError err); public void visit(AttributeMissingError err);
......
...@@ -46,7 +46,7 @@ import de.hft.stuttgart.citydoctor2.check.error.SchematronError; ...@@ -46,7 +46,7 @@ import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError; import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError; import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
import de.hft.stuttgart.citydoctor2.check.error.SurfaceUnfragmentedError; import de.hft.stuttgart.citydoctor2.check.error.SurfaceUnfragmentedError;
import de.hft.stuttgart.citydoctor2.check.error.TinyEdgeError; import de.hft.stuttgart.citydoctor2.check.error.DegeneratedPolygonError;
import de.hft.stuttgart.citydoctor2.check.error.TooFewPolygonsError; import de.hft.stuttgart.citydoctor2.check.error.TooFewPolygonsError;
import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError; import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError;
...@@ -64,7 +64,7 @@ public interface HealingMethod { ...@@ -64,7 +64,7 @@ public interface HealingMethod {
return false; return false;
} }
default boolean visit(TinyEdgeError e, ModificationListener l) { default boolean visit(DegeneratedPolygonError e, ModificationListener l) {
return false; return false;
} }
......
...@@ -28,13 +28,13 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener; ...@@ -28,13 +28,13 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement; import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
public class TinyEdgeError implements CheckError { public class DegeneratedPolygonError implements CheckError {
private static final long serialVersionUID = 865493182529055651L; private static final long serialVersionUID = 865493182529055651L;
private Polygon p; private Polygon p;
public TinyEdgeError(Polygon p) { public DegeneratedPolygonError(Polygon p) {
this.p = p; this.p = p;
} }
......
...@@ -25,6 +25,7 @@ import java.util.HashMap; ...@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ServiceLoader;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -34,6 +35,8 @@ import org.citygml4j.CityGMLContext; ...@@ -34,6 +35,8 @@ import org.citygml4j.CityGMLContext;
import org.citygml4j.builder.jaxb.CityGMLBuilder; import org.citygml4j.builder.jaxb.CityGMLBuilder;
import org.citygml4j.builder.jaxb.CityGMLBuilderException; import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.factory.GMLGeometryFactory; import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.model.citygml.ade.binding.ADEContext;
import org.citygml4j.model.citygml.core.CityModel; import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.model.citygml.core.CityObjectMember; import org.citygml4j.model.citygml.core.CityObjectMember;
import org.citygml4j.model.module.citygml.CityGMLVersion; import org.citygml4j.model.module.citygml.CityGMLVersion;
...@@ -123,8 +126,14 @@ public class CityDoctorModel { ...@@ -123,8 +126,14 @@ public class CityDoctorModel {
water.stream()).flatMap(co -> co); water.stream()).flatMap(co -> co);
} }
public void saveAs(String file) throws CityGMLBuilderException, CityGMLWriteException { public void saveAs(String file) throws CityGMLBuilderException, CityGMLWriteException, ADEException {
CityGMLContext gmlContext = CityGMLContext.getInstance(); CityGMLContext gmlContext = CityGMLContext.getInstance();
// setup energy ade stuff, so the parser doesn't crash on encountering this
if (!gmlContext.hasADEContexts()) {
for (ADEContext adeContext : ServiceLoader.load(ADEContext.class)) {
gmlContext.registerADEContext(adeContext);
}
}
CityGMLBuilder builder = gmlContext.createCityGMLBuilder(); CityGMLBuilder builder = gmlContext.createCityGMLBuilder();
CityGMLOutputFactory factory = builder.createCityGMLOutputFactory(); CityGMLOutputFactory factory = builder.createCityGMLOutputFactory();
try (CityGMLWriter writer = factory.createCityGMLWriter(new File(file))) { try (CityGMLWriter writer = factory.createCityGMLWriter(new File(file))) {
......
...@@ -26,6 +26,7 @@ import java.util.List; ...@@ -26,6 +26,7 @@ import java.util.List;
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.citygml4j.builder.jaxb.CityGMLBuilderException; import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException; import org.citygml4j.xml.io.writer.CityGMLWriteException;
import de.hft.stuttgart.citydoctor2.check.Checker; import de.hft.stuttgart.citydoctor2.check.Checker;
...@@ -64,8 +65,9 @@ public class CityDoctorValidation { ...@@ -64,8 +65,9 @@ public class CityDoctorValidation {
* the cityGML schema. * the cityGML schema.
* @throws CityGMLWriteException * @throws CityGMLWriteException
* @throws CityGMLBuilderException * @throws CityGMLBuilderException
* @throws ADEException
*/ */
public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException { public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException, ADEException {
ArgumentParser argParser = new ArgumentParser(args); ArgumentParser argParser = new ArgumentParser(args);
String inputFile = getInputFile(argParser); String inputFile = getInputFile(argParser);
String xmlOutput = getXmlOutput(argParser); String xmlOutput = getXmlOutput(argParser);
...@@ -107,9 +109,10 @@ public class CityDoctorValidation { ...@@ -107,9 +109,10 @@ public class CityDoctorValidation {
* happens. * happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to * @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema. * the cityGML schema.
* @throws ADEException
*/ */
public static void validate(File inputFile, File xmlOutput, File pdfOutput) public static void validate(File inputFile, File xmlOutput, File pdfOutput)
throws IOException, CityGmlParseException, InvalidGmlFileException { throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
validate(inputFile, xmlOutput, pdfOutput, null); validate(inputFile, xmlOutput, pdfOutput, null);
} }
...@@ -126,9 +129,10 @@ public class CityDoctorValidation { ...@@ -126,9 +129,10 @@ public class CityDoctorValidation {
* happens. * happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to * @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema. * the cityGML schema.
* @throws ADEException
*/ */
public static void validate(File inputFile, File xmlOutput, File pdfOutput, File validationConfigFile) public static void validate(File inputFile, File xmlOutput, File pdfOutput, File validationConfigFile)
throws IOException, CityGmlParseException, InvalidGmlFileException { throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
ValidationConfiguration config; ValidationConfiguration config;
if (validationConfigFile == null) { if (validationConfigFile == null) {
config = ValidationConfiguration.loadStandardValidationConfig(); config = ValidationConfiguration.loadStandardValidationConfig();
...@@ -166,10 +170,11 @@ public class CityDoctorValidation { ...@@ -166,10 +170,11 @@ public class CityDoctorValidation {
* @throws CityGMLWriteException if something goes wrong while writing the gml * @throws CityGMLWriteException if something goes wrong while writing the gml
* file * file
* @throws CityGMLBuilderException * @throws CityGMLBuilderException
* @throws ADEException
*/ */
public static void startValidationProcess(File inputFile, String xmlOutput, String pdfOutput, public static void startValidationProcess(File inputFile, String xmlOutput, String pdfOutput,
ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException, ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException,
InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException { InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException, ADEException {
if (config.isUseStreaming()) { if (config.isUseStreaming()) {
Checker.streamCheck(inputFile, xmlOutput, pdfOutput, config, outputFile); Checker.streamCheck(inputFile, xmlOutput, pdfOutput, config, outputFile);
......
...@@ -34,7 +34,7 @@ import de.hft.stuttgart.citydoctor2.check.ResultStatus; ...@@ -34,7 +34,7 @@ import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.Unit; import de.hft.stuttgart.citydoctor2.check.Unit;
import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError; import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError;
import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonNormalsDeviation; import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonNormalsDeviation;
import de.hft.stuttgart.citydoctor2.check.error.TinyEdgeError; import de.hft.stuttgart.citydoctor2.check.error.DegeneratedPolygonError;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex; import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
...@@ -59,7 +59,7 @@ public class PlanarCheck extends Check { ...@@ -59,7 +59,7 @@ public class PlanarCheck extends Check {
private static final String DISTANCE_TOLERANCE = "distanceTolerance"; private static final String DISTANCE_TOLERANCE = "distanceTolerance";
private static final String ANGLE_TOLERANCE = "angleTolerance"; private static final String ANGLE_TOLERANCE = "angleTolerance";
private static final String TYPE = "type"; private static final String TYPE = "type";
private static final String TINY_EDGE_TOLERANCE = "tinyEdgeTolerance"; private static final String DEGENERATED_POLYGON_TOLERANCE = "degeneratedPolygonTolerance";
private static final List<CheckId> dependencies; private static final List<CheckId> dependencies;
private static final List<DefaultParameter> defaultParameters; private static final List<DefaultParameter> defaultParameters;
...@@ -76,7 +76,7 @@ public class PlanarCheck extends Check { ...@@ -76,7 +76,7 @@ public class PlanarCheck extends Check {
defParameters.add(new DefaultParameter(TYPE, DISTANCE, Unit.NONE)); defParameters.add(new DefaultParameter(TYPE, DISTANCE, Unit.NONE));
defParameters.add(new DefaultParameter(DISTANCE_TOLERANCE, "0.01", Unit.METER)); defParameters.add(new DefaultParameter(DISTANCE_TOLERANCE, "0.01", Unit.METER));
defParameters.add(new DefaultParameter(ANGLE_TOLERANCE, "1", Unit.DEGREE)); defParameters.add(new DefaultParameter(ANGLE_TOLERANCE, "1", Unit.DEGREE));
defParameters.add(new DefaultParameter(TINY_EDGE_TOLERANCE, "0.00000", Unit.METER)); defParameters.add(new DefaultParameter(DEGENERATED_POLYGON_TOLERANCE, "0.00000", Unit.METER));
defaultParameters = Collections.unmodifiableList(defParameters); defaultParameters = Collections.unmodifiableList(defParameters);
} }
...@@ -85,29 +85,21 @@ public class PlanarCheck extends Check { ...@@ -85,29 +85,21 @@ public class PlanarCheck extends Check {
private double rad = Math.toRadians(1); private double rad = Math.toRadians(1);
private double delta = 0.01; private double delta = 0.01;
private double tinyEdgeTolerance = 0.00000; private double degeneratedPolygonTolerance = 0.00000;
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<String, String> parameters, ParserConfiguration config) {
if (parameters.containsKey(TYPE)) { if (parameters.containsKey(TYPE)) {
planarCheckType = parameters.get(TYPE).toLowerCase(); planarCheckType = parameters.get(TYPE).toLowerCase();
} else {
planarCheckType = DISTANCE;
} }
if (parameters.containsKey(ANGLE_TOLERANCE)) { if (parameters.containsKey(ANGLE_TOLERANCE)) {
rad = Math.toRadians(Double.parseDouble(parameters.get(ANGLE_TOLERANCE))); rad = Math.toRadians(Double.parseDouble(parameters.get(ANGLE_TOLERANCE)));
} else {
rad = Math.toRadians(1);
} }
if (parameters.containsKey(DISTANCE_TOLERANCE)) { if (parameters.containsKey(DISTANCE_TOLERANCE)) {
delta = Double.parseDouble(parameters.get(DISTANCE_TOLERANCE)); delta = Double.parseDouble(parameters.get(DISTANCE_TOLERANCE));
} else {
delta = 0.01;
} }
if (parameters.containsKey(TINY_EDGE_TOLERANCE)) { if (parameters.containsKey(DEGENERATED_POLYGON_TOLERANCE)) {
tinyEdgeTolerance = Double.parseDouble(parameters.get(TINY_EDGE_TOLERANCE)); degeneratedPolygonTolerance = Double.parseDouble(parameters.get(DEGENERATED_POLYGON_TOLERANCE));
} else {
tinyEdgeTolerance = 0.00002;
} }
} }
...@@ -231,12 +223,12 @@ public class PlanarCheck extends Check { ...@@ -231,12 +223,12 @@ public class PlanarCheck extends Check {
private boolean checkEigenvalues(Polygon p, Vector3d eigenvalues) { private boolean checkEigenvalues(Polygon p, Vector3d eigenvalues) {
int nrOfEigenvaluesBelowTolerance = 0; int nrOfEigenvaluesBelowTolerance = 0;
for (double d : eigenvalues.getCoordinates()) { for (double d : eigenvalues.getCoordinates()) {
if (d <= tinyEdgeTolerance) { if (d <= degeneratedPolygonTolerance) {
nrOfEigenvaluesBelowTolerance++; nrOfEigenvaluesBelowTolerance++;
} }
} }
if (nrOfEigenvaluesBelowTolerance >= 2) { if (nrOfEigenvaluesBelowTolerance >= 2) {
CheckError err = new TinyEdgeError(p); CheckError err = new DegeneratedPolygonError(p);
p.addCheckResult(new CheckResult(this, ResultStatus.ERROR, err)); p.addCheckResult(new CheckResult(this, ResultStatus.ERROR, err));
return true; return true;
} }
......
...@@ -25,6 +25,7 @@ import java.io.File; ...@@ -25,6 +25,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.citygml4j.builder.jaxb.CityGMLBuilderException; import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException; import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -70,7 +71,7 @@ public class CheckerTest { ...@@ -70,7 +71,7 @@ public class CheckerTest {
@Test @Test
public void testChecker() throws CityGmlParseException, IOException, InvalidGmlFileException, public void testChecker() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException { CityGMLBuilderException, CityGMLWriteException, ADEException {
File f = folder.newFile(); File f = folder.newFile();
File f2 = folder.newFile(); File f2 = folder.newFile();
...@@ -93,7 +94,7 @@ public class CheckerTest { ...@@ -93,7 +94,7 @@ public class CheckerTest {
@Test @Test
public void testStreaming() throws CityGmlParseException, IOException, InvalidGmlFileException, public void testStreaming() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException { CityGMLBuilderException, CityGMLWriteException, ADEException {
File f = folder.newFile(); File f = folder.newFile();
File f2 = folder.newFile(); File f2 = folder.newFile();
File f3 = folder.newFile(); File f3 = folder.newFile();
......
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