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