Commit 314f1216 authored by Riegel's avatar Riegel
Browse files

Add parsing of GenericAttributes

Showing with 109 additions and 1 deletion
+109 -1
...@@ -45,7 +45,7 @@ public abstract class CityObject extends GmlElement { ...@@ -45,7 +45,7 @@ public abstract class CityObject extends GmlElement {
private static final long serialVersionUID = 651712070755024188L; private static final long serialVersionUID = 651712070755024188L;
private final List<Geometry> geometryList = new ArrayList<>(); private final List<Geometry> geometryList = new ArrayList<>();
private final List<GenericAttribute> genericAttributeList = new ArrayList<>();
/** /**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is * Recreates the CityGML4j geometry in this object. The CityGML4j geometry is
* deleted from the data structure as was mapped to the city doctor data * deleted from the data structure as was mapped to the city doctor data
...@@ -77,6 +77,7 @@ public abstract class CityObject extends GmlElement { ...@@ -77,6 +77,7 @@ public abstract class CityObject extends GmlElement {
geom.setParent(this); geom.setParent(this);
} }
public List<Geometry> getGeometries() { public List<Geometry> getGeometries() {
return geometryList; return geometryList;
} }
...@@ -101,6 +102,14 @@ public abstract class CityObject extends GmlElement { ...@@ -101,6 +102,14 @@ public abstract class CityObject extends GmlElement {
return highestLodGeometry; return highestLodGeometry;
} }
public void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute);
}
public List<GenericAttribute> getGenericAttributes() {
return genericAttributeList;
}
public abstract FeatureType getFeatureType(); public abstract FeatureType getFeatureType();
@Override @Override
......
package de.hft.stuttgart.citydoctor2.datastructure;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.AbstractGenericAttributeProperty;
import org.citygml4j.core.model.generics.*;
public class GenericAttribute {
private static final Logger logger = LogManager.getLogger(GenericAttribute.class);
private final AbstractGenericAttributeProperty original;
private String type;
private String name;
private String value;
public GenericAttribute(AbstractGenericAttributeProperty attributeProperty) {
original = attributeProperty;
if (attributeProperty.getObject() == null) {
logger.warn("GenericAttribute {} is null", attributeProperty);
return;
}
name = attributeProperty.getObject().getName();
if (attributeProperty.getObject() instanceof StringAttribute sa) {
type = "StringAttribute";
value = sa.getValue();
} else if (attributeProperty.getObject() instanceof IntAttribute ia) {
type = "IntAttribute";
value = ia.getValue().toString();
} else if (attributeProperty.getObject() instanceof DoubleAttribute da) {
type = "DoubleAttribute";
value = da.getValue().toString();
} else if (attributeProperty.getObject() instanceof DateAttribute date) {
type = "DateAttribute";
value = date.getValue().toString();
} else if (attributeProperty.getObject() instanceof UriAttribute ua) {
type = "UriAttribute";
value = ua.getValue();
} else if (attributeProperty.getObject() instanceof MeasureAttribute ma) {
type = "MeasureAttribute";
value = ma.getValue().toString();
} else if (attributeProperty.getObject() instanceof CodeAttribute ca) {
type = "CodeAttribute";
value = ca.getValue().toString();
} else {
logger.warn("GenericAttribute {} is of unknown type {}", attributeProperty, attributeProperty.getObject());
value = attributeProperty.getObject().getValue().toString();
type = "Unknown type";
}
}
public AbstractGenericAttributeProperty getOriginal() {
return original;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.format("%s: [ %s = %s ]", type, name, value);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.GenericAttribute;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class GenericAttributeNode extends Renderable {
private final GenericAttribute gen;
public GenericAttributeNode(GenericAttribute gen) {
this.gen = gen;
}
@Override
public void refreshTextColor() {
}
@Override
public String getText() {
return gen.toString();
}
@Override
public void visit(Renderer renderer) {
}
}
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