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

Add parsing of Tunnel

parent 2d9f08ee
Showing with 286 additions and 14 deletions
+286 -14
......@@ -61,6 +61,7 @@ public class CityDoctorModel {
private final List<GenericCityObject> genericObjects;
private final List<CityObject> land;
private final List<TransportationObject> roads;
private final List<Tunnel> tunnels;
private final List<WaterObject> water;
private CityModel cModel;
private final ParserConfiguration config;
......@@ -83,6 +84,7 @@ public class CityDoctorModel {
bridges = new ArrayList<>();
land = new ArrayList<>();
roads = new ArrayList<>();
tunnels = new ArrayList<>();
water = new ArrayList<>();
cityfurniture = new ArrayList<>();
genericObjects = new ArrayList<>();
......@@ -125,7 +127,7 @@ public class CityDoctorModel {
public Stream<CityObject> createFeatureStream() {
return Stream.of(buildings.stream(), vegetation.stream(), bridges.stream(), land.stream(), roads.stream(),
water.stream(), cityfurniture.stream(),genericObjects.stream()).flatMap(co -> co);
tunnels.stream() ,water.stream(), cityfurniture.stream(),genericObjects.stream()).flatMap(co -> co);
}
public void saveAs(String file, boolean saveQualityAde) throws CityDoctorWriteException {
......@@ -227,6 +229,7 @@ public class CityDoctorModel {
collectErrorsFromList(errors, bridges);
collectErrorsFromList(errors, land);
collectErrorsFromList(errors, roads);
collectErrorsFromList(errors, tunnels);
collectErrorsFromList(errors, water);
collectErrorsFromList(errors, cityfurniture);
collectErrorsFromList(errors, genericObjects);
......@@ -287,6 +290,10 @@ public class CityDoctorModel {
return roads;
}
public List<Tunnel> getTunnels() {
return tunnels;
}
public List<WaterObject> getWater() {
return water;
}
......@@ -315,9 +322,13 @@ public class CityDoctorModel {
roads.add(to);
}
public void addTunnel(Tunnel tunnel) {
tunnels.add(tunnel);
}
public int getNumberOfFeatures() {
return buildings.size() + vegetation.size() + bridges.size() + land.size() + roads.size() + water.size() + cityfurniture.size()
+ genericObjects.size();
return buildings.size() + vegetation.size() + bridges.size() + land.size() + tunnels.size()
+roads.size() + water.size() + cityfurniture.size() + genericObjects.size();
}
public ParserConfiguration getParserConfig() {
......@@ -331,7 +342,9 @@ public class CityDoctorModel {
replaceBridge(currentFeature, nextFeature);
} else if (nextFeature instanceof TransportationObject) {
replaceTransportationObject(currentFeature, nextFeature);
} else if (nextFeature instanceof Vegetation) {
}else if (nextFeature instanceof Tunnel) {
replaceTunnel(currentFeature, nextFeature);
}else if (nextFeature instanceof Vegetation) {
replaceVegetation(currentFeature, nextFeature);
} else if (nextFeature instanceof LandObject) {
replaceLandObject(currentFeature, nextFeature);
......@@ -392,6 +405,14 @@ public class CityDoctorModel {
roads.set(index, (TransportationObject) nextFeature);
}
private void replaceTunnel(CityObject currentFeature, CityObject nextFeature){
int index = tunnels.indexOf(currentFeature);
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in tunnels");
}
tunnels.set(index, (Tunnel) nextFeature);
}
private void replaceBridge(CityObject currentFeature, CityObject nextFeature) {
int index = bridges.indexOf(currentFeature);
if (index == -1) {
......@@ -415,6 +436,8 @@ public class CityDoctorModel {
bridges.add(bo);
} else if (co instanceof TransportationObject to) {
roads.add(to);
} else if (co instanceof Tunnel tu) {
tunnels.add(tu);
} else if (co instanceof Vegetation veg) {
vegetation.add(veg);
} else if (co instanceof LandObject lo) {
......
......@@ -14,8 +14,8 @@ public class TunnelHollow extends AbstractRoom{
private final List<TunnelFurnitureProperty> furnitureRefs = new ArrayList<>(2);
private CityObject parent;
public void setGmlObject(org.citygml4j.core.model.building.BuildingRoom cgmlRoom){
super.cgmlRoom = cgmlRoom;
public void setGmlObject(org.citygml4j.core.model.tunnel.HollowSpace gmlHollowSpace){
super.cgmlRoom = gmlHollowSpace;
}
......
......@@ -12,8 +12,6 @@ public class TunnelPart extends AbstractTunnel {
private Tunnel parent;
private TunnelPart() {
}
public TunnelPart(Tunnel parent) {
this.parent = parent;
......@@ -52,4 +50,5 @@ public class TunnelPart extends AbstractTunnel {
return new TunnelPart();
}
private TunnelPart(){}
}
......@@ -26,9 +26,12 @@ import java.util.Map;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractTunnel;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingRoom;
import de.hft.stuttgart.citydoctor2.datastructure.TunnelFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.TunnelPart;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.CityGMLVersion;
......@@ -58,12 +61,13 @@ import org.citygml4j.core.model.transportation.Track;
import org.citygml4j.core.model.transportation.TrafficArea;
import org.citygml4j.core.model.transportation.TrafficSpace;
import org.citygml4j.core.model.transportation.TrafficSpaceProperty;
import org.citygml4j.core.model.tunnel.*;
import org.citygml4j.core.model.tunnel.Tunnel;
import org.citygml4j.core.model.vegetation.AbstractVegetationObject;
import org.citygml4j.core.model.vegetation.PlantCover;
import org.citygml4j.core.model.vegetation.SolitaryVegetationObject;
import org.citygml4j.core.model.waterbody.WaterBody;
import org.citygml4j.core.visitor.ObjectWalker;
import org.xmlobjects.gml.adapter.geometry.complexes.CompositeSurfaceAdapter;
import org.xmlobjects.gml.model.base.AbstractGML;
import org.xmlobjects.gml.model.feature.AbstractFeature;
import org.xmlobjects.gml.model.geometry.AbstractGeometry;
......@@ -357,6 +361,195 @@ public class Citygml3FeatureMapper extends ObjectWalker {
return bi;
}
@Override
public void visit(Tunnel tunnel){
de.hft.stuttgart.citydoctor2.datastructure.Tunnel tu = new de.hft.stuttgart.citydoctor2.datastructure.Tunnel();
for (TunnelPartProperty tPartProperty : tunnel.getTunnelParts()) {
if (!tPartProperty.isSetObject()) {
continue;
}
org.citygml4j.core.model.tunnel.TunnelPart gmlTunnelPart = tPartProperty.getObject();
TunnelPart tPart = new TunnelPart(tu);
readAbstractTunnel(gmlTunnelPart, tPart);
tu.addTunnelPart(tPart);
}
readAbstractTunnel(tunnel, tu);
resolveAndClearReferences();
updateEdgesAndVertices(tu);
for (TunnelPart part : tu.getTunnelParts()) {
updateEdgesAndVertices(part);
}
model.addTunnel(tu);
}
private void readAbstractTunnel(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
mapAbstractOccupiedSpace(gmlTunnel, cdTunnel);
cdTunnel.setGmlObject(gmlTunnel);
// parse deprecated geometries
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod1MultiSurface(), Lod.LOD1, cdTunnel);
parseAndAddMultiSurface(gmlTunnel.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, cdTunnel);
parseAndAddSolid(gmlTunnel.getDeprecatedProperties().getLod4Solid(), Lod.LOD4, cdTunnel);
for (TunnelInstallationProperty tiProp : gmlTunnel.getTunnelInstallations()) {
var gmlTi = tiProp.getObject();
if (gmlTi == null) {
// ignore empty properties
continue;
}
Installation ti = mapTunnelInstallation(gmlTi);
cdTunnel.addTunnelInstallation(ti);
}
for (HollowSpaceProperty thProp : gmlTunnel.getHollowSpaces()) {
var gmlTh = thProp.getObject();
if (gmlTh == null) {
continue;
}
TunnelHollow br = mapTunnelHollow(gmlTh);
cdTunnel.addTunnelHollow(br);
}
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTunnel.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
cdTunnel.unsetGmlGeometries();
resolveAndClearReferences();
updateEdgesAndVertices(cdTunnel);
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
for (Installation ti : cdTunnel.getTunnelInstallations()) {
updateEdgesAndVertices(ti);
for (BoundarySurface bs : ti.getBoundarySurfaces()) {
updateEdgesAndVertices(bs);
for (Opening o : bs.getOpenings()) {
updateEdgesAndVertices(o);
}
}
}
for (TunnelFurnitureProperty tfProp : gmlTunnel.getTunnelFurniture()){
var gmlTf = tfProp.getObject();
if (gmlTf == null) {
continue;
}
TunnelFurniture tf = mapTunnelFurniture(gmlTf);
cdTunnel.addTunnelFurniture(tf);
}
}
private Installation mapTunnelInstallation(TunnelInstallation gmlTi){
Installation ti = new Installation();
ti.setGmlObject(gmlTi);
mapAbstractOccupiedSpace(gmlTi, ti);
GeometryProperty<?> lod2Prop = gmlTi.getDeprecatedProperties().getLod2Geometry();
parseAndAddAbstractGeometry(lod2Prop, Lod.LOD2, ti);
GeometryProperty<?> lod3Prop = gmlTi.getDeprecatedProperties().getLod3Geometry();
parseAndAddAbstractGeometry(lod3Prop, Lod.LOD3, ti);
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti);
ti.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
ti.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
p.setPartOfInstallation(ti);
}
}
}
for (Geometry geom : ti.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfInstallation(ti);
}
}
return ti;
}
private TunnelHollow mapTunnelHollow(HollowSpace gmlHo){
TunnelHollow tHollow = new TunnelHollow();
tHollow.setGmlObject(gmlHo);
mapAbstractUnoccupiedSpace(gmlHo,tHollow);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlHo.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
tHollow.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
for (TunnelInstallationProperty tiProp : gmlHo.getTunnelInstallations()) {
var gmlTi = tiProp.getObject();
if (gmlTi == null) {
// ignore empty properties
continue;
}
Installation bi = mapTunnelInstallation(gmlTi);
tHollow.addRoomInstallation(bi);
}
for (TunnelFurnitureProperty tfProp : gmlHo.getTunnelFurniture()){
var gmlHref = tfProp.getHref();
if (gmlHref == null) {
continue;
}
tHollow.addFurnitureRef(tfProp);
}
return tHollow;
}
private TunnelFurniture mapTunnelFurniture(org.citygml4j.core.model.tunnel.TunnelFurniture gmlTf){
TunnelFurniture tf = new TunnelFurniture();
tf.setGmlObject(gmlTf);
mapAbstractOccupiedSpace(gmlTf, tf);
tf.unsetGmlGeometries();
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTf.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
continue;
}
AbstractSpaceBoundary surface = surfaceProp.getObject();
surface.accept(surfaceMapper);
}
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
tf.addBoundarySurface(bs);
for (Geometry geom : bs.getGeometries()) {
for (Polygon p : geom.getPolygons()) {
p.setPartOfSurface(bs);
}
}
}
return tf;
}
private void updatePartOfSurface(BridgeObject bo, SurfaceMapper surfaceMapper) {
for (BoundarySurface bs : surfaceMapper.getSurfaces()) {
bo.addBoundarySurface(bs);
......
......@@ -47,6 +47,7 @@ MainWindow.languageChange=For the change in language to apply, restart CityDocto
MainWindow.buildingsTab=Buildings
MainWindow.vegetationTab=Vegetation
MainWindow.transportationTab=Transportation
MainWindow.tunnelTab=Tunnels
MainWindow.bridgeTab=Bridges
MainWindow.waterTab=Water
MainWindow.terrainTab=Terrain
......
......@@ -45,6 +45,7 @@ MainWindow.languageChange=Um die Spracheinstellung zu \u00fcbernehmen muss CityD
MainWindow.buildingsTab=Geb\u00e4ude
MainWindow.vegetationTab=Vegetation
MainWindow.transportationTab=Verkehrsobjekte
MainWindow.tunnelTab=Tunnel
MainWindow.bridgeTab=Br\u00fccken
MainWindow.waterTab=Gew\u00e4sser
MainWindow.terrainTab=Gel\u00e4nde
......
......@@ -63,6 +63,7 @@ public class CityDoctorController {
private AtomicInteger buildingChunkNr = new AtomicInteger(0);
private AtomicInteger vegetationChunkNr = new AtomicInteger(0);
private AtomicInteger transportationChunkNr = new AtomicInteger(0);
private AtomicInteger tunnelChunkNr = new AtomicInteger(0);
private AtomicInteger bridgeChunkNr = new AtomicInteger(0);
private AtomicInteger waterChunkNr = new AtomicInteger(0);
private AtomicInteger landChunkNr = new AtomicInteger(0);
......@@ -159,6 +160,7 @@ public class CityDoctorController {
buildingChunkNr.set(0);
vegetationChunkNr.set(0);
transportationChunkNr.set(0);
tunnelChunkNr.set(0);
bridgeChunkNr.set(0);
waterChunkNr.set(0);
landChunkNr.set(0);
......@@ -278,6 +280,18 @@ public class CityDoctorController {
addMoreButtonIfNecessary(trans, transView, transRoot, transportationChunkNr);
}
private void buildTunnel(List<Tunnel> tunnels){
if (tunnels.isEmpty()) {
return;
}
TreeView<Renderable> transView = mainWindow.getTunnelView();
TreeItem<Renderable> transRoot = new TreeItem<>(new AllTunnelsNode(model.getTunnels()));
transRoot.setExpanded(true);
transView.setRoot(transRoot);
buildTreeFromList(tunnels, transView.getRoot(), tunnelChunkNr);
addMoreButtonIfNecessary(tunnels, transView, transRoot, tunnelChunkNr);
}
private void buildVegetation(List<Vegetation> veg) {
if (veg.isEmpty()) {
return;
......@@ -853,6 +867,11 @@ public class CityDoctorController {
cos = filterFeatures(searchString, model.getTransportation());
chunkCounter = transportationChunkNr;
break;
case TUNNEL:
view = mainWindow.getTunnelView();
cos = model.getTunnels();
chunkCounter = tunnelChunkNr;
break;
case WATER:
view = mainWindow.getWaterView();
cos = filterFeatures(searchString, model.getWater());
......@@ -930,6 +949,11 @@ public class CityDoctorController {
cos = model.getTransportation();
chunkCounter = transportationChunkNr;
break;
case TUNNEL:
view = mainWindow.getTunnelView();
cos = model.getTunnels();
chunkCounter = tunnelChunkNr;
break;
case WATER:
view = mainWindow.getWaterView();
cos = model.getWater();
......@@ -1045,6 +1069,13 @@ public class CityDoctorController {
transportationChunkNr);
}
public void fillTreeViewWithErrorTunnel(){
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getTunnelView(), model.getTunnels(), tunnelChunkNr);
}
public void fillTreeViewWithErrorWater() {
if (model == null) {
return;
......
......@@ -95,6 +95,9 @@ public class MainWindow extends Application {
@FXML
private TreeView<Renderable> transView;
@FXML
private TreeView<Renderable> tunnelView;
@FXML
private TreeView<Renderable> bridgeView;
......@@ -176,6 +179,9 @@ public class MainWindow extends Application {
@FXML
private Tab transportationTab;
@FXML
private Tab tunnelTab;
@FXML
private Tab bridgeTab;
......@@ -426,6 +432,7 @@ public class MainWindow extends Application {
buildingsTab.setText(Localization.getText("MainWindow.buildingsTab"));
vegetationTab.setText(Localization.getText("MainWindow.vegetationTab"));
transportationTab.setText(Localization.getText("MainWindow.transportationTab"));
tunnelTab.setText(Localization.getText("MainWindow.tunnelTab"));
bridgeTab.setText(Localization.getText("MainWindow.bridgeTab"));
waterTab.setText(Localization.getText("MainWindow.waterTab"));
terrainTab.setText(Localization.getText("MainWindow.terrainTab"));
......@@ -638,18 +645,21 @@ public class MainWindow extends Application {
selectedTab = FeatureType.TRANSPORTATION;
break;
case 3:
selectedTab = FeatureType.BRIDGE;
selectedTab = FeatureType.TRANSPORTATION;
break;
case 4:
selectedTab = FeatureType.WATER;
selectedTab = FeatureType.BRIDGE;
break;
case 5:
selectedTab = FeatureType.LAND;
selectedTab = FeatureType.WATER;
break;
case 6:
selectedTab = FeatureType.CITY_FURNITURE;
selectedTab = FeatureType.LAND;
break;
case 7:
selectedTab = FeatureType.CITY_FURNITURE;
break;
case 8:
selectedTab = FeatureType.GENERIC_CITY_OBJECT;
break;
default:
......@@ -721,6 +731,10 @@ public class MainWindow extends Application {
setupSelectListener(transView);
transView.setCellFactory(param -> new RenderableTreeCell());
tunnelView.setShowRoot(true);
setupSelectListener(tunnelView);
tunnelView.setCellFactory(param -> new RenderableTreeCell());
bridgeView.setShowRoot(true);
setupSelectListener(bridgeView);
bridgeView.setCellFactory(param -> new RenderableTreeCell());
......@@ -868,6 +882,10 @@ public class MainWindow extends Application {
return transView;
}
public TreeView<Renderable> getTunnelView() {
return tunnelView;
}
public TreeView<Renderable> getBridgeView() {
return bridgeView;
}
......@@ -932,6 +950,7 @@ public class MainWindow extends Application {
buildingsView.getSelectionModel().clearSelection();
vegetationView.getSelectionModel().clearSelection();
transView.getSelectionModel().clearSelection();
tunnelView.getSelectionModel().clearSelection();
waterView.getSelectionModel().clearSelection();
terrainView.getSelectionModel().clearSelection();
cityFurnitureView.getSelectionModel().clearSelection();
......
......@@ -16,7 +16,7 @@ public class AllFurnitureNode extends Renderable{
@Override
public String getText() {
return "Building Furniture";
return "Furniture";
}
@Override
......
......@@ -73,6 +73,11 @@
<TreeView id="transTree" fx:id="transView" prefHeight="200.0" prefWidth="200.0" showRoot="false" />
</content>
</Tab>
<Tab fx:id="tunnelTab" text="Tunnel">
<content>
<TreeView id="tunnelTree" fx:id="tunnelView" prefHeight="200.0" prefWidth="200.0" showRoot="false" />
</content>
</Tab>
<Tab fx:id="bridgeTab" text="Bridges">
<content>
<TreeView id="bridgesTree" fx:id="bridgeView" prefHeight="200.0" prefWidth="200.0" showRoot="false" />
......
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