Commit 67343044 authored by Matthias Betz's avatar Matthias Betz
Browse files

replace copy mechanism

logo now in jar, extracted when needed to temp dir
change version to 3.10
parent 3d26f0e9
Pipeline #5579 failed with stage
in 39 seconds
......@@ -231,7 +231,7 @@ public class Vector3d implements Serializable {
*
* @return a copy of this vector
*/
public Vector3d copy() {
public Vector3d copyVector() {
return new Vector3d(coords[0], coords[1], coords[2]);
}
......
......@@ -98,10 +98,10 @@ public class KDTree {
public List<Vertex> getNodesInRange(Vertex node, double radius) {
// construct box:
Vector3d leftBotFront = node.copy();
Vector3d leftBotFront = node.copyVector();
leftBotFront.plus(-radius);
Vector3d topRightBehind = node.copy();
Vector3d topRightBehind = node.copyVector();
topRightBehind.plus(radius);
List<Vertex> nodesInRangeBox = getNodesInRange(leftBotFront, topRightBehind, new ArrayList<>());
......
......@@ -117,5 +117,9 @@ public class ParserConfiguration implements Serializable {
public boolean useLowMemoryConsumption() {
return useLowMemoryConsumption;
}
public void setUseLowMemoryConsumption(boolean useLowMemoryConsumption) {
this.useLowMemoryConsumption = useLowMemoryConsumption;
}
}
/*-
* Copyright 2020 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.utils;
public class Copy {
private Copy() {
}
public static <T extends Copyable> T copy(T original) {
CopyHandler handler = new CopyHandler();
return handler.copy(original);
}
}
/*-
* Copyright 2020 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.utils;
import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class CopyHandler {
private Set<Copyable> toBeDoneInstances = new HashSet<>();
private Map<Copyable, Copyable> finishedInstances = new IdentityHashMap<>();
@SuppressWarnings("unchecked")
public <T extends Copyable> T copy(T original) {
toBeDoneInstances.add(original);
while (!toBeDoneInstances.isEmpty()) {
handleNextInstance();
}
for (Entry<Copyable, Copyable> e : finishedInstances.entrySet()) {
e.getValue().fillValues(e.getKey(), this);
}
return (T) finishedInstances.get(original);
}
@SuppressWarnings("unchecked")
public <T extends Copyable> T getCopyInstance(T original) {
if (original == null) {
// null gets copied to null
return null;
}
return (T) finishedInstances.get(original);
}
public void addInstance(Copyable copyable) {
if (copyable == null) {
// don't care for null instances
return;
}
if (finishedInstances.containsKey(copyable)) {
// already processed
return;
}
toBeDoneInstances.add(copyable);
}
private void handleNextInstance() {
Iterator<Copyable> iterator = toBeDoneInstances.iterator();
Copyable next = iterator.next();
iterator.remove();
finishedInstances.put(next, next.createCopyInstance());
next.collectInstances(this);
}
public void addInstance(Collection<? extends Copyable> collection) {
if (collection == null) {
return;
}
for (Copyable c : collection) {
addInstance(c);
}
}
}
/*-
* Copyright 2020 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.utils;
public interface Copyable {
public void collectInstances(CopyHandler handler);
public Copyable createCopyInstance();
public void fillValues(Copyable original, CopyHandler handler);
}
......@@ -51,14 +51,13 @@ import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
public class AbstractBuildingTest {
@Test
public void testAccept() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -2487075796550827114L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(new BoundarySurface(null));
ab.addBuildingInstallation(new BuildingInstallation());
ab.addBuildingInstallation(new BuildingInstallation());
......@@ -98,9 +97,7 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
ab.prepareForChecking();
......@@ -113,9 +110,7 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
ab.clearMetaInformation();
......@@ -125,9 +120,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsError() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
assertTrue(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
......@@ -135,9 +128,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsErrorInBs() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
BoundarySurface bsMock = mock(BoundarySurface.class);
ab.addBoundarySurface(bsMock);
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
......@@ -147,9 +138,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsErrorInBi() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
BuildingInstallation biMock = mock(BuildingInstallation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
......@@ -162,9 +151,7 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.OK, null));
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
......@@ -178,9 +165,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsAnyError() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
assertFalse(ab.containsAnyError());
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.OK, null));
assertFalse(ab.containsAnyError());
......@@ -191,9 +176,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsAnyErrorInBs() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
BoundarySurface bsMock = mock(BoundarySurface.class);
ab.addBoundarySurface(bsMock);
assertFalse(ab.containsAnyError());
......@@ -203,9 +186,7 @@ public class AbstractBuildingTest {
@Test
public void testContainsAnyErrorInBi() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
BuildingInstallation biMock = mock(BuildingInstallation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsAnyError());
......@@ -218,9 +199,7 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
......@@ -235,9 +214,7 @@ public class AbstractBuildingTest {
public void testReCreateGeometriesSolid() {
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.addGeometry(geom);
......@@ -270,9 +247,7 @@ public class AbstractBuildingTest {
public void testReCreateGeometriesMultiSurface() {
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
ab.setCityGmlBuilding(gmlAb);
ab.addGeometry(geom);
......@@ -286,9 +261,7 @@ public class AbstractBuildingTest {
@Test
public void testReCreateGeometriesBs() {
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
List<Geometry> geometries = new ArrayList<>();
geometries.add(GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE));
Mockito.when(bsMock.getGeometries()).thenReturn(geometries);
......@@ -306,9 +279,7 @@ public class AbstractBuildingTest {
WallSurface ws = new WallSurface();
BoundarySurface bsMock = mock(BoundarySurface.class);
Mockito.when(bsMock.getGmlObject()).thenReturn(ws);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
......@@ -326,9 +297,7 @@ public class AbstractBuildingTest {
@Test
public void testReCreateGeometriesEmptyBi() {
BuildingInstallation biMock = mock(BuildingInstallation.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBuildingInstallation(biMock);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
......@@ -343,9 +312,7 @@ public class AbstractBuildingTest {
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
AbstractBuilding ab = createAbstractBuilding();
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
org.citygml4j.model.citygml.building.AbstractBuilding gmlAb = new org.citygml4j.model.citygml.building.Building();
......@@ -373,10 +340,21 @@ public class AbstractBuildingTest {
@Test
public void testGetFeatureType() {
AbstractBuilding ab = createAbstractBuilding();
assertEquals(FeatureType.BUILDING, ab.getFeatureType());
}
private AbstractBuilding createAbstractBuilding() {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
@Override
public Copyable createCopyInstance() {
return null;
}
};
assertEquals(FeatureType.BUILDING, ab.getFeatureType());
return ab;
}
}
......@@ -379,12 +379,6 @@ public class BoundarySurfaceTest {
assertNull(ws.getLod4MultiSurface());
}
@Test(expected = UnsupportedOperationException.class)
public void testCopy() {
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, null);
bs.copy();
}
@Test
public void testGetFeatureType() {
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.TUNNEL, BoundarySurfaceType.WALL, null);
......
......@@ -28,6 +28,7 @@ import org.citygml4j.model.gml.basicTypes.Code;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.utils.Copy;
/**
*
......@@ -64,11 +65,10 @@ public class BuildingTest {
surface.addGeometry(geomSurface);
b.addBoundarySurface(surface);
Building copy = b.copy();
Building copy = Copy.copy(b);
assertNotSame(b, copy);
assertEquals(b.getGmlId(), copy.getGmlId());
assertNotSame(b.getGmlId(), copy.getGmlId());
Geometry copyGeom = copy.getGeometries().get(0);
assertNotSame(geom, copyGeom);
......@@ -110,7 +110,6 @@ public class BuildingTest {
assertNotNull(copyAdjacentPoly);
assertNotSame(adjacentPoly, copyAdjacentPoly);
assertNotSame(b.getGmlObject(), copy.getGmlObject());
assertEquals(b.getGmlObject().getFunction().get(0).getValue(), copy.getGmlObject().getFunction().get(0).getValue());
}
......
/*-
* Copyright 2020 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.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryTestUtils;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
public class CopyTest {
@Test
public void testCopy() {
Geometry geometry = GeometryTestUtils.createDummyGeometry(GeometryType.COMPOSITE_SURFACE);
Geometry copy = Copy.copy(geometry);
assertEquals(geometry.getType(), copy.getType());
assertEquals(geometry.getLod(), copy.getLod());
assertEquals(geometry.getGmlId(), copy.getGmlId());
assertNotSame(geometry, copy);
}
}
......@@ -5,7 +5,7 @@
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<version>3.10.0</version>
</parent>
<artifactId>CityDoctorValidation</artifactId>
<name>CityDoctorValidation</name>
......@@ -39,6 +39,20 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>java.xml</groupId>
<artifactId>java.xml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-ext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
......
......@@ -16,11 +16,6 @@
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>./assets/</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>./assets</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
......
......@@ -577,8 +577,7 @@ public class Checker {
parameterMap.compute(proto.getCheckId(), (k, v) -> {
if (v == null) {
v = new HashMap<>();
v.put(GlobalParameters.NUMBER_OF_ROUNDING_PLACES,
config.getNumberOfRoundingPlacesAsString());
v.put(GlobalParameters.NUMBER_OF_ROUNDING_PLACES, config.getNumberOfRoundingPlacesAsString());
v.put(GlobalParameters.MIN_VERTEX_DISTANCE, config.getMinVertexDistanceAsString());
}
v.putAll(e.getValue().getParameters());
......@@ -682,7 +681,8 @@ public class Checker {
}
/**
* Executes all checks for the checkable. This will bypass the filters.
* Executes all checks for the checkable. This will bypass the filters. This
* will clear the old check results
*
* @param co the checkable.
*/
......@@ -795,8 +795,7 @@ public class Checker {
return pdfReporter;
}
public static void writeReport(StreamReporter reporter)
throws CheckReportWriteException {
public static void writeReport(StreamReporter reporter) throws CheckReportWriteException {
if (reporter != null) {
reporter.finishReport();
}
......@@ -810,6 +809,15 @@ public class Checker {
return xmlOutput != null ? new BufferedOutputStream(new FileOutputStream(xmlOutput)) : null;
}
/**
* Checks the city object and writes report information into reporters. Clears
* old check results. If the city object would be filtered by the configured
* filters it is ignored and old check results are not cleared.
*
* @param xmlReporter a xml reporter
* @param pdfReporter a pdf reporter
* @param co the city object to be checked
*/
public void checkFeature(XmlStreamReporter xmlReporter, PdfStreamReporter pdfReporter, CityObject co) {
if (logger.isDebugEnabled()) {
logger.debug(Localization.getText("Checker.checkFeature"), co);
......
......@@ -59,7 +59,7 @@ public class ValidationConfiguration implements Serializable {
private static final Logger logger = LogManager.getLogger(ValidationConfiguration.class);
private Map<String, String> globalParameters;
private Map<String, String> globalParameters = new HashMap<>();
private boolean xmlValidation = false;
private boolean useStreaming = false;
private FilterConfiguration filter;
......@@ -91,12 +91,14 @@ public class ValidationConfiguration implements Serializable {
config.requirements.put(req.getId(), reqConfig);
}
}
config.globalParameters = new HashMap<>();
config.globalParameters.put(GlobalParameters.NUMBER_OF_ROUNDING_PLACES, NUMBER_OF_ROUNDING_PLACES_DEFAULT);
config.globalParameters.put(GlobalParameters.MIN_VERTEX_DISTANCE, MIN_VERTEX_DISTANCE_DEFAULT);
config.setSchematronFilePathInGlobalParameters(CHECK_FOR_SOLID_XML);
return config;
}
private ValidationConfiguration() {
}
public void saveAs(File f) throws IOException {
DumperOptions options = new DumperOptions();
......@@ -142,9 +144,6 @@ public class ValidationConfiguration implements Serializable {
}
public Map<String, String> getGlobalParameters() {
if (globalParameters == null) {
globalParameters = new HashMap<>();
}
return globalParameters;
}
......
......@@ -96,7 +96,6 @@ public class DuplicatePointsCheck extends Check {
Vertex point2 = pointList.get(i + 1);
if (point1.equalsWithEpsilon(point2, epsilon)) {
// consecutive points same
System.out.println(point1.getDistance(point2));
CheckError err = new ConsecutivePointSameError(lr, point1, point2);
CheckResult cr = new CheckResult(this, ResultStatus.ERROR, err);
lr.addCheckResult(cr);
......
......@@ -21,7 +21,6 @@ package de.hft.stuttgart.citydoctor2.checks.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringJoiner;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -47,8 +46,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.edge.MeshSurface;
import de.hft.stuttgart.citydoctor2.edge.MeshSurfaceUtils;
import de.hft.stuttgart.citydoctor2.edge.PolyLine;
import de.hft.stuttgart.citydoctor2.edge.PolyLineSegment;
import de.hft.stuttgart.citydoctor2.edge.PolygonPolygonIntersection;
import de.hft.stuttgart.citydoctor2.math.MovedPolygon;
import de.hft.stuttgart.citydoctor2.math.MovedRing;
......@@ -98,54 +95,24 @@ public class SelfIntersectionUtil {
List<PolygonPolygonIntersection> selfIntersects = MeshSurfaceUtils.selfIntersects(meshSurface, 0.000001, 0.001);
if (!selfIntersects.isEmpty()) {
PolygonPolygonIntersection polygonPolygonIntersection = selfIntersects.get(0);
// DebugUtils.printGeoknechtPolygon(polygonPolygonIntersection.getPolygon1(), polygonPolygonIntersection.getPolygon2());
Polygon p1 = polygonPolygonIntersection.getPolygon1().getOriginal();
Polygon p2 = polygonPolygonIntersection.getPolygon2().getOriginal();
System.out.println();
for (Vertex v : p1.getExteriorRing().getVertices()) {
System.out.println(v);
}
System.out.println();
for (Vertex v : p2.getExteriorRing().getVertices()) {
System.out.println(v);
}
de.hft.stuttgart.citydoctor2.edge.IntersectionType intersectionType = polygonPolygonIntersection.getIntersectionType();
System.out.println(intersectionType);
PolyLine polyLine = polygonPolygonIntersection.getPolyLine();
PolyLineSegment firstSegment = polyLine.getFirstSegment();
PolyLineSegment next = firstSegment.getNext();
System.out.println(firstSegment.getStart());
while (firstSegment != next && next != null) {
System.out.println(next.getStart());
next = next.getNext();
}
// DebugUtils.printPolygon3d(polygonPolygonIntersection.getPolygon1(), polygonPolygonIntersection.getPolygon2());
Vertex movedBy = p1.getExteriorRing().getVertices().get(0);
MovedPolygon movedPolygon = MovedPolygon.ofPolygon(p1, movedBy);
MovedPolygon movedPolygon2 = MovedPolygon.ofPolygon(p2, p1.getExteriorRing().getVertices().get(0));
StringJoiner sj = new StringJoiner(" ", "polygon(", ")");
for (Vector3d v : movedPolygon.getExteriorRing().getVertices()) {
StringJoiner sj2 = new StringJoiner("|");
sj2.add("" + v.getX());
sj2.add("" + v.getY());
sj2.add("" + v.getZ());
sj.add(sj2.toString());
}
System.out.println(sj);
sj = new StringJoiner(" ", "polygon(", ")");
for (Vector3d v : movedPolygon2.getExteriorRing().getVertices()) {
StringJoiner sj2 = new StringJoiner("|");
sj2.add("" + v.getX());
sj2.add("" + v.getY());
sj2.add("" + v.getZ());
sj.add(sj2.toString());
}
System.out.println(sj);
// int counter = 0;
// for (Vertex v : p1.getExteriorRing().getVertices()) {
// System.out.println("Vertex v" + counter + " = new Vertex(" + v.getX() + ", " + v.getY() + ", " + v.getZ());
// counter++;
// }
// System.out.println();
// counter = 0;
// for (Vertex v : p2.getExteriorRing().getVertices()) {
// System.out.println("Vertex v" + counter + " = new Vertex(" + v.getX() + ", " + v.getY() + ", " + v.getZ());
// counter++;
// }
// DebugUtils.printPolygon3d(polygonPolygonIntersection.getPolygon1());
// DebugUtils.printPolygon3d(polygonPolygonIntersection.getPolygon1(), polygonPolygonIntersection.getPolygon2());
// System.out.println();
// DebugUtils.printPolygon3d(polygonPolygonIntersection.getPolygon2());
intersections.add(PolygonIntersection.lines(Collections.emptyList(), p1, p2));
......
......@@ -22,6 +22,8 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
......@@ -83,7 +85,7 @@ public class PdfReport {
static final Namespace FO_NS = Namespace.getNamespace("fo", "http://www.w3.org/1999/XSL/Format");
static final Namespace SVG_NS = Namespace.getNamespace("svg", "http://www.w3.org/2000/svg");
private static final String COPY_RIGHT = "Copyright (c) 2020 HFT Stuttgart. All rights reserved."
private static final String COPY_RIGHT = "Copyright (c) 2021 HFT Stuttgart. All rights reserved."
+ " HFT Stuttgart and its licensors retain all intellectual property"
+ " and proprietary rights in and to this software and related documentation."
+ " Any use, reproduction, disclosure, or distribution of this software and"
......@@ -97,12 +99,14 @@ public class PdfReport {
private List<Section> sections;
private Element externalPicture;
static {
URI uri = new File(".").toURI();
FOP_FACTORY = FopFactory.newInstance(uri);
}
public PdfReport(String logoPath) {
public PdfReport() {
doc = new Document();
sections = new ArrayList<>();
Element root = new Element("root", FO_NS);
......@@ -110,7 +114,7 @@ public class PdfReport {
root.addNamespaceDeclaration(FO_NS);
createLayout(root);
writeFrontPage(root, logoPath);
writeFrontPage(root);
writeTableOfContent(root);
createHeaderAndFooter(root);
......@@ -163,9 +167,23 @@ public class PdfReport {
}
}
}
File tempFile = null;
try {
// write logo file into temp dir
tempFile = File.createTempFile("logo", ".png");
Files.copy(getClass().getResourceAsStream("/Logo.png"), tempFile.toPath(),
StandardCopyOption.REPLACE_EXISTING);
externalPicture.setAttribute("src", tempFile.toURI().toASCIIString());
} catch (IOException e) {
logger.warn("Could not write logo into temporary file. Report won't contain the CityDoctor logo", e);
if (tempFile != null) {
tempFile.delete();
}
}
try {
FOUserAgent userAgent = FOP_FACTORY.newFOUserAgent();
userAgent.setDocumentHandlerOverride(null);
userAgent.getEventBroadcaster().addEventListener(event -> {
EventSeverity severity = event.getSeverity();
String msg = EventFormatter.format(event);
......@@ -183,7 +201,7 @@ public class PdfReport {
TransformerFactory factory = TransformerFactory.newInstance();
// deactivate external dtds because of security issues
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// identity transformer
Transformer transformer = factory.newTransformer();
......@@ -194,6 +212,10 @@ public class PdfReport {
outFile.flush();
} catch (FOPException | JDOMException | TransformerException | IOException e) {
throw new CheckReportWriteException(e);
} finally {
if (tempFile != null) {
tempFile.delete();
}
}
}
......@@ -244,7 +266,7 @@ public class PdfReport {
title.addContent("Table of Contents");
}
private void writeFrontPage(Element root, String logoPath) {
private void writeFrontPage(Element root) {
Element pageSequence = new Element(PAGE_SEQUENCE, FO_NS);
root.addContent(pageSequence);
pageSequence.setAttribute(MASTER_REFERENCE, FRONT_PAGE);
......@@ -262,9 +284,8 @@ public class PdfReport {
Element blockPicture = new Element(BLOCK, FO_NS);
frontPageFlow.addContent(blockPicture);
blockPicture.setAttribute(TEXT_ALIGN, CENTER);
Element externalPicture = new Element("external-graphic", FO_NS);
externalPicture = new Element("external-graphic", FO_NS);
blockPicture.addContent(externalPicture);
externalPicture.setAttribute("src", logoPath);
fileElement = new Element(BLOCK, FO_NS);
frontPageFlow.addContent(fileElement);
......
......@@ -113,7 +113,7 @@ public class PdfStreamReporter implements StreamReporter {
this.config = config;
errorStatistics = new HashMap<>();
outFile = pdfOutputFile;
report = new PdfReport(logoPath);
report = new PdfReport();
report.writeSourceFileName(fileName);
writeEnvironment();
......
......@@ -18,13 +18,21 @@
*/
package de.hft.stuttgart.citydoctor2.checks.geometry;
import static org.junit.Assert.assertFalse;
import org.junit.Assert;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.Checker;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.checks.util.GeometryTestUtils;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
/**
*
......@@ -54,5 +62,15 @@ public class SolidSelfIntCheckTest {
Assert.assertNotNull(cr);
Assert.assertEquals(ResultStatus.ERROR, cr.getResultStatus());
}
@Test
public void testSolidSelfIntTest1() throws CityGmlParseException, InvalidGmlFileException {
ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig();
config.setSchematronFilePathInGlobalParameters(null);
CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest1.gml", config.getParserConfiguration());
Checker c = new Checker(config, m);
c.runChecks();
assertFalse(m.getBuildings().get(0).containsAnyError());
}
}
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