Commit 183b4ce7 authored by Luna Riegel's avatar Luna Riegel
Browse files

Merge branch 'dev' into dev_advanced_db_management

parents 8e7a9551 d3ca6500
...@@ -345,7 +345,7 @@ public abstract non-sealed class Check implements CheckableVisitor { ...@@ -345,7 +345,7 @@ public abstract non-sealed class Check implements CheckableVisitor {
* @param config sometimes there are global parameters which can be used by * @param config sometimes there are global parameters which can be used by
* checks. Those are be stored in this container * checks. Those are be stored in this container
*/ */
public void init(Map<String, String> params, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
} }
......
...@@ -18,6 +18,16 @@ ...@@ -18,6 +18,16 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor; import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.math.Triangle3d; import de.hft.stuttgart.citydoctor2.math.Triangle3d;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
...@@ -26,11 +36,6 @@ import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator; ...@@ -26,11 +36,6 @@ import de.hft.stuttgart.citydoctor2.utils.BoundingBoxCalculator;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair; import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.util.*;
/** /**
* Representation of a geometry containing the polygons and edges * Representation of a geometry containing the polygons and edges
* *
...@@ -55,9 +60,11 @@ public class Geometry extends GmlElement { ...@@ -55,9 +60,11 @@ public class Geometry extends GmlElement {
private CityObject parent; private CityObject parent;
private final List<Polygon> polygons = new ArrayList<>(2); private final List<Polygon> polygons = new ArrayList<>(2);
private transient List<Edge> edges; private List<Edge> edges;
private transient Map<SerializablePair<Vertex, Vertex>, Edge> edgeMap; private Map<SerializablePair<Vertex, Vertex>, Edge> edgeMap;
private transient List<Vertex> vertices; private List<Vertex> vertices;
private Map<Vertex, Set<LinearRing>> adjacentRingsOfVertices = new HashMap<>();
private Orientation orientation; private Orientation orientation;
public Geometry(GeometryType type, Lod lod, Orientation orientation) { public Geometry(GeometryType type, Lod lod, Orientation orientation) {
...@@ -69,6 +76,15 @@ public class Geometry extends GmlElement { ...@@ -69,6 +76,15 @@ public class Geometry extends GmlElement {
this.orientation = orientation; this.orientation = orientation;
} }
public Set<LinearRing> getAdjacentRingsOfVertex(Vertex v) {
return adjacentRingsOfVertices.compute(v, (vertex, set) -> {
if (set == null) {
return new HashSet<>(4);
}
return set;
});
}
public Orientation getOrientation() { public Orientation getOrientation() {
return orientation; return orientation;
} }
...@@ -346,18 +362,9 @@ public class Geometry extends GmlElement { ...@@ -346,18 +362,9 @@ public class Geometry extends GmlElement {
return false; return false;
} }
@Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
edges = new ArrayList<>();
edgeMap = new HashMap<>();
}
public void clearMetaData() { public void clearMetaData() {
if (vertices != null) { if (vertices != null) {
for (Vertex v : vertices) { adjacentRingsOfVertices = new HashMap<>();
v.clearAdjacentRings();
}
vertices = null; vertices = null;
} }
edges = null; edges = null;
......
...@@ -18,16 +18,12 @@ ...@@ -18,16 +18,12 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial; import java.io.Serial;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
/** /**
* Contains the vertex information of a point in a linear ring * Contains the vertex information of a point in a linear ring
...@@ -39,7 +35,6 @@ public class Vertex extends Vector3d { ...@@ -39,7 +35,6 @@ public class Vertex extends Vector3d {
@Serial @Serial
private static final long serialVersionUID = -5525361920397934892L; private static final long serialVersionUID = -5525361920397934892L;
private transient List<SerializablePair<Geometry, HashSet<LinearRing>>> adjacentRings = new ArrayList<>(2);
public Vertex(double x, double y, double z) { public Vertex(double x, double y, double z) {
super(x, y, z); super(x, y, z);
...@@ -49,58 +44,16 @@ public class Vertex extends Vector3d { ...@@ -49,58 +44,16 @@ public class Vertex extends Vector3d {
super(vec); super(vec);
} }
private Set<LinearRing> getAdjacentRingsWithoutNeighbor(Geometry geom) {
for (SerializablePair<Geometry, HashSet<LinearRing>> adjacency : adjacentRings) {
if (adjacency.getValue0() == geom) {
return adjacency.getValue1();
}
}
throw new IllegalStateException("Requested adjacent rings with Geometry not containing this vertex");
}
public Set<LinearRing> getAdjacentRings(Geometry geom) { public Set<LinearRing> getAdjacentRings(Geometry geom) {
return getAdjacentRingsWithoutNeighbor(geom); return geom.getAdjacentRingsOfVertex(this);
} }
void addAdjacentRing(LinearRing ring, Geometry geom) { void addAdjacentRing(LinearRing ring, Geometry geom) {
findAdjacentRingsForGeometry(geom).add(ring); getAdjacentRings(geom).add(ring);
}
private Set<LinearRing> findAdjacentRingsForGeometry(Geometry geom) {
HashSet<LinearRing> adjacendRingsSet = null;
for (SerializablePair<Geometry, HashSet<LinearRing>> adjacency : adjacentRings) {
if (adjacency.getValue0() == geom) {
adjacendRingsSet = adjacency.getValue1();
}
}
if (adjacendRingsSet == null) {
adjacendRingsSet = new HashSet<>(4);
adjacentRings.add(new SerializablePair<>(geom, adjacendRingsSet));
}
return adjacendRingsSet;
}
private Set<Polygon> getAdjacentPolygonsWithoutNeighbor(Geometry geom) {
for (SerializablePair<Geometry, HashSet<LinearRing>> adjacency : adjacentRings) {
if (adjacency.getValue0() == geom) {
Set<Polygon> polygons = new HashSet<>();
for (LinearRing lr : adjacency.getValue1()) {
polygons.add(lr.getParent());
}
return polygons;
}
}
throw new IllegalStateException("Requested adjacent polygons with Geometry not containing this vertex");
}
@Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
clearAdjacentRings();
} }
public Set<Polygon> getAdjacentPolygons(Geometry geom) { public Set<Polygon> getAdjacentPolygons(Geometry geom) {
return getAdjacentPolygonsWithoutNeighbor(geom); return getAdjacentRings(geom).stream().map(r -> r.getParent()).collect(Collectors.toCollection(HashSet::new));
} }
@Override @Override
...@@ -127,21 +80,11 @@ public class Vertex extends Vector3d { ...@@ -127,21 +80,11 @@ public class Vertex extends Vector3d {
} }
public void clearAdjacentRings(Geometry geometry) { public void clearAdjacentRings(Geometry geometry) {
if (adjacentRings == null) { getAdjacentRings(geometry).clear();
return;
}
findAdjacentRingsForGeometry(geometry).clear();
} }
void removeAdjacency(LinearRing lr, Geometry geom) { void removeAdjacency(LinearRing lr, Geometry geom) {
findAdjacentRingsForGeometry(geom).remove(lr); getAdjacentRings(geom).remove(lr);
}
/**
* Remove all adjacent rings from this vertex, ignoring geometry association
*/
void clearAdjacentRings() {
adjacentRings = new ArrayList<>(2);
} }
} }
...@@ -34,8 +34,6 @@ public class Segment3d implements Serializable { ...@@ -34,8 +34,6 @@ public class Segment3d implements Serializable {
private static final double PRECISION = 0.00000001; private static final double PRECISION = 0.00000001;
private static final double EPSILON = 0.01;
private final Vector3d pointA; private final Vector3d pointA;
private final Vector3d pointB; private final Vector3d pointB;
...@@ -178,7 +176,7 @@ public class Segment3d implements Serializable { ...@@ -178,7 +176,7 @@ public class Segment3d implements Serializable {
return "Segment3d [pointA=" + pointA + ", pointB=" + pointB + "]"; return "Segment3d [pointA=" + pointA + ", pointB=" + pointB + "]";
} }
public Vector3d intersection(Triangle3d triangle) { public Vector3d intersection(Triangle3d triangle, double eps) {
Vector3d v0 = triangle.getP1(); Vector3d v0 = triangle.getP1();
Vector3d v1 = triangle.getP2(); Vector3d v1 = triangle.getP2();
Vector3d v2 = triangle.getP3(); Vector3d v2 = triangle.getP3();
...@@ -188,7 +186,7 @@ public class Segment3d implements Serializable { ...@@ -188,7 +186,7 @@ public class Segment3d implements Serializable {
Vector3d p = direction.cross(edge2); Vector3d p = direction.cross(edge2);
double det = edge1.dot(p); double det = edge1.dot(p);
if (det > -EPSILON && det < EPSILON) { if (det > -eps && det < eps) {
return null; return null;
} }
...@@ -197,7 +195,7 @@ public class Segment3d implements Serializable { ...@@ -197,7 +195,7 @@ public class Segment3d implements Serializable {
Vector3d s = pointA.minus(v0); Vector3d s = pointA.minus(v0);
double u = invDet * s.dot(p); double u = invDet * s.dot(p);
if (u < EPSILON || u > (1.0 - EPSILON)) { if (u < eps || u > (1.0 - eps)) {
return null; return null;
} }
...@@ -210,7 +208,7 @@ public class Segment3d implements Serializable { ...@@ -210,7 +208,7 @@ public class Segment3d implements Serializable {
} }
double t = edge2.dot(q) * invDet; double t = edge2.dot(q) * invDet;
if (t > EPSILON && t < 1 - EPSILON) { if (t > eps && t < 1 - eps) {
// t is in segment // t is in segment
return pointA.plus(direction.mult(t)); return pointA.plus(direction.mult(t));
} }
......
...@@ -35,6 +35,8 @@ public class Triangle3d implements Serializable { ...@@ -35,6 +35,8 @@ public class Triangle3d implements Serializable {
private static final long serialVersionUID = -6907333357794272435L; private static final long serialVersionUID = -6907333357794272435L;
private static final double EPSILON = 0.0001; private static final double EPSILON = 0.0001;
private static final double PLANAR_EPSILON = 0.0000001;
private final Vector3d p1; private final Vector3d p1;
private final Vector3d p2; private final Vector3d p2;
private final Vector3d p3; private final Vector3d p3;
...@@ -52,6 +54,53 @@ public class Triangle3d implements Serializable { ...@@ -52,6 +54,53 @@ public class Triangle3d implements Serializable {
this.partOf = partOf; this.partOf = partOf;
} }
public boolean hasMinExtent(double minExtent) {
Vector3d ab = p2.minus(p1);
Vector3d ac = p3.minus(p1);
Vector3d bc = p3.minus(p2);
// Find the longest edge to use as primary axis
double lenAB2 = ab.getSquaredLength();
double lenAC2 = ac.getSquaredLength();
double lenBC2 = bc.getSquaredLength();
Vector3d axisX;
if (lenAB2 >= lenAC2 && lenAB2 >= lenBC2) {
axisX = ab;
} else if (lenAC2 >= lenBC2) {
axisX = ac;
} else {
axisX = bc;
}
axisX = axisX.normalize();
// Pick any vector not parallel to axisX for in-plane Y axis
Vector3d axisY = pickPerpendicular(axisX);
// Project vertices onto axes
double minX = Math.min(p1.dot(axisX), Math.min(p2.dot(axisX), p3.dot(axisX)));
double maxX = Math.max(p1.dot(axisX), Math.max(p2.dot(axisX), p3.dot(axisX)));
double minY = Math.min(p1.dot(axisY), Math.min(p2.dot(axisY), p3.dot(axisY)));
double maxY = Math.max(p1.dot(axisY), Math.max(p2.dot(axisY), p3.dot(axisY)));
double extentX = maxX - minX;
double extentY = maxY - minY;
return extentX > minExtent && extentY > minExtent;
}
private Vector3d pickPerpendicular(Vector3d v) {
// choose smallest component to avoid near-zero cross
if (Math.abs(v.getX()) < Math.abs(v.getY()) && Math.abs(v.getX()) < Math.abs(v.getZ())) {
return new Vector3d(0, -v.getZ(), v.getY()).normalize();
}
if (Math.abs(v.getY()) < Math.abs(v.getZ())) {
return new Vector3d(-v.getZ(), 0, v.getX()).normalize();
}
return new Vector3d(-v.getY(), v.getX(), 0).normalize();
}
public TesselatedPolygon getPartOf() { public TesselatedPolygon getPartOf() {
return partOf; return partOf;
} }
...@@ -101,13 +150,13 @@ public class Triangle3d implements Serializable { ...@@ -101,13 +150,13 @@ public class Triangle3d implements Serializable {
double distanceP2T2 = planeT2.getSignedDistance(p2); double distanceP2T2 = planeT2.getSignedDistance(p2);
double distanceP3T2 = planeT2.getSignedDistance(p3); double distanceP3T2 = planeT2.getSignedDistance(p3);
if (Math.abs(distanceP1T2) < epsilon) { if (Math.abs(distanceP1T2) < PLANAR_EPSILON) {
distanceP1T2 = 0.0; distanceP1T2 = 0.0;
} }
if (Math.abs(distanceP2T2) < epsilon) { if (Math.abs(distanceP2T2) < PLANAR_EPSILON) {
distanceP2T2 = 0.0; distanceP2T2 = 0.0;
} }
if (Math.abs(distanceP3T2) < epsilon) { if (Math.abs(distanceP3T2) < PLANAR_EPSILON) {
distanceP3T2 = 0.0; distanceP3T2 = 0.0;
} }
...@@ -144,20 +193,18 @@ public class Triangle3d implements Serializable { ...@@ -144,20 +193,18 @@ public class Triangle3d implements Serializable {
return false; return false;
} }
boolean intersects = checkTriangleLineIntersection(other, p1, p2) || checkTriangleLineIntersection(other, p1, p3) boolean intersects = checkTriangleLineIntersection(other, p1, p2, epsilon)
|| checkTriangleLineIntersection(other, p2, p3) || checkTriangleLineIntersection(other, p1, p3, epsilon)
|| checkTriangleLineIntersection(this, other.p1, other.p2) || checkTriangleLineIntersection(other, p2, p3, epsilon)
|| checkTriangleLineIntersection(this, other.p1, other.p3) || checkTriangleLineIntersection(this, other.p1, other.p2, epsilon)
|| checkTriangleLineIntersection(this, other.p2, other.p3); || checkTriangleLineIntersection(this, other.p1, other.p3, epsilon)
if (intersects) { || checkTriangleLineIntersection(this, other.p2, other.p3, epsilon);
System.out.println();
}
return intersects; return intersects;
} }
private boolean checkTriangleLineIntersection(Triangle3d other, Vector3d a, Vector3d b) { private boolean checkTriangleLineIntersection(Triangle3d other, Vector3d a, Vector3d b, double eps) {
Segment3d seg = new Segment3d(a, b); Segment3d seg = new Segment3d(a, b);
Vector3d intersection1 = seg.intersection(other); Vector3d intersection1 = seg.intersection(other, eps);
return intersection1 != null; return intersection1 != null;
} }
...@@ -274,5 +321,4 @@ public class Triangle3d implements Serializable { ...@@ -274,5 +321,4 @@ public class Triangle3d implements Serializable {
public void setPartOf(TesselatedPolygon p) { public void setPartOf(TesselatedPolygon p) {
partOf = p; partOf = p;
} }
} }
...@@ -49,6 +49,7 @@ public class Vector3d implements Serializable { ...@@ -49,6 +49,7 @@ public class Vector3d implements Serializable {
/** /**
* Convert JTS Coordinate class to Vector3d. * Convert JTS Coordinate class to Vector3d.
*
* @param coord JTS Coordinate * @param coord JTS Coordinate
*/ */
public Vector3d(Coordinate coord) { public Vector3d(Coordinate coord) {
...@@ -210,7 +211,8 @@ public class Vector3d implements Serializable { ...@@ -210,7 +211,8 @@ public class Vector3d implements Serializable {
} }
/** /**
* normalizes this vector. This method changes the coordinates of this instance. * returns a normalized vector in the same direction as this one. This method
* does not change the coordinates of this instance.
*/ */
public UnitVector3d normalize() { public UnitVector3d normalize() {
return UnitVector3d.of(this); return UnitVector3d.of(this);
...@@ -253,9 +255,9 @@ public class Vector3d implements Serializable { ...@@ -253,9 +255,9 @@ public class Vector3d implements Serializable {
@Override @Override
public String toString() { public String toString() {
final int maxLen = 5; final int maxLen = 5;
return "Vector3d [coords=" + return "Vector3d [coords="
(coords != null ? Arrays.toString(Arrays.copyOf(coords, Math.min(coords.length, maxLen))) : null) + + (coords != null ? Arrays.toString(Arrays.copyOf(coords, Math.min(coords.length, maxLen))) : null)
"]"; + "]";
} }
@Override @Override
......
...@@ -52,12 +52,12 @@ public class BuildingTest { ...@@ -52,12 +52,12 @@ public class BuildingTest {
Vertex v2 = new Vertex(2, 0, 0); Vertex v2 = new Vertex(2, 0, 0);
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR); LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
ConcretePolygon p = new ConcretePolygon(); ConcretePolygon p = new ConcretePolygon();
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD0, Orientation.OUTWARD);
geom.addPolygon(p);
p.setExteriorRing(lr); p.setExteriorRing(lr);
lr.addVertex(v1); lr.addVertex(v1);
lr.addVertex(v2); lr.addVertex(v2);
lr.addVertex(v1); lr.addVertex(v1);
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD0, Orientation.OUTWARD);
geom.addPolygon(p);
geom.updateEdgesAndVertices(); geom.updateEdgesAndVertices();
b.addGeometry(geom); b.addGeometry(geom);
......
...@@ -105,9 +105,9 @@ public class GeometryTest { ...@@ -105,9 +105,9 @@ public class GeometryTest {
ConcretePolygon p = new ConcretePolygon(); ConcretePolygon p = new ConcretePolygon();
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR); LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr); p.setExteriorRing(lr);
geom.addPolygon(p);
lr.addVertex(new Vertex(0, 0, 0)); lr.addVertex(new Vertex(0, 0, 0));
geom.addPolygon(p);
p.setPartOfSurface(bs); p.setPartOfSurface(bs);
p.setPartOfInstallation(bi); p.setPartOfInstallation(bi);
...@@ -139,9 +139,9 @@ public class GeometryTest { ...@@ -139,9 +139,9 @@ public class GeometryTest {
ConcretePolygon p = new ConcretePolygon(); ConcretePolygon p = new ConcretePolygon();
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR); LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr); p.setExteriorRing(lr);
geom.addPolygon(p);
lr.addVertex(new Vertex(0, 0, 0)); lr.addVertex(new Vertex(0, 0, 0));
geom.addPolygon(p);
p.setPartOfSurface(bs); p.setPartOfSurface(bs);
bs.addGeometry(geom); bs.addGeometry(geom);
...@@ -165,10 +165,10 @@ public class GeometryTest { ...@@ -165,10 +165,10 @@ public class GeometryTest {
ConcretePolygon p = new ConcretePolygon(); ConcretePolygon p = new ConcretePolygon();
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR); LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr); p.setExteriorRing(lr);
geom.addPolygon(p);
lr.addVertex(new Vertex(0, 0, 0)); lr.addVertex(new Vertex(0, 0, 0));
bs.addGeometry(geom); bs.addGeometry(geom);
geom.addPolygon(p);
p.setPartOfSurface(bs); p.setPartOfSurface(bs);
p.setPartOfInstallation(bi); p.setPartOfInstallation(bi);
......
...@@ -22,6 +22,7 @@ import static org.junit.Assert.*; ...@@ -22,6 +22,7 @@ import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry.Orientation;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.math.UnitVector3d; import de.hft.stuttgart.citydoctor2.math.UnitVector3d;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
...@@ -35,7 +36,9 @@ public class LinearRingTest { ...@@ -35,7 +36,9 @@ public class LinearRingTest {
@Test @Test
public void testIsPointInside1() { public void testIsPointInside1() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2, Orientation.OUTWARD);
Polygon p = new ConcretePolygon(); Polygon p = new ConcretePolygon();
geom.addPolygon(p);
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR); LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr); p.setExteriorRing(lr);
......
...@@ -62,20 +62,4 @@ public class VertexTest { ...@@ -62,20 +62,4 @@ public class VertexTest {
assertEquals(1, adjacentRings.size()); assertEquals(1, adjacentRings.size());
assertTrue(adjacentRings.contains(lr)); assertTrue(adjacentRings.contains(lr));
} }
@Test(expected = IllegalStateException.class)
public void testGetAdjacentRingsGeometryNotContainingVertex() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD1, Orientation.OUTWARD);
Polygon p = new ConcretePolygon();
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr);
Vertex v0 = new Vertex(0, 0, 0);
lr.addVertex(v0);
v0.getAdjacentRings(geom);
}
} }
...@@ -636,7 +636,7 @@ public class Checker { ...@@ -636,7 +636,7 @@ public class Checker {
ArrayList<Check> checkList = new ArrayList<>(); ArrayList<Check> checkList = new ArrayList<>();
for (CheckId id : enabledCheck) { for (CheckId id : enabledCheck) {
Check c = checkConfig.getCheckForId(id); Check c = checkConfig.getCheckForId(id);
c.init(parameterMap.get(id), parserConfig); c.init(parameterMap, parserConfig);
checkList.add(c); checkList.add(c);
} }
return checkList; return checkList;
...@@ -652,7 +652,6 @@ public class Checker { ...@@ -652,7 +652,6 @@ public class Checker {
parameterMap.compute(proto.getCheckId(), (k, v) -> { parameterMap.compute(proto.getCheckId(), (k, v) -> {
if (v == null) { if (v == null) {
v = new HashMap<>(); v = new HashMap<>();
v.put(GlobalParameters.NUMBER_OF_ROUNDING_PLACES, config.getNumberOfRoundingPlacesAsString());
v.put(GlobalParameters.MIN_VERTEX_DISTANCE, config.getMinVertexDistanceAsString()); v.put(GlobalParameters.MIN_VERTEX_DISTANCE, config.getMinVertexDistanceAsString());
} }
v.putAll(e.getValue().getParameters()); v.putAll(e.getValue().getParameters());
......
...@@ -62,7 +62,7 @@ public class CheckContainer extends Check { ...@@ -62,7 +62,7 @@ public class CheckContainer extends Check {
} }
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> parameters, ParserConfiguration config) {
check.init(parameters, config); check.init(parameters, config);
} }
......
...@@ -30,10 +30,12 @@ import de.hft.stuttgart.citydoctor2.check.CheckId; ...@@ -30,10 +30,12 @@ import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult; import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.RequirementType; import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.Checkable; import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.check.GlobalParameters;
import de.hft.stuttgart.citydoctor2.check.Requirement; import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.ResultStatus; import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError; import de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError;
import de.hft.stuttgart.citydoctor2.check.error.RingDuplicatePointError; import de.hft.stuttgart.citydoctor2.check.error.RingDuplicatePointError;
import de.hft.stuttgart.citydoctor2.checks.Checks;
import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils; import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex; import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
...@@ -52,8 +54,6 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -52,8 +54,6 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/ */
public class DuplicatePointsCheck extends Check { public class DuplicatePointsCheck extends Check {
private static final String EPSILON_NAME = "minVertexDistance";
private static final List<CheckId> dependencies; private static final List<CheckId> dependencies;
static { static {
...@@ -66,11 +66,16 @@ public class DuplicatePointsCheck extends Check { ...@@ -66,11 +66,16 @@ public class DuplicatePointsCheck extends Check {
classes.add(LinearRing.class); classes.add(LinearRing.class);
} }
private double epsilon = 0.0001; private double epsilon = Checks.MIN_VERTEX_DISTANCE_DEFAULT;
@Override @Override
public void init(Map<String, String> params, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
String epsilonString = params.get(EPSILON_NAME); Map<String, String> localParameters = params.get(getCheckId());
if (localParameters == null) {
// no parameters
return;
}
String epsilonString = localParameters.get(GlobalParameters.MIN_VERTEX_DISTANCE);
if (epsilonString != null) { if (epsilonString != null) {
epsilon = Double.parseDouble(epsilonString); epsilon = Double.parseDouble(epsilonString);
} }
......
...@@ -29,10 +29,12 @@ import de.hft.stuttgart.citydoctor2.check.Check; ...@@ -29,10 +29,12 @@ import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult; import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.GlobalParameters;
import de.hft.stuttgart.citydoctor2.check.RequirementType; import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.Requirement; import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.ResultStatus; import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.PolygonInteriorDisconnectedError; import de.hft.stuttgart.citydoctor2.check.error.PolygonInteriorDisconnectedError;
import de.hft.stuttgart.citydoctor2.checks.Checks;
import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils; import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils;
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;
...@@ -49,8 +51,6 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -49,8 +51,6 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/ */
public class InteriorDisconnectedCheck extends Check { public class InteriorDisconnectedCheck extends Check {
private static final String EPSILON_NAME = "minVertexDistance";
private static final List<CheckId> dependencies; private static final List<CheckId> dependencies;
static { static {
...@@ -63,11 +63,16 @@ public class InteriorDisconnectedCheck extends Check { ...@@ -63,11 +63,16 @@ public class InteriorDisconnectedCheck extends Check {
dependencies = Collections.unmodifiableList(deps); dependencies = Collections.unmodifiableList(deps);
} }
private double epsilon = 0.0001; private double epsilon = Checks.MIN_VERTEX_DISTANCE_DEFAULT;
@Override @Override
public void init(Map<String, String> params, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
String epsilonString = params.get(EPSILON_NAME); Map<String, String> localParameters = params.get(getCheckId());
if (localParameters == null) {
// no parameters
return;
}
String epsilonString = localParameters.get(GlobalParameters.MIN_VERTEX_DISTANCE);
if (epsilonString != null) { if (epsilonString != null) {
epsilon = Double.parseDouble(epsilonString); epsilon = Double.parseDouble(epsilonString);
} }
......
...@@ -44,9 +44,10 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedRing; ...@@ -44,9 +44,10 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedRing;
public class NullAreaCheck extends Check { public class NullAreaCheck extends Check {
private static final String DELTA_NAME = "delta"; private static final String DELTA_NAME = "delta";
private static final List<CheckId> dependencies; private static final List<CheckId> dependencies;
private double delta = 0.0001;
static { static {
ArrayList<CheckId> deps = new ArrayList<>(); ArrayList<CheckId> deps = new ArrayList<>();
deps.add(CheckId.C_GE_R_TOO_FEW_POINTS); deps.add(CheckId.C_GE_R_TOO_FEW_POINTS);
...@@ -55,12 +56,16 @@ public class NullAreaCheck extends Check { ...@@ -55,12 +56,16 @@ public class NullAreaCheck extends Check {
dependencies = Collections.unmodifiableList(deps); dependencies = Collections.unmodifiableList(deps);
} }
private double delta = 0.0001;
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
if (parameters.containsKey(DELTA_NAME)) { Map<String, String> localParameters = params.get(getCheckId());
delta = Double.parseDouble(parameters.get(DELTA_NAME)); if (localParameters == null) {
// no parameters
return;
}
String epsilonString = localParameters.get(DELTA_NAME);
if (epsilonString != null) {
delta = Double.parseDouble(epsilonString);
} }
} }
......
...@@ -81,17 +81,22 @@ public class PlanarCheck extends Check { ...@@ -81,17 +81,22 @@ public class PlanarCheck extends Check {
private double delta = 0.01; private double delta = 0.01;
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> parameters, ParserConfiguration config) {
if (parameters.containsKey(TYPE)) { Map<String, String> localParameters = parameters.get(getCheckId());
planarCheckType = parameters.get(TYPE).toLowerCase(); if (localParameters == null) {
// no parameters
return;
}
if (localParameters.containsKey(TYPE)) {
planarCheckType = localParameters.get(TYPE).toLowerCase();
} else { } else {
throw new IllegalStateException("Parameter " + TYPE + " is missing from parameters"); throw new IllegalStateException("Parameter " + TYPE + " is missing from parameters");
} }
if (parameters.containsKey(ANGLE_TOLERANCE)) { if (localParameters.containsKey(ANGLE_TOLERANCE)) {
rad = Math.toRadians(Double.parseDouble(parameters.get(ANGLE_TOLERANCE))); rad = Math.toRadians(Double.parseDouble(localParameters.get(ANGLE_TOLERANCE)));
} }
if (parameters.containsKey(DISTANCE_TOLERANCE)) { if (localParameters.containsKey(DISTANCE_TOLERANCE)) {
delta = Double.parseDouble(parameters.get(DISTANCE_TOLERANCE)); delta = Double.parseDouble(localParameters.get(DISTANCE_TOLERANCE));
} }
} }
......
...@@ -29,6 +29,7 @@ import de.hft.stuttgart.citydoctor2.check.Check; ...@@ -29,6 +29,7 @@ import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError; import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId; import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult; import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.GlobalParameters;
import de.hft.stuttgart.citydoctor2.check.Requirement; import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementType; import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.ResultStatus; import de.hft.stuttgart.citydoctor2.check.ResultStatus;
...@@ -59,15 +60,12 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -59,15 +60,12 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/ */
public class RingSelfIntCheck extends Check { public class RingSelfIntCheck extends Check {
private static final String EPSILON_NAME = "minVertexDistance"; private static final List<CheckId> dependencies;
// check requirement class for default parameters // check requirement class for default parameters
private double degeneratedRingTolerance = 0.01; private double degeneratedRingTolerance = 0.01;
private double epsilon = Checks.MIN_VERTEX_DISTANCE_DEFAULT; private double epsilon = Checks.MIN_VERTEX_DISTANCE_DEFAULT;
private static final List<CheckId> dependencies;
static { static {
ArrayList<CheckId> deps = new ArrayList<>(); ArrayList<CheckId> deps = new ArrayList<>();
deps.add(CheckId.C_GE_R_TOO_FEW_POINTS); deps.add(CheckId.C_GE_R_TOO_FEW_POINTS);
...@@ -78,13 +76,18 @@ public class RingSelfIntCheck extends Check { ...@@ -78,13 +76,18 @@ public class RingSelfIntCheck extends Check {
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> parameters, ParserConfiguration config) {
String epsilonString = parameters.get(EPSILON_NAME); Map<String, String> localParameters = parameters.get(getCheckId());
if (localParameters == null) {
// no parameters
return;
}
String epsilonString = localParameters.get(GlobalParameters.MIN_VERTEX_DISTANCE);
if (epsilonString != null) { if (epsilonString != null) {
epsilon = Double.parseDouble(epsilonString); epsilon = Double.parseDouble(epsilonString);
} }
if (parameters.containsKey(Requirement.DEGENERATED_RING_TOLERANCE)) { if (localParameters.containsKey(Requirement.DEGENERATED_RING_TOLERANCE)) {
degeneratedRingTolerance = Double.parseDouble(parameters.get(Requirement.DEGENERATED_RING_TOLERANCE)); degeneratedRingTolerance = Double.parseDouble(localParameters.get(Requirement.DEGENERATED_RING_TOLERANCE));
} }
} }
......
...@@ -73,10 +73,16 @@ public class SolidSelfIntCheck extends Check { ...@@ -73,10 +73,16 @@ public class SolidSelfIntCheck extends Check {
} }
@Override @Override
public void init(Map<String, String> parameters, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> parameters, ParserConfiguration config) {
if (parameters.containsKey(PlanarCheck.DISTANCE_TOLERANCE)) { Map<String, String> planarParameters = parameters.get(CheckId.C_GE_P_NON_PLANAR);
delta = Double.parseDouble(parameters.get(PlanarCheck.DISTANCE_TOLERANCE)); if (planarParameters == null) {
// no parameters
return;
} }
planarParameters.computeIfPresent(PlanarCheck.DISTANCE_TOLERANCE, (k, v) -> {
delta = Double.parseDouble(v);
return v;
});
} }
@Override @Override
......
...@@ -75,13 +75,18 @@ public class IsWallCheck extends Check { ...@@ -75,13 +75,18 @@ public class IsWallCheck extends Check {
private double upperAngleCos = Math.cos(135 * Math.PI / 180); private double upperAngleCos = Math.cos(135 * Math.PI / 180);
@Override @Override
public void init(Map<String, String> params, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
String lowerAngleString = params.get(LOWER_ANGLE_NAME); Map<String, String> localParameters = params.get(getCheckId());
if (localParameters == null) {
// no parameters
return;
}
String lowerAngleString = localParameters.get(LOWER_ANGLE_NAME);
if (lowerAngleString != null) { if (lowerAngleString != null) {
lowerAngleCos = Double.parseDouble(lowerAngleString); lowerAngleCos = Double.parseDouble(lowerAngleString);
lowerAngleCos = Math.cos(lowerAngleCos * Math.PI / 180); lowerAngleCos = Math.cos(lowerAngleCos * Math.PI / 180);
} }
String upperAngleString = params.get(UPPER_ANGLE_NAME); String upperAngleString = localParameters.get(UPPER_ANGLE_NAME);
if (upperAngleString != null) { if (upperAngleString != null) {
upperAngleCos = Double.parseDouble(upperAngleString); upperAngleCos = Double.parseDouble(upperAngleString);
upperAngleCos = Math.cos(upperAngleCos * Math.PI / 180); upperAngleCos = Math.cos(upperAngleCos * Math.PI / 180);
......
...@@ -60,8 +60,13 @@ public class RoofSurfaceUnfragmentedCheck extends Check { ...@@ -60,8 +60,13 @@ public class RoofSurfaceUnfragmentedCheck extends Check {
} }
@Override @Override
public void init(Map<String, String> params, ParserConfiguration config) { public void init(Map<CheckId, Map<String, String>> params, ParserConfiguration config) {
String maxAngleString = params.get(MAX_ANGLE_DEVIATION); Map<String, String> localParameters = params.get(getCheckId());
if (localParameters == null) {
// no parameters
return;
}
String maxAngleString = localParameters.get(MAX_ANGLE_DEVIATION);
if (maxAngleString != null) { if (maxAngleString != null) {
maxAngleDeviation = Math.toRadians(Double.parseDouble(maxAngleString)); maxAngleDeviation = Math.toRadians(Double.parseDouble(maxAngleString));
} }
......
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