Commit c42d600d authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Unify methods

parent 2d2568b9
......@@ -39,7 +39,7 @@ import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class Installation extends CityObject {
public class Installation extends CityObject implements BoundedSpace{
@Serial
private static final long serialVersionUID = 1576237433322680191L;
......@@ -216,6 +216,7 @@ public class Installation extends CityObject {
return FeatureType.INSTALLATION;
}
@Override
public List<BoundarySurface> getBoundarySurfaces() {
if (boundarySurfaces == null) {
boundarySurfaces = new ArrayList<>(4);
......
......@@ -18,7 +18,7 @@ import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class OtherConstructionObject extends CityObject{
public class OtherConstructionObject extends CityObject implements BoundedSpace{
@Serial
private static final long serialVersionUID = -3885206364978761701L;
......@@ -136,6 +136,7 @@ public class OtherConstructionObject extends CityObject{
bs.setParent(this);
}
@Override
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
......
......@@ -32,4 +32,8 @@ public class Storey extends AbstractBuildingSubdivision {
public List<BuildingUnit> getBuildingUnits() {
return buildingUnits;
}
public void addBuildingUnit(BuildingUnit buildingUnit) {
buildingUnits.add(buildingUnit);
}
}
......@@ -31,7 +31,7 @@ import java.util.List;
*
* @author Matthias Betz
*/
public abstract class TransportationObject extends CityObject {
public abstract class TransportationObject extends CityObject implements BoundedSpace{
@Serial
private static final long serialVersionUID = -2698907271726700390L;
......@@ -43,6 +43,7 @@ public abstract class TransportationObject extends CityObject {
private AbstractCityObject ato;
protected TransportationType type;
private List<BoundarySurface> boundarySurfaces = new ArrayList<>();
public TransportationObject(TransportationType type) {
this.type = type;
......@@ -65,6 +66,16 @@ public abstract class TransportationObject extends CityObject {
return ato;
}
@Override
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaces;
}
public void addBoundarySurface(BoundarySurface b) {
boundarySurfaces.add(b);
b.setParent(this);
}
@Override
public Color getRenderColor() {
return switch (type) {
......
......@@ -14,7 +14,7 @@ import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.util.ArrayList;
import java.util.List;
public abstract class TransportationSpace extends TransportationObject {
public abstract class TransportationSpace extends TransportationObject{
private final List<TrafficSpaceObject> trafficSpaces = new ArrayList<>();
private final List<TrafficSpaceObject> auxTrafficSpaces = new ArrayList<>();
......
......@@ -37,6 +37,7 @@ public class Tunnel extends AbstractTunnel {
}
}
public void addTunnelPart(TunnelPart tunnelPart) {
tunnelParts.add(tunnelPart);
}
......@@ -52,7 +53,7 @@ public class Tunnel extends AbstractTunnel {
}
org.citygml4j.core.model.tunnel.Tunnel gmlT = new org.citygml4j.core.model.tunnel.Tunnel();
gmlT.setId(GmlId.generateId().getGmlString());
for (Installation ti : getTunnelInstallations()) {
for (Installation ti : getInstallations()) {
ti.anonymize();
gmlT.getTunnelInstallations().add(new TunnelInstallationProperty((TunnelInstallation) ti.getGmlObject()));
}
......
......@@ -17,7 +17,7 @@ import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
public class TunnelConstructiveElement extends CityObject {
public class TunnelConstructiveElement extends AbstractConstructiveElement{
private static final Logger logger = LogManager.getLogger(TunnelConstructiveElement.class);
......@@ -27,8 +27,6 @@ public class TunnelConstructiveElement extends CityObject {
private static final long serialVersionUID = 7353233899458901155L;
private final org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlTunnelElement;
private final List<BoundarySurface> boundarySurfaceList = new ArrayList<>();
private final List<AbstractConstructiveFillingElement> fillings = new ArrayList<>();
private AbstractTunnel parent;
public TunnelConstructiveElement(org.citygml4j.core.model.tunnel.TunnelConstructiveElement gmlObject) {
......@@ -74,7 +72,7 @@ public class TunnelConstructiveElement extends CityObject {
}
private void removeEmptyBoundarySurfaces() {
for (BoundarySurface bs : boundarySurfaceList) {
for (BoundarySurface bs : super.getBoundarySurfaces()) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlTunnelElement.getBoundaries()) {
if (bsp.getObject() != null && bsp.getObject() == bs.getGmlObject()) {
......@@ -87,17 +85,6 @@ public class TunnelConstructiveElement extends CityObject {
}
}
@Override
public void accept(CheckableVisitor c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaceList) {
bs.accept(c);
}
}
private void reCreateBoundarySurface(GeometryFactory factory, ParserConfiguration config, BoundarySurface bs) {
if (bs.getGeometries().isEmpty()) {
for (AbstractSpaceBoundaryProperty bsp : gmlTunnelElement.getBoundaries()) {
......@@ -170,23 +157,4 @@ public class TunnelConstructiveElement extends CityObject {
return FeatureType.TUNNEL_CONSTRUCTION_ELEMENT;
}
public void addBoundarySurface(BoundarySurface bs) {
boundarySurfaceList.add(bs);
bs.setParent(this);
}
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
public void addFilling(AbstractConstructiveFillingElement fe) {
fillings.add(fe);
fe.setParent(this);
}
public List<AbstractConstructiveFillingElement> getFillings() {
return fillings;
}
}
......@@ -7,9 +7,27 @@ public class TunnelFurniture extends AbstractFurniture {
@Serial
private static final long serialVersionUID = -4667219019432204174L;
private CityObject parent;
public void setGmlObject(org.citygml4j.core.model.tunnel.TunnelFurniture gmlObject) {
super.setGmlObject(gmlObject);
}
public void setParent(AbstractTunnel parent) {
this.parent = parent;
}
public void setParent(TunnelHollow parent) {
this.parent = parent;
}
@Override
public CityObject getParent() {
return parent;
}
@Override
public CityObject getTopLevelCityObject() {
return parent.getTopLevelCityObject();
}
}
......@@ -10,27 +10,30 @@ import java.util.List;
public class TunnelHollow extends AbstractRoom {
@Serial
private static final long serialVersionUID = -276088332165299253L;
private final List<TunnelFurnitureProperty> furnitureRefs = new ArrayList<>(2);
private CityObject parent;
private final List<TunnelFurniture> furnitureList = new ArrayList<>(2);
private AbstractTunnel parent;
public void setGmlObject(org.citygml4j.core.model.tunnel.HollowSpace gmlHollowSpace) {
super.cgmlRoom = gmlHollowSpace;
}
public void setParent(CityObject parent) {
public void setParent(AbstractTunnel parent) {
this.parent = parent;
}
public void addFurnitureRef(TunnelFurnitureProperty furnitureRef) {
furnitureRefs.add(furnitureRef);
public void addFurniture(TunnelFurniture furniture) {
furnitureList.add(furniture);
}
public List<TunnelFurnitureProperty> getFurnitureRefs() {
return furnitureRefs;
@Override
public List<TunnelFurniture> getFurniture() {
return furnitureList;
}
public CityObject getParent() {
@Override
public AbstractTunnel getParent() {
return parent;
}
......
......@@ -33,13 +33,15 @@ import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
/**
* Representation of CityGML vegetation objects
*
* @author Matthias Betz
*/
public class Vegetation extends CityObject {
public class Vegetation extends CityObject implements BoundedSpace{
@Serial
private static final long serialVersionUID = -5136358065541704146L;
......@@ -55,6 +57,17 @@ public class Vegetation extends CityObject {
this.type = type;
}
private final List<BoundarySurface> boundarySurfaces = new ArrayList<>();
@Override
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaces;
}
public void addBoundarySurface(BoundarySurface boundarySurface){
boundarySurfaces.add(boundarySurface);
}
@Override
public FeatureType getFeatureType() {
return FeatureType.VEGETATION;
......
......@@ -42,7 +42,7 @@ import java.util.List;
*
* @author Matthias Betz
*/
public class WaterObject extends CityObject {
public class WaterObject extends CityObject implements BoundedSpace{
@Serial
private static final long serialVersionUID = -3821060595086337424L;
......@@ -121,11 +121,7 @@ public class WaterObject extends CityObject {
}
}
/**
* Getter for all boundary surfaces contained in this building.
*
* @return the boundary surfaces
*/
@Override
public List<BoundarySurface> getBoundarySurfaces() {
return boundarySurfaceList;
}
......
......@@ -54,8 +54,8 @@ public class AbstractBuildingTest {
public void testAccept() {
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(new BoundarySurface(null));
ab.addBuildingInstallation(new Installation());
ab.addBuildingInstallation(new Installation());
ab.addInstallation(new Installation());
ab.addInstallation(new Installation());
AtomicInteger abCounter = new AtomicInteger(0);
AtomicInteger bsCounter = new AtomicInteger(0);
AtomicInteger biCounter = new AtomicInteger(0);
......@@ -99,10 +99,10 @@ public class AbstractBuildingTest {
BoundarySurface mockBSurface = mock(BoundarySurface.class);
Geometry mockGeometry = mock(Geometry.class);
ab.addBuildingRoom(mockRoom);
ab.addBuildingInstallation(mockInstallation);
ab.addRoom(mockRoom);
ab.addInstallation(mockInstallation);
ab.addConstructiveElement(mockConstructiveElement);
ab.addBuildingRoomFurniture(mockBuildingRoomFurniture);
ab.addFurniture(mockBuildingRoomFurniture);
ab.addBuildingUnit(mockBuildingUnit);
ab.addStorey(mockStorey);
ab.addBoundarySurface(mockBSurface);
......@@ -253,7 +253,7 @@ public class AbstractBuildingTest {
public void testReCreateGeometriesEmptyBi() {
Installation biMock = mock(Installation.class);
AbstractBuilding ab = createAbstractBuilding();
ab.addBuildingInstallation(biMock);
ab.addInstallation(biMock);
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
......
......@@ -32,6 +32,16 @@ public class AbstractRoomTest {
@Before
public void setUp() {
abRoom = new AbstractRoom() {
@Override
public List<? extends AbstractFurniture> getFurniture() {
return List.of();
}
@Override
public CityObject getParent() {
return null;
}
@Override
public CityObject getTopLevelCityObject() {
return null;
......@@ -46,7 +56,7 @@ public class AbstractRoomTest {
BoundarySurface mockBoundarySurface = Mockito.mock(BoundarySurface.class);
Geometry geometry = Mockito.mock(Geometry.class);
abRoom.addRoomInstallation(mockInstallation);
abRoom.addInstallation(mockInstallation);
abRoom.addBoundarySurface(mockBoundarySurface);
abRoom.addGeometry(geometry);
......
......@@ -94,10 +94,10 @@ public class BridgeObjectTest {
Geometry geomMock = mock(Geometry.class);
bo.addBridgePart(partMock);
bo.addBridgeRoom(mockRoom);
bo.addBridgeFurniture(mockFurn);
bo.addRoom(mockRoom);
bo.addFurniture(mockFurn);
bo.addConstructiveElement(ceMock);
bo.addBridgeInstallation(instMock);
bo.addInstallation(instMock);
bo.addBoundarySurface(bsMock);
bo.addGeometry(geomMock);
......
......@@ -141,14 +141,14 @@ public class BuildingTest {
BuildingUnit mockBuildingUnit = mock(BuildingUnit.class);
Storey mockStorey = mock(Storey.class);
b.addBuildingRoom(mockRoom);
b.addBuildingInstallation(mockInstallation);
b.addBuildingRoomFurniture(mockBuildingRoomFurniture);
b.addRoom(mockRoom);
b.addInstallation(mockInstallation);
b.addFurniture(mockBuildingRoomFurniture);
b.addBuildingUnit(mockBuildingUnit);
b.addStorey(mockStorey);
bp.addBuildingRoom(mockRoom);
bp.addBuildingInstallation(mockInstallation);
bp.addBuildingRoomFurniture(mockBuildingRoomFurniture);
bp.addRoom(mockRoom);
bp.addInstallation(mockInstallation);
bp.addFurniture(mockBuildingRoomFurniture);
bp.addBuildingUnit(mockBuildingUnit);
bp.addStorey(mockStorey);
......
......@@ -654,9 +654,9 @@ public class AutoProWindow extends JDialog implements ItemListener {
}
}
}
else if(0 != building.getBuildingInstallations().size())
else if(0 != building.getInstallations().size())
{
for(Installation buildingInstallation: building.getBuildingInstallations())
for(Installation buildingInstallation: building.getInstallations())
{
for(Geometry geometry : buildingInstallation.getGeometries())
{
......
......@@ -67,7 +67,7 @@ public class HealMainBuilding implements HealingMethod {
b.getGeometries().addAll(largestPart.getGeometries());
b.getBoundarySurfaces().addAll(largestPart.getBoundarySurfaces());
b.getBuildingInstallations().addAll(largestPart.getBuildingInstallations());
b.getInstallations().addAll(largestPart.getInstallations());
org.citygml4j.core.model.building.BuildingPart partObject = buildingPartProp.getObject();
gmlBuilding.getBoundaries().addAll(partObject.getBoundaries());
......
......@@ -149,7 +149,7 @@ public class HealMissingSolid implements HealingMethod {
for (BoundarySurface bs : feature.getBoundarySurfaces()) {
collectPolygons(bs, lod, polygons, solidGeometry);
}
for (Installation bi : feature.getBuildingInstallations()) {
for (Installation bi : feature.getInstallations()) {
collectPolygons(bi, lod, polygons, solidGeometry);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
collectPolygons(bs, lod, polygons, solidGeometry);
......
......@@ -50,7 +50,7 @@ public class MeshGenerator {
for (BoundarySurface bs : b.getBoundarySurfaces()) {
replacePolygonsInGeometry(bs, maxArea);
}
for (Installation bi : b.getBuildingInstallations()) {
for (Installation bi : b.getInstallations()) {
replacePolygonsInGeometry(bi, maxArea);
for (BoundarySurface bs : bi.getBoundarySurfaces()) {
replacePolygonsInGeometry(bs, maxArea);
......
......@@ -98,7 +98,7 @@ public class HealMissingSolidTest {
geom.addPolygon(p5);
Installation bi = new Installation();
b.addBuildingInstallation(bi);
b.addInstallation(bi);
Geometry geom3 = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2, Orientation.OUTWARD);
bi.addGeometry(geom3);
ConcretePolygon p3 = new ConcretePolygon();
......
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