Commit 1745865f authored by Riegel's avatar Riegel
Browse files

Code cleaning Ref #69

parent 5a6f4b46
......@@ -28,7 +28,7 @@ public enum Lod {
LOD0(0), LOD1(1), LOD2(2), LOD3(3), LOD4(4);
private int rank;
private final int rank;
private Lod(int rank) {
this.rank = rank;
......
......@@ -30,6 +30,8 @@ import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
/**
* Represents an Opening suchs a window or Door in a surface of a feature.
* Contains a reference to the boundary surface where this opening is embedded
......@@ -40,6 +42,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/
public class Opening extends CityObject {
@Serial
private static final long serialVersionUID = 6409303152284607944L;
private BoundarySurface partOf;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
......@@ -31,6 +32,7 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
*/
public abstract class Polygon extends GmlElement {
@Serial
private static final long serialVersionUID = -613942946364706513L;
public abstract Vector3d calculateNormalNormalized();
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
......@@ -33,11 +34,12 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class ReliefObject extends CityObject {
@Serial
private static final long serialVersionUID = -9162169874426519903L;
private ReliefFeature feature;
private final ReliefFeature feature;
private List<TinObject> components = new ArrayList<>();
private final List<TinObject> components = new ArrayList<>();
public ReliefObject(ReliefFeature feature) {
this.feature = feature;
......
......@@ -26,6 +26,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
*/
public enum SurfaceFeatureType {
BUILDING, BRIDGE, TUNNEL;
BUILDING, BRIDGE, TUNNEL
}
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
......@@ -46,6 +47,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/
public class TransportationObject extends CityObject {
@Serial
private static final long serialVersionUID = -2698907271726700390L;
public enum TransportationType {
......@@ -53,8 +55,8 @@ public class TransportationObject extends CityObject {
}
private AbstractCityObject ato;
private List<TransportationObject> composesOf = new ArrayList<>(1);
private TransportationType type;
private final List<TransportationObject> composesOf = new ArrayList<>(1);
private final TransportationType type;
public TransportationObject(TransportationType type) {
this.type = type;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.Collections;
import org.citygml4j.core.model.core.AbstractCityObject;
......@@ -45,6 +46,7 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/
public class Vegetation extends CityObject {
@Serial
private static final long serialVersionUID = -5136358065541704146L;
public enum VegetationType {
......@@ -52,7 +54,7 @@ public class Vegetation extends CityObject {
}
private AbstractVegetationObject citygmlVegetation;
private VegetationType type;
private final VegetationType type;
public Vegetation(VegetationType type) {
this.type = type;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -36,6 +37,7 @@ import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
*/
public class Vertex extends Vector3d implements Copyable {
@Serial
private static final long serialVersionUID = -5525361920397934892L;
private List<SerializablePair<Geometry, HashSet<LinearRing>>> adjacentRings = new ArrayList<>(2);
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
......@@ -41,10 +42,11 @@ import de.hft.stuttgart.citydoctor2.utils.Copyable;
*/
public class WaterObject extends CityObject {
@Serial
private static final long serialVersionUID = -3821060595086337424L;
private WaterBody gmlWater;
private List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
......
......@@ -18,8 +18,11 @@
*/
package de.hft.stuttgart.citydoctor2.exceptions;
import java.io.Serial;
public class CityDoctorWriteException extends Exception {
@Serial
private static final long serialVersionUID = 2902212162405599516L;
public CityDoctorWriteException() {
......
......@@ -114,14 +114,14 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private static final Logger logger = LogManager.getLogger(Citygml3FeatureMapper.class);
private CityDoctorModel model;
private final CityDoctorModel model;
private Map<String, ConcretePolygon> polygonMap = new HashMap<>();
private List<ResolvableReference> references = new ArrayList<>();
private Map<Vertex, Vertex> vertexMap = new HashMap<>();
private ParserConfiguration config;
private final ParserConfiguration config;
private double neighborDistance;
private final double neighborDistance;
public Citygml3FeatureMapper(ParserConfiguration config, Path path) {
this.config = config;
......
......@@ -46,12 +46,12 @@ public class Citygml3GeometryMapper extends GeometryWalker {
private static final Logger logger = LogManager.getLogger(Citygml3GeometryMapper.class);
private List<ConcretePolygon> polygons = new ArrayList<>();
private final List<ConcretePolygon> polygons = new ArrayList<>();
private LinearRing currentRing = null;
private ParserConfiguration config;
private ProjCoordinate p1 = new ProjCoordinate();
private ProjCoordinate p2 = new ProjCoordinate();
private Map<Vertex, Vertex> vertexMap;
private final ParserConfiguration config;
private final ProjCoordinate p1 = new ProjCoordinate();
private final ProjCoordinate p2 = new ProjCoordinate();
private final Map<Vertex, Vertex> vertexMap;
public Citygml3GeometryMapper(ParserConfiguration config, Map<Vertex, Vertex> vertices) {
this.config = config;
......@@ -62,7 +62,7 @@ public class Citygml3GeometryMapper extends GeometryWalker {
public void visit(Polygon polygon) {
parsePolygon(polygon.getId(), polygon.getExterior(), polygon.getInterior());
if (polygon.getExterior() == null) {
System.out.println("No exterior: " + polygon.getId());
logger.warn(String.format("No exterior: %s" ,polygon.getId()));
}
}
......@@ -132,7 +132,7 @@ public class Citygml3GeometryMapper extends GeometryWalker {
logger.warn("The number of coordinates for linear ring {} do not result in fully 3D points", id);
}
for (int i = 0; i < coordinates.size(); i = i + 3) {
double x = coordinates.get(i + 0);
double x = coordinates.get(i);
double y = coordinates.get(i + 1);
double z = coordinates.get(i + 2);
createVertex(x, y, z);
......
......@@ -29,7 +29,7 @@ import org.xml.sax.SAXParseException;
public class GMLValidationHandler implements ErrorHandler {
private static final Logger logger = LogManager.getLogger(GMLValidationHandler.class);
private List<String> messages = new ArrayList<>();
private final List<String> messages = new ArrayList<>();
@Override
public void error(SAXParseException exception) {
......
......@@ -58,11 +58,11 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
public class SurfaceMapper extends ObjectWalker {
private List<BoundarySurface> surfaces = new ArrayList<>();
private Map<String, ConcretePolygon> polygonMap;
private List<ResolvableReference> references;
private Map<Vertex, Vertex> vertexMap;
private ParserConfiguration config;
private final List<BoundarySurface> surfaces = new ArrayList<>();
private final Map<String, ConcretePolygon> polygonMap;
private final List<ResolvableReference> references;
private final Map<Vertex, Vertex> vertexMap;
private final ParserConfiguration config;
public SurfaceMapper(Map<String, ConcretePolygon> polygonMap, List<ResolvableReference> references,
Map<Vertex, Vertex> vertexMap, ParserConfiguration config) {
......
......@@ -26,9 +26,9 @@ package de.hft.stuttgart.citydoctor2.math;
*/
public class DistanceResult {
private Vector3d point1;
private Vector3d point2;
private double distance;
private final Vector3d point1;
private final Vector3d point2;
private final double distance;
public DistanceResult(Vector3d point1, Vector3d point2, double distance) {
super();
......
......@@ -29,8 +29,8 @@ public class Edge2d {
private static final double EPSILON = 0.0000001;
private static final double ONE_MINUS_EPSILON = 1 - EPSILON;
private ProjectedVector2d a;
private ProjectedVector2d b;
private final ProjectedVector2d a;
private final ProjectedVector2d b;
public Edge2d(ProjectedVector2d a, ProjectedVector2d b) {
this.a = a;
......@@ -150,11 +150,8 @@ public class Edge2d {
} else if (!a.equals(other.a))
return false;
if (b == null) {
if (other.b != null)
return false;
} else if (!b.equals(other.b))
return false;
return true;
}
return other.b == null;
} else return b.equals(other.b);
}
}
......@@ -20,31 +20,14 @@ package de.hft.stuttgart.citydoctor2.math;
/**
* Result of an intersection calculation
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public class IntersectionPoint2d {
private Line2d line;
private double scalar;
public IntersectionPoint2d(Line2d line, double scalar) {
super();
this.line = line;
this.scalar = scalar;
}
public record IntersectionPoint2d(Line2d line, double scalar) {
public Vector2d getIntersectionPoint() {
return line.getPoint().plus(line.getDirection().mult(scalar));
}
public Line2d getLine() {
return line;
return line.point().plus(line.direction().mult(scalar));
}
public double getScalar() {
return scalar;
}
}
......@@ -24,22 +24,6 @@ package de.hft.stuttgart.citydoctor2.math;
* @author Matthias Betz
*
*/
public class Line2d {
private Vector2d p;
private Vector2d dir;
public Line2d(Vector2d p, Vector2d dir) {
this.p = p;
this.dir = dir;
}
public Vector2d getPoint() {
return p;
}
public Vector2d getDirection() {
return dir;
}
public record Line2d(Vector2d point, Vector2d direction) {
}
......@@ -20,37 +20,13 @@ package de.hft.stuttgart.citydoctor2.math;
/**
* A line described by a point and a direction
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public class Line3d {
public record Line3d(Vector3d point, Vector3d direction) {
public static final double EPSILON = 0.00001;
private Vector3d point;
private Vector3d direction;
public Line3d(Vector3d point, Vector3d direction) {
super();
this.point = point;
this.direction = direction;
}
/**
* @return the point
*/
public Vector3d getPoint() {
return point;
}
/**
* @return the direction
*/
public Vector3d getDirection() {
return direction;
}
public double distanceToPoint(Vector3d v) {
double x = v.getX() - point.getX();
double y = v.getY() - point.getY();
......
......@@ -28,7 +28,7 @@ import java.util.Arrays;
*/
public class Matrix3x3d {
private double[][] values;
private final double[][] values;
/**
* Identity matrix
......@@ -123,10 +123,9 @@ public class Matrix3x3d {
*/
public Matrix3x3d transpose() {
Matrix3x3d x = new Matrix3x3d();
double[][] copyValues = x.values;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
copyValues[j][i] = values[i][j];
x.values[j][i] = values[i][j];
}
}
return x;
......
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