Commit a1602768 authored by Matthias Betz's avatar Matthias Betz
Browse files

general cleanup of code

parent 8afe47c2
Pipeline #10955 passed with stage
in 1 minute and 9 seconds
...@@ -124,7 +124,10 @@ public abstract class AbstractFurniture extends CityObject { ...@@ -124,7 +124,10 @@ public abstract class AbstractFurniture extends CityObject {
public void setParent(CityObject co) { public void setParent(CityObject co) {
parent = co; parent = co;
} }
public CityObject getParent() {
return parent;
}
@Override @Override
public void unsetGmlGeometries() { public void unsetGmlGeometries() {
......
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import org.citygml4j.core.model.core.ImplicitGeometry;
import de.hft.stuttgart.citydoctor2.check.Check; 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.math.TransformationMatrix; import de.hft.stuttgart.citydoctor2.math.TransformationMatrix;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.ImplicitGeometry;
import java.io.Serial;
import java.util.List;
/** /**
* Datastructure for representation and resolving of implicit geometries * Datastructure for representation and resolving of implicit geometries
...@@ -18,7 +17,6 @@ import java.util.List; ...@@ -18,7 +17,6 @@ import java.util.List;
*/ */
public class ImplicitGeometryHolder extends Geometry { public class ImplicitGeometryHolder extends Geometry {
private static final Logger logger = LogManager.getLogger(ImplicitGeometryHolder.class);
@Serial @Serial
private static final long serialVersionUID = -8938931081577196349L; private static final long serialVersionUID = -8938931081577196349L;
......
...@@ -14,68 +14,66 @@ import java.util.Map; ...@@ -14,68 +14,66 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Reference object for handling of implicit geometries with a library object contained in an external file * Reference object for handling of implicit geometries with a library object
* contained in an external file
* *
* @author Riegel * @author Riegel
*/ */
public class LibraryObject extends Geometry { public class LibraryObject extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class); private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial @Serial
private static final long serialVersionUID = -50293435187454911L; private static final long serialVersionUID = -50293435187454911L;
private final String filepath;
private final ParserConfiguration config;
private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
public static LibraryObject of(Path path, ParserConfiguration config) { private static Map<String, LibraryObject> libraryObjects = new ConcurrentHashMap<>();
if (libraryObjects.containsKey(path.toString())) {
return libraryObjects.get(path.toString());
}
Geometry protoGeom = parseFile(path, config);
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod(), path, config);
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod, Path path, ParserConfiguration config) { public static LibraryObject of(Path path, ParserConfiguration config) {
super(type, lod); if (libraryObjects.containsKey(path.toString())) {
this.filepath = path.toString(); return libraryObjects.get(path.toString());
this.config = config; }
} Geometry protoGeom = parseFile(path, config);
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod());
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
return libOb;
}
private LibraryObject(GeometryType type, Lod lod) {
super(type, lod);
}
private static Geometry parseFile(Path path, ParserConfiguration config) { private static Geometry parseFile(Path path, ParserConfiguration config) {
Geometry geo = null; Geometry geo = null;
if (path.toFile().exists()) { if (path.toFile().exists()) {
try { try {
CityGmlParser.gagLogger(true); CityGmlParser.gagLogger(true);
CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config); CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config);
List<CityObject> objects = model.createFeatureStream().toList(); List<CityObject> objects = model.createFeatureStream().toList();
if (objects.isEmpty()) { if (objects.isEmpty()) {
throw new InvalidGmlFileException("Referenced library-object's gml file does not contain a CityGML object!"); throw new InvalidGmlFileException(
} else if (objects.size() > 1) { "Referenced library-object's gml file does not contain a CityGML object!");
throw new InvalidGmlFileException("Referenced library-object's gml file contains more than one CityGML object!"); } else if (objects.size() > 1) {
} throw new InvalidGmlFileException(
geo = objects.get(0).getHighestLodGeometry(); "Referenced library-object's gml file contains more than one CityGML object!");
} catch (CityGmlParseException e) { }
logger.error(String.format( geo = objects.get(0).getHighestLodGeometry();
"Encountered an error while parsing library object %s", path)); } catch (CityGmlParseException e) {
logger.error(e.getStackTrace()); logger.error("Encountered an error while parsing library object {}", path);
} catch (InvalidGmlFileException e) { logger.error(e.getStackTrace());
logger.error(e.getStackTrace()); } catch (InvalidGmlFileException e) {
} finally { logger.error(e.getStackTrace());
// Failsafe to remove gag should parsing fail } finally {
CityGmlParser.gagLogger(false); // Failsafe to remove gag should parsing fail
} CityGmlParser.gagLogger(false);
} else { }
logger.error(String.format("Implicit geometry references non-existing library object file %s.", path)); } else {
} logger.error("Implicit geometry references non-existing library object file {}.", path);
return geo; }
} return geo;
}
} }
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial; import java.io.Serial;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -15,27 +11,23 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -15,27 +11,23 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class RelativeGeometry extends Geometry { public class RelativeGeometry extends Geometry {
private static final Logger logger = LogManager.getLogger(RelativeGeometry.class); @Serial
@Serial private static final long serialVersionUID = -686112245455298977L;
private static final long serialVersionUID = -686112245455298977L;
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
private static Map<Geometry, RelativeGeometry> relativeGeometries = new ConcurrentHashMap<>();
public static RelativeGeometry of(Geometry geom) {
public static RelativeGeometry of(Geometry geom) { if (relativeGeometries.containsKey(geom)) {
if (relativeGeometries.containsKey(geom)) { return relativeGeometries.get(geom);
return relativeGeometries.get(geom); }
} RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod());
RelativeGeometry relGeo = new RelativeGeometry(geom.getType(), geom.getLod()); geom.getPolygons().forEach(relGeo::addPolygon);
geom.getPolygons().forEach(relGeo::addPolygon); relGeo.updateEdgesAndVertices();
relGeo.updateEdgesAndVertices(); relativeGeometries.put(geom, relGeo);
relativeGeometries.put(geom, relGeo); return relGeo;
return relGeo; }
}
private RelativeGeometry(GeometryType type, Lod lod) {
super(type, lod);
private RelativeGeometry(GeometryType type, Lod lod) { }
super(type, lod);
}
} }
...@@ -60,6 +60,8 @@ public class TunnelConstructiveElement extends CityObject { ...@@ -60,6 +60,8 @@ public class TunnelConstructiveElement extends CityObject {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config); MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
setMultiSurfaceAccordingToLod(geom, ms); setMultiSurfaceAccordingToLod(geom, ms);
break; break;
case COMPOSITE_SURFACE:
throw new IllegalStateException("Tunnel constructive element cannot have a composite surface geometry");
} }
} }
for (BoundarySurface bs : boundarySurfaceList) { for (BoundarySurface bs : boundarySurfaceList) {
......
...@@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.AbstractCityObjectProperty; import org.citygml4j.core.model.core.AbstractCityObjectProperty;
import org.citygml4j.core.model.core.AbstractFeatureProperty; import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel; import org.citygml4j.core.model.core.CityModel;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
...@@ -65,11 +65,11 @@ ...@@ -65,11 +65,11 @@
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId> <artifactId>Saxon-HE</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
......
...@@ -65,23 +65,19 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -65,23 +65,19 @@ public class SvrlContentHandler implements ContentHandler {
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void endPrefixMapping(String prefix) throws SAXException { public void endPrefixMapping(String prefix) throws SAXException {
// not needed // not needed
...@@ -133,17 +129,14 @@ public class SvrlContentHandler implements ContentHandler { ...@@ -133,17 +129,14 @@ public class SvrlContentHandler implements ContentHandler {
buffer.append(ch, start, length); buffer.append(ch, start, length);
} }
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void processingInstruction(String target, String data) throws SAXException { public void processingInstruction(String target, String data) throws SAXException {
// not needed // not needed
} }
@SuppressWarnings("RedundantThrows")
@Override @Override
public void skippedEntity(String name) throws SAXException { public void skippedEntity(String name) throws SAXException {
// not needed // not needed
......
...@@ -27,19 +27,16 @@ import de.hft.stuttgart.citydoctor2.check.Check; ...@@ -27,19 +27,16 @@ 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.RequirementType;
import de.hft.stuttgart.citydoctor2.check.GeometrySelfIntersection; import de.hft.stuttgart.citydoctor2.check.GeometrySelfIntersection;
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.ResultStatus; import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError; import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils; import de.hft.stuttgart.citydoctor2.checks.util.CollectionUtils;
import de.hft.stuttgart.citydoctor2.checks.util.SelfIntersectionUtil; import de.hft.stuttgart.citydoctor2.checks.util.SelfIntersectionUtil;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType; import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.math.Segment3d;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection; import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection.IntersectionType;
/** /**
* Check for self intersecting solids * Check for self intersecting solids
......
...@@ -160,6 +160,7 @@ public class CityDoctorController { ...@@ -160,6 +160,7 @@ public class CityDoctorController {
buildLand(model); buildLand(model);
buildCityFurniture(model); buildCityFurniture(model);
buildOtherCityObjects(model); buildOtherCityObjects(model);
buildTunnel(model.getTunnels());
} }
private void resetFeatureChunks() { private void resetFeatureChunks() {
......
package de.hft.stuttgart.citydoctor2.gui.tree; package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractRoom;
import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture; import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus; import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer; import de.hft.stuttgart.citydoctor2.gui.Renderer;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.image.*?> <?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="5.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> <HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="5.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<HBox spacing="5.0" HBox.hgrow="NEVER"> <HBox spacing="5.0" HBox.hgrow="NEVER">
<children> <children>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<BorderPane fx:id="mainPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="400.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> <BorderPane fx:id="mainPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="400.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<center> <center>
<SplitPane fx:id="mainContainer" dividerPositions="0.47069431920649235" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="300.0" prefHeight="600.0" prefWidth="1100.0"> <SplitPane fx:id="mainContainer" dividerPositions="0.47069431920649235" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="300.0" prefHeight="600.0" prefWidth="1100.0">
<items> <items>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hft.stuttgart</groupId> <groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId> <artifactId>CityDoctorParent</artifactId>
......
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