Commit 660255ab authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev_gui_features_zip_loading' into 'dev'

TransportationObject model rework

See merge request !27
2 merge requests!28Version 3.17.0 Release,!27TransportationObject model rework
Pipeline #11009 passed with stage
in 1 minute and 12 seconds
Showing with 1901 additions and 610 deletions
+1901 -610
......@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.17.0] (TBD)
## [3.17.0] (2025-03-13)
### Added
......
......@@ -50,6 +50,7 @@ public class ConcretePolygon extends Polygon {
private BoundarySurface partOfSurface;
private Installation partfOfInstallation;
private CompositeCollection partOfComposite = null;
private PatchCollection partOfPatch = null;
private Geometry parent;
private LinkedPolygon linkedFromPolygon;
......@@ -141,6 +142,18 @@ public class ConcretePolygon extends Polygon {
this.partOfComposite = comp;
}
protected void setPartOfPatch(PatchCollection pc) {
this.partOfPatch = pc;
}
public PatchCollection getPartOfPatch(PatchCollection pc) {
return partOfPatch;
}
public boolean isPatchMember() {
return partOfPatch != null;
}
public CompositeCollection getPartOfComposite() {
return partOfComposite;
}
......
package de.hft.stuttgart.citydoctor2.datastructure;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public final class PatchCollection implements Serializable {
@Serial
private static final long serialVersionUID = -1748657379840997228L;
private List<ConcretePolygon> patchMembers = new ArrayList<>();
public void addPatchMember(ConcretePolygon patchMember) {
patchMembers.add(patchMember);
patchMember.setPartOfPatch(this);
}
public List<ConcretePolygon> getPatchMembers() {
return new ArrayList<>(patchMembers);
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import org.citygml4j.core.model.deprecated.transportation.TransportationComplex;
import org.citygml4j.core.model.transportation.Railway;
import org.citygml4j.core.model.transportation.Road;
import org.citygml4j.core.model.transportation.Square;
import org.citygml4j.core.model.transportation.Track;
import org.citygml4j.core.model.transportation.Waterway;
import org.citygml4j.core.util.geometry.GeometryFactory;
import java.util.ArrayList;
import java.util.List;
public class TopLevelTransportFeature extends TransportationSpace {
private final List<TransportSection> sections = new ArrayList<>();
private final List<TransportSection> intersections = new ArrayList<>();
public static TopLevelTransportFeature from(Track t) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.TRACK);
top.setGmlObject(t);
return top;
}
public static TopLevelTransportFeature from(Road r) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.ROAD);
top.setGmlObject(r);
return top;
}
public static TopLevelTransportFeature from(Waterway w) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.WATERWAY);
top.setGmlObject(w);
return top;
}
public static TopLevelTransportFeature from(Railway r) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.RAILWAY);
top.setGmlObject(r);
return top;
}
public static TopLevelTransportFeature from(Square s) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.SQUARE);
top.setGmlObject(s);
return top;
}
public static TopLevelTransportFeature from(TransportationComplex tc) {
TopLevelTransportFeature top = new TopLevelTransportFeature(TransportationType.TRANSPORTATION_COMPLEX);
top.setGmlObject(tc);
return top;
}
private TopLevelTransportFeature(TransportationType type) {
super(type);
}
public void addSection(TransportSection section) {
sections.add(section);
}
public void addIntersection(TransportSection section) {
intersections.add(section);
}
public List<TransportSection> getSections() {
return sections;
}
public List<TransportSection> getIntersections() {
return intersections;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
super.reCreateGeometries(factory, config);
for (TransportSection section : sections) {
section.reCreateGeometries(factory, config);
}
for (TransportSection section : intersections) {
section.reCreateGeometries(factory, config);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TransportSection section : sections) {
if (section.containsError(checkIdentifier)) {
return true;
}
}
for (TransportSection section : intersections) {
if (section.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TransportSection section : sections) {
section.clearAllContainedCheckResults();
}
for (TransportSection section : intersections) {
section.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TransportSection section : sections) {
section.collectContainedErrors(errors);
}
for (TransportSection section : intersections) {
section.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TransportSection section : sections) {
if (section.containsAnyError()) {
return true;
}
}
for (TransportSection section : intersections) {
if (section.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TransportSection section : sections) {
section.accept(c);
}
for (TransportSection section : intersections) {
section.accept(c);
}
}
@Override
public void unsetGmlGeometries() {
super.unsetGmlGeometries();
for (TransportSection section : sections) {
section.unsetGmlGeometries();
}
for (TransportSection section : intersections) {
section.unsetGmlGeometries();
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public String toString() {
return "TopLevelTransportFeature [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TransportSection section : sections) {
section.prepareForChecking();
}
for (TransportSection section : intersections) {
section.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TransportSection section : sections) {
section.clearMetaInformation();
}
for (TransportSection section : intersections) {
section.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TransportSection section : sections) {
section.collectInstances(handler);
}
for (TransportSection section : intersections) {
section.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TransportSection section : sections) {
section.fillValues(originalTo, handler);
}
for (TransportSection section : intersections) {
section.fillValues(originalTo, handler);
}
}
@Override
public Copyable createCopyInstance() {
return new TopLevelTransportFeature(type);
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficArea;
import org.citygml4j.core.model.transportation.TrafficArea;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
public class TrafficAreaObject extends TransportationObject {
public enum TrafficAreaType {
TRAFFIC_AREA, AUXILIARY_TRAFFIC_AREA
}
public TrafficAreaObject(TrafficAreaType trafficAreaType) {
if (trafficAreaType == TrafficAreaType.TRAFFIC_AREA) {
setType(TransportationType.TRAFFIC_AREA);
} else {
setType(TransportationType.AUXILLIARY_TRAFFIC_AREA);
}
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
switch (type) {
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) super.getGmlObject();
setMultiSurfaceAccordingToLod(ta, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject();
setMultiSurfaceAccordingToLod(ata, ms, geom.getLod());
break;
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
}
private void setMultiSurfaceAccordingToLod(AuxiliaryTrafficArea ata, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ata.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ata.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ata.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ata.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ata.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficArea: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(TrafficArea ta, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ta.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ta.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ta.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ta.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ta.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TrafficArea: " + lod);
}
}
@Override
public void unsetGmlGeometries() {
switch (type) {
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) super.getGmlObject();
ta.setLod2MultiSurface(null);
ta.setLod3MultiSurface(null);
ta.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) super.getGmlObject();
ata.setLod0MultiSurface(null);
ata.setLod1MultiSurface(null);
ata.setLod2MultiSurface(null);
ata.setLod3MultiSurface(null);
ata.getDeprecatedProperties().setLod4MultiSurface(null);
break;
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public String toString() {
return "TrafficArea [id=" + getGmlId() + "]";
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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.core.AbstractSpace;
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.util.ArrayList;
import java.util.List;
public class TrafficSpaceObject extends TransportationObject {
private final List<TrafficAreaObject> trafficAreas = new ArrayList<>();
public enum TrafficSpaceType {
TRAFFIC_SPACE, AUXILIARY_TRAFFIC_SPACE
}
public TrafficSpaceObject(TrafficSpaceType trafficSpaceType) {
if (trafficSpaceType == TrafficSpaceType.TRAFFIC_SPACE) {
super.setType(TransportationType.TRAFFIC_SPACE);
} else {
super.setType(TransportationType.AUXILLIARY_TRAFFIC_SPACE);
}
}
public List<TrafficAreaObject> getTrafficAreas() {
return trafficAreas;
}
public void addTrafficArea(TrafficAreaObject trafficAreaObject) {
trafficAreas.add(trafficAreaObject);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
AbstractSpace ats = (AbstractSpace) super.getGmlObject();
setMultiSurfaceAccordingToLod(ats, ms, geom.getLod());
}
for (TrafficAreaObject tao : trafficAreas) {
tao.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TrafficAreaObject tao : trafficAreas) {
if (tao.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TrafficAreaObject tao : trafficAreas) {
tao.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TrafficAreaObject tao : trafficAreas) {
tao.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TrafficAreaObject tao : trafficAreas) {
if (tao.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TrafficAreaObject tao : trafficAreas) {
tao.accept(c);
}
}
@Override
public void unsetGmlGeometries() {
AbstractSpace ats = (AbstractSpace) super.getGmlObject();
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
for (TrafficAreaObject tao : trafficAreas) {
tao.unsetGmlGeometries();
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public String toString() {
return "TransportationSpaceObject [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TrafficAreaObject tao : trafficAreas) {
tao.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TrafficAreaObject tao : trafficAreas) {
tao.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TrafficAreaObject tao : trafficAreas) {
handler.addInstance(tao);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TrafficSpaceObject originalTao = (TrafficSpaceObject) original;
for (TrafficAreaObject tao : originalTao.trafficAreas) {
trafficAreas.add(handler.getCopyInstance(tao));
}
super.setGmlObject(originalTao.getGmlObject());
}
@Override
public Copyable createCopyInstance() {
return new TrafficSpaceObject(null);
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
public class TransportSection extends TransportationSpace {
public enum SectionType {
SECTION, INTERSECTION
}
public TransportSection(SectionType sectionType) {
super(TransportationType.SECTION);
if (sectionType == SectionType.INTERSECTION) {
super.setType(TransportationType.INTERSECTION);
}
}
}
......@@ -43,190 +43,33 @@ import java.util.List;
*
* @author Matthias Betz
*/
public class TransportationObject extends CityObject {
public abstract class TransportationObject extends CityObject {
@Serial
private static final long serialVersionUID = -2698907271726700390L;
public enum TransportationType {
ROAD, TRACK, RAILWAY, TRAFFIC_AREA, AUXILLIARY_TRAFFIC_AREA, TRANSPORTATION_COMPLEX, SQUARE, AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE
ROAD, TRACK, RAILWAY, TRAFFIC_AREA, AUXILLIARY_TRAFFIC_AREA, TRANSPORTATION_COMPLEX, SQUARE, AUXILLIARY_TRAFFIC_SPACE,
TRAFFIC_SPACE, WATERWAY, SECTION, INTERSECTION
}
private AbstractCityObject ato;
private final List<TransportationObject> composesOf = new ArrayList<>(1);
private final TransportationType type;
protected TransportationType type;
public TransportationObject(TransportationType type) {
this.type = type;
}
@Override
public FeatureType getFeatureType() {
return FeatureType.TRANSPORTATION;
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
switch (type) {
case ROAD, TRACK, RAILWAY, SQUARE, TRANSPORTATION_COMPLEX:
AbstractTransportationSpace tc = (AbstractTransportationSpace) ato;
setMultiSurfaceAccordingToLod(tc, ms, geom.getLod());
break;
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) ato;
setMultiSurfaceAccordingToLod(ta, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) ato;
setMultiSurfaceAccordingToLod(ata, ms, geom.getLod());
break;
case AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE:
AbstractSpace ats = (AbstractSpace) ato;
setMultiSurfaceAccordingToLod(ats, ms, geom.getLod());
break;
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
for (TransportationObject children : composesOf) {
children.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(AbstractTransportationSpace tc, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD1:
tc.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
tc.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
tc.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
tc.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TransportationComplex: " + lod);
}
protected TransportationObject() {
}
private void setMultiSurfaceAccordingToLod(AuxiliaryTrafficArea ata, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
ata.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD1:
ata.setLod1MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
ata.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ata.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ata.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficArea: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(TrafficArea ta, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD2:
ta.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
ta.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD4:
ta.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for TrafficArea: " + lod);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TransportationObject to : composesOf) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TransportationObject to : composesOf) {
to.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TransportationObject to : composesOf) {
to.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TransportationObject to : composesOf) {
if (to.containsAnyError()) {
return true;
}
}
return false;
void setType(TransportationType type) {
this.type = type;
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TransportationObject to : composesOf) {
to.accept(c);
}
public FeatureType getFeatureType() {
return FeatureType.TRANSPORTATION;
}
@Override
......@@ -234,55 +77,11 @@ public class TransportationObject extends CityObject {
return ato;
}
@Override
public void unsetGmlGeometries() {
switch (type) {
case ROAD, TRACK, RAILWAY, SQUARE, TRANSPORTATION_COMPLEX:
AbstractTransportationSpace tc = (AbstractTransportationSpace) ato;
tc.getDeprecatedProperties().setLod1MultiSurface(null);
tc.setLod2MultiSurface(null);
tc.setLod3MultiSurface(null);
tc.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case TRAFFIC_AREA:
TrafficArea ta = (TrafficArea) ato;
ta.setLod2MultiSurface(null);
ta.setLod3MultiSurface(null);
ta.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea ata = (AuxiliaryTrafficArea) ato;
ata.setLod0MultiSurface(null);
ata.setLod1MultiSurface(null);
ata.setLod2MultiSurface(null);
ata.setLod3MultiSurface(null);
ata.getDeprecatedProperties().setLod4MultiSurface(null);
break;
case AUXILLIARY_TRAFFIC_SPACE, TRAFFIC_SPACE:
AbstractSpace ats = (AbstractSpace) ato;
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
break;
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
public void setGmlObject(AbstractCityObject tc) {
ato = tc;
}
public void addChild(TransportationObject subTrans) {
composesOf.add(subTrans);
}
public List<TransportationObject> getChildren() {
return composesOf;
}
public TransportationType getTransportationType() {
return type;
......@@ -293,43 +92,17 @@ public class TransportationObject extends CityObject {
return "TransportationObject [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TransportationObject child : composesOf) {
child.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TransportationObject child : composesOf) {
child.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TransportationObject to : composesOf) {
handler.addInstance(to);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TransportationObject to : originalTo.composesOf) {
composesOf.add(handler.getCopyInstance(to));
}
ato = originalTo.ato;
}
@Override
public Copyable createCopyInstance() {
return new TransportationObject(type);
return null;
}
}
package de.hft.stuttgart.citydoctor2.datastructure;
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.core.AbstractSpace;
import org.citygml4j.core.model.transportation.AbstractTransportationSpace;
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.util.ArrayList;
import java.util.List;
public abstract class TransportationSpace extends TransportationObject {
private final List<TrafficSpaceObject> trafficSpaces = new ArrayList<>();
private final List<TrafficSpaceObject> auxTrafficSpaces = new ArrayList<>();
protected TransportationSpace(TransportationType type) {
super(type);
}
public List<TrafficSpaceObject> getTrafficSpaces() {
return trafficSpaces;
}
public List<TrafficSpaceObject> getAuxTrafficSpaces() {
return auxTrafficSpaces;
}
public void addTrafficSpace(TrafficSpaceObject t) {
trafficSpaces.add(t);
}
public void addAuxTrafficSpace(TrafficSpaceObject t) {
auxTrafficSpaces.add(t);
}
@Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder) {
continue;
}
if (geom.getType() == GeometryType.MULTI_SURFACE) {
MultiSurface ms = CityGmlUtils.createMultiSurface(geom, factory, config);
if (super.getGmlObject() instanceof AbstractTransportationSpace ats) {
setMultiSurfaceAccordingToLod(ats, ms, geom.getLod());
} else {
AbstractSpace as = (AbstractSpace) super.getGmlObject();
setMultiSurfaceAccordingToLod(as, ms, geom.getLod());
}
} else {
throw new IllegalStateException("Geometry in TransportationObject cannot be of type " + geom.getType()
+ ". Only MultiSurface allowed");
}
}
for (TrafficSpaceObject spaces : trafficSpaces) {
spaces.reCreateGeometries(factory, config);
}
for (TrafficSpaceObject spaces : auxTrafficSpaces) {
spaces.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(AbstractTransportationSpace ats, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0 -> ats.setLod0MultiSurface(new MultiSurfaceProperty(ms));
case LOD1 -> ats.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
case LOD2 -> ats.setLod2MultiSurface(new MultiSurfaceProperty(ms));
case LOD3 -> ats.setLod3MultiSurface(new MultiSurfaceProperty(ms));
case LOD4 -> ats.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty(ms));
default ->
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
private void setMultiSurfaceAccordingToLod(AbstractSpace as, MultiSurface ms, Lod lod) {
switch (lod) {
case LOD0:
as.setLod0MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD2:
as.setLod2MultiSurface(new MultiSurfaceProperty(ms));
break;
case LOD3:
as.setLod3MultiSurface(new MultiSurfaceProperty(ms));
break;
default:
throw new IllegalStateException("cannot set geometry with LOD for AuxiliaryTrafficSpace: " + lod);
}
}
@Override
public boolean containsError(CheckId checkIdentifier) {
boolean hasError = super.containsError(checkIdentifier);
if (hasError) {
return true;
}
for (TrafficSpaceObject to : trafficSpaces) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
if (to.containsError(checkIdentifier)) {
return true;
}
}
return false;
}
@Override
public void clearAllContainedCheckResults() {
super.clearAllContainedCheckResults();
for (TrafficSpaceObject to : trafficSpaces) {
to.clearAllContainedCheckResults();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.clearAllContainedCheckResults();
}
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
super.collectContainedErrors(errors);
for (TrafficSpaceObject to : trafficSpaces) {
to.collectContainedErrors(errors);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.collectContainedErrors(errors);
}
}
@Override
public boolean containsAnyError() {
boolean hasError = super.containsAnyError();
if (hasError) {
return true;
}
for (TrafficSpaceObject to : trafficSpaces) {
if (to.containsAnyError()) {
return true;
}
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
if (to.containsAnyError()) {
return true;
}
}
return false;
}
@Override
public void accept(Check c) {
super.accept(c);
if (c.canExecute(this)) {
c.check(this);
}
for (TrafficSpaceObject to : trafficSpaces) {
to.accept(c);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.accept(c);
}
}
@Override
public void unsetGmlGeometries() {
AbstractSpace ats = (AbstractSpace) super.getGmlObject();
ats.setLod0MultiSurface(null);
ats.setLod2MultiSurface(null);
ats.setLod3MultiSurface(null);
for (TrafficSpaceObject to : trafficSpaces) {
to.unsetGmlGeometries();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.unsetGmlGeometries();
}
}
@Override
public CityObject getTopLevelCityObject() {
return this;
}
@Override
public String toString() {
return "TransportationSpace [id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
for (TrafficSpaceObject to : trafficSpaces) {
to.prepareForChecking();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
for (TrafficSpaceObject to : trafficSpaces) {
to.clearMetaInformation();
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
for (TrafficSpaceObject to : trafficSpaces) {
to.collectInstances(handler);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.collectInstances(handler);
}
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
TransportationObject originalTo = (TransportationObject) original;
for (TrafficSpaceObject to : trafficSpaces) {
to.fillValues(originalTo, handler);
}
for (TrafficSpaceObject to : auxTrafficSpaces) {
to.fillValues(originalTo, handler);
}
}
}
......@@ -30,7 +30,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.TunnelConstructiveElement;
import de.hft.stuttgart.citydoctor2.datastructure.TunnelFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.TunnelPart;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject.TransportationType;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation.VegetationType;
import de.hft.stuttgart.citydoctor2.math.graph.KDTree;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
......@@ -658,26 +657,52 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
@Override
public void visit(AuxiliaryTrafficArea ata) {
TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_AREA);
mapAbstractThematicSurface(ata, to);
finishTransportationMapping(to);
public void visit(Track track) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(track);
mapSectionsAndIntersections(track.getSections(), track.getIntersections(), top);
mapAbstractTransportationSpace(track, top);
finishTransportationMapping(top);
}
@Override
public void visit(TrafficArea ta) {
TransportationObject to = new TransportationObject(TransportationType.TRAFFIC_AREA);
mapAbstractThematicSurface(ta, to);
finishTransportationMapping(to);
public void visit(Road road) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(road);
mapSectionsAndIntersections(road.getSections(), road.getIntersections(), top);
mapAbstractTransportationSpace(road, top);
finishTransportationMapping(top);
}
@Override
public void visit(Road road) {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
mapAbstractTransportationSpace(road, to);
finishTransportationMapping(to);
public void visit(Waterway waterway) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(waterway);
mapSectionsAndIntersections(waterway.getSections(), waterway.getIntersections(), top);
mapAbstractTransportationSpace(waterway, top);
finishTransportationMapping(top);
}
@Override
public void visit(Railway railway) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(railway);
mapSectionsAndIntersections(railway.getSections(), railway.getIntersections(), top);
mapAbstractTransportationSpace(railway, top);
finishTransportationMapping(top);
}
@Override
public void visit(Square square) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(square);
mapAbstractTransportationSpace(square, top);
finishTransportationMapping(top);
}
@Override
public void visit(TransportationComplex tc) {
TopLevelTransportFeature top = TopLevelTransportFeature.from(tc);
mapAbstractTransportationSpace(tc, top);
finishTransportationMapping(top);
}
private void mapAbstractThematicSurface(AbstractThematicSurface ats, CityObject co) {
mapAbstractSpaceBoundary(ats, co);
parseAndAddMultiSurface(ats.getLod0MultiSurface(), Lod.LOD0, co);
......@@ -707,33 +732,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseId(ag, to);
}
@Override
public void visit(Railway railway) {
TransportationObject to = new TransportationObject(TransportationType.RAILWAY);
mapAbstractTransportationSpace(railway, to);
finishTransportationMapping(to);
}
@Override
public void visit(Square square) {
TransportationObject to = new TransportationObject(TransportationType.SQUARE);
mapAbstractTransportationSpace(square, to);
finishTransportationMapping(to);
}
@Override
public void visit(Track track) {
TransportationObject to = new TransportationObject(TransportationType.TRACK);
mapAbstractTransportationSpace(track, to);
finishTransportationMapping(to);
}
@Override
public void visit(TransportationComplex transportationComplex) {
TransportationObject to = new TransportationObject(TransportationType.TRANSPORTATION_COMPLEX);
mapAbstractTransportationSpace(transportationComplex, to);
finishTransportationMapping(to);
}
private void finishTransportationMapping(TransportationObject to) {
finishCityObjectConstruction(to);
......@@ -746,39 +744,97 @@ public class Citygml3FeatureMapper extends ObjectWalker {
updateEdgesAndVertices(co);
}
private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationObject to) {
to.setGmlObject(ats);
parseAbstractTransportationSpaceGeometries(ats, to);
private void mapAbstractTransportationSpace(AbstractTransportationSpace ats, TransportationSpace trsp) {
parseAbstractTransportationSpaceGeometries(ats, trsp);
for (TrafficSpaceProperty tsp : ats.getTrafficSpaces()) {
if (tsp.isSetObject()) {
TransportationObject trafficSpace = new TransportationObject(TransportationType.TRAFFIC_SPACE);
mapTrafficSpace(tsp.getObject(), trafficSpace);
finishTransportationMapping(trafficSpace);
to.getChildren().add(trafficSpace);
TrafficSpaceObject tso = new TrafficSpaceObject(TrafficSpaceObject.TrafficSpaceType.TRAFFIC_SPACE);
mapTrafficSpace(tsp.getObject(), tso);
trsp.addTrafficSpace(tso);
}
}
for (AuxiliaryTrafficSpaceProperty auxTrafficProp : ats.getAuxiliaryTrafficSpaces()) {
if (auxTrafficProp.isSetObject()) {
TransportationObject trafficSpace = parseAuxiliaryTrafficSpace(auxTrafficProp.getObject());
finishTransportationMapping(trafficSpace);
to.addChild(trafficSpace);
for (AuxiliaryTrafficSpaceProperty atsp : ats.getAuxiliaryTrafficSpaces()) {
if (atsp.isSetObject()) {
TrafficSpaceObject atso = new TrafficSpaceObject(TrafficSpaceObject.TrafficSpaceType.AUXILIARY_TRAFFIC_SPACE);
mapAuxiliaryTrafficSpace(atsp.getObject(), atso);
trsp.addTrafficSpace(atso);
}
}
}
private void mapTrafficSpace(TrafficSpace ts, TransportationObject to) {
mapAbstractUnoccupiedSpace(ts, to);
private void mapSectionsAndIntersections(List<SectionProperty> sectionProps, List<IntersectionProperty> intersectionProps,
TopLevelTransportFeature top) {
for (SectionProperty sectionProp : sectionProps) {
if (sectionProp.isSetObject()) {
TransportSection sect = new TransportSection(TransportSection.SectionType.SECTION);
sect.setGmlObject(sectionProp.getObject());
mapAbstractTransportationSpace(sectionProp.getObject(), sect);
finishCityObjectConstruction(sect);
top.addSection(sect);
}
}
for (IntersectionProperty intersectionProp : intersectionProps) {
if (intersectionProp.isSetObject()) {
TransportSection isect = new TransportSection(TransportSection.SectionType.INTERSECTION);
isect.setGmlObject(intersectionProp.getObject());
mapAbstractTransportationSpace(intersectionProp.getObject(), isect);
finishCityObjectConstruction(isect);
top.addIntersection(isect);
}
}
}
private void mapAbstractUnoccupiedSpace(AbstractUnoccupiedSpace aus, CityObject co) {
mapAbstractPhysicalSpace(aus, co);
private void mapTrafficSpace(TrafficSpace ts, TrafficSpaceObject tso) {
tso.setGmlObject(ts);
mapAbstractUnoccupiedSpace(ts, tso);
for (AbstractSpaceBoundaryProperty boundary : ts.getBoundaries()) {
if (boundary.isSetObject()) {
TrafficArea area = (TrafficArea) boundary.getObject();
TrafficAreaObject tao = new TrafficAreaObject(TrafficAreaObject.TrafficAreaType.TRAFFIC_AREA);
mapTrafficArea(area, tao);
tso.addTrafficArea(tao);
}
}
finishCityObjectConstruction(tso);
}
private TransportationObject parseAuxiliaryTrafficSpace(AuxiliaryTrafficSpace ats) {
TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_SPACE);
parseAbstractSpaceGeometries(ats, to);
finishCityObjectConstruction(to);
return to;
private void mapAuxiliaryTrafficSpace(AuxiliaryTrafficSpace ats, TrafficSpaceObject tso) {
tso.setGmlObject(ats);
mapAbstractUnoccupiedSpace(ats, tso);
for (AbstractSpaceBoundaryProperty boundary : ats.getBoundaries()) {
if (boundary.isSetObject()) {
AuxiliaryTrafficArea area = (AuxiliaryTrafficArea) boundary.getObject();
TrafficAreaObject tao = new TrafficAreaObject(TrafficAreaObject.TrafficAreaType.AUXILIARY_TRAFFIC_AREA);
mapAuxiliaryTrafficArea(area, tao);
tso.addTrafficArea(tao);
}
}
finishCityObjectConstruction(tso);
}
private void mapTrafficArea(TrafficArea ta, TrafficAreaObject tao) {
tao.setGmlObject(ta);
parseAndAddMultiSurface(ta.getLod0MultiSurface(), Lod.LOD0, tao);
parseAndAddMultiSurface(ta.getLod1MultiSurface(), Lod.LOD1, tao);
parseAndAddMultiSurface(ta.getLod2MultiSurface(), Lod.LOD2, tao);
parseAndAddMultiSurface(ta.getLod3MultiSurface(), Lod.LOD3, tao);
parseAndAddMultiSurface(ta.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, tao);
finishCityObjectConstruction(tao);
}
private void mapAuxiliaryTrafficArea(AuxiliaryTrafficArea ats, TrafficAreaObject tao) {
tao.setGmlObject(ats);
parseAndAddMultiSurface(ats.getLod0MultiSurface(), Lod.LOD0, tao);
parseAndAddMultiSurface(ats.getLod1MultiSurface(), Lod.LOD1, tao);
parseAndAddMultiSurface(ats.getLod2MultiSurface(), Lod.LOD2, tao);
parseAndAddMultiSurface(ats.getLod3MultiSurface(), Lod.LOD3, tao);
parseAndAddMultiSurface(ats.getDeprecatedProperties().getLod4MultiSurface(), Lod.LOD4, tao);
finishCityObjectConstruction(tao);
}
private void mapAbstractUnoccupiedSpace(AbstractUnoccupiedSpace aus, CityObject co) {
mapAbstractPhysicalSpace(aus, co);
}
private void parseAbstractTransportationSpaceGeometries(AbstractTransportationSpace space, CityObject co) {
......
......@@ -63,6 +63,51 @@ public class Citygml3GeometryMapper extends GeometryWalker {
}
}
@Override
public void visit(Surface surface) {
if (surface.getPatches() != null && !surface.getPatches().isSetObjects()) {
logger.warn("Surface {} has no PolygonPatches.", surface.getId());
return;
}
PatchCollection patchCollection = new PatchCollection();
GeometryWalker patchCollector = new GeometryWalker() {
@Override
public void visit(PolygonPatch patch) {
parsePolygonPatch(patch, patchCollection);
}
};
surface.getPatches().getObjects().forEach(abstractSurfacePatch -> abstractSurfacePatch.accept(patchCollector));
}
private void parsePolygonPatch(PolygonPatch patch, PatchCollection collection) {
AbstractRingProperty exterior = patch.getExterior();
List<AbstractRingProperty> interior = patch.getInterior();
if (exterior == null || exterior.getObject() == null) {
if (logger.isWarnEnabled()) {
logger.warn(Localization.getText("GeometryMapper.emptyPolygon"));
}
return;
}
ConcretePolygon conc = new ConcretePolygon();
polygons.add(conc);
currentRing = new LinearRing(LinearRingType.EXTERIOR);
exterior.getObject().accept(this);
conc.setExteriorRing(currentRing);
for (AbstractRingProperty interiorGmlRing : interior) {
AbstractRing gmlRing = interiorGmlRing.getObject();
if (gmlRing == null) {
continue;
}
currentRing = new LinearRing(LinearRingType.INTERIOR);
gmlRing.accept(this);
conc.addInteriorRing(currentRing);
}
collection.addPatchMember(conc);
polygons.add(conc);
}
private void parsePolygon(String id, AbstractRingProperty exterior, List<AbstractRingProperty> interior) {
if (exterior == null || exterior.getObject() == null) {
if (logger.isWarnEnabled()) {
......
......@@ -26,6 +26,10 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.TopLevelTransportFeature;
import de.hft.stuttgart.citydoctor2.datastructure.TrafficSpaceObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationSpace;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
......@@ -49,7 +53,7 @@ public class BoundingBoxCalculator {
* Only the exterior rings of the polygons is used as inner rings should be
* within the exterior or they are faulty.
*
* @param a list of polygons containing the vertices
* @param polygons a list of polygons containing the vertices
* @return an BoundingBox containing the two end points of the bounding box.
*/
public static BoundingBox calculateBoundingBox(Collection<? extends Polygon> polygons) {
......@@ -98,12 +102,16 @@ public class BoundingBoxCalculator {
Vector3d low = new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
Vector3d high = new Vector3d(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
//TODO: Rework this using visitors
findMinMax(low, high, model.getBuildings());
findMinMax(low, high, model.getBridges());
findMinMax(low, high, model.getLand());
findMinMax(low, high, model.getTransportation());
findMinMaxTransport(low, high, model.getTransportation());
findMinMax(low, high, model.getWater());
findMinMax(low, high, model.getVegetation());
findMinMax(low, high, model.getTunnels());
findMinMax(low, high, model.getCityFurniture());
findMinMax(low, high, model.getGenericCityObjects());
Vector3d[] result = new Vector3d[2];
result[0] = low;
......@@ -151,6 +159,23 @@ public class BoundingBoxCalculator {
}
}
//TODO: Implement this properly with visitor. Quick and dirty fix for the renderer
private static void findMinMaxTransport(Vector3d low, Vector3d high, List<? extends TransportationObject> features) {
for (TransportationObject to : features) {
findMinMax(low, high, to);
if (to instanceof TransportationSpace ts) {
findMinMaxTransport(low, high, ts.getTrafficSpaces());
findMinMaxTransport(low, high, ts.getAuxTrafficSpaces());
if (to instanceof TopLevelTransportFeature top) {
findMinMaxTransport(low, high, top.getSections());
findMinMaxTransport(low, high, top.getIntersections());
}
} else if (to instanceof TrafficSpaceObject tso) {
findMinMaxTransport(low, high, tso.getTrafficAreas());
}
}
}
private static void findMinMax(Vector3d low, Vector3d high, CityObject co) {
for (Geometry geom : co.getGeometries()) {
if (geom.getVertices() == null) {
......
......@@ -286,9 +286,6 @@ public class PdfStreamReporter implements StreamReporter {
}
writeErrorForCityObject(co, tSection);
TransportationObject to = (TransportationObject) co;
for (TransportationObject transO : to.getChildren()) {
writeCheckResultForTransportationObject(transO, tSection);
}
}
private void reportVegetation(CityObject co, boolean hasError) {
......
......@@ -179,7 +179,7 @@ public class CheckerTest {
cgmlArch.mountArchive(new ParserConfiguration(8, false));
ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig();
FeatureCheckedListener l = co -> {
assertTrue(co.isValidated());
assertTrue("CityObject should be validated", co.isValidated());
};
for (CityGmlZipEntry entry : cgmlArch.getEntries()) {
Checker.streamCheck(entry, null, null, config, l, null);
......
......@@ -19,13 +19,11 @@ import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.skin.VirtualFlow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
......@@ -1026,7 +1024,7 @@ public class MainWindow extends Application {
return attributeView;
}
public TreeView<Renderable> getOtherObjectsView() {
public TreeView<Renderable> getGenericCityObjectView() {
return otherObjectsView;
}
......
......@@ -366,6 +366,35 @@ public class Renderer {
return polygons;
}
private Set<ConcretePolygon> setupTransportationObjectPolygons(TransportationObject to) {
Set<ConcretePolygon> polygons = new HashSet<>();
addPolygons(to, polygons);
if (to instanceof TransportationSpace ts) {
if (ts instanceof TopLevelTransportFeature top) {
for (TransportSection sect : top.getSections()) {
polygons.addAll(setupTransportationObjectPolygons(sect));
}
for (TransportSection isect : top.getIntersections()) {
polygons.addAll(setupTransportationObjectPolygons(isect));
}
}
for (TrafficSpaceObject tso : ts.getTrafficSpaces()) {
polygons.addAll(setupTransportationObjectPolygons(tso));
}
for (TrafficSpaceObject atso : ts.getAuxTrafficSpaces()) {
polygons.addAll(setupTransportationObjectPolygons(atso));
}
}
if (to instanceof TrafficSpaceObject tso) {
for (TrafficAreaObject tao : tso.getTrafficAreas()) {
polygons.addAll(setupTransportationObjectPolygons(tao));
}
}
return polygons;
}
public void render(Tunnel tunnel) {
refresher = () -> {
Set<ConcretePolygon> setupTunnelPolygons = setupTunnelPolygons(tunnel);
......@@ -578,6 +607,20 @@ public class Renderer {
return polygons;
}
public void render(TransportationObject to) {
refresher = () -> {
Set<ConcretePolygon> setupTransportationPolygons = setupTransportationObjectPolygons(to);
mainWindow.zoomOutForBoundingBox(BoundingBox.of(setupTransportationPolygons));
render(setupTransportationPolygons);
Platform.runLater(() -> {
errorUpdater = () -> displayErrors(to);
errorUpdater.run();
addGenericAttributesToView(to);
});
};
refresher.run();
}
public void render(BoundarySurface bs) {
refresher = () -> {
Set<ConcretePolygon> setupBoundarySurfacePolygons = setupBoundarySurfacePolygons(bs);
......@@ -827,8 +870,34 @@ public class Renderer {
renderCityObjects(vegetation, Color.LIGHTGREEN);
}
public void renderTransportation(List<TransportationObject> transportation) {
renderCityObjects(transportation, Color.YELLOW);
public void renderTransportation(List<? extends TransportationObject> transportation) {
errorUpdater = null;
refresher = () -> {
Platform.runLater(() -> {
loadingDialog.show();
clearGeometryTrees();
clearAttributes();
});
Thread t = new Thread(() -> {
Set<ConcretePolygon> polygons = new HashSet<>();
for (TransportationObject to : transportation) {
polygons.addAll(setupTransportationObjectPolygons(to));
}
currentTriGeom = TriangulatedGeometry.of(polygons, Color.YELLOW);
errVisitor.setGeometry(currentTriGeom);
Platform.runLater(() -> {
setupRenderState();
mainWindow.zoomOutForBoundingBox(BoundingBox.of(polygons));
loadingDialog.hide();
});
});
t.setUncaughtExceptionHandler((thread, e) -> {
Platform.runLater(() -> loadingDialog.hide());
logger.catching(e);
});
t.start();
};
refresher.run();
}
public void renderBridges(List<BridgeObject> bridges) {
......
......@@ -78,7 +78,7 @@ public class TriangulatedGeometry {
addPointsFromBuildings(model.getBuildings(), points);
addPointsFromCityObject(model.getBridges(), points);
addPointsFromCityObject(model.getLand(), points);
addPointsFromCityObject(model.getTransportation(), points);
addPointsFromTransportationObjects(model.getTransportation(), points);
addPointsFromCityObject(model.getVegetation(), points);
addPointsFromCityObject(model.getWater(), points);
......@@ -90,7 +90,7 @@ public class TriangulatedGeometry {
addPolygonDataFromBuildings(model.getBuildings(), triGeom, filters);
addPolygonDataFromBridges(model.getBridges(), triGeom, filters);
addPolygonDataFromCityObjects(model.getLand(), triGeom, Color.BROWN, filters);
addPolygonDataFromCityObjects(model.getTransportation(), triGeom, Color.YELLOW, filters);
addPolygonDataFromTransportationObjects(model.getTransportation(), triGeom, filters);
addPolygonDataFromCityObjects(model.getVegetation(), triGeom, Color.LIGHTGREEN, filters);
addPolygonDataFromCityObjects(model.getWater(), triGeom, Color.LIGHTSKYBLUE, filters);
addPolygonDataFromCityObjects(model.getCityFurniture(), triGeom, Color.BLUEVIOLET, filters);
......@@ -132,6 +132,45 @@ public class TriangulatedGeometry {
}
}
private static void addPolygonDataFromTransportationObjects(List<TransportationObject> tos, TriangulatedGeometry triGeom,
List<ViewFilter> filters) {
for (TransportationObject to : tos) {
if (to instanceof TransportationSpace tsp) {
addPolygonDataFromTransportationSpace(tsp, triGeom, filters);
if (tsp instanceof TopLevelTransportFeature top) {
for (TransportSection tse : top.getSections()) {
addPolygonDataFromTransportationSpace(tse, triGeom, filters);
}
for (TransportSection tse : top.getIntersections()) {
addPolygonDataFromTransportationSpace(tse, triGeom, filters);
}
}
} else {
addPolygonData(to, triGeom, Color.YELLOW, filters);
}
}
}
private static void addPolygonDataFromTransportationSpace(TransportationSpace ts, TriangulatedGeometry triGeom,
List<ViewFilter> filters) {
addPolygonData(ts, triGeom, Color.YELLOW, filters);
addPolygonDataFromTrafficSpaces(ts.getTrafficSpaces(), triGeom, filters);
addPolygonDataFromTrafficSpaces(ts.getAuxTrafficSpaces(), triGeom, filters);
}
private static void addPolygonDataFromTrafficSpaces(List<TrafficSpaceObject> spaces, TriangulatedGeometry triGeom,
List<ViewFilter> filters) {
for (TrafficSpaceObject space : spaces) {
addPolygonData(space, triGeom, Color.YELLOW, filters);
for (TrafficAreaObject area : space.getTrafficAreas()) {
addPolygonData(area, triGeom, Color.YELLOW, filters);
}
}
}
private static void addPolygonDataFromBoundarySurfaces(List<BoundarySurface> boundarySurfaces,
TriangulatedGeometry triGeom, List<ViewFilter> filters) {
for (BoundarySurface bs : boundarySurfaces) {
......@@ -187,6 +226,29 @@ public class TriangulatedGeometry {
}
}
private static void addPointsFromTransportationObjects(List<? extends TransportationObject> tos, List<Vector3d> points) {
for (TransportationObject to : tos) {
addPoints(to, points);
if (to instanceof TransportationSpace ts) {
addPointsFromTrafficSpace(ts.getTrafficSpaces(), points);
addPointsFromTrafficSpace(ts.getAuxTrafficSpaces(), points);
if (ts instanceof TopLevelTransportFeature top) {
addPointsFromTransportationObjects(top.getSections(), points);
addPointsFromTransportationObjects(top.getIntersections(), points);
}
}
}
}
private static void addPointsFromTrafficSpace(List<TrafficSpaceObject> tos, List<Vector3d> points) {
for (TrafficSpaceObject to : tos) {
addPoints(to, points);
for (TrafficAreaObject area : to.getTrafficAreas()) {
addPoints(area, points);
}
}
}
private static void addPointsFromCityObject(List<? extends CityObject> cos, List<Vector3d> points) {
for (CityObject co : cos) {
addPoints(co, points);
......
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.TrafficAreaObject;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
import java.util.List;
public class AllTrafficAreaNode extends Renderable {
private final List<TrafficAreaObject> areas;
private final String text;
public AllTrafficAreaNode(List<TrafficAreaObject> areas, TrafficAreaObject.TrafficAreaType type) {
this.areas = areas;
this.text = type.toString();
}
@Override
public void refreshTextColor() {
// no use
}
@Override
public String getText() {
return this.text;
}
@Override
public void visit(Renderer renderer) {
renderer.renderTransportation(areas);
}
}
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