Commit 02de0a22 authored by Riegel's avatar Riegel
Browse files

Reformat code

parent ad3589e8
Pipeline #10297 passed with stage
in 1 minute and 5 seconds
......@@ -11,12 +11,18 @@ import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Dataholding class for parsing and resolving of CompositeSurfaces.
* Pseudo-abstract polygon class for parsing and resolving of CompositeSurfaces and references to them.
* <p>CompositePolygons have no exterior or interior LinearRings themselves and need to be filtered out from
* the polygons of a CityObject geometry before further processing steps.
*
* @author Riegel
*/
public final class CompositePolygon extends ConcretePolygon{
public final class CompositePolygon extends ConcretePolygon {
@Serial
private static final long serialVersionUID = -1867197873443341287L;
......@@ -32,7 +38,8 @@ public final class CompositePolygon extends ConcretePolygon{
}
@Override
public void accept(Check c){}
public void accept(Check c) {
}
@Override
public Class<? extends Checkable> getCheckClass() {
......@@ -40,24 +47,25 @@ public final class CompositePolygon extends ConcretePolygon{
}
@Override
public boolean containsAnyError(){
public boolean containsAnyError() {
return false;
}
@Override
public void collectContainedErrors(List<CheckError> errors) {}
public void collectContainedErrors(List<CheckError> errors) {
}
@Override
public void clearAllContainedCheckResults() {
}
public void addCompositeMember(ConcretePolygon p){
public void addCompositeMember(ConcretePolygon p) {
compositeMembers.add(p);
p.setPartOfComposite(this);
}
public List<ConcretePolygon> getCompositeMembers(){
public List<ConcretePolygon> getCompositeMembers() {
return compositeMembers;
}
......@@ -67,7 +75,6 @@ public final class CompositePolygon extends ConcretePolygon{
}
@Override
public Vector3d calculateNormal() {
return compositeMembers.get(0).calculateNormal();
......@@ -76,7 +83,7 @@ public final class CompositePolygon extends ConcretePolygon{
@Override
public TesselatedPolygon tesselate() {
List<Triangle3d> tessPolys = new ArrayList<>();
return new TesselatedPolygon(tessPolys,this );
return new TesselatedPolygon(tessPolys, this);
}
@Override
......@@ -190,7 +197,6 @@ public final class CompositePolygon extends ConcretePolygon{
}
@Override
public void collectInstances(CopyHandler handler) {
......
......@@ -53,9 +53,7 @@ public class ConcretePolygon extends Polygon {
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
public ConcretePolygon() {
// TODO Auto-generated constructor stub
}
public ConcretePolygon() {}
/*
* (non-Javadoc)
......
......@@ -18,19 +18,18 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
/**
* Representing an edge between two consecutive points of a linear ring
*
* @author Matthias Betz
*
*/
public class Edge implements Serializable, Copyable {
......
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* Possible feature types in CityGML
*
* @author Matthias Betz
*
*/
public enum FeatureType {
......
......@@ -24,7 +24,7 @@ import java.util.List;
/**
*
*/
public class GenericCityObject extends CityObject{
public class GenericCityObject extends CityObject {
@Serial
private static final long serialVersionUID = 5886527664552294353L;
......@@ -49,7 +49,7 @@ public class GenericCityObject extends CityObject{
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
......@@ -213,7 +213,7 @@ public class GenericCityObject extends CityObject{
}
}
public void setGmlObject(org.citygml4j.core.model.generics.GenericOccupiedSpace gos){
public void setGmlObject(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) {
this.cgmlGos = gos;
}
......
......@@ -18,16 +18,6 @@
*/
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.Map.Entry;
import java.util.Random;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -39,11 +29,14 @@ import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import java.io.Serial;
import java.util.*;
import java.util.Map.Entry;
/**
* Representation of a geometry containing the polygons and edges
*
* @author Matthias Betz
*
*/
public class Geometry extends GmlElement {
......
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* Available geometry types
*
* @author Matthias Betz
*
*/
public enum GeometryType {
......
......@@ -28,7 +28,6 @@ import java.io.Serial;
* A general GML element that has a gml id
*
* @author Matthias Betz
*
*/
public abstract class GmlElement extends Checkable implements Copyable {
......
......@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicInteger;
* generated by city doctor
*
* @author Matthias Betz
*
*/
public class GmlId implements Serializable {
......
......@@ -2,7 +2,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.math.TransformationMatrix;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.ImplicitGeometry;
......@@ -10,9 +9,11 @@ import org.citygml4j.core.model.core.ImplicitGeometry;
import java.io.Serial;
/**
* Datastructure for representation of implicit geometries
* Datastructure for representation and resolving of implicit geometries
*
* @author Riegel
*/
public class ImplicitGeometryHolder extends Geometry{
public class ImplicitGeometryHolder extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial
......@@ -34,7 +35,7 @@ public class ImplicitGeometryHolder extends Geometry{
}
public ImplicitGeometryHolder(ImplicitGeometry cgmlImplicitGeometry, RelativeGeometry relativeGeometry) {
super(relativeGeometry.getType(),relativeGeometry.getLod());
super(relativeGeometry.getType(), relativeGeometry.getLod());
this.libObject = null;
this.relativeGeom = relativeGeometry;
this.cgmlImplicitGeometry = cgmlImplicitGeometry;
......@@ -59,15 +60,15 @@ public class ImplicitGeometryHolder extends Geometry{
* Applies the transformation matrix of the implicit geometry to a copy of the reference geometry and copies the resulting
* transformed geometry into this object.
*/
private void applyTransformation(){
private void applyTransformation() {
TransformationMatrix transformMatrix = new TransformationMatrix(cgmlImplicitGeometry);
Geometry refGeo = null;
if (libObject == null){
if (libObject == null) {
refGeo = relativeGeom;
} else if (relativeGeom == null){
} else if (relativeGeom == null) {
refGeo = libObject;
}
if (refGeo == null){
if (refGeo == null) {
throw new NullPointerException("Geometry reference object of ImplicitGeometryHolder is null!");
}
Geometry transformedGeom = transformMatrix.transformGeometry(refGeo);
......
......@@ -18,10 +18,13 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.bridge.BridgeInstallation;
import org.citygml4j.core.model.construction.AbstractInstallation;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
......@@ -32,13 +35,9 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.complexes.CompositeSurface;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
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;
import java.util.ArrayList;
import java.util.List;
public class Installation extends CityObject {
......
......@@ -18,24 +18,22 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.model.landuse.LandUse;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
/**
* Represents a land use CityGML object.
*
* @author Matthias Betz
*
*/
public class LandObject extends CityObject {
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.Citygml3FeatureMapper;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -14,17 +11,20 @@ import java.io.Serial;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
/**
* Reference object for handling of implicit geometries with a library object contained in an external file
*
* @author Riegel
*/
public class LibraryObject extends Geometry{
public class LibraryObject extends Geometry {
private static final Logger logger = LogManager.getLogger(LibraryObject.class);
@Serial
private static final long serialVersionUID = -50293435187454911L;
private final String filepath;
private final ParserConfiguration config;
private static HashMap<String,LibraryObject> libraryObjects = new HashMap<>();
private static HashMap<String, LibraryObject> libraryObjects = new HashMap<>();
public static LibraryObject of(Path path, ParserConfiguration config) {
if (libraryObjects.containsKey(path.toString())) {
......@@ -34,7 +34,7 @@ public class LibraryObject extends Geometry{
if (protoGeom == null) {
return null;
}
LibraryObject libOb = new LibraryObject(protoGeom.getType(),protoGeom.getLod(),path, config);
LibraryObject libOb = new LibraryObject(protoGeom.getType(), protoGeom.getLod(), path, config);
protoGeom.getPolygons().forEach(libOb::addPolygon);
libOb.updateEdgesAndVertices();
libraryObjects.put(path.toString(), libOb);
......@@ -42,7 +42,7 @@ public class LibraryObject extends Geometry{
}
private LibraryObject(GeometryType type, Lod lod, Path path, ParserConfiguration config) {
super(type,lod);
super(type, lod);
this.filepath = path.toString();
this.config = config;
}
......@@ -50,28 +50,28 @@ public class LibraryObject extends Geometry{
private static Geometry parseFile(Path path, ParserConfiguration config) {
Geometry geo = null;
if (path.toFile().exists()){
if (path.toFile().exists()) {
try {
CityGmlParser.gagLogger(true);
CityDoctorModel model = CityGmlParser.parseCityGmlFile(path.toString(), config);
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!");
} else if (objects.size() > 1){
} else if (objects.size() > 1) {
throw new InvalidGmlFileException("Referenced library-object's gml file contains more than one CityGML object!");
}
geo = objects.get(0).getHighestLodGeometry();
} catch (CityGmlParseException e){
} catch (CityGmlParseException e) {
logger.error(String.format(
"Encountered an error while parsing library object %s", path));
logger.error(e.getStackTrace());
} catch (InvalidGmlFileException e){
} catch (InvalidGmlFileException e) {
logger.error(e.getStackTrace());
} finally {
// Failsafe to remove gag should parsing fail
CityGmlParser.gagLogger(false);
}
} else{
} else {
logger.error(String.format("Implicit geometry references non-existing library object file %s.", path));
}
return geo;
......
......@@ -18,24 +18,19 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.math.ProjectionAxis;
import de.hft.stuttgart.citydoctor2.math.Ring2d;
import de.hft.stuttgart.citydoctor2.math.UnitVector3d;
import de.hft.stuttgart.citydoctor2.math.Vector2d;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.math.*;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a linear ring used in polygons. The ring contains the vertices.
*
* @author Matthias Betz
*
*/
public class LinearRing extends GmlElement {
......
......@@ -18,10 +18,6 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import java.util.Map;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -31,12 +27,15 @@ import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial;
import java.util.List;
import java.util.Map;
/**
* A polygon that does not contain the geometry but is only a link to an actual
* polygon. Created when href in CityGML are used.
*
* @author Matthias Betz
*
*/
public class LinkedPolygon extends Polygon {
......@@ -50,7 +49,6 @@ public class LinkedPolygon extends Polygon {
}
/**
*
* @param poly polygon this is linked to
* @param parent the parent of the linked polygon
*/
......
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* The different LODs available in CityGML
*
* @author Matthias Betz
*
*/
public enum Lod {
......
......@@ -18,17 +18,16 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import org.citygml4j.core.model.construction.AbstractFillingSurface;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.construction.AbstractFillingSurface;
import org.citygml4j.core.model.core.AbstractCityObject;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import java.io.Serial;
......@@ -38,7 +37,6 @@ import java.io.Serial;
* in.
*
* @author Matthias Betz
*
*/
public class Opening extends CityObject {
......
......@@ -22,7 +22,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
* The available opening types in CityGML
*
* @author Matthias Betz
*
*/
public enum OpeningType {
......
......@@ -18,17 +18,16 @@
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.util.List;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
import de.hft.stuttgart.citydoctor2.tesselation.TesselatedPolygon;
import java.io.Serial;
import java.util.List;
/**
* Interface for concrete and linked polygons.
*
* @author Matthias Betz
*
*/
public abstract class Polygon extends GmlElement {
......@@ -36,6 +35,7 @@ public abstract class Polygon extends GmlElement {
private static final long serialVersionUID = -613942946364706513L;
public abstract Vector3d calculateNormalNormalized();
public abstract Vector3d calculateNormal();
public abstract TesselatedPolygon tesselate();
......
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -10,6 +9,8 @@ import java.util.HashMap;
/**
* Reference object for handling of implicit geometries with a relative geometry
*
* @author Riegel
*/
public class RelativeGeometry extends Geometry {
......@@ -17,16 +18,16 @@ public class RelativeGeometry extends Geometry {
@Serial
private static final long serialVersionUID = -686112245455298977L;
private static HashMap<Geometry,RelativeGeometry> relativeGeometries = new HashMap<>();
private static HashMap<Geometry, RelativeGeometry> relativeGeometries = new HashMap<>();
public static RelativeGeometry of(Geometry geom){
if (relativeGeometries.containsKey(geom)){
public static RelativeGeometry of(Geometry geom) {
if (relativeGeometries.containsKey(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);
relGeo.updateEdgesAndVertices();
relativeGeometries.put(geom,relGeo);
relativeGeometries.put(geom, relGeo);
return relGeo;
}
......
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