Commit 571a3248 authored by Matthias Betz's avatar Matthias Betz
Browse files

update model for citygml4j 3 and quality ade 1.4.0

parent 009cef54
......@@ -148,7 +148,7 @@ fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
*.iml
modules.xml
.idea/misc.xml
*.ipr
......@@ -271,6 +271,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
idea/
**/.idea/
# End of https://www.gitignore.io/api/java,maven,macos,linux,eclipse,windows,netbeans,intellij
/.apt_generated_tests/
*.iml
......@@ -8,16 +8,20 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.citygml4j/citygml4j -->
<dependency>
<groupId>org.citygml4j</groupId>
<artifactId>citygml4j</artifactId>
<version>2.10.2</version>
<artifactId>citygml4j-core</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.citygml4j</groupId>
<artifactId>citygml4j-xml</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
......
......@@ -18,36 +18,23 @@ package de.hft.stuttgart.quality;
import java.util.Collections;
import java.util.List;
import org.citygml4j.model.citygml.ade.binding.ADEContext;
import org.citygml4j.model.citygml.ade.binding.ADEMarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEUnmarshaller;
import org.citygml4j.model.module.ade.ADEModule;
import org.citygml4j.core.visitor.ADEWalker;
import org.citygml4j.xml.ade.CityGMLADE;
import org.citygml4j.xml.module.ade.ADEModule;
import de.hft.stuttgart.quality.marshaller.QualityAdeMarshaller;
import de.hft.stuttgart.quality.marshaller.QualityAdeUnmarshaller;
public class QualityADEContext implements ADEContext {
public class QualityADEContext implements CityGMLADE {
private final List<ADEModule> modules = Collections.singletonList(QualityADEModule.V0_1_3);
private final List<ADEModule> modules = Collections.singletonList(QualityADEModule.V0_1_4);
@Override
public List<ADEModule> getADEModules() {
return modules;
}
@Override
public List<String> getModelPackageNames() {
return Collections.singletonList("de.hft.stuttgart.quality.model");
}
@Override
public ADEMarshaller createADEMarshaller() {
return new QualityAdeMarshaller();
}
@Override
public ADEUnmarshaller createADEUnmarshaller() {
return new QualityAdeUnmarshaller();
public ADEWalker getADEWalker() {
return new QualityADEWalker();
}
}
......@@ -16,66 +16,22 @@
package de.hft.stuttgart.quality;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
import org.citygml4j.model.gml.feature.AbstractFeature;
import org.citygml4j.model.module.ade.ADEModule;
import org.citygml4j.model.module.citygml.CityGMLVersion;
import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.xml.module.ade.ADEModule;
public class QualityADEModule extends ADEModule {
public static final String NAMESPACE_URI = "https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.3";
public static final QualityADEModule V0_1_3 = new QualityADEModule();
private static final long serialVersionUID = -8208579547274734280L;
public QualityADEModule() {
super(NAMESPACE_URI, "qual", CityGMLVersion.v2_0_0);
}
@Override
public URL getSchemaResource() {
return QualityADEContext.class.getResource("/qualityAde.xsd");
}
@Override
public List<String> getJAXBPackageNames() {
return Collections.singletonList("de.hft.stuttgart.quality.model.jaxb");
}
public static final String NAMESPACE_URI = "https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4";
@Override
public boolean hasFeatureProperty(String name) {
return false;
}
public static final QualityADEModule V0_1_4 = new QualityADEModule();
@Override
public boolean hasFeature(String name) {
return false;
}
@Override
public Class<? extends AbstractFeature> getFeatureClass(String name) {
throw new IllegalStateException("No feature classes available");
}
@Override
public QName getFeatureName(Class<? extends AbstractFeature> featureClass) {
return null;
}
@Override
public Map<String, Class<? extends AbstractFeature>> getFeatures() {
return Collections.emptyMap();
}
@Override
public boolean isTopLevelFeature(String name) {
return false;
}
public QualityADEModule() {
super(NAMESPACE_URI, "qual", CityGMLVersion.v2_0);
}
@Override
public URL getSchemaResource() {
return QualityADEContext.class.getResource("/qualityAde.xsd");
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
package de.hft.stuttgart.quality;
public abstract class ValidationError extends ChildObject {
import org.citygml4j.core.visitor.ADEWalker;
public class QualityADEWalker extends ADEWalker {
private static final long serialVersionUID = -2995694676938108325L;
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.marshaller;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import javax.xml.bind.JAXBElement;
import org.citygml4j.builder.jaxb.marshal.citygml.ade.ADEMarshallerHelper;
import org.citygml4j.model.citygml.ade.binding.ADEMarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.util.mapper.TypeMapper;
import de.hft.stuttgart.quality.model.AllPolygonsWrongOrientation;
import de.hft.stuttgart.quality.model.AttributeMissing;
import de.hft.stuttgart.quality.model.AttributeWrongValue;
import de.hft.stuttgart.quality.model.ConsecutivePointsSame;
import de.hft.stuttgart.quality.model.Edge;
import de.hft.stuttgart.quality.model.HoleOutside;
import de.hft.stuttgart.quality.model.InnerRingsNested;
import de.hft.stuttgart.quality.model.InteriorDisconnected;
import de.hft.stuttgart.quality.model.IntersectingRings;
import de.hft.stuttgart.quality.model.MultipleConnectedComponents;
import de.hft.stuttgart.quality.model.NonManifoldEdge;
import de.hft.stuttgart.quality.model.NonManifoldVertex;
import de.hft.stuttgart.quality.model.NonPlanarDistancePlane;
import de.hft.stuttgart.quality.model.NonPlanarNormalsDeviation;
import de.hft.stuttgart.quality.model.OrientationRingsSame;
import de.hft.stuttgart.quality.model.PolygonWrongOrientation;
import de.hft.stuttgart.quality.model.RingNotClosed;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.SolidNotClosed;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.TooFewPoints;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.ValidationResult;
import de.hft.stuttgart.quality.model.jaxb.AllPolygonsWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.AttributeMissingType;
import de.hft.stuttgart.quality.model.jaxb.AttributeWrongValueType;
import de.hft.stuttgart.quality.model.jaxb.ConsecutivePointsSameType;
import de.hft.stuttgart.quality.model.jaxb.EdgeType;
import de.hft.stuttgart.quality.model.jaxb.HoleOutsideType;
import de.hft.stuttgart.quality.model.jaxb.InnerRingsNestedType;
import de.hft.stuttgart.quality.model.jaxb.InteriorDisconnectedType;
import de.hft.stuttgart.quality.model.jaxb.IntersectingRingsType;
import de.hft.stuttgart.quality.model.jaxb.MultipleConnectedComponentsType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldEdgeType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldVertexType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarDistancePlaneType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarNormalsDeviationType;
import de.hft.stuttgart.quality.model.jaxb.ObjectFactory;
import de.hft.stuttgart.quality.model.jaxb.OrientationRingsSameType;
import de.hft.stuttgart.quality.model.jaxb.PolygonWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.RingNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.RingSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.SolidNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.SolidSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPointsType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPolygonsType;
import de.hft.stuttgart.quality.model.jaxb.ValidationErrorType;
import de.hft.stuttgart.quality.model.jaxb.ValidationResultType;
import de.hft.stuttgart.quality.model.jaxb.ValidationType;
public class QualityAdeMarshaller implements ADEMarshaller {
private final ReentrantLock lock = new ReentrantLock();
private final ObjectFactory factory = new ObjectFactory();
private TypeMapper<JAXBElement<?>> elementMapper;
private TypeMapper<Object> typeMapper;
private ADEMarshallerHelper helper;
private TypeMapper<JAXBElement<?>> getElementMapper() {
if (elementMapper == null) {
lock.lock();
try {
if (elementMapper == null) {
elementMapper = TypeMapper.<JAXBElement<?>>create().with(Validation.class, this::createValidation)
.with(ValidationResult.class, this::createValidationResult);
}
} finally {
lock.unlock();
}
}
return elementMapper;
}
private TypeMapper<Object> getTypeMapper() {
if (typeMapper == null) {
lock.lock();
try {
if (typeMapper == null) {
typeMapper = TypeMapper.create().with(Validation.class, this::marshalValidation)
.with(ValidationResult.class, this::marshalValidationResult)
.with(ConsecutivePointsSame.class, this::marshalConsecutivePointsSame)
.with(TooFewPoints.class, this::marshalTooFewPoints)
.with(RingSelfIntersection.class, this::marshalRingSelfIntersection)
.with(RingNotClosed.class, this::marshalRingNotClosed)
.with(InteriorDisconnected.class, this::marshalInteriorDisconnected)
.with(IntersectingRings.class, this::marshalIntersectingRings)
.with(NonPlanarDistancePlane.class, this::marshalNonPlanarDistancePlane)
.with(InnerRingsNested.class, this::marshalInnerRingsNested)
.with(HoleOutside.class, this::marshalHoleOutside)
.with(NonPlanarNormalsDeviation.class, this::marshalNonPlanarNormalsDeviation)
.with(OrientationRingsSame.class, this::marshalOrientationRingsSame)
.with(AllPolygonsWrongOrientation.class, this::marshalAllPolygonsWrongOrientation)
.with(PolygonWrongOrientation.class, this::marshalPolygonWrongOrientation)
.with(SolidSelfIntersection.class, this::marshalSolidSelfIntersection)
.with(NonManifoldVertex.class, this::marshalNonManifoldVertex)
.with(NonManifoldEdge.class, this::marshalNonManifoldEdge)
.with(SolidNotClosed.class, this::marshalSolidNotClosed)
.with(TooFewPolygons.class, this::marshalTooFewPolygons)
.with(MultipleConnectedComponents.class, this::marshalMultipleConnectedComponents)
.with(AttributeWrongValue.class, this::marshalAttributeWrongValue)
.with(AttributeMissing.class, this::marshalAttributeMissing);
}
} finally {
lock.unlock();
}
}
return typeMapper;
}
private ValidationType marshalValidation(Validation src) {
ValidationType dest = new ValidationType();
if (src.isSetDateTime()) {
dest.setValidationDate(src.getValidationDate());
}
if (src.isSetValidationSoftware()) {
dest.setValidationSoftware(src.getValidationSoftware());
}
if (src.isSetValidationPlan()) {
dest.setValidationPlan(src.getValidationPlan());
}
if (src.isSetStatistics()) {
dest.setStatistics(src.getStatistics());
}
return dest;
}
private ValidationResultType marshalValidationResult(ValidationResult src) {
ValidationResultType dest = factory.createValidationResultType();
dest.setResult(src.getResult());
if (src.hasErrors()) {
for (ValidationError err : src.getErrors()) {
dest.getErrors().add(marshalValidationError(err));
// sort lexicographic, order does not actually matter but xml is restrictive
// that way
// could be solved with xsd v1.1 but jaxb can only process v1.0
dest.getErrors().sort((e1, e2) -> e1.getName().compareTo(e2.getName()));
}
}
return dest;
}
private JAXBElement<?> createValidation(Validation src) {
return factory.createValidationType(marshalValidation(src));
}
private JAXBElement<?> createValidationResult(ValidationResult src) {
return factory.createValidationResultType(marshalValidationResult(src));
}
private ValidationErrorType marshalValidationError(ValidationError err) {
return (ValidationErrorType) marshal(err);
}
@Override
public void setADEMarshallerHelper(ADEMarshallerHelper helper) {
this.helper = helper;
}
@Override
public JAXBElement<?> marshalJAXBElement(ADEModelObject src) {
return getElementMapper().apply(src);
}
@Override
public Object marshal(ADEModelObject src) {
return getTypeMapper().apply(src);
}
private ConsecutivePointsSameType marshalConsecutivePointsSame(ConsecutivePointsSame src) {
ConsecutivePointsSameType dest = factory.createConsecutivePointsSameType();
dest.setLinearRingId(src.getLinearRingId());
if (src.getVertex1() != null) {
dest.setVertex1(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex1()));
}
if (src.getVertex2() != null) {
dest.setVertex2(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex2()));
}
return dest;
}
private TooFewPointsType marshalTooFewPoints(TooFewPoints src) {
TooFewPointsType dest = factory.createTooFewPointsType();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private RingSelfIntersectionType marshalRingSelfIntersection(RingSelfIntersection src) {
RingSelfIntersectionType dest = factory.createRingSelfIntersectionType();
dest.setLinearRingId(src.getLinearRingId());
dest.setType(src.getType());
if (src.getEdge1() != null) {
dest.setEdge1(marshalEdge(src.getEdge1()));
}
if (src.getEdge2() != null) {
dest.setEdge2(marshalEdge(src.getEdge2()));
}
if (src.getVertex1() != null) {
dest.setVertex1(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex1()));
}
if (src.getVertex2() != null) {
dest.setVertex2(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex2()));
}
return dest;
}
private EdgeType marshalEdge(Edge src) {
EdgeType dest = new EdgeType();
if (src.getFrom() != null) {
dest.setFrom(helper.getGMLMarshaller().marshalDirectPosition(src.getFrom()));
}
if (src.getTo() != null) {
dest.setTo(helper.getGMLMarshaller().marshalDirectPosition(src.getTo()));
}
return dest;
}
private RingNotClosedType marshalRingNotClosed(RingNotClosed src) {
RingNotClosedType dest = new RingNotClosedType();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private InteriorDisconnectedType marshalInteriorDisconnected(InteriorDisconnected src) {
InteriorDisconnectedType dest = new InteriorDisconnectedType();
dest.setPolygonId(src.getPolygonId());
return dest;
}
private IntersectingRingsType marshalIntersectingRings(IntersectingRings src) {
IntersectingRingsType dest = new IntersectingRingsType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private NonPlanarDistancePlaneType marshalNonPlanarDistancePlane(NonPlanarDistancePlane src) {
NonPlanarDistancePlaneType dest = new NonPlanarDistancePlaneType();
dest.setPolygonId(src.getPolygonId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
if (src.getDistance() != null) {
dest.setDistance(helper.getGMLMarshaller().marshalLength(src.getDistance()));
}
return dest;
}
private InnerRingsNestedType marshalInnerRingsNested(InnerRingsNested src) {
InnerRingsNestedType dest = new InnerRingsNestedType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private HoleOutsideType marshalHoleOutside(HoleOutside src) {
HoleOutsideType dest = new HoleOutsideType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private NonPlanarNormalsDeviationType marshalNonPlanarNormalsDeviation(NonPlanarNormalsDeviation src) {
NonPlanarNormalsDeviationType dest = new NonPlanarNormalsDeviationType();
dest.setPolygonId(src.getPolygonId());
if (src.getDeviation() != null) {
dest.setDeviation(helper.getGMLMarshaller().marshalAngle(src.getDeviation()));
}
return dest;
}
private OrientationRingsSameType marshalOrientationRingsSame(OrientationRingsSame src) {
OrientationRingsSameType dest = new OrientationRingsSameType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private AllPolygonsWrongOrientationType marshalAllPolygonsWrongOrientation(AllPolygonsWrongOrientation src) {
AllPolygonsWrongOrientationType dest = new AllPolygonsWrongOrientationType();
dest.setGeometryId(src.getGeometryId());
return dest;
}
private PolygonWrongOrientationType marshalPolygonWrongOrientation(PolygonWrongOrientation src) {
PolygonWrongOrientationType dest = new PolygonWrongOrientationType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<EdgeType> edges = dest.getEdges();
for (Edge e : src.getEdges()) {
edges.add(marshalEdge(e));
}
}
return dest;
}
private SolidSelfIntersectionType marshalSolidSelfIntersection(SolidSelfIntersection src) {
SolidSelfIntersectionType dest = new SolidSelfIntersectionType();
dest.setGeometryId(src.getGeometryId());
dest.setPolygonId1(src.getPolygonId1());
dest.setPolygonId2(src.getPolygonId2());
return dest;
}
private NonManifoldVertexType marshalNonManifoldVertex(NonManifoldVertex src) {
NonManifoldVertexType dest = new NonManifoldVertexType();
dest.setGeometryId(src.getGeometryId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
return dest;
}
private NonManifoldEdgeType marshalNonManifoldEdge(NonManifoldEdge src) {
NonManifoldEdgeType dest = new NonManifoldEdgeType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<EdgeType> edges = dest.getEdges();
for (Edge e : src.getEdges()) {
edges.add(marshalEdge(e));
}
}
return dest;
}