Commit 3f3c1884 authored by Matthias Betz's avatar Matthias Betz
Browse files

change to citygml4j 3.0.0 rc4

change to quality ade 0.1.4
parent 92f3e523
Pipeline #6596 failed with stage
in 17 seconds
......@@ -23,10 +23,10 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.QualityAdeErrorVisitor;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
......@@ -34,8 +34,10 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty;
import de.hft.stuttgart.quality.model.types.AbstractError;
import de.hft.stuttgart.quality.model.types.SolidSelfIntersectionError;
import de.hft.stuttgart.quality.model.types.ValidationResult;
public class SolidSelfIntErrorTest {
......@@ -55,9 +57,16 @@ public class SolidSelfIntErrorTest {
intersections.add(inter);
SolidSelfIntError err = new SolidSelfIntError(geom, intersections);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
SolidSelfIntersection adeErr = (SolidSelfIntersection) optional.get();
ValidationResult result = new ValidationResult();
QualityAdeErrorVisitor visitor = new QualityAdeErrorVisitor(result);
err.accept(visitor);
List<AbstractErrorProperty> errors = result.getErrors();
assertEquals(1, errors.size());
AbstractError ae = errors.get(0).getObject();
assertTrue(ae instanceof SolidSelfIntersectionError);
SolidSelfIntersectionError adeErr = (SolidSelfIntersectionError) ae;
assertEquals(geomId.getGmlString(), adeErr.getGeometryId());
assertEquals(p1Id.getGmlString(), adeErr.getPolygonId1());
assertEquals(p2Id.getGmlString(), adeErr.getPolygonId2());
......
......@@ -21,16 +21,19 @@ package de.hft.stuttgart.citydoctor2.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import java.util.List;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.QualityAdeErrorVisitor;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty;
import de.hft.stuttgart.quality.model.types.AbstractError;
import de.hft.stuttgart.quality.model.types.SolidTooFewPolygonsError;
import de.hft.stuttgart.quality.model.types.ValidationResult;
public class TooFewPolygonsErrorTest {
......@@ -42,11 +45,16 @@ public class TooFewPolygonsErrorTest {
TooFewPolygonsError err = new TooFewPolygonsError(geom);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
TooFewPolygons adeErr = (TooFewPolygons) optional.get();
ValidationResult result = new ValidationResult();
QualityAdeErrorVisitor visitor = new QualityAdeErrorVisitor(result);
err.accept(visitor);
List<AbstractErrorProperty> errors = result.getErrors();
assertEquals(1, errors.size());
AbstractError ae = errors.get(0).getObject();
assertTrue(ae instanceof SolidTooFewPolygonsError);
SolidTooFewPolygonsError adeErr = (SolidTooFewPolygonsError) ae;
assertEquals(geomId.getGmlString(), adeErr.getGeometryId());
}
}
......@@ -29,21 +29,19 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
import org.citygml4j.model.citygml.building.WallSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.complexes.CompositeSurface;
import org.citygml4j.model.gml.geometry.primitives.AbstractRing;
import org.citygml4j.model.gml.geometry.primitives.AbstractSolid;
import org.citygml4j.model.gml.geometry.primitives.AbstractSurface;
import org.citygml4j.model.gml.geometry.primitives.DirectPositionList;
import org.citygml4j.model.gml.geometry.primitives.Polygon;
import org.citygml4j.model.gml.geometry.primitives.Solid;
import org.citygml4j.model.gml.geometry.primitives.SolidProperty;
import org.citygml4j.model.gml.geometry.primitives.SurfaceProperty;
import org.citygml4j.core.model.construction.WallSurface;
import org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.junit.Test;
import org.mockito.Mockito;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRing;
import org.xmlobjects.gml.model.geometry.primitives.AbstractSolid;
import org.xmlobjects.gml.model.geometry.primitives.AbstractSurface;
import org.xmlobjects.gml.model.geometry.primitives.Shell;
import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -215,31 +213,28 @@ public class AbstractBuildingTest {
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID);
AbstractBuilding ab = createAbstractBuilding();
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
ab.reCreateGeometries(factory, config);
AbstractSolid aSolid = gmlAb.getLod2Solid().getSolid();
AbstractSolid aSolid = gmlAb.getLod2Solid().getObject();
assertTrue(aSolid instanceof Solid);
Solid solid = (Solid) aSolid;
AbstractSurface geometry = solid.getExterior().getGeometry();
assertTrue(geometry instanceof CompositeSurface);
CompositeSurface cSurface = (CompositeSurface) geometry;
List<SurfaceProperty> surfaceMember = cSurface.getSurfaceMember();
Shell geometry = solid.getExterior().getObject();
List<SurfaceProperty> surfaceMember = geometry.getSurfaceMembers();
assertEquals(1, surfaceMember.size());
AbstractSurface polySurface = surfaceMember.get(0).getSurface();
assertTrue(polySurface instanceof org.citygml4j.model.gml.geometry.primitives.Polygon);
org.citygml4j.model.gml.geometry.primitives.Polygon gmlPoly = (Polygon) polySurface;
AbstractRing ring = gmlPoly.getExterior().getRing();
org.citygml4j.model.gml.geometry.primitives.LinearRing gmlRing = (org.citygml4j.model.gml.geometry.primitives.LinearRing) ring;
DirectPositionList posList = gmlRing.getPosList();
AbstractSurface polySurface = surfaceMember.get(0).getObject();
assertTrue(polySurface instanceof org.xmlobjects.gml.model.geometry.primitives.Polygon);
var gmlPoly = (org.xmlobjects.gml.model.geometry.primitives.Polygon) polySurface;
AbstractRing ring = gmlPoly.getExterior().getObject();
var gmlRing = (org.xmlobjects.gml.model.geometry.primitives.LinearRing) ring;
List<Double> posList = gmlRing.toCoordinateList3D();
double[] expectedValues = new double[] { 427583.301, 6003502.571, 9.711, 427583.304, 6003502.574, 9.713,
427583.304, 6003502.574, 4.097, 427583.301, 6003502.571, 4.097, 427583.301, 6003502.571, 9.711 };
List<Double> values = posList.getValue();
for (int i = 0; i < values.size(); i++) {
assertEquals(expectedValues[i], values.get(i), 0.00000001);
for (int i = 0; i < posList.size(); i++) {
assertEquals(expectedValues[i], posList.get(i), 0.00000001);
}
}
......@@ -248,14 +243,14 @@ public class AbstractBuildingTest {
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE);
AbstractBuilding ab = createAbstractBuilding();
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
ab.reCreateGeometries(factory, config);
assertNotNull(gmlAb.getLod2MultiSurface());
assertNotNull(gmlAb.getLod2MultiSurface().getGeometry());
assertNotNull(gmlAb.getLod2MultiSurface().getObject());
}
@Test
......@@ -266,9 +261,9 @@ public class AbstractBuildingTest {
geometries.add(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE));
Mockito.when(bsMock.getGeometries()).thenReturn(geometries);
ab.addBoundarySurface(bsMock);
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
ab.setCityGmlBuilding(gmlAb);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
ab.reCreateGeometries(factory, config);
Mockito.verify(bsMock).reCreateGeometries(factory, config);
......@@ -281,17 +276,17 @@ public class AbstractBuildingTest {
Mockito.when(bsMock.getGmlObject()).thenReturn(ws);
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.reCreateGeometries(factory, config);
gmlAb.addBoundedBySurface(new BoundarySurfaceProperty());
gmlAb.addBoundedBySurface(new BoundarySurfaceProperty(new WallSurface()));
gmlAb.addBoundedBySurface(new BoundarySurfaceProperty(ws));
assertEquals(3, gmlAb.getBoundedBySurface().size());
gmlAb.addBoundary(new AbstractSpaceBoundaryProperty());
gmlAb.addBoundary(new AbstractSpaceBoundaryProperty(new WallSurface()));
gmlAb.addBoundary(new AbstractSpaceBoundaryProperty(ws));
assertEquals(3, gmlAb.getBoundaries().size());
ab.reCreateGeometries(factory, config);
assertEquals(2, gmlAb.getBoundedBySurface().size());
assertEquals(2, gmlAb.getBoundaries().size());
}
@Test
......@@ -299,9 +294,9 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
AbstractBuilding ab = createAbstractBuilding();
ab.addBuildingInstallation(biMock);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.reCreateGeometries(factory, config);
Mockito.verify(biMock).reCreateGeometries(factory, config);
......@@ -315,15 +310,15 @@ public class AbstractBuildingTest {
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.AbstractBuilding gmlAb = new org.citygml4j.core.model.building.Building();
gmlAb.setLod1Solid(new SolidProperty());
gmlAb.setLod2Solid(new SolidProperty());
gmlAb.setLod3Solid(new SolidProperty());
gmlAb.setLod4Solid(new SolidProperty());
gmlAb.setLod1MultiSurface(new MultiSurfaceProperty());
gmlAb.getDeprecatedProperties().setLod4Solid(new SolidProperty());
gmlAb.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty());
gmlAb.setLod2MultiSurface(new MultiSurfaceProperty());
gmlAb.setLod3MultiSurface(new MultiSurfaceProperty());
gmlAb.setLod4MultiSurface(new MultiSurfaceProperty());
gmlAb.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty());
ab.setCityGmlBuilding(gmlAb);
ab.unsetGmlGeometries();
Mockito.verify(biMock).unsetGmlGeometries();
......@@ -331,11 +326,11 @@ public class AbstractBuildingTest {
assertNull(gmlAb.getLod1Solid());
assertNull(gmlAb.getLod2Solid());
assertNull(gmlAb.getLod3Solid());
assertNull(gmlAb.getLod4Solid());
assertNull(gmlAb.getLod1MultiSurface());
assertNull(gmlAb.getDeprecatedProperties().getLod4Solid());
assertNull(gmlAb.getDeprecatedProperties().getLod1MultiSurface());
assertNull(gmlAb.getLod2MultiSurface());
assertNull(gmlAb.getLod3MultiSurface());
assertNull(gmlAb.getLod4MultiSurface());
assertNull(gmlAb.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
......
......@@ -28,12 +28,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.WallSurface;
import org.citygml4j.model.citygml.core.AbstractCityObject;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.core.model.construction.AbstractConstructionSurface;
import org.citygml4j.core.model.construction.WallSurface;
import org.citygml4j.core.model.core.AbstractThematicSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.junit.Test;
import org.mockito.Mockito;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.CheckError;
......@@ -172,7 +173,7 @@ public class BoundarySurfaceTest {
public void testReCreateGeometriesWithoutId() {
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNotNull(ws.getId());
}
......@@ -181,12 +182,12 @@ public class BoundarySurfaceTest {
WallSurface ws = new WallSurface();
ws.setId("test");
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
// nothing has changed
assertEquals("test", ws.getId());
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
......@@ -194,76 +195,76 @@ public class BoundarySurfaceTest {
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNotNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceBridgeLod2() {
org.citygml4j.model.citygml.bridge.WallSurface ws = new org.citygml4j.model.citygml.bridge.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BRIDGE, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNotNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceBridgeLod3() {
org.citygml4j.model.citygml.bridge.WallSurface ws = new org.citygml4j.model.citygml.bridge.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BRIDGE, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceBridgeLod4() {
org.citygml4j.model.citygml.bridge.WallSurface ws = new org.citygml4j.model.citygml.bridge.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BRIDGE, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceTunnelLod2() {
org.citygml4j.model.citygml.tunnel.WallSurface ws = new org.citygml4j.model.citygml.tunnel.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNotNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceTunnelLod3() {
org.citygml4j.model.citygml.tunnel.WallSurface ws = new org.citygml4j.model.citygml.tunnel.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testReCreateGeometriesMultiSurfaceTunnelLod4() {
org.citygml4j.model.citygml.tunnel.WallSurface ws = new org.citygml4j.model.citygml.tunnel.WallSurface();
WallSurface ws = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
......@@ -272,10 +273,10 @@ public class BoundarySurfaceTest {
ws.setId("test");
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
......@@ -284,19 +285,20 @@ public class BoundarySurfaceTest {
ws.setId("test");
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test(expected = IllegalStateException.class)
public void testReCreateGeometriesMultiSurfaceLod1() {
@Test
public void testReCreateGeometriesMultiSurfaceLod0() {
WallSurface ws = new WallSurface();
ws.setId("test");
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD1));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD0));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
assertNotNull(ws.getLod0MultiSurface());
}
@Test(expected = IllegalStateException.class)
......@@ -305,7 +307,7 @@ public class BoundarySurfaceTest {
ws.setId("test");
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
bs.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID));
bs.reCreateGeometries(new GMLGeometryFactory(), new ParserConfiguration(8, false));
bs.reCreateGeometries(GeometryFactory.newInstance(), new ParserConfiguration(8, false));
}
@Test
......@@ -315,7 +317,7 @@ public class BoundarySurfaceTest {
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
Opening oMock = Mockito.mock(Opening.class);
bs.addOpening(oMock);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bs.reCreateGeometries(factory, config);
Mockito.verify(oMock).reCreateGeometries(factory, config);
......@@ -333,10 +335,10 @@ public class BoundarySurfaceTest {
WallSurface ws = new WallSurface();
ws.setLod2MultiSurface(new MultiSurfaceProperty());
ws.setLod3MultiSurface(new MultiSurfaceProperty());
ws.setLod4MultiSurface(new MultiSurfaceProperty());
ws.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty());
assertNotNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, ws);
Opening oMock = Mockito.mock(Opening.class);
bs.addOpening(oMock);
......@@ -344,39 +346,39 @@ public class BoundarySurfaceTest {
Mockito.verify(oMock).unsetGmlGeometries();
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testUnsetGmlGeometriesBridge() {
org.citygml4j.model.citygml.bridge.WallSurface ws = new org.citygml4j.model.citygml.bridge.WallSurface();
WallSurface ws = new WallSurface();
ws.setLod2MultiSurface(new MultiSurfaceProperty());
ws.setLod3MultiSurface(new MultiSurfaceProperty());
ws.setLod4MultiSurface(new MultiSurfaceProperty());
ws.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty());
assertNotNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BRIDGE, BoundarySurfaceType.WALL, ws);
bs.unsetGmlGeometries();
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
public void testUnsetGmlGeometriesTunnel() {
org.citygml4j.model.citygml.tunnel.WallSurface ws = new org.citygml4j.model.citygml.tunnel.WallSurface();
WallSurface ws = new WallSurface();
ws.setLod2MultiSurface(new MultiSurfaceProperty());
ws.setLod3MultiSurface(new MultiSurfaceProperty());
ws.setLod4MultiSurface(new MultiSurfaceProperty());
ws.getDeprecatedProperties().setLod4MultiSurface(new MultiSurfaceProperty());
assertNotNull(ws.getLod2MultiSurface());
assertNotNull(ws.getLod3MultiSurface());
assertNotNull(ws.getLod4MultiSurface());
assertNotNull(ws.getDeprecatedProperties().getLod4MultiSurface());
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, ws);
bs.unsetGmlGeometries();
assertNull(ws.getLod2MultiSurface());
assertNull(ws.getLod3MultiSurface());
assertNull(ws.getLod4MultiSurface());
assertNull(ws.getDeprecatedProperties().getLod4MultiSurface());
}
@Test
......@@ -387,7 +389,7 @@ public class BoundarySurfaceTest {
@Test
public void testBoundarySurfaceAbstractCityObject() {
AbstractCityObject aco = Mockito.mock(AbstractCityObject.class);
AbstractConstructionSurface aco = Mockito.mock(AbstractConstructionSurface.class);
BoundarySurface bs = new BoundarySurface(aco);
assertEquals(aco, bs.getGmlObject());
}
......@@ -408,7 +410,7 @@ public class BoundarySurfaceTest {
@Test
public void testSetGmlObject() {
AbstractCityObject aco = Mockito.mock(AbstractCityObject.class);
AbstractThematicSurface aco = Mockito.mock(AbstractThematicSurface.class);
BoundarySurface bs = new BoundarySurface(null);
bs.setGmlObject(aco);
assertEquals(aco, bs.getGmlObject());
......
......@@ -29,9 +29,10 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.bridge.AbstractBridge;
import org.citygml4j.model.citygml.bridge.Bridge;
import org.citygml4j.core.model.bridge.AbstractBridge;
import org.citygml4j.core.model.bridge.Bridge;
import org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfAbstractBridge;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
......@@ -148,7 +149,7 @@ public class BridgeObjectTest {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
GMLGeometryFactory factoryMock = mock(GMLGeometryFactory.class);
GeometryFactory factoryMock = mock(GeometryFactory.class);
ParserConfiguration configMock = mock(ParserConfiguration.class);
bo.reCreateGeometries(factoryMock, configMock);
verify(bsMock).reCreateGeometries(factoryMock, configMock);
......@@ -161,11 +162,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod1MultiSurface());
assertNotNull(ab.getLod1MultiSurface().getGeometry());
assertNotNull(ab.getDeprecatedProperties().getLod1MultiSurface());
assertNotNull(ab.getDeprecatedProperties().getLod1MultiSurface().getObject());
}
......@@ -176,11 +177,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod2MultiSurface());
assertNotNull(ab.getLod2MultiSurface().getGeometry());
assertNotNull(ab.getLod2MultiSurface().getObject());
}
@Test
......@@ -190,11 +191,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod3MultiSurface());
assertNotNull(ab.getLod3MultiSurface().getGeometry());
assertNotNull(ab.getLod3MultiSurface().getObject());
}
@Test
......@@ -204,11 +205,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod4MultiSurface());
assertNotNull(ab.getLod4MultiSurface().getGeometry());
assertNotNull(ab.getDeprecatedProperties().getLod4MultiSurface());
assertNotNull(ab.getDeprecatedProperties().getLod4MultiSurface().getObject());
}
@Test
......@@ -218,11 +219,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod1Solid());
assertNotNull(ab.getLod1Solid().getGeometry());
assertNotNull(ab.getLod1Solid().getObject());
}
@Test
......@@ -232,11 +233,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod2Solid());
assertNotNull(ab.getLod2Solid().getGeometry());
assertNotNull(ab.getLod2Solid().getObject());
}
@Test
......@@ -246,11 +247,11 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod3Solid());
assertNotNull(ab.getLod3Solid().getGeometry());
assertNotNull(ab.getLod3Solid().getObject());
}
@Test
......@@ -260,30 +261,33 @@ public class BridgeObjectTest {
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod4Solid());
assertNotNull(ab.getLod4Solid().getGeometry());
assertNotNull(ab.getDeprecatedProperties().getLod4Solid());
assertNotNull(ab.getDeprecatedProperties().getLod4Solid().getObject());
}
@Test
public void testUnsetGmlGeometries() {
AbstractBridge abMock = mock(AbstractBridge.class);
DeprecatedPropertiesOfAbstractBridge propsMock = mock(DeprecatedPropertiesOfAbstractBridge.class);
when(abMock.getDeprecatedProperties()).thenReturn(propsMock);
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, abMock);
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.unsetGmlGeometries();
verify(bsMock).unsetGmlGeometries();
verify(abMock).unsetLod1MultiSurface();
verify(abMock).unsetLod2MultiSurface();
verify(abMock).unsetLod3MultiSurface();
verify(abMock).unsetLod4MultiSurface();
verify(abMock).unsetLod1Solid();
verify(abMock).unsetLod2Solid();
verify(abMock).unsetLod3Solid();
verify(abMock).unsetLod4Solid();
verify(propsMock).setLod1MultiSurface(null);
verify(abMock).setLod2MultiSurface(null);
verify(abMock).setLod3MultiSurface(null);
verify(propsMock).setLod4MultiSurface(null);
verify(abMock).setLod1Solid(null);
verify(abMock).setLod2Solid(null);
verify(abMock).setLod3Solid(null);
verify(propsMock).setLod4Solid(null);
}
@Test
......
......@@ -23,9 +23,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import org.citygml4j.model.citygml.building.RoofSurface;
import org.citygml4j.model.gml.basicTypes.Code;
import org.citygml4j.core.model.construction.RoofSurface;
import org.junit.Test;
import org.xmlobjects.gml.model.basictypes.Code;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.utils.Copy;
......@@ -110,12 +110,12 @@ public class BuildingTest {
assertNotNull(copyAdjacentPoly);
assertNotSame(adjacentPoly, copyAdjacentPoly);
assertEquals(b.getGmlObject().getFunction().get(0).getValue(), copy.getGmlObject().getFunction().get(0).getValue());
assertEquals(b.getGmlObject().getFunctions().get(0).getValue(), copy.getGmlObject().getFunctions().get(0).getValue());
}
private org.citygml4j.model.citygml.building.Building createCityGmlBuilding() {
org.citygml4j.model.citygml.building.Building b = new org.citygml4j.model.citygml.building.Building();
b.addFunction(new Code("2349"));
private org.citygml4j.core.model.building.Building createCityGmlBuilding() {
org.citygml4j.core.model.building.Building b = new org.citygml4j.core.model.building.Building();
b.getFunctions().add(new Code("2349"));
b.setId("test");
return b;
}
......
......@@ -26,11 +26,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEComponent;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.citygml4j.core.ade.ADEException;
import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel;
import org.citygml4j.xml.writer.CityGMLWriteException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
......@@ -47,14 +46,18 @@ import de.hft.stuttgart.citydoctor2.check.ErrorVisitor;
import de.hft.stuttgart.citydoctor2.check.HealingMethod;
import de.hft.stuttgart.citydoctor2.check.ModificationListener;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.jaxb.ErrorStatistics;
import de.hft.stuttgart.quality.model.jaxb.Parameter;
import de.hft.stuttgart.quality.model.jaxb.ValidationPlan;
import de.hft.stuttgart.quality.model.properties.GlobalParametersProperty;
import de.hft.stuttgart.quality.model.properties.ParameterProperty;
import de.hft.stuttgart.quality.model.types.CityObjectProperties;
import de.hft.stuttgart.quality.model.types.GlobalParameters;
import de.hft.stuttgart.quality.model.types.Parameter;
import de.hft.stuttgart.quality.model.types.Validation;
import de.hft.stuttgart.quality.model.types.ValidationPlan;
public class CityDoctorModelTest {
......@@ -122,8 +125,8 @@ public class CityDoctorModelTest {
}
@Test
public void testSaveAsWithoutValidation() throws CityGMLBuilderException, CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException {
public void testSaveAsWithoutValidation() throws CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException, CityDoctorWriteException {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
......@@ -131,7 +134,7 @@ public class CityDoctorModelTest {
model.setCityModel(cModel);
Building b = new Building();
b.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID));
org.citygml4j.model.citygml.building.Building gmlBuilding = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.Building gmlBuilding = new org.citygml4j.core.model.building.Building();
gmlBuilding.setId("testId");
b.setGmlObject(gmlBuilding);
model.addBuilding(b);
......@@ -147,14 +150,16 @@ public class CityDoctorModelTest {
}
@Test
public void testSaveAsWithValidation() throws CityGMLBuilderException, CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException {
public void testSaveAsWithValidation() throws CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException, CityDoctorWriteException {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityModel cModel = new CityModel();
ValidationPlan plan = new ValidationPlan();
plan.getGlobalParameters().add(new Parameter());
GlobalParameters globParams = new GlobalParameters();
plan.setGlobalParameters(new GlobalParametersProperty(globParams));
plan.getGlobalParameters().getObject().getParameters().add(new ParameterProperty(new Parameter()));
model.setValidated(plan);
model.setCityModel(cModel);
Building b = new Building();
......@@ -193,7 +198,7 @@ public class CityDoctorModelTest {
};
b.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, error));
b.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID));
org.citygml4j.model.citygml.building.Building gmlBuilding = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.Building gmlBuilding = new org.citygml4j.core.model.building.Building();
gmlBuilding.setId("testId");
b.setGmlObject(gmlBuilding);
model.addBuilding(b);
......@@ -206,14 +211,14 @@ public class CityDoctorModelTest {
Building parsedBuilding = parsedModel.getBuildings().get(0);
assertEquals("testId", parsedBuilding.getGmlId().getGmlString());
assertEquals(1, parsedBuilding.getGeometries().size());
assertEquals(1, parsedBuilding.getGmlObject().getGenericApplicationPropertyOfCityObject().size());
assertEquals(1, parsedModel.getCityModel().getGenericApplicationPropertyOfCityModel().size());
List<ADEComponent> adeComps = parsedModel.getCityModel().getGenericApplicationPropertyOfCityModel();
ADEComponent adeComponent = adeComps.get(0);
Validation val = (Validation) adeComponent;
ErrorStatistics errorStatistics = val.getStatistics().getErrorStatistics().get(0);
assertEquals(de.hft.stuttgart.quality.model.jaxb.ErrorId.GE_P_HOLE_OUTSIDE, errorStatistics.getName());
assertEquals(1, errorStatistics.getAmount());
List<CityObjectProperties> props = parsedBuilding.getGmlObject().getADEProperties(CityObjectProperties.class);
assertEquals(1, props.size());
List<AbstractFeatureProperty> featureMembers = parsedModel.getCityModel().getFeatureMembers();
assertEquals(1, featureMembers.size());
Validation val = (Validation) featureMembers.get(0).getObject();
de.hft.stuttgart.quality.model.types.Error errorStatistics = val.getStatistics().getObject().getErrors().get(0).getObject();
assertEquals(de.hft.stuttgart.quality.model.enums.ErrorId.GE_P_HOLE_OUTSIDE, errorStatistics.getName());
assertEquals(1, errorStatistics.getOccurrences());
}
@Test
......
......@@ -31,9 +31,9 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.building.AbstractBoundarySurface;
import org.citygml4j.model.citygml.building.WallSurface;
import org.citygml4j.core.model.construction.AbstractConstructionSurface;
import org.citygml4j.core.model.construction.WallSurface;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.Check;
......@@ -76,9 +76,9 @@ public class GeometryTest {
@Test
public void testRemovePolygonConcreteWithLink() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractBoundarySurface abs = new WallSurface();
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
org.citygml4j.model.citygml.building.BuildingInstallation gmlBi = new org.citygml4j.model.citygml.building.BuildingInstallation();
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
BuildingInstallation bi = new BuildingInstallation();
bi.setGmlObject(gmlBi);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2);
......@@ -103,17 +103,17 @@ public class GeometryTest {
assertEquals(0, geom.getPolygons().size());
assertEquals(0, biGeom.getPolygons().size());
bs.reCreateGeometries(new GMLGeometryFactory(), config);
bs.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(abs.getLod2MultiSurface());
bi.reCreateGeometries(new GMLGeometryFactory(), config);
assertNull(gmlBi.getLod2Geometry());
bi.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(gmlBi.getDeprecatedProperties().getLod2Geometry());
}
@Test
public void testRemovePolygonOnlyConcrete() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractBoundarySurface abs = new WallSurface();
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2);
......@@ -129,16 +129,16 @@ public class GeometryTest {
geom.removePolygon(p);
bs.reCreateGeometries(new GMLGeometryFactory(), config);
bs.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(abs.getLod2MultiSurface());
}
@Test
public void testRemovePolygonLinked() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractBoundarySurface abs = new WallSurface();
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
org.citygml4j.model.citygml.building.BuildingInstallation gmlBi = new org.citygml4j.model.citygml.building.BuildingInstallation();
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
BuildingInstallation bi = new BuildingInstallation();
bi.setGmlObject(gmlBi);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2);
......@@ -163,19 +163,19 @@ public class GeometryTest {
assertEquals(0, geom.getPolygons().size());
assertEquals(0, biGeom.getPolygons().size());
bs.reCreateGeometries(new GMLGeometryFactory(), config);
bs.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(abs.getLod2MultiSurface());
bi.reCreateGeometries(new GMLGeometryFactory(), config);
assertNull(gmlBi.getLod2Geometry());
bi.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(gmlBi.getDeprecatedProperties().getLod2Geometry());
}
@Test
public void testReplacePolygon() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractBoundarySurface abs = new WallSurface();
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
org.citygml4j.model.citygml.building.BuildingInstallation gmlBi = new org.citygml4j.model.citygml.building.BuildingInstallation();
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
BuildingInstallation bi = new BuildingInstallation();
bi.setGmlObject(gmlBi);
bi.addBoundarySurface(bs);
......@@ -185,6 +185,9 @@ public class GeometryTest {
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
p.setExteriorRing(lr);
lr.addVertex(new Vertex(0, 0, 0));
lr.addVertex(new Vertex(1, 0, 0));
lr.addVertex(new Vertex(2, 0, 0));
lr.addVertex(new Vertex(0, 0, 0));
p.setPartOfSurface(bs);
p.setPartOfInstallation(bi);
bs.addGeometry(geom2);
......@@ -204,18 +207,18 @@ public class GeometryTest {
assertEquals(2, geom.getPolygons().size());
assertEquals(2, geom2.getPolygons().size());
bi.reCreateGeometries(new GMLGeometryFactory(), config);
assertNull(gmlBi.getLod2Geometry());
assertNull(gmlBi.getLod3Geometry());
assertNull(gmlBi.getLod4Geometry());
bi.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNull(gmlBi.getDeprecatedProperties().getLod2Geometry());
assertNull(gmlBi.getDeprecatedProperties().getLod3Geometry());
assertNull(gmlBi.getDeprecatedProperties().getLod4Geometry());
bs.reCreateGeometries(new GMLGeometryFactory(), config);
bs.reCreateGeometries(GeometryFactory.newInstance(), config);
assertNotNull(abs.getLod2MultiSurface());
assertNotNull(abs.getLod2MultiSurface().getMultiSurface());
assertNotNull(abs.getLod2MultiSurface().getMultiSurface().getSurfaceMember());
assertFalse(abs.getLod2MultiSurface().getMultiSurface().getSurfaceMember().isEmpty());
assertEquals(2, abs.getLod2MultiSurface().getMultiSurface().getSurfaceMember().size());
assertNull(gmlBi.getLod2Geometry());
assertNotNull(abs.getLod2MultiSurface().getObject());
assertNotNull(abs.getLod2MultiSurface().getObject().getSurfaceMember());
assertFalse(abs.getLod2MultiSurface().getObject().getSurfaceMember().isEmpty());
assertEquals(2, abs.getLod2MultiSurface().getObject().getSurfaceMember().size());
assertNull(gmlBi.getDeprecatedProperties().getLod2Geometry());
}
@Test
......
......@@ -24,20 +24,23 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.transportation.AuxiliaryTrafficArea;
import org.citygml4j.model.citygml.transportation.AuxiliaryTrafficAreaProperty;
import org.citygml4j.model.citygml.transportation.Road;
import org.citygml4j.model.citygml.transportation.TrafficArea;
import org.citygml4j.model.citygml.transportation.TransportationComplex;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.core.model.deprecated.core.DeprecatedPropertiesOfAbstractThematicSurface;
import org.citygml4j.core.model.deprecated.transportation.DeprecatedPropertiesOfAbstractTransportationSpace;
import org.citygml4j.core.model.deprecated.transportation.TransportationComplex;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficArea;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficSpace;
import org.citygml4j.core.model.transportation.AuxiliaryTrafficSpaceProperty;
import org.citygml4j.core.model.transportation.Road;
import org.citygml4j.core.model.transportation.TrafficArea;
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.junit.Test;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -58,25 +61,24 @@ public class TransportationObjectTest {
public void testReCreateGeometriesSolid() {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD1));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
}
@Test
public void testReCreateGeometriesWithComposedOf() {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
TransportationComplex tcMock = mock(TransportationComplex.class);
TransportationComplex tcMock = new TransportationComplex();
to.setGmlObject(tcMock);
TransportationObject ataTo = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_AREA);
AuxiliaryTrafficArea ataMock = mock(AuxiliaryTrafficArea.class);
TransportationObject ataTo = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_SPACE);
AuxiliaryTrafficSpace ataMock = mock(AuxiliaryTrafficSpace.class);
ataTo.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD2));
ataTo.setGmlObject(ataMock);
tcMock.addAuxiliaryTrafficArea(new AuxiliaryTrafficAreaProperty(ataMock));
tcMock.getAuxiliaryTrafficSpaces().add(new AuxiliaryTrafficSpaceProperty(ataMock));
to.addChild(ataTo);
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(tcMock, never()).setLod1MultiSurface(any());
verify(ataMock).setLod2MultiSurface(any());
}
......@@ -85,11 +87,13 @@ public class TransportationObjectTest {
public void testReCreateGeometriesMultiSurfaceLod1() {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
Road roadMock = mock(Road.class);
DeprecatedPropertiesOfAbstractTransportationSpace dSpace = mock(DeprecatedPropertiesOfAbstractTransportationSpace.class);
when(roadMock.getDeprecatedProperties()).thenReturn(dSpace);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD1));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod1MultiSurface(any());
verify(dSpace).setLod1MultiSurface(any());
}
@Test
......@@ -98,7 +102,7 @@ public class TransportationObjectTest {
Road roadMock = mock(Road.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD2));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod2MultiSurface(any());
}
......@@ -109,7 +113,7 @@ public class TransportationObjectTest {
Road roadMock = mock(Road.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod3MultiSurface(any());
}
......@@ -118,11 +122,13 @@ public class TransportationObjectTest {
public void testReCreateGeometriesMultiSurfaceLod4() {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
Road roadMock = mock(Road.class);
DeprecatedPropertiesOfAbstractTransportationSpace dSpace = mock(DeprecatedPropertiesOfAbstractTransportationSpace.class);
when(roadMock.getDeprecatedProperties()).thenReturn(dSpace);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod4MultiSurface(any());
verify(dSpace).setLod4MultiSurface(any());
}
@Test(expected = IllegalStateException.class)
......@@ -131,7 +137,7 @@ public class TransportationObjectTest {
Road roadMock = mock(Road.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD0));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
}
......@@ -141,7 +147,7 @@ public class TransportationObjectTest {
TrafficArea roadMock = mock(TrafficArea.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD1));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
}
......@@ -151,7 +157,7 @@ public class TransportationObjectTest {
TrafficArea roadMock = mock(TrafficArea.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD2));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod2MultiSurface(any());
}
......@@ -162,7 +168,7 @@ public class TransportationObjectTest {
TrafficArea roadMock = mock(TrafficArea.class);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod3MultiSurface(any());
}
......@@ -171,11 +177,13 @@ public class TransportationObjectTest {
public void testReCreateGeometriesTrafficAreaMultiSurfaceLod4() {
TransportationObject to = new TransportationObject(TransportationType.TRAFFIC_AREA);
TrafficArea roadMock = mock(TrafficArea.class);
DeprecatedPropertiesOfAbstractThematicSurface dSpace = mock(DeprecatedPropertiesOfAbstractThematicSurface.class);
when(roadMock.getDeprecatedProperties()).thenReturn(dSpace);
to.setGmlObject(roadMock);
to.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4));
GMLGeometryFactory factory = new GMLGeometryFactory();
GeometryFactory factory = GeometryFactory.newInstance();
to.reCreateGeometries(factory, mock(ParserConfiguration.class));
verify(roadMock).setLod4MultiSurface(any());
verify(dSpace).setLod4MultiSurface(any());
}
@Test
......@@ -226,15 +234,17 @@ public class TransportationObjectTest {
TransportationObject to = new TransportationObject(TransportationType.ROAD);
Road r = mock(Road.class);
to.setGmlObject(r);
r.setLod1MultiSurface(mock(MultiSurfaceProperty.class));
DeprecatedPropertiesOfAbstractTransportationSpace dSpace = mock(DeprecatedPropertiesOfAbstractTransportationSpace.class);
when(r.getDeprecatedProperties()).thenReturn(dSpace);
dSpace.setLod1MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod2MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod3MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
dSpace.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
to.unsetGmlGeometries();
assertNull(r.getLod1MultiSurface());
assertNull(dSpace.getLod1MultiSurface());
assertNull(r.getLod2MultiSurface());
assertNull(r.getLod3MultiSurface());
assertNull(r.getLod4MultiSurface());
assertNull(dSpace.getLod4MultiSurface());
}
@Test
......@@ -242,13 +252,15 @@ public class TransportationObjectTest {
TransportationObject to = new TransportationObject(TransportationType.TRAFFIC_AREA);
TrafficArea r = mock(TrafficArea.class);
to.setGmlObject(r);
DeprecatedPropertiesOfAbstractThematicSurface dSpace = mock(DeprecatedPropertiesOfAbstractThematicSurface.class);
when(r.getDeprecatedProperties()).thenReturn(dSpace);
r.setLod2MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod3MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
dSpace.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
to.unsetGmlGeometries();
assertNull(r.getLod2MultiSurface());
assertNull(r.getLod3MultiSurface());
assertNull(r.getLod4MultiSurface());
assertNull(dSpace.getLod4MultiSurface());
}
@Test
......@@ -256,13 +268,15 @@ public class TransportationObjectTest {
TransportationObject to = new TransportationObject(TransportationType.AUXILLIARY_TRAFFIC_AREA);
AuxiliaryTrafficArea r = mock(AuxiliaryTrafficArea.class);
to.setGmlObject(r);
DeprecatedPropertiesOfAbstractThematicSurface dSpace = mock(DeprecatedPropertiesOfAbstractThematicSurface.class);
when(r.getDeprecatedProperties()).thenReturn(dSpace);
r.setLod2MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod3MultiSurface(mock(MultiSurfaceProperty.class));
r.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
dSpace.setLod4MultiSurface(mock(MultiSurfaceProperty.class));
to.unsetGmlGeometries();
assertNull(r.getLod2MultiSurface());
assertNull(r.getLod3MultiSurface());
assertNull(r.getLod4MultiSurface());
assertNull(dSpace.getLod4MultiSurface());
}
}
......@@ -26,18 +26,19 @@ import static org.mockito.Mockito.mock;
import java.io.File;
import java.io.IOException;
import org.citygml4j.model.citygml.vegetation.PlantCover;
import org.citygml4j.model.citygml.waterbody.WaterBody;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.primitives.Coord;
import org.citygml4j.model.gml.geometry.primitives.Exterior;
import org.citygml4j.model.gml.geometry.primitives.LinearRing;
import org.citygml4j.model.gml.geometry.primitives.Polygon;
import org.citygml4j.model.gml.geometry.primitives.SurfaceProperty;
import org.citygml4j.core.model.vegetation.PlantCover;
import org.citygml4j.core.model.waterbody.WaterBody;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.xmlobjects.gml.model.geometry.DirectPosition;
import org.xmlobjects.gml.model.geometry.GeometricPosition;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.primitives.LinearRing;
import org.xmlobjects.gml.model.geometry.primitives.Polygon;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
......@@ -45,6 +46,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.Citygml3FeatureMapper;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
/**
......@@ -56,11 +58,12 @@ public class FeatureMapperTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testVisitWaterBody() {
WaterBody body = new WaterBody();
FeatureMapper mapper = new FeatureMapper(mock(ParserConfiguration.class), new File(""));
Citygml3FeatureMapper mapper = new Citygml3FeatureMapper(mock(ParserConfiguration.class),
new File("").toPath());
mapper.visit(body);
assertEquals(1, mapper.getModel().getWater().size());
body.setId("test1");
......@@ -68,35 +71,36 @@ public class FeatureMapperTest {
assertEquals(2, mapper.getModel().getWater().size());
WaterObject waterObject = mapper.getModel().getWater().get(1);
assertEquals("test1", waterObject.getGmlId().getGmlString());
body.setLod1MultiSurface(createDummyMsp());
body.getDeprecatedProperties().setLod1MultiSurface(createDummyMsp());
mapper.visit(body);
assertEquals(3, mapper.getModel().getWater().size());
assertNull(body.getLod1MultiSurface());
assertNull(body.getDeprecatedProperties().getLod1MultiSurface());
Geometry geometry = mapper.getModel().getWater().get(2).getGeometries().get(0);
assertEquals(1, geometry.getPolygons().size());
assertEquals(Lod.LOD1, geometry.getLod());
assertEquals(GeometryType.MULTI_SURFACE, geometry.getType());
}
@Test
public void testVisitPlantCover() {
PlantCover cover = new PlantCover();
FeatureMapper mapper = new FeatureMapper(mock(ParserConfiguration.class), new File(""));
Citygml3FeatureMapper mapper = new Citygml3FeatureMapper(mock(ParserConfiguration.class),
new File("").toPath());
mapper.visit(cover);
}
private MultiSurfaceProperty createDummyMsp() {
LinearRing ext = new LinearRing();
ext.addCoord(createCoord(0, 0, 0));
ext.addCoord(createCoord(10, 0, 0));
ext.addCoord(createCoord(10, 10, 0));
ext.addCoord(createCoord(0, 10, 0));
ext.addCoord(createCoord(0, 0, 0));
ext.getControlPoints().getGeometricPositions().add(createCoord(0, 0, 0));
ext.getControlPoints().getGeometricPositions().add(createCoord(10, 0, 0));
ext.getControlPoints().getGeometricPositions().add(createCoord(10, 10, 0));
ext.getControlPoints().getGeometricPositions().add(createCoord(0, 10, 0));
ext.getControlPoints().getGeometricPositions().add(createCoord(0, 0, 0));
Polygon p = new Polygon();
p.setExterior(new Exterior(ext));
p.setExterior(new AbstractRingProperty(ext));
MultiSurface ms = new MultiSurface();
ms.addSurfaceMember(new SurfaceProperty(p));
ms.getSurfaceMember().add(new SurfaceProperty(p));
return new MultiSurfaceProperty(ms);
}
......@@ -105,20 +109,22 @@ public class FeatureMapperTest {
WaterBody body = new WaterBody();
Polygon p = new Polygon();
LinearRing ring = new LinearRing();
Coord coord = createCoord(0, 0.0000000049, 0);
ring.addCoord(coord);
p.setExterior(new Exterior(ring));
GeometricPosition coord = createCoord(0, 0.0000000049, 0);
ring.getControlPoints().getGeometricPositions().add(coord);
p.setExterior(new AbstractRingProperty(ring));
Polygon p2 = new Polygon();
LinearRing ring2 = new LinearRing();
coord = createCoord(0, 0.0000000050, 0);
ring2.addCoord(coord);
p2.setExterior(new Exterior(ring2));
MultiSurface ms = new MultiSurface(p, p2);
body.setLod1MultiSurface(new MultiSurfaceProperty(ms));
ring2.getControlPoints().getGeometricPositions().add(coord);
p2.setExterior(new AbstractRingProperty(ring2));
MultiSurface ms = new MultiSurface();
ms.getSurfaceMember().add(new SurfaceProperty(p));
ms.getSurfaceMember().add(new SurfaceProperty(p2));
body.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
ParserConfiguration config = new ParserConfiguration(8, false);
FeatureMapper mapper = new FeatureMapper(config, folder.newFile());
Citygml3FeatureMapper mapper = new Citygml3FeatureMapper(config, folder.newFile().toPath());
mapper.visit(body);
CityDoctorModel model = mapper.getModel();
......@@ -135,17 +141,18 @@ public class FeatureMapperTest {
WaterBody body = new WaterBody();
Polygon p = new Polygon();
LinearRing ring = new LinearRing();
Coord coord = createCoord(0, 0.0000000049, 0);
ring.addCoord(coord);
GeometricPosition coord = createCoord(0, 0.0000000049, 0);
ring.getControlPoints().getGeometricPositions().add(coord);
coord = createCoord(0, 0.0000000150, 0);
ring.addCoord(coord);
p.setExterior(new Exterior(ring));
MultiSurface ms = new MultiSurface(p);
body.setLod1MultiSurface(new MultiSurfaceProperty(ms));
ring.getControlPoints().getGeometricPositions().add(coord);
p.setExterior(new AbstractRingProperty(ring));
MultiSurface ms = new MultiSurface();
ms.getSurfaceMember().add(new SurfaceProperty(p));
body.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
ParserConfiguration config = new ParserConfiguration(8, false);
FeatureMapper mapper = new FeatureMapper(config, folder.newFile());
Citygml3FeatureMapper mapper = new Citygml3FeatureMapper(config, folder.newFile().toPath());
mapper.visit(body);
CityDoctorModel model = mapper.getModel();
......@@ -168,29 +175,31 @@ public class FeatureMapperTest {
WaterBody body = new WaterBody();
Polygon p1 = new Polygon();
LinearRing ring1 = new LinearRing();
p1.setExterior(new Exterior(ring1));
ring1.addCoord(createCoord(0, 0, 0));
ring1.addCoord(createCoord(1, 0, 0));
ring1.addCoord(createCoord(1, 1, 0));
ring1.addCoord(createCoord(1, 2, 0));
ring1.addCoord(createCoord(0, 2, 0));
ring1.addCoord(createCoord(0, 0, 0));
p1.setExterior(new AbstractRingProperty(ring1));
ring1.getControlPoints().getGeometricPositions().add(createCoord(0, 0, 0));
ring1.getControlPoints().getGeometricPositions().add(createCoord(1, 0, 0));
ring1.getControlPoints().getGeometricPositions().add(createCoord(1, 1, 0));
ring1.getControlPoints().getGeometricPositions().add(createCoord(1, 2, 0));
ring1.getControlPoints().getGeometricPositions().add(createCoord(0, 2, 0));
ring1.getControlPoints().getGeometricPositions().add(createCoord(0, 0, 0));
Polygon p2 = new Polygon();
LinearRing ring2 = new LinearRing();
p2.setExterior(new Exterior(ring2));
ring2.addCoord(createCoord(1, 0, 0));
ring2.addCoord(createCoord(2, 0, 0));
ring2.addCoord(createCoord(2, 2, 0));
ring2.addCoord(createCoord(1, 2, 0));
ring2.addCoord(createCoord(1, 1.0000000050, 0));
ring2.addCoord(createCoord(1, 0, 0));
p2.setExterior(new AbstractRingProperty(ring2));
ring2.getControlPoints().getGeometricPositions().add(createCoord(1, 0, 0));
ring2.getControlPoints().getGeometricPositions().add(createCoord(2, 0, 0));
ring2.getControlPoints().getGeometricPositions().add(createCoord(2, 2, 0));
ring2.getControlPoints().getGeometricPositions().add(createCoord(1, 2, 0));
ring2.getControlPoints().getGeometricPositions().add(createCoord(1, 1.0000000050, 0));
ring2.getControlPoints().getGeometricPositions().add(createCoord(1, 0, 0));
MultiSurface ms = new MultiSurface(p1, p2);
body.setLod1MultiSurface(new MultiSurfaceProperty(ms));
MultiSurface ms = new MultiSurface();
ms.getSurfaceMember().add(new SurfaceProperty(p1));
ms.getSurfaceMember().add(new SurfaceProperty(p2));
body.getDeprecatedProperties().setLod1MultiSurface(new MultiSurfaceProperty(ms));
ParserConfiguration config = new ParserConfiguration(8, false);
FeatureMapper mapper = new FeatureMapper(config, folder.newFile());
Citygml3FeatureMapper mapper = new Citygml3FeatureMapper(config, folder.newFile().toPath());
mapper.visit(body);
CityDoctorModel model = mapper.getModel();
......@@ -201,12 +210,8 @@ public class FeatureMapperTest {
assertEquals(8, geometry.getEdges().size());
}
private Coord createCoord(double x, double y, double z) {
Coord coord = new Coord();
coord.setX(x);
coord.setY(y);
coord.setZ(z);
return coord;
private GeometricPosition createCoord(double x, double y, double z) {
return new GeometricPosition(new DirectPosition(x, y, z));
}
}
......@@ -20,24 +20,19 @@ package de.hft.stuttgart.citydoctor2.mapper;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.citygml4j.model.gml.geometry.primitives.Coord;
import org.citygml4j.model.gml.geometry.primitives.Exterior;
import org.citygml4j.model.gml.geometry.primitives.LinearRing;
import org.citygml4j.model.gml.geometry.primitives.Polygon;
import org.junit.Test;
import org.xmlobjects.gml.model.geometry.DirectPosition;
import org.xmlobjects.gml.model.geometry.GeometricPosition;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.primitives.LinearRing;
import org.xmlobjects.gml.model.geometry.primitives.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.Citygml3GeometryMapper;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Pair;
/**
*
......@@ -50,25 +45,16 @@ public class GeometryMapperTest {
public void testRounding() {
Polygon p = new Polygon();
LinearRing ring = new LinearRing();
Coord coord = new Coord();
coord.setX(0d);
coord.setY(0.0000000049d);
coord.setZ(0d);
ring.addCoord(coord);
GeometricPosition coord = new GeometricPosition(new DirectPosition(0d, 0.0000000049d, 0d));
ring.getControlPoints().getGeometricPositions().add(coord);
coord = new Coord();
coord.setX(0d);
coord.setY(0.0000000050d);
coord.setZ(0d);
ring.addCoord(coord);
p.setExterior(new Exterior(ring));
coord = new GeometricPosition(new DirectPosition(0d, 0.0000000050d, 0d));
ring.getControlPoints().getGeometricPositions().add(coord);
p.setExterior(new AbstractRingProperty(ring));
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD0);
ParserConfiguration config = new ParserConfiguration(8, false);
Map<String, ConcretePolygon> polygons = new HashMap<>();
List<Pair<String, Geometry>> linkedPolygons = new ArrayList<>();
Map<Vertex, Vertex> vertices = new HashMap<>();
GeometryMapper mapper = new GeometryMapper(geom, config, polygons, linkedPolygons, vertices);
Citygml3GeometryMapper mapper = new Citygml3GeometryMapper(config, vertices);
mapper.visit(p);
assertEquals(2, vertices.size());
}
......
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.citygml4j.core.ade.ADE;
import org.citygml4j.core.ade.ADERegistry;
import org.citygml4j.xml.CityGMLContext;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.quality.QualityADEContext;
public class CityGml3ParserTest {
@Test
public void testGetContext() {
CityGMLContext context = CityGmlParser.getContext();
List<ADE> ades = ADERegistry.getInstance().getADEs();
ADE ade = ades.get(0);
assertEquals(QualityADEContext.class, ade.getClass());
assertNotNull(context);
}
@Test
public void testParseFileWithoutValidation() throws CityGmlParseException, InvalidGmlFileException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/SimpleSolid_SrefBS.gml", config);
assertNotNull(model);
List<Building> buildings = model.getBuildings();
assertEquals(1, buildings.size());
Building building = buildings.get(0);
assertEquals("_Simple_BD.1", building.getGmlId().getGmlString());
List<BoundarySurface> surfaces = building.getBoundarySurfaces();
assertEquals(6, surfaces.size());
}
}
......@@ -23,8 +23,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.UUID;
import org.citygml4j.model.citygml.ade.ADEComponent;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -32,26 +32,30 @@ import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.quality.model.ValidationResult;
import de.hft.stuttgart.quality.model.jaxb.ResultType;
import de.hft.stuttgart.quality.model.enums.ResultType;
import de.hft.stuttgart.quality.model.types.CityObjectProperties;
import de.hft.stuttgart.quality.model.types.Validation;
import de.hft.stuttgart.quality.model.types.ValidationResult;
public class QualityADEUtilsTest {
@Test
public void testWriteQualityADE() {
Building b = new Building();
org.citygml4j.model.citygml.building.Building gmlB = new org.citygml4j.model.citygml.building.Building();
org.citygml4j.core.model.building.Building gmlB = new org.citygml4j.core.model.building.Building();
b.setGmlObject(gmlB);
List<ADEComponent> coADE = gmlB.getGenericApplicationPropertyOfCityObject();
List<CityObjectProperties> coADE = gmlB.getADEProperties(CityObjectProperties.class);
assertTrue(coADE.isEmpty());
Validation val = new Validation();
val.setId(UUID.randomUUID().toString());
b.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, new UnknownCheckError(b, new NullPointerException(), CheckId.C_GE_P_HOLE_OUTSIDE)));
QualityADEUtils.writeQualityAde(b);
coADE = gmlB.getGenericApplicationPropertyOfCityObject();
QualityADEUtils.writeQualityAde(b, val);
coADE = gmlB.getADEProperties(CityObjectProperties.class);
assertFalse(coADE.isEmpty());
assertEquals(1, coADE.size());
ADEComponent adeComponent = coADE.get(0);
ValidationResult valResult = (ValidationResult) adeComponent;
assertEquals(ResultType.NOT_CHECKED, valResult.getResult());
CityObjectProperties adeComponent = coADE.get(0);
ValidationResult valResult = adeComponent.getValidationResult().getObject();
assertEquals(ResultType.NOT_CHECKED, valResult.getResultType());
}
}
<?xml version="1.0" encoding="utf-8"?>
<core:CityModel xmlns:core="http://www.opengis.net/citygml/2.0" xmlns:gen="http://www.opengis.net/citygml/generics/2.0" xmlns:bldg="http://www.opengis.net/citygml/building/2.0" xmlns:app="http://www.opengis.net/citygml/appearance/2.0" xmlns:dem="http://www.opengis.net/citygml/relief/2.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/citygml/building/2.0 http://schemas.opengis.net/citygml/building/2.0/building.xsd http://www.opengis.net/citygml/appearance/2.0 http://schemas.opengis.net/citygml/appearance/2.0/appearance.xsd http://www.opengis.net/citygml/relief/2.0 http://schemas.opengis.net/citygml/relief/2.0/relief.xsd http://www.opengis.net/citygml/2.0 http://schemas.opengis.net/citygml/2.0/cityGMLBase.xsd http://www.opengis.net/citygml/generics/2.0 http://schemas.opengis.net/citygml/generics/2.0/generics.xsd">
<!--
Einfaches Gebäude mit Grundriss 3m x 5m und Satteldach, Traufhöhe 3m, Firsthöhe 4,5m
Modelliert mit Begrenzungsflächen (eine Dachfläche, 4 Wandflächen, 1 Grundfläche),
die Gebäudegeometrie als Solid, der auf die Polygone der Begrenzungsflächen referenziert
CityGML 2.0
Gebäudevolumen: 56,25 m3
10.5.2017
Author: V. Coors, HFT Stuttgart
Lizenz:
-->
<core:cityObjectMember>
<bldg:Building gml:id="_Simple_BD.1">
<bldg:lod2Solid>
<gml:Solid>
<gml:exterior>
<gml:CompositeSurface>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.1"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.2"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.3"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.4"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.5"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.6"/>
<gml:surfaceMember xlink:href="#_Simple_BD.1_PG.7"/>
</gml:CompositeSurface>
</gml:exterior>
</gml:Solid>
</bldg:lod2Solid>
<bldg:boundedBy>
<bldg:WallSurface gml:id="_Simple_BD.1_WallSurface_1">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.2">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.2_LR.1">
<gml:posList srsDimension="3">
13.0 15.0 0.0
13.0 15.0 3.0
13.0 10.0 3.0
13.0 10.0 0.0
13.0 15.0 0.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:WallSurface>
</bldg:boundedBy>
<bldg:boundedBy>
<bldg:WallSurface gml:id="_Simple_BD.1_WallSurface_2">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.3">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.3_LR.1">
<gml:posList srsDimension="3">
10.0 15.0 0.0
10.0 15.0 3.0
11.5 15.0 4.5
13.0 15.0 3.0
13.0 15.0 0.0
10.0 15.0 0.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:WallSurface>
</bldg:boundedBy>
<bldg:boundedBy>
<bldg:WallSurface gml:id="_Simple_BD.1_WallSurface_3">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.4">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.4_LR.1">
<gml:posList srsDimension="3">
10.0 10.0 3.0
10.0 15.0 3.0
10.0 15.0 0.0
10.0 10.0 0.0
10.0 10.0 3.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:WallSurface>
</bldg:boundedBy>
<bldg:boundedBy>
<bldg:WallSurface gml:id="_Simple_BD.1_WallSurface_4">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.5">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.5_LR.1">
<gml:posList srsDimension="3">
13.0 10.0 0.0
13.0 10.0 3.0
11.5 10.0 4.5
10.0 10.0 3.0
10.0 10.0 0.0
13.0 10.0 0.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:WallSurface>
</bldg:boundedBy>
<bldg:boundedBy>
<bldg:RoofSurface gml:id="_Simple_BD.1_RoofSurface_1">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.6">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.6_LR.1">
<gml:posList srsDimension="3">
10.0 10.0 3.0
11.5 10.0 4.5
11.5 15.0 4.5
10.0 15.0 3.0
10.0 10.0 3.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.7">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.7_LR.1">
<gml:posList srsDimension="3">
11.5 10.0 4.5
13.0 10.0 3.0
13.0 15.0 3.0
11.5 15.0 4.5
11.5 10.0 4.5
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:RoofSurface>
</bldg:boundedBy>
<bldg:boundedBy>
<bldg:GroundSurface gml:id="_Simple_BD.1_GroundSurface_1">
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon gml:id="_Simple_BD.1_PG.1">
<gml:exterior>
<gml:LinearRing gml:id="_Simple_BD.1_PG.1_LR.1">
<gml:posList srsDimension="3">
10.0 10.0 0.0
10.0 15.0 0.0
13.0 15.0 0.0
13.0 10.0 0.0
10.0 10.0 0.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:GroundSurface>
</bldg:boundedBy>
</bldg:Building>
</core:cityObjectMember>
</core:CityModel>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.10.3</version>
<version>3.11.0</version>
</parent>
<artifactId>CityDoctorValidation</artifactId>
<name>CityDoctorValidation</name>
......@@ -27,10 +27,6 @@
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
</dependency>
<dependency>
<groupId>org.citygml4j</groupId>
<artifactId>citygml4j</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
......@@ -25,13 +25,12 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.citygml4j.core.ade.ADEException;
import de.hft.stuttgart.citydoctor2.check.Checker;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parameter.ArgumentParser;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
......@@ -63,11 +62,9 @@ public class CityDoctorValidation {
* happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema.
* @throws CityGMLWriteException
* @throws CityGMLBuilderException
* @throws ADEException
* @throws CityDoctorWriteException
*/
public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException, ADEException {
public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException, CityDoctorWriteException {
ArgumentParser argParser = new ArgumentParser(args);
String inputFile = getInputFile(argParser);
String xmlOutput = getXmlOutput(argParser);
......@@ -109,10 +106,9 @@ public class CityDoctorValidation {
* happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema.
* @throws ADEException
*/
public static void validate(File inputFile, File xmlOutput, File pdfOutput)
throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
throws IOException, CityGmlParseException, InvalidGmlFileException {
validate(inputFile, xmlOutput, pdfOutput, null);
}
......@@ -129,10 +125,9 @@ public class CityDoctorValidation {
* happens.
* @throws InvalidGmlFileException If the cityGML file is not valid according to
* the cityGML schema.
* @throws ADEException
*/
public static void validate(File inputFile, File xmlOutput, File pdfOutput, File validationConfigFile)
throws IOException, CityGmlParseException, InvalidGmlFileException, ADEException {
throws IOException, CityGmlParseException, InvalidGmlFileException {
ValidationConfiguration config;
if (validationConfigFile == null) {
config = ValidationConfiguration.loadStandardValidationConfig();
......@@ -150,7 +145,7 @@ public class CityDoctorValidation {
}
try {
startValidationProcess(inputFile, xmlOutputPath, pdfOutputPath, config, null);
} catch (CityGMLBuilderException | CityGMLWriteException e) {
} catch (CityDoctorWriteException e) {
// this does not happen as no output file is specified
logger.catching(e);
}
......@@ -164,17 +159,14 @@ public class CityDoctorValidation {
* @param pdfOutput the output path for the pdf report (optional)
* @param config the configuration path for the validation plan
* @param outputFile storing the validated gml file with quality ade
* @throws IOException
* @throws CityGmlParseException
* @throws InvalidGmlFileException
* @throws CityGMLWriteException if something goes wrong while writing the gml
* @throws CityDoctorWriteException if something goes wrong while writing the gml
* file
* @throws CityGMLBuilderException
* @throws ADEException
*/
public static void startValidationProcess(File inputFile, String xmlOutput, String pdfOutput,
ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException,
InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException, ADEException {
InvalidGmlFileException, CityDoctorWriteException {
if (config.isUseStreaming()) {
Checker.streamCheck(inputFile, xmlOutput, pdfOutput, config, outputFile);
......
......@@ -74,12 +74,16 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlValidationReporter;
import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfReporter;
import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfStreamReporter;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.quality.model.jaxb.Checking;
import de.hft.stuttgart.quality.model.jaxb.Parameter;
import de.hft.stuttgart.quality.model.jaxb.Requirement;
import de.hft.stuttgart.quality.model.jaxb.RequirementId;
import de.hft.stuttgart.quality.model.jaxb.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.jaxb.ValidationPlan;
import de.hft.stuttgart.quality.model.enums.RequirementId;
import de.hft.stuttgart.quality.model.enums.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.properties.CheckingProperty;
import de.hft.stuttgart.quality.model.properties.FilterProperty;
import de.hft.stuttgart.quality.model.properties.GlobalParametersProperty;
import de.hft.stuttgart.quality.model.properties.ParameterProperty;
import de.hft.stuttgart.quality.model.properties.RequirementProperty;
import de.hft.stuttgart.quality.model.types.Checking;
import de.hft.stuttgart.quality.model.types.Parameter;
import de.hft.stuttgart.quality.model.types.ValidationPlan;
import net.sf.saxon.s9api.DOMDestination;
import net.sf.saxon.s9api.Destination;
import net.sf.saxon.s9api.Processor;
......@@ -242,7 +246,8 @@ public class Checker {
ValidationPlan createValidationPlan() {
ValidationPlan plan = new ValidationPlan();
List<Checking> filter = createFilter();
de.hft.stuttgart.quality.model.types.Filter filter = createFilter();
plan.setFilter(new FilterProperty(filter));
Map<String, de.hft.stuttgart.citydoctor2.check.Requirement> reqs = Checks.getAvailableRequirements();
for (Entry<String, RequirementConfiguration> e : config.getRequirements().entrySet()) {
......@@ -250,10 +255,10 @@ public class Checker {
if (reqId == null) {
continue;
}
Requirement req = new Requirement();
req.setName(reqId);
de.hft.stuttgart.quality.model.types.Requirement req = new de.hft.stuttgart.quality.model.types.Requirement();
req.setRequirementType(reqId);
req.setEnabled(e.getValue().isEnabled());
plan.getRequirements().add(req);
plan.getRequirements().add(new RequirementProperty(req));
Map<String, String> parameters = e.getValue().getParameters();
if (parameters != null) {
for (Entry<String, String> param : parameters.entrySet()) {
......@@ -264,21 +269,20 @@ public class Checker {
}
p.setName(param.getKey());
p.setValue(param.getValue());
req.getParameters().add(p);
req.getParameters().add(new ParameterProperty(p));
}
}
}
Requirement missing = new Requirement();
missing.setName(RequirementId.R_SE_ATTRIBUTES_EXISTING);
Requirement correct = new Requirement();
correct.setName(RequirementId.R_SE_ATTRIBUTES_CORRECT);
de.hft.stuttgart.quality.model.types.Requirement missing = new de.hft.stuttgart.quality.model.types.Requirement();
missing.setRequirementType(RequirementId.R_SE_ATTRIBUTES_EXISTING);
de.hft.stuttgart.quality.model.types.Requirement correct = new de.hft.stuttgart.quality.model.types.Requirement();
correct.setRequirementType(RequirementId.R_SE_ATTRIBUTES_CORRECT);
missing.setEnabled(config.getSchematronFilePath() != null);
correct.setEnabled(config.getSchematronFilePath() != null);
plan.getRequirements().add(missing);
plan.getRequirements().add(correct);
plan.getRequirements().add(new RequirementProperty(missing));
plan.getRequirements().add(new RequirementProperty(correct));
plan.getFilter().addAll(filter);
Parameter numRounding = new Parameter();
numRounding.setName("numberOfRoundingPlaces");
numRounding.setValue("" + config.getNumberOfRoundingPlaces());
......@@ -289,9 +293,11 @@ public class Checker {
Parameter schematronFile = new Parameter();
schematronFile.setName("schematronFile");
schematronFile.setValue(config.getSchematronFilePath());
plan.getGlobalParameters().add(numRounding);
plan.getGlobalParameters().add(minVertexDistance);
plan.getGlobalParameters().add(schematronFile);
de.hft.stuttgart.quality.model.types.GlobalParameters globParams = new de.hft.stuttgart.quality.model.types.GlobalParameters();
plan.setGlobalParameters(new GlobalParametersProperty(globParams));
globParams.getParameters().add(new ParameterProperty(numRounding));
globParams.getParameters().add(new ParameterProperty(minVertexDistance));
globParams.getParameters().add(new ParameterProperty(schematronFile));
return plan;
}
......@@ -308,8 +314,8 @@ public class Checker {
return null;
}
private List<Checking> createFilter() {
List<Checking> filter = new ArrayList<>();
private de.hft.stuttgart.quality.model.types.Filter createFilter() {
var filter = new de.hft.stuttgart.quality.model.types.Filter();
handleInputFilter(filter);
if (excludeFilters != null) {
for (Filter f : excludeFilters) {
......@@ -327,23 +333,24 @@ public class Checker {
return filter;
}
private void handleInputFilter(List<Checking> filter) {
private void handleInputFilter(de.hft.stuttgart.quality.model.types.Filter filter) {
if (includeFilters == null || includeFilters.isEmpty()) {
// no filter means, use all
addAllFilters(filter);
} else {
for (Filter f : includeFilters) {
if (f instanceof TypeFilter) {
TypeFilter tf = (TypeFilter) f;
if (f instanceof TypeFilter tf) {
FeatureType type = tf.getType();
TopLevelFeatureType tlft = mapToTopLevelFeatureType(type);
if (tlft == null) {
continue;
}
filter.add(new Checking(tlft));
Checking c = new Checking();
c.setFeatureType(tlft);
filter.getChecking().add(new CheckingProperty(c));
}
}
if (filter.isEmpty()) {
if (filter.getChecking().isEmpty()) {
// this happens if no type include filter was used
// it is possible only single objects were tested then
// so include everything
......@@ -352,19 +359,36 @@ public class Checker {
}
}
private void addAllFilters(List<Checking> filter) {
filter.add(new Checking(TopLevelFeatureType.BUILDING));
filter.add(new Checking(TopLevelFeatureType.BRIDGE));
filter.add(new Checking(TopLevelFeatureType.LAND));
filter.add(new Checking(TopLevelFeatureType.TRANSPORTATION));
filter.add(new Checking(TopLevelFeatureType.VEGETATION));
filter.add(new Checking(TopLevelFeatureType.WATER));
private void addAllFilters(de.hft.stuttgart.quality.model.types.Filter filter) {
Checking buildingChecking = new Checking();
buildingChecking.setFeatureType(TopLevelFeatureType.BUILDING);
filter.getChecking().add(new CheckingProperty(buildingChecking));
Checking bridgeChecking = new Checking();
bridgeChecking.setFeatureType(TopLevelFeatureType.BRIDGE);
filter.getChecking().add(new CheckingProperty(bridgeChecking));
Checking landChecking = new Checking();
landChecking.setFeatureType(TopLevelFeatureType.LAND);
filter.getChecking().add(new CheckingProperty(landChecking));
Checking transportationChecking = new Checking();
transportationChecking.setFeatureType(TopLevelFeatureType.TRANSPORTATION);
filter.getChecking().add(new CheckingProperty(transportationChecking));
Checking vegetationChecking = new Checking();
vegetationChecking.setFeatureType(TopLevelFeatureType.VEGETATION);
filter.getChecking().add(new CheckingProperty(vegetationChecking));
Checking waterChecking = new Checking();
waterChecking.setFeatureType(TopLevelFeatureType.WATER);
filter.getChecking().add(new CheckingProperty(waterChecking));
}
private void removeFilter(TopLevelFeatureType tlft, List<Checking> filter) {
for (Checking c : filter) {
if (c.getValue().equals(tlft)) {
filter.remove(c);
private void removeFilter(TopLevelFeatureType tlft, de.hft.stuttgart.quality.model.types.Filter filter) {
for (CheckingProperty c : filter.getChecking()) {
if (c.getObject().getFeatureType().equals(tlft)) {
filter.getChecking().remove(c);
return;
}
}
......@@ -762,7 +786,7 @@ public class Checker {
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, inputFile);
CityGmlConsumer con = new StreamCityGmlConsumer(c, xmlReporter, pdfReporter, handler, config, l);
// parse and validate
CityGmlParser.streamCityGml(inputFile, config.getParserConfiguration(), con, outputFile);
CityGmlParser.streamCityGml(inputFile.getAbsolutePath(), config.getParserConfiguration(), con, outputFile);
// write reports if available
writeReport(xmlReporter);
......
......@@ -35,6 +35,13 @@ public class RequirementConfiguration implements Serializable {
private boolean enabled;
private Map<String, String> parameters;
public RequirementConfiguration() {
}
public RequirementConfiguration(boolean enabled) {
this.enabled = enabled;
}
/**
* @return Whether this check is enabled
......
......@@ -24,14 +24,16 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel;
import org.citygml4j.core.util.geometry.GeometryFactory;
import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler;
......@@ -48,10 +50,13 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlStreamReporter;
import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfStreamReporter;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.jaxb.ErrorStatistics;
import de.hft.stuttgart.quality.model.jaxb.FeatureStatistics;
import de.hft.stuttgart.quality.model.jaxb.Statistics;
import de.hft.stuttgart.quality.model.properties.ErrorProperty;
import de.hft.stuttgart.quality.model.properties.FeatureStatisticsProperty;
import de.hft.stuttgart.quality.model.properties.StatisticsProperty;
import de.hft.stuttgart.quality.model.properties.ValidationPlanProperty;
import de.hft.stuttgart.quality.model.types.FeatureStatistics;
import de.hft.stuttgart.quality.model.types.Statistics;
import de.hft.stuttgart.quality.model.types.Validation;
public class StreamCityGmlConsumer implements CityGmlConsumer {
......@@ -62,7 +67,7 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
private PdfStreamReporter pdfReporter;
private SvrlContentHandler handler;
private Map<ErrorId, AtomicInteger> errorCount;
private GMLGeometryFactory gmlFactory;
private GeometryFactory gmlFactory;
private ValidationConfiguration config;
private Statistics statistics;
private FeatureStatistics buildingStatistics;
......@@ -83,24 +88,25 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
this.config = config;
this.l = l;
errorCount = new HashMap<>();
gmlFactory = new GMLGeometryFactory();
gmlFactory = GeometryFactory.newInstance();
val = new Validation();
val.setId("CD" + UUID.randomUUID().toString());
val.setValidationDate(ZonedDateTime.now());
val.setValidationSoftware("CityDoctor " + Localization.getText(Localization.VERSION));
statistics = new Statistics();
buildingStatistics = new FeatureStatistics();
statistics.setNumErrorBuildings(buildingStatistics);
statistics.setNumErrorBuildings(new FeatureStatisticsProperty(buildingStatistics));
bridgeStatistics = new FeatureStatistics();
statistics.setNumErrorBridgeObjects(bridgeStatistics);
statistics.setNumErrorBridgeObjects(new FeatureStatisticsProperty(bridgeStatistics));
transportationStatistics = new FeatureStatistics();
statistics.setNumErrorTransportation(transportationStatistics);
statistics.setNumErrorTransportation(new FeatureStatisticsProperty(transportationStatistics));
vegetationStatistics = new FeatureStatistics();
statistics.setNumErrorVegetation(vegetationStatistics);
statistics.setNumErrorVegetation(new FeatureStatisticsProperty(vegetationStatistics));
landStatistics = new FeatureStatistics();
statistics.setNumErrorLandObjects(landStatistics);
statistics.setNumErrorLandObjects(new FeatureStatisticsProperty(landStatistics));
waterStatistics = new FeatureStatistics();
statistics.setNumErrorWaterObjects(waterStatistics);
statistics.setNumErrorWaterObjects(new FeatureStatisticsProperty(waterStatistics));
}
......@@ -132,10 +138,8 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
pdfReporter.report(co);
}
// remove existing quality ade datastructure if existing
QualityADEUtils.removeValidationResult(co);
// store quality ade datastructures in cityobject
QualityADEUtils.writeQualityAde(co);
QualityADEUtils.writeQualityAde(co, val);
// recreate geometry
co.reCreateGeometries(gmlFactory, config.getParserConfiguration());
......@@ -164,21 +168,21 @@ public class StreamCityGmlConsumer implements CityGmlConsumer {
@Override
public void accept(CityModel cm) {
QualityADEUtils.removeValidation(cm);
for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) {
ErrorStatistics stats = new ErrorStatistics();
stats.setAmount(e.getValue().get());
de.hft.stuttgart.quality.model.jaxb.ErrorId adeId = QualityADEUtils.mapErrorIdToAdeId(e.getKey());
var stats = new de.hft.stuttgart.quality.model.types.Error();
stats.setOccurrences(e.getValue().get());
de.hft.stuttgart.quality.model.enums.ErrorId adeId = QualityADEUtils.mapErrorIdToAdeId(e.getKey());
if (adeId == null) {
// error that is not part of the ade standard
continue;
}
statistics.getErrorStatistics().add(stats);
stats.setName(adeId);
statistics.getErrors().add(new ErrorProperty(stats));
}
val.setStatistics(statistics);
val.setValidationPlan(c.createValidationPlan());
val.setStatistics(new StatisticsProperty(statistics));
val.setValidationPlan(new ValidationPlanProperty(c.createValidationPlan()));
cm.addGenericApplicationPropertyOfCityModel(val);
cm.getFeatureMembers().add(new AbstractFeatureProperty(val));
}
private static void applyToStatistics(FeatureStatistics buildingStatistics, FeatureStatistics bridgeStatistics,
......
......@@ -24,9 +24,6 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import org.citygml4j.builder.jaxb.CityGMLBuilderException;
import org.citygml4j.model.citygml.ade.ADEException;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
......@@ -34,6 +31,7 @@ import org.junit.rules.TemporaryFolder;
import de.hft.stuttgart.citydoctor2.CityDoctorValidation;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
......@@ -58,20 +56,17 @@ public class CheckerTest {
Checker checker = new Checker(config, model);
checker.runChecks();
for (Building b : model.getBuildings()) {
if (!b.getGmlId().getGmlString().startsWith("UUID")) {
// if it starts with UUID the gml id was generated by citygml4j, but the file
// does not actually contain that gml id
// the schematron errors cannot be assigned to buildings without gml id, so they
// are excluded here
if (b.getGmlId().getGmlString().equals("_Simple_BD.1")) {
assertTrue(b.containsAnyError());
} else {
assertFalse(b.containsAnyError());
}
}
assertFalse(model.getGlobalErrors().isEmpty());
}
@Test
public void testChecker() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException, ADEException {
public void testChecker() throws CityGmlParseException, IOException, InvalidGmlFileException, CityDoctorWriteException {
File f = folder.newFile();
File f2 = folder.newFile();
......@@ -93,8 +88,7 @@ public class CheckerTest {
}
@Test
public void testStreaming() throws CityGmlParseException, IOException, InvalidGmlFileException,
CityGMLBuilderException, CityGMLWriteException, ADEException {
public void testStreaming() throws CityGmlParseException, IOException, InvalidGmlFileException, CityDoctorWriteException {
File f = folder.newFile();
File f2 = folder.newFile();
File f3 = folder.newFile();
......
Markdown is supported
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