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;
import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
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.UnknownCheckError;
......@@ -123,7 +123,7 @@ public interface ErrorVisitor {
public void visit(SurfaceUnfragmentedError err);
public void visit(TinyEdgeError err);
public void visit(DegeneratedPolygonError err);
public void visit(AttributeMissingError err);
......
......@@ -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.SolidSelfIntError;
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.UnknownCheckError;
......@@ -64,7 +64,7 @@ public interface HealingMethod {
return false;
}
default boolean visit(TinyEdgeError e, ModificationListener l) {
default boolean visit(DegeneratedPolygonError e, ModificationListener l) {
return false;
}
......
......@@ -28,13 +28,13 @@ import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.datastructure.GmlElement;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
public class TinyEdgeError implements CheckError {
public class DegeneratedPolygonError implements CheckError {
private static final long serialVersionUID = 865493182529055651L;
private Polygon p;
public TinyEdgeError(Polygon p) {
public DegeneratedPolygonError(Polygon p) {
this.p = p;
}
......
......@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -34,6 +35,8 @@ import org.citygml4j.CityGMLContext;
import org.citygml4j.builder.jaxb.CityGMLBuilder;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
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.CityObjectMember;
import org.citygml4j.model.module.citygml.CityGMLVersion;
......@@ -123,8 +126,14 @@ public class CityDoctorModel {
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();
// 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();
CityGMLOutputFactory factory = builder.createCityGMLOutputFactory();
try (CityGMLWriter writer = factory.createCityGMLWriter(new File(file))) {
......
......@@ -26,6 +26,7 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import de.hft.stuttgart.citydoctor2.check.Checker;
......@@ -64,8 +65,9 @@ public class CityDoctorValidation {
* the cityGML schema.
* @throws CityGMLWriteException
* @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);
String inputFile = getInputFile(argParser);
String xmlOutput = getXmlOutput(argParser);
......@@ -107,9 +109,10 @@ public class CityDoctorValidation {
* happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema.
* @throws ADEException
*/
public static void validate(File inputFile, File xmlOutput, File pdfOutput)
throws IOException, CityGmlParseException, InvalidGmlFileException {
throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
validate(inputFile, xmlOutput, pdfOutput, null);
}
......@@ -126,9 +129,10 @@ public class CityDoctorValidation {
* happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema.
* @throws ADEException
*/
public static void validate(File inputFile, File xmlOutput, File pdfOutput, File validationConfigFile)
throws IOException, CityGmlParseException, InvalidGmlFileException {
throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
ValidationConfiguration config;
if (validationConfigFile == null) {
config = ValidationConfiguration.loadStandardValidationConfig();
......@@ -166,10 +170,11 @@ public class CityDoctorValidation {
* @throws CityGMLWriteException if something goes wrong while writing the gml
* file
* @throws CityGMLBuilderException
* @throws ADEException
*/
public static void startValidationProcess(File inputFile, String xmlOutput, String pdfOutput,
ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException,
InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException {
InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException, ADEException {
if (config.isUseStreaming()) {
Checker.streamCheck(inputFile, xmlOutput, pdfOutput, config, outputFile);
......
......@@ -34,7 +34,7 @@ import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.Unit;
import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError;
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.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
......@@ -59,7 +59,7 @@ public class PlanarCheck extends Check {
private static final String DISTANCE_TOLERANCE = "distanceTolerance";
private static final String ANGLE_TOLERANCE = "angleTolerance";
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<DefaultParameter> defaultParameters;
......@@ -76,7 +76,7 @@ public class PlanarCheck extends Check {
defParameters.add(new DefaultParameter(TYPE, DISTANCE, Unit.NONE));
defParameters.add(new DefaultParameter(DISTANCE_TOLERANCE, "0.01", Unit.METER));
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);
}
......@@ -85,29 +85,21 @@ public class PlanarCheck extends Check {
private double rad = Math.toRadians(1);
private double delta = 0.01;
private double tinyEdgeTolerance = 0.00000;
private double degeneratedPolygonTolerance = 0.00000;
@Override
public void init(Map<String, String> parameters, ParserConfiguration config) {
if (parameters.containsKey(TYPE)) {
planarCheckType = parameters.get(TYPE).toLowerCase();
} else {
planarCheckType = DISTANCE;
}
if (parameters.containsKey(ANGLE_TOLERANCE)) {
rad = Math.toRadians(Double.parseDouble(parameters.get(ANGLE_TOLERANCE)));
} else {
rad = Math.toRadians(1);
}
if (parameters.containsKey(DISTANCE_TOLERANCE)) {
delta = Double.parseDouble(parameters.get(DISTANCE_TOLERANCE));
} else {
delta = 0.01;
}
if (parameters.containsKey(TINY_EDGE_TOLERANCE)) {
tinyEdgeTolerance = Double.parseDouble(parameters.get(TINY_EDGE_TOLERANCE));
} else {
tinyEdgeTolerance = 0.00002;
if (parameters.containsKey(DEGENERATED_POLYGON_TOLERANCE)) {
degeneratedPolygonTolerance = Double.parseDouble(parameters.get(DEGENERATED_POLYGON_TOLERANCE));
}
}
......@@ -231,12 +223,12 @@ public class PlanarCheck extends Check {
private boolean checkEigenvalues(Polygon p, Vector3d eigenvalues) {
int nrOfEigenvaluesBelowTolerance = 0;
for (double d : eigenvalues.getCoordinates()) {
if (d <= tinyEdgeTolerance) {
if (d <= degeneratedPolygonTolerance) {
nrOfEigenvaluesBelowTolerance++;
}
}
if (nrOfEigenvaluesBelowTolerance >= 2) {
CheckError err = new TinyEdgeError(p);
CheckError err = new DegeneratedPolygonError(p);
p.addCheckResult(new CheckResult(this, ResultStatus.ERROR, err));
return true;
}
......
......@@ -25,6 +25,7 @@ import java.io.File;
import java.io.IOException;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.junit.Rule;
import org.junit.Test;
......@@ -70,7 +71,7 @@ public class CheckerTest {
@Test
public void testChecker() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException {
CityGMLBuilderException, CityGMLWriteException, ADEException {
File f = folder.newFile();
File f2 = folder.newFile();
......@@ -93,7 +94,7 @@ public class CheckerTest {
@Test
public void testStreaming() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException {
CityGMLBuilderException, CityGMLWriteException, ADEException {
File f = folder.newFile();
File f2 = 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