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