Commit 81be0b1d authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev_GUI' into 'dev'

Open source release of CityDoctorGUI and other extensions.

See merge request !6
parents 12d96d95 5a4d0a74
Pipeline #10056 passed with stage
in 1 minute and 6 seconds
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.math; package de.hft.stuttgart.citydoctor2.math;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
...@@ -29,6 +30,7 @@ import java.util.Arrays; ...@@ -29,6 +30,7 @@ import java.util.Arrays;
*/ */
public class Vector3d implements Serializable { public class Vector3d implements Serializable {
@Serial
private static final long serialVersionUID = 3495650092142761365L; private static final long serialVersionUID = 3495650092142761365L;
private static final Vector3d ORIGIN = new Vector3d(); private static final Vector3d ORIGIN = new Vector3d();
...@@ -37,7 +39,7 @@ public class Vector3d implements Serializable { ...@@ -37,7 +39,7 @@ public class Vector3d implements Serializable {
public static final int Y = 1; public static final int Y = 1;
public static final int Z = 2; public static final int Z = 2;
private double[] coords; private final double[] coords;
public Vector3d() { public Vector3d() {
this(0d, 0d, 0d); this(0d, 0d, 0d);
...@@ -238,11 +240,9 @@ public class Vector3d implements Serializable { ...@@ -238,11 +240,9 @@ public class Vector3d implements Serializable {
@Override @Override
public String toString() { public String toString() {
final int maxLen = 5; final int maxLen = 5;
StringBuilder builder = new StringBuilder(); return "Vector3d [coords=" +
builder.append("Vector3d [coords="); (coords != null ? Arrays.toString(Arrays.copyOf(coords, Math.min(coords.length, maxLen))) : null) +
builder.append(coords != null ? Arrays.toString(Arrays.copyOf(coords, Math.min(coords.length, maxLen))) : null); "]";
builder.append("]");
return builder.toString();
} }
@Override @Override
......
...@@ -44,7 +44,7 @@ public class CycleNode { ...@@ -44,7 +44,7 @@ public class CycleNode {
private boolean visited = false; private boolean visited = false;
private Set<CycleNode> children; private final Set<CycleNode> children;
public CycleNode(LinearRing value) { public CycleNode(LinearRing value) {
children = new HashSet<>(); children = new HashSet<>();
...@@ -92,7 +92,7 @@ public class CycleNode { ...@@ -92,7 +92,7 @@ public class CycleNode {
if (lowlink == index) { if (lowlink == index) {
List<LinearRing> comps = new LinkedList<>(); List<LinearRing> comps = new LinkedList<>();
CycleNode w = null; CycleNode w;
do { do {
w = s.pop(); w = s.pop();
w.onStack = false; w.onStack = false;
......
...@@ -35,7 +35,7 @@ public class KDTree { ...@@ -35,7 +35,7 @@ public class KDTree {
private static final int K = 3; private static final int K = 3;
private Vertex location; private Vertex location;
private int axis; private final int axis;
private KDTree left; private KDTree left;
private KDTree right; private KDTree right;
......
...@@ -38,21 +38,14 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex; ...@@ -38,21 +38,14 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
*/ */
public class PolygonGraph { public class PolygonGraph {
private Map<Polygon, PolygonNode> nodeMap; private final Map<Polygon, PolygonNode> nodeMap;
public PolygonGraph() { public PolygonGraph() {
nodeMap = new HashMap<>(); nodeMap = new HashMap<>();
} }
private PolygonNode createOrGetNode(Polygon p) { private PolygonNode createOrGetNode(Polygon p) {
PolygonNode node = nodeMap.get(p); return nodeMap.computeIfAbsent(p, PolygonNode::new);
if (node != null) {
return node;
} else {
node = new PolygonNode(p);
nodeMap.put(p, node);
return node;
}
} }
public void addPolygonConnectionsFromVertex(Vertex v, Geometry geom) { public void addPolygonConnectionsFromVertex(Vertex v, Geometry geom) {
...@@ -92,7 +85,7 @@ public class PolygonGraph { ...@@ -92,7 +85,7 @@ public class PolygonGraph {
List<List<Polygon>> components = new ArrayList<>(); List<List<Polygon>> components = new ArrayList<>();
for (PolygonNode node : nodeMap.values()) { for (PolygonNode node : nodeMap.values()) {
if (!node.visited()) { if (node.isUnvisited()) {
List<Polygon> component = new ArrayList<>(); List<Polygon> component = new ArrayList<>();
Deque<PolygonNode> stack = new LinkedList<>(); Deque<PolygonNode> stack = new LinkedList<>();
stack.push(node); stack.push(node);
...@@ -109,7 +102,7 @@ public class PolygonGraph { ...@@ -109,7 +102,7 @@ public class PolygonGraph {
node.setVisited(true); node.setVisited(true);
component.add(node.getContent()); component.add(node.getContent());
for (PolygonNode child : node.getChildren()) { for (PolygonNode child : node.getChildren()) {
if (!child.visited()) { if (child.isUnvisited()) {
child.setVisited(true); child.setVisited(true);
stack.push(child); stack.push(child);
} }
......
...@@ -31,8 +31,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon; ...@@ -31,8 +31,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
*/ */
public class PolygonNode { public class PolygonNode {
private Polygon content; private final Polygon content;
private Set<PolygonNode> children; private final Set<PolygonNode> children;
private boolean visited = false; private boolean visited = false;
public PolygonNode(Polygon p) { public PolygonNode(Polygon p) {
...@@ -56,8 +56,8 @@ public class PolygonNode { ...@@ -56,8 +56,8 @@ public class PolygonNode {
this.visited = b; this.visited = b;
} }
public boolean visited() { public boolean isUnvisited() {
return visited; return !visited;
} }
/* /*
...@@ -88,13 +88,9 @@ public class PolygonNode { ...@@ -88,13 +88,9 @@ public class PolygonNode {
return false; return false;
PolygonNode other = (PolygonNode) obj; PolygonNode other = (PolygonNode) obj;
if (content == null) { if (content == null) {
if (other.content != null) return other.content == null;
return false; } else return content.equals(other.content);
} else if (!content.equals(other.content)) { }
return false;
}
return true;
}
@Override @Override
public String toString() { public String toString() {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
package de.hft.stuttgart.citydoctor2.parser; package de.hft.stuttgart.citydoctor2.parser;
import java.io.Serial;
/** /**
* Exception when something went wrong while parsing the CityGML file. * Exception when something went wrong while parsing the CityGML file.
* *
...@@ -26,6 +28,7 @@ package de.hft.stuttgart.citydoctor2.parser; ...@@ -26,6 +28,7 @@ package de.hft.stuttgart.citydoctor2.parser;
*/ */
public class CityGmlParseException extends Exception { public class CityGmlParseException extends Exception {
@Serial
private static final long serialVersionUID = 8602390540552748135L; private static final long serialVersionUID = 8602390540552748135L;
public CityGmlParseException() { public CityGmlParseException() {
......
...@@ -501,20 +501,14 @@ public class CityGmlParser { ...@@ -501,20 +501,14 @@ public class CityGmlParser {
Matcher mURN = P_URN.matcher(srsName); Matcher mURN = P_URN.matcher(srsName);
// NOTE: Could use a HashMap if the switch/case becomes too long. // NOTE: Could use a HashMap if the switch/case becomes too long.
if (mURN.find()) { if (mURN.find()) {
switch (mURN.group(1)) { return switch (mURN.group(1)) {
case "DE_DHDN_3GK2": case "DE_DHDN_3GK2" -> CRS_FACTORY.createFromName("EPSG:31466");
return CRS_FACTORY.createFromName("EPSG:31466"); case "DE_DHDN_3GK3" -> CRS_FACTORY.createFromName("EPSG:31467");
case "DE_DHDN_3GK3": case "DE_DHDN_3GK4" -> CRS_FACTORY.createFromName("EPSG:31468");
return CRS_FACTORY.createFromName("EPSG:31467"); case "DE_DHDN_3GK5" -> CRS_FACTORY.createFromName("EPSG:31469");
case "DE_DHDN_3GK4": case "ETRS89_UTM32" -> CRS_FACTORY.createFromName("EPSG:25832");
return CRS_FACTORY.createFromName("EPSG:31468"); default -> null;
case "DE_DHDN_3GK5": };
return CRS_FACTORY.createFromName("EPSG:31469");
case "ETRS89_UTM32":
return CRS_FACTORY.createFromName("EPSG:25832");
default:
return null;
}
} }
if (srsName.equals("http://www.opengis.net/def/crs/EPSG/0/6697")) { if (srsName.equals("http://www.opengis.net/def/crs/EPSG/0/6697")) {
return CRS_FACTORY.createFromParameters("EPSG:6697", "+proj=longlat +ellps=GRS80 +no_defs +axis=neu"); return CRS_FACTORY.createFromParameters("EPSG:6697", "+proj=longlat +ellps=GRS80 +no_defs +axis=neu");
......
...@@ -20,6 +20,8 @@ package de.hft.stuttgart.citydoctor2.parser; ...@@ -20,6 +20,8 @@ package de.hft.stuttgart.citydoctor2.parser;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import java.io.Serial;
/** /**
* To stop the SAXParser from further parsing when the relevant section has * To stop the SAXParser from further parsing when the relevant section has
* already been found. * already been found.
...@@ -29,6 +31,7 @@ import org.xml.sax.SAXException; ...@@ -29,6 +31,7 @@ import org.xml.sax.SAXException;
*/ */
public class EnvelopeFoundException extends SAXException { public class EnvelopeFoundException extends SAXException {
@Serial
private static final long serialVersionUID = -9188617211115043815L; private static final long serialVersionUID = -9188617211115043815L;
public EnvelopeFoundException() { public EnvelopeFoundException() {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
package de.hft.stuttgart.citydoctor2.parser; package de.hft.stuttgart.citydoctor2.parser;
import java.io.Serial;
/** /**
* Used when an invalid CityGML file is found. * Used when an invalid CityGML file is found.
* *
...@@ -26,6 +28,7 @@ package de.hft.stuttgart.citydoctor2.parser; ...@@ -26,6 +28,7 @@ package de.hft.stuttgart.citydoctor2.parser;
*/ */
public class InvalidGmlFileException extends Exception { public class InvalidGmlFileException extends Exception {
@Serial
private static final long serialVersionUID = 5490585939707730933L; private static final long serialVersionUID = 5490585939707730933L;
public InvalidGmlFileException() { public InvalidGmlFileException() {
......
...@@ -37,10 +37,10 @@ import java.util.ArrayList; ...@@ -37,10 +37,10 @@ import java.util.ArrayList;
public class ObservedInputStream extends FilterInputStream { public class ObservedInputStream extends FilterInputStream {
/** List of registered progress listeners. */ /** List of registered progress listeners. */
private ArrayList<InputStreamListener> listeners = new ArrayList<>(); private final ArrayList<InputStreamListener> listeners = new ArrayList<>();
/** The number of bytes of the file to be read. */ /** The number of bytes of the file to be read. */
private long fileLength; private final long fileLength;
/** The number of bytes read so far. */ /** The number of bytes read so far. */
private long location; private long location;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.parser; package de.hft.stuttgart.citydoctor2.parser;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import org.locationtech.proj4j.BasicCoordinateTransform; import org.locationtech.proj4j.BasicCoordinateTransform;
...@@ -33,13 +34,14 @@ import org.locationtech.proj4j.CoordinateReferenceSystem; ...@@ -33,13 +34,14 @@ import org.locationtech.proj4j.CoordinateReferenceSystem;
*/ */
public class ParserConfiguration implements Serializable { public class ParserConfiguration implements Serializable {
@Serial
private static final long serialVersionUID = 6209047092991074661L; private static final long serialVersionUID = 6209047092991074661L;
private static final CRSFactory CRS_FACTORY = new CRSFactory(); private static final CRSFactory CRS_FACTORY = new CRSFactory();
private int roundingPlaces = 8; private final int roundingPlaces ;
private boolean validate = false; private final boolean validate;
private transient BasicCoordinateTransform targetTransform = null; private transient BasicCoordinateTransform targetTransform = null;
private transient BasicCoordinateTransform originalTransform = null; private transient BasicCoordinateTransform originalTransform = null;
...@@ -89,8 +91,8 @@ public class ParserConfiguration implements Serializable { ...@@ -89,8 +91,8 @@ public class ParserConfiguration implements Serializable {
} }
private void createCoordinateTransforms() { private void createCoordinateTransforms() {
CoordinateReferenceSystem tgtCrs = null; CoordinateReferenceSystem tgtCrs ;
CoordinateReferenceSystem crs = null; CoordinateReferenceSystem crs;
synchronized (CRS_FACTORY) { synchronized (CRS_FACTORY) {
tgtCrs = CRS_FACTORY.createFromParameters("Target", targetTransformString); tgtCrs = CRS_FACTORY.createFromParameters("Target", targetTransformString);
crs = CRS_FACTORY.createFromParameters("Original", originalTransformString); crs = CRS_FACTORY.createFromParameters("Original", originalTransformString);
......
...@@ -36,7 +36,7 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d; ...@@ -36,7 +36,7 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d;
*/ */
public class Primitive { public class Primitive {
private static Logger logger = LogManager.getLogger(Primitive.class); private static final Logger logger = LogManager.getLogger(Primitive.class);
private static final double AREA_EPSILON = 0.00001; private static final double AREA_EPSILON = 0.00001;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.tesselation; package de.hft.stuttgart.citydoctor2.tesselation;
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;
...@@ -35,10 +36,11 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d; ...@@ -35,10 +36,11 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d;
*/ */
public class TesselatedPolygon implements Serializable { public class TesselatedPolygon implements Serializable {
@Serial
private static final long serialVersionUID = 3117655580899570369L; private static final long serialVersionUID = 3117655580899570369L;
private List<Triangle3d> triangles; private final List<Triangle3d> triangles;
private Polygon original; private final Polygon original;
public TesselatedPolygon(List<Triangle3d> triangles, Polygon original) { public TesselatedPolygon(List<Triangle3d> triangles, Polygon original) {
this.triangles = triangles; this.triangles = triangles;
...@@ -54,7 +56,7 @@ public class TesselatedPolygon implements Serializable { ...@@ -54,7 +56,7 @@ public class TesselatedPolygon implements Serializable {
} }
triangles = new ArrayList<>(); triangles = new ArrayList<>();
for (int i = 0; i < indices.size(); i = i + 3) { for (int i = 0; i < indices.size(); i = i + 3) {
Vector3d v1 = vertices.get(indices.get(i + 0)); Vector3d v1 = vertices.get(indices.get(i));
Vector3d v2 = vertices.get(indices.get(i + 1)); Vector3d v2 = vertices.get(indices.get(i + 1));
Vector3d v3 = vertices.get(indices.get(i + 2)); Vector3d v3 = vertices.get(indices.get(i + 2));
triangles.add(new Triangle3d(v1, v2, v3, this)); triangles.add(new Triangle3d(v1, v2, v3, this));
......
...@@ -34,8 +34,8 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d; ...@@ -34,8 +34,8 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d;
*/ */
public class TesselatedRing { public class TesselatedRing {
private List<Triangle3d> triangles; private final List<Triangle3d> triangles;
private LinearRing ring; private final LinearRing ring;
public TesselatedRing(List<Triangle3d> triangles, LinearRing ring) { public TesselatedRing(List<Triangle3d> triangles, LinearRing ring) {
this.ring = ring; this.ring = ring;
...@@ -48,7 +48,7 @@ public class TesselatedRing { ...@@ -48,7 +48,7 @@ public class TesselatedRing {
} }
triangles = new ArrayList<>(); triangles = new ArrayList<>();
for (int i = 0; i < indices.size(); i = i + 3) { for (int i = 0; i < indices.size(); i = i + 3) {
Vector3d v1 = vertices.get(indices.get(i + 0)); Vector3d v1 = vertices.get(indices.get(i));
Vector3d v2 = vertices.get(indices.get(i + 1)); Vector3d v2 = vertices.get(indices.get(i + 1));
Vector3d v3 = vertices.get(indices.get(i + 2)); Vector3d v3 = vertices.get(indices.get(i + 2));
triangles.add(new Triangle3d(v1, v2, v3)); triangles.add(new Triangle3d(v1, v2, v3));
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
package de.hft.stuttgart.citydoctor2.tesselation; package de.hft.stuttgart.citydoctor2.tesselation;
import java.io.Serial;
/** /**
* Thrown when something went wrong with the tesselation process. * Thrown when something went wrong with the tesselation process.
* *
...@@ -43,6 +45,7 @@ public class TesselationException extends RuntimeException { ...@@ -43,6 +45,7 @@ public class TesselationException extends RuntimeException {
super(cause); super(cause);
} }
@Serial
private static final long serialVersionUID = -2010522579830781136L; private static final long serialVersionUID = -2010522579830781136L;
public TesselationException(String message) { public TesselationException(String message) {
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
*/ */
package de.hft.stuttgart.citydoctor2.utils; package de.hft.stuttgart.citydoctor2.utils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
...@@ -26,6 +30,8 @@ import java.io.ObjectOutputStream; ...@@ -26,6 +30,8 @@ import java.io.ObjectOutputStream;
public class Copy { public class Copy {
private static final Logger logger = LogManager.getLogger(Copy.class);
private Copy() { private Copy() {
} }
...@@ -41,16 +47,11 @@ public class Copy { ...@@ -41,16 +47,11 @@ public class Copy {
ByteArrayInputStream in = new ByteArrayInputStream(byteArray); ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(in); ObjectInputStream ois = new ObjectInputStream(in);
return (T) ois.readObject(); return (T) ois.readObject();
} catch (IOException e) { } catch (IOException | ClassNotFoundException e) {
e.printStackTrace(); logger.log(Level.ERROR, e.getMessage(), e);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} }
throw new IllegalStateException(); throw new IllegalStateException();
// CopyHandler handler = new CopyHandler();
// return handler.copy(original);
} }
} }
...@@ -29,8 +29,8 @@ import java.util.Set; ...@@ -29,8 +29,8 @@ import java.util.Set;
public class CopyHandler { public class CopyHandler {
private Set<Copyable> toBeDoneInstances = new HashSet<>(); private final Set<Copyable> toBeDoneInstances = new HashSet<>();
private Map<Copyable, Copyable> finishedInstances = new IdentityHashMap<>(); private final Map<Copyable, Copyable> finishedInstances = new IdentityHashMap<>();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Copyable> T copy(T original) { public <T extends Copyable> T copy(T original) {
......
...@@ -30,7 +30,7 @@ public class Localization { ...@@ -30,7 +30,7 @@ public class Localization {
public static final String VERSION = "CityDoctorValidation.Version"; public static final String VERSION = "CityDoctorValidation.Version";
private static ResourceBundle bundle; private static final ResourceBundle bundle;
static { static {
bundle = ResourceBundle.getBundle("CityDoctorLocalization"); bundle = ResourceBundle.getBundle("CityDoctorLocalization");
......
...@@ -28,8 +28,8 @@ package de.hft.stuttgart.citydoctor2.utils; ...@@ -28,8 +28,8 @@ package de.hft.stuttgart.citydoctor2.utils;
*/ */
public class Pair<A, B> { public class Pair<A, B> {
private A a; private final A a;
private B b; private final B b;
public Pair(A a, B b) { public Pair(A a, B b) {
this.a = a; this.a = a;
...@@ -78,14 +78,9 @@ public class Pair<A, B> { ...@@ -78,14 +78,9 @@ public class Pair<A, B> {
return false; return false;
} }
if (b == null) { if (b == null) {
if (other.b != null) { return other.b == null;
return false; } else return b.equals(other.b);
} }
} else if (!b.equals(other.b)) {
return false;
}
return true;
}
@Override @Override
public String toString() { public String toString() {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.utils; package de.hft.stuttgart.citydoctor2.utils;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -33,13 +34,14 @@ import de.hft.stuttgart.citydoctor2.math.Segment3d; ...@@ -33,13 +34,14 @@ import de.hft.stuttgart.citydoctor2.math.Segment3d;
*/ */
public class PolygonIntersection implements Serializable { public class PolygonIntersection implements Serializable {
@Serial
private static final long serialVersionUID = -6301963226688351725L; private static final long serialVersionUID = -6301963226688351725L;
public enum IntersectionType { public enum IntersectionType {
NONE, LINE, POLYGON NONE, LINE, POLYGON
} }
private IntersectionType type; private final IntersectionType type;
private List<Segment3d> lines; private List<Segment3d> lines;
private ConcretePolygon polygon; private ConcretePolygon polygon;
......
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