Commit 8bafe709 authored by Matthias Betz's avatar Matthias Betz
Browse files

Added citygml4j quality ade integration

Removed produce consumer from stream reading
Added -out parameter to validation streams for writing quality ade stuff
parent b0bdd91b
Pipeline #1910 failed with stage
in 38 seconds
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.quality.model.InnerRingsNested;
import de.hft.stuttgart.quality.model.ValidationError;
public class NestedRingErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
LinearRing r2 = new LinearRing(LinearRingType.INTERIOR);
GmlId r2Id = new GmlId("r2Id");
r2.setGmlId(r2Id);
NestedRingError err = new NestedRingError(p1, r1, r2);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
InnerRingsNested validationError = (InnerRingsNested) optional.get();
assertEquals(p1Id.getGmlString(), validationError.getPolygonId());
assertEquals(r1Id.getGmlString(), validationError.getLinearRingId1());
assertEquals(r2Id.getGmlString(), validationError.getLinearRingId2());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.NonManifoldEdge;
import de.hft.stuttgart.quality.model.ValidationError;
public class NonManifoldEdgeErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
Vertex v1 = new Vertex(1, 2, 3);
Vertex v2 = new Vertex(4, 5, 6);
Vertex v3 = new Vertex(7, 8, 9);
Edge e1 = new Edge(v1, v2);
Edge e2 = new Edge(v2, v3);
List<Edge> edges = new ArrayList<>();
edges.add(e1);
edges.add(e2);
NonManifoldEdgeError err = new NonManifoldEdgeError(geom, edges);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
NonManifoldEdge validationError = (NonManifoldEdge) optional.get();
assertEquals(geomId.getGmlString(), validationError.getGeometryId());
List<de.hft.stuttgart.quality.model.Edge> adeEdges = validationError.getEdges();
de.hft.stuttgart.quality.model.Edge adeE1 = adeEdges.get(0);
de.hft.stuttgart.quality.model.Edge adeE2 = adeEdges.get(1);
assertEquals(1, adeE1.getFrom().getValue().get(0), 0.00001);
assertEquals(4, adeE1.getTo().getValue().get(0), 0.00001);
assertEquals(7, adeE2.getTo().getValue().get(0), 0.00001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.NonManifoldVertex;
import de.hft.stuttgart.quality.model.ValidationError;
public class NonManifoldVertexErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
Polygon p2 = new ConcretePolygon();
GmlId p2Id = new GmlId("p2Id");
p2.setGmlId(p2Id);
Polygon p3 = new ConcretePolygon();
GmlId p3Id = new GmlId("p3Id");
p3.setGmlId(p3Id);
List<List<Polygon>> components = new ArrayList<>();
List<Polygon> component1 = new ArrayList<>();
component1.add(p1);
component1.add(p2);
components.add(component1);
List<Polygon> component2 = new ArrayList<>();
component2.add(p3);
components.add(component2);
Vertex v1 = new Vertex(1, 2, 3);
NonManifoldVertexError err = new NonManifoldVertexError(geom, components, v1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
NonManifoldVertex validationError = (NonManifoldVertex) optional.get();
assertEquals(geomId.getGmlString(), validationError.getGeometryId());
assertEquals(1, validationError.getVertex().getValue().get(0), 0.0001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.NonPlanarDistancePlane;
import de.hft.stuttgart.quality.model.ValidationError;
public class NonPlanarPolygonDistancePlaneErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
Vertex v = new Vertex(1, 2, 3);
NonPlanarPolygonDistancePlaneError err = new NonPlanarPolygonDistancePlaneError(p1, 5, v, null);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
NonPlanarDistancePlane error = (NonPlanarDistancePlane) optional.get();
assertEquals(p1Id.getGmlString(), error.getPolygonId());
assertEquals(1, error.getVertex().getValue().get(0), 0.00001);
assertEquals(5, error.getDistance().getValue(), 0.000001);
}
}
\ No newline at end of file
/*-
* 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.check.error;
import static org.junit.Assert.*;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.quality.model.NonPlanarNormalsDeviation;
import de.hft.stuttgart.quality.model.ValidationError;
public class NonPlanarPolygonNormalsDeviationTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
NonPlanarPolygonNormalsDeviation err = new NonPlanarPolygonNormalsDeviation(p1, 5);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
NonPlanarNormalsDeviation error = (NonPlanarNormalsDeviation) optional.get();
assertEquals(5, error.getDeviation().getValue(), 0.00001);
assertEquals(p1Id.getGmlString(), error.getPolygonId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
public class PointTouchesEdgeErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
GmlId id = new GmlId("id");
lr.setGmlId(id);
Vertex v1 = new Vertex(1, 2, 3);
Vertex v2 = new Vertex(4, 5, 6);
Edge e1 = new Edge(v1, v2);
PointTouchesEdgeError err = new PointTouchesEdgeError(lr, e1, v1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
RingSelfIntersection error = (RingSelfIntersection) optional.get();
assertEquals(id.getGmlString(), error.getLinearRingId());
assertEquals(1, error.getVertex1().getValue().get(0), 0.00001);
assertEquals(1, error.getEdge1().getFrom().getValue().get(0), 0.000001);
assertEquals(4, error.getEdge1().getTo().getValue().get(0), 0.000001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.quality.model.HoleOutside;
import de.hft.stuttgart.quality.model.ValidationError;
public class PolygonHoleOutsideErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
List<LinearRing> rings = new ArrayList<>();
rings.add(r1);
PolygonHoleOutsideError err = new PolygonHoleOutsideError(p1, rings);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
HoleOutside validationError = (HoleOutside) optional.get();
assertEquals(p1Id.getGmlString(), validationError.getPolygonId());
assertEquals(r1Id.getGmlString(), validationError.getLinearRingId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.quality.model.InteriorDisconnected;
import de.hft.stuttgart.quality.model.ValidationError;
public class PolygonInteriorDisconnectedErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
PolygonInteriorDisconnectedError err = new PolygonInteriorDisconnectedError(p1, null);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
InteriorDisconnected adeErr = (InteriorDisconnected) optional.get();
assertEquals(p1Id.getGmlString(), adeErr.getPolygonId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.*;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import de.hft.stuttgart.quality.model.IntersectingRings;
import de.hft.stuttgart.quality.model.ValidationError;
public class PolygonIntersectingRingsErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
LinearRing r2 = new LinearRing(LinearRingType.INTERIOR);
GmlId r2Id = new GmlId("r2Id");
r2.setGmlId(r2Id);
SerializablePair<LinearRing, LinearRing> pair = new SerializablePair<>(r1, r2);
PolygonIntersectingRingsError err = new PolygonIntersectingRingsError(p1, pair);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
IntersectingRings error = (IntersectingRings) optional.get();
assertEquals(p1Id.getGmlString(), error.getPolygonId());
assertEquals(r1Id.getGmlString(), error.getLinearRingId1());
assertEquals(r2Id.getGmlString(), error.getLinearRingId2());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.quality.model.OrientationRingsSame;
import de.hft.stuttgart.quality.model.ValidationError;
public class PolygonSameOrientationErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
PolygonSameOrientationError err = new PolygonSameOrientationError(p1, r1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
OrientationRingsSame adeErr = (OrientationRingsSame) optional.get();
assertEquals(p1Id.getGmlString(), adeErr.getPolygonId());
assertEquals(r1Id.getGmlString(), adeErr.getLinearRingId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.PolygonWrongOrientation;
import de.hft.stuttgart.quality.model.ValidationError;
public class PolygonWrongOrientationErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
Vertex v1 = new Vertex(1, 2, 3);
Vertex v2 = new Vertex(4, 5, 6);
Vertex v3 = new Vertex(7, 8, 9);
Edge e1 = new Edge(v1, v2);
Edge e2 = new Edge(v2, v3);
List<Edge> edges = new ArrayList<>();
edges.add(e1);
edges.add(e2);
PolygonWrongOrientationError err = new PolygonWrongOrientationError(geom, edges);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
PolygonWrongOrientation adeErr = (PolygonWrongOrientation) optional.get();
assertEquals(geomId.getGmlString(), adeErr.getGeometryId());
List<de.hft.stuttgart.quality.model.Edge> adeEdges = adeErr.getEdges();
de.hft.stuttgart.quality.model.Edge adeE1 = adeEdges.get(0);
de.hft.stuttgart.quality.model.Edge adeE2 = adeEdges.get(1);
assertEquals(1, adeE1.getFrom().getValue().get(0), 0.00001);
assertEquals(4, adeE1.getTo().getValue().get(0), 0.00001);
assertEquals(7, adeE2.getTo().getValue().get(0), 0.00001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
public class RingDuplicatePointErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
GmlId id = new GmlId("id");
lr.setGmlId(id);
Vertex p1 = new Vertex(1, 2, 3);
Vertex p2 = new Vertex(4, 5, 6);
RingDuplicatePointError err = new RingDuplicatePointError(lr, p1, p2);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
RingSelfIntersection adeErr = (RingSelfIntersection) optional.get();
assertEquals(id.getGmlString(), adeErr.getLinearRingId());
assertEquals(1, adeErr.getVertex1().getValue().get(0), 0.00001);
assertEquals(4, adeErr.getVertex2().getValue().get(0), 0.00001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.*;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
public class RingEdgeIntersectionErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
LinearRing lr = new LinearRing(LinearRingType.EXTERIOR);
GmlId id = new GmlId("id");
lr.setGmlId(id);
Vertex v1 = new Vertex(1, 2, 3);
Vertex v2 = new Vertex(4, 5, 6);
Vertex v3 = new Vertex(7, 8, 9);
Edge e1 = new Edge(v1, v2);
Edge e2 = new Edge(v2, v3);
RingEdgeIntersectionError err = new RingEdgeIntersectionError(lr, e1, e2, v1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
RingSelfIntersection adeErr = (RingSelfIntersection) optional.get();
assertEquals(id.getGmlString(), adeErr.getLinearRingId());
assertEquals(1, adeErr.getEdge1().getFrom().getValue().get(0), 0.00001);
assertEquals(4, adeErr.getEdge1().getTo().getValue().get(0), 0.00001);
assertEquals(4, adeErr.getEdge2().getFrom().getValue().get(0), 0.00001);
assertEquals(7, adeErr.getEdge2().getTo().getValue().get(0), 0.00001);
assertEquals(1, adeErr.getVertex1().getValue().get(0), 0.00001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.*;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.quality.model.RingNotClosed;
import de.hft.stuttgart.quality.model.ValidationError;
public class RingNotClosedErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
RingNotClosedError err = new RingNotClosedError(r1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
RingNotClosed adeErr = (RingNotClosed) optional.get();
assertEquals(r1Id.getGmlString(), adeErr.getLinearRingId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.quality.model.TooFewPoints;
import de.hft.stuttgart.quality.model.ValidationError;
public class RingTooFewPointsErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
LinearRing r1 = new LinearRing(LinearRingType.INTERIOR);
GmlId r1Id = new GmlId("r1Id");
r1.setGmlId(r1Id);
RingTooFewPointsError err = new RingTooFewPointsError(r1);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
TooFewPoints adeErr = (TooFewPoints) optional.get();
assertEquals(r1Id.getGmlString(), adeErr.getLinearRingId());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.quality.model.SolidNotClosed;
import de.hft.stuttgart.quality.model.ValidationError;
public class SolidNotClosedErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
Vertex v1 = new Vertex(1, 2, 3);
Vertex v2 = new Vertex(4, 5, 6);
Vertex v3 = new Vertex(7, 8, 9);
Edge e1 = new Edge(v1, v2);
Edge e2 = new Edge(v2, v3);
List<Edge> edges = new ArrayList<>();
edges.add(e1);
edges.add(e2);
SolidNotClosedError err = new SolidNotClosedError(geom, edges);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
SolidNotClosed validationError = (SolidNotClosed) optional.get();
assertEquals(geomId.getGmlString(), validationError.getGeometryId());
List<de.hft.stuttgart.quality.model.Edge> adeEdges = validationError.getEdges();
de.hft.stuttgart.quality.model.Edge adeE1 = adeEdges.get(0);
de.hft.stuttgart.quality.model.Edge adeE2 = adeEdges.get(1);
assertEquals(1, adeE1.getFrom().getValue().get(0), 0.00001);
assertEquals(4, adeE1.getTo().getValue().get(0), 0.00001);
assertEquals(7, adeE2.getTo().getValue().get(0), 0.00001);
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.ValidationError;
public class SolidSelfIntErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
Polygon p1 = new ConcretePolygon();
GmlId p1Id = new GmlId("p1Id");
p1.setGmlId(p1Id);
Polygon p2 = new ConcretePolygon();
GmlId p2Id = new GmlId("p2Id");
p2.setGmlId(p2Id);
PolygonIntersection inter = PolygonIntersection.lines(null, p1, p2);
List<PolygonIntersection> intersections = new ArrayList<>();
intersections.add(inter);
SolidSelfIntError err = new SolidSelfIntError(geom, intersections);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
SolidSelfIntersection adeErr = (SolidSelfIntersection) optional.get();
assertEquals(geomId.getGmlString(), adeErr.getGeometryId());
assertEquals(p1Id.getGmlString(), adeErr.getPolygonId1());
assertEquals(p2Id.getGmlString(), adeErr.getPolygonId2());
}
}
/*-
* 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.check.error;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.ValidationError;
public class TooFewPolygonsErrorTest {
@Test
public void testConvertToQualityAdeDatastructure() {
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
GmlId geomId = new GmlId("geomId");
geom.setGmlId(geomId);
TooFewPolygonsError err = new TooFewPolygonsError(geom);
Optional<ValidationError> optional = err.convertToQualityAdeDatastructure();
assertTrue(optional.isPresent());
TooFewPolygons adeErr = (TooFewPolygons) optional.get();
assertEquals(geomId.getGmlString(), adeErr.getGeometryId());
}
}
...@@ -25,13 +25,14 @@ import java.util.List; ...@@ -25,13 +25,14 @@ 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.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.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.ParserConfiguration;
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;
...@@ -55,23 +56,42 @@ public class CityDoctorValidation { ...@@ -55,23 +56,42 @@ public class CityDoctorValidation {
* parameters happens here, then the validation process is called. * parameters happens here, then the validation process is called.
* *
* @param args command line parameters * @param args command line parameters
* @throws InterruptedException When the reading thread gets interrupted.
* @throws IOException When an exception while writing the report * @throws IOException When an exception while writing the report
* files happens. * files happens.
* @throws CityGmlParseException When an error while parsing the cityGML file * @throws CityGmlParseException When an error while parsing the cityGML file
* 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 CityGMLBuilderException
*/ */
public static void main(String[] args) public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException {
throws CityGmlParseException, IOException, InterruptedException, InvalidGmlFileException {
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);
String pdfOutput = getPdfOutput(argParser); String pdfOutput = getPdfOutput(argParser);
String outputFile = getOutputFile(argParser, true);
ValidationConfiguration config = getValidationConfig(argParser); ValidationConfiguration config = getValidationConfig(argParser);
startValidationProcess(inputFile, xmlOutput, pdfOutput, config); startValidationProcess(new File(inputFile), xmlOutput, pdfOutput, config, outputFile);
}
private static String getOutputFile(ArgumentParser argParser, boolean optional) {
String outputFile;
if (!argParser.containsOption("out")) {
if (optional) {
return null;
}
logger.error("No output file specified. (-out [FILE])");
System.exit(11);
}
List<String> outFiles = argParser.getValues("out");
if (outFiles.size() != 1) {
logger.error("Specify exactly one file as output.");
System.exit(12);
}
outputFile = outFiles.get(0);
return outputFile;
} }
/** /**
...@@ -89,7 +109,7 @@ public class CityDoctorValidation { ...@@ -89,7 +109,7 @@ public class CityDoctorValidation {
* the cityGML schema. * the cityGML schema.
*/ */
public static void validate(File inputFile, File xmlOutput, File pdfOutput) public static void validate(File inputFile, File xmlOutput, File pdfOutput)
throws InterruptedException, IOException, CityGmlParseException, InvalidGmlFileException { throws IOException, CityGmlParseException, InvalidGmlFileException {
validate(inputFile, xmlOutput, pdfOutput, null); validate(inputFile, xmlOutput, pdfOutput, null);
} }
...@@ -100,7 +120,6 @@ public class CityDoctorValidation { ...@@ -100,7 +120,6 @@ public class CityDoctorValidation {
* @param xmlOutput The XML report file location. Can be null. * @param xmlOutput The XML report file location. Can be null.
* @param pdfOutput The PDF report file location. Can be null. * @param pdfOutput The PDF report file location. Can be null.
* @param validationConfigFile The validation configuration file location. * @param validationConfigFile The validation configuration file location.
* @throws InterruptedException When the reading thread gets interrupted.
* @throws IOException When an exception while writing the report * @throws IOException When an exception while writing the report
* files happens. * files happens.
* @throws CityGmlParseException When an error while parsing the cityGML file * @throws CityGmlParseException When an error while parsing the cityGML file
...@@ -109,7 +128,7 @@ public class CityDoctorValidation { ...@@ -109,7 +128,7 @@ public class CityDoctorValidation {
* the cityGML schema. * the cityGML schema.
*/ */
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 InterruptedException, IOException, CityGmlParseException, InvalidGmlFileException { throws IOException, CityGmlParseException, InvalidGmlFileException {
ValidationConfiguration config; ValidationConfiguration config;
if (validationConfigFile == null) { if (validationConfigFile == null) {
config = ValidationConfiguration.loadStandardValidationConfig(); config = ValidationConfiguration.loadStandardValidationConfig();
...@@ -125,20 +144,43 @@ public class CityDoctorValidation { ...@@ -125,20 +144,43 @@ public class CityDoctorValidation {
if (pdfOutput != null) { if (pdfOutput != null) {
pdfOutputPath = pdfOutput.getAbsolutePath(); pdfOutputPath = pdfOutput.getAbsolutePath();
} }
startValidationProcess(inputFile.getAbsolutePath(), xmlOutputPath, pdfOutputPath, config); try {
startValidationProcess(inputFile, xmlOutputPath, pdfOutputPath, config, null);
} catch (CityGMLBuilderException | CityGMLWriteException e) {
// this does not happen as no output file is specified
logger.catching(e);
}
} }
public static void startValidationProcess(String inputFile, String xmlOutput, String pdfOutput, /**
ValidationConfiguration config) * This function will handle the complete validation process
throws InterruptedException, IOException, CityGmlParseException, InvalidGmlFileException { *
ParserConfiguration parserConfig = config.getParserConfiguration(); * @param inputFile the gml file path that is going to be checked
* @param xmlOutput the output path for the xml report (optional)
* @param pdfOutput the output path for the pdf report (optional)
* @param config the configuration path for the validation plan
* @param outputFile storing the validated gml file with quality ade
* @throws IOException
* @throws CityGmlParseException
* @throws InvalidGmlFileException
* @throws CityGMLWriteException if something goes wrong while writing the gml
* file
* @throws CityGMLBuilderException
*/
public static void startValidationProcess(File inputFile, String xmlOutput, String pdfOutput,
ValidationConfiguration config, String outputFile) throws IOException, CityGmlParseException,
InvalidGmlFileException, CityGMLBuilderException, CityGMLWriteException {
if (config.isUseStreaming()) { if (config.isUseStreaming()) {
Checker.streamCheck(CityGmlParser.streamCityGml(inputFile, parserConfig), xmlOutput, pdfOutput, config); Checker.streamCheck(inputFile, xmlOutput, pdfOutput, config, outputFile);
} else { } else {
CityDoctorModel model = CityGmlParser.parseCityGmlFile(inputFile, parserConfig); CityDoctorModel model = CityGmlParser.parseCityGmlFile(inputFile.getAbsolutePath(),
config.getParserConfiguration());
Checker c = new Checker(config, model); Checker c = new Checker(config, model);
c.runChecks(xmlOutput, pdfOutput, null); c.runChecks(xmlOutput, pdfOutput, null);
if (outputFile != null) {
model.saveAs(outputFile);
}
} }
} }
...@@ -170,7 +212,8 @@ public class CityDoctorValidation { ...@@ -170,7 +212,8 @@ public class CityDoctorValidation {
return getValidationConfig(argParser, true); return getValidationConfig(argParser, true);
} }
public static ValidationConfiguration getValidationConfig(ArgumentParser argParser, boolean optional) throws FileNotFoundException { public static ValidationConfiguration getValidationConfig(ArgumentParser argParser, boolean optional)
throws FileNotFoundException {
if (argParser.containsOption("config")) { if (argParser.containsOption("config")) {
List<String> configFiles = argParser.getValues("config"); List<String> configFiles = argParser.getValues("config");
if (configFiles.size() != 1) { if (configFiles.size() != 1) {
......
...@@ -23,6 +23,7 @@ import java.io.File; ...@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
...@@ -32,6 +33,7 @@ import java.util.List; ...@@ -32,6 +33,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
...@@ -45,19 +47,30 @@ import javax.xml.transform.stream.StreamSource; ...@@ -45,19 +47,30 @@ import javax.xml.transform.stream.StreamSource;
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.model.citygml.core.CityModel;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError; import de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError; import de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError;
import de.hft.stuttgart.citydoctor2.check.error.SchematronError; import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException; import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException;
import de.hft.stuttgart.citydoctor2.checks.CheckPrototype;
import de.hft.stuttgart.citydoctor2.checks.Checks; import de.hft.stuttgart.citydoctor2.checks.Checks;
import de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler; import de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler;
import de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener; import de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
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.datastructure.CityObject; import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.FeatureType; import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
import de.hft.stuttgart.citydoctor2.parser.FeatureStream; import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.parser.CityGmlConsumer;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.parser.ProgressListener; import de.hft.stuttgart.citydoctor2.parser.ProgressListener;
import de.hft.stuttgart.citydoctor2.reporting.Reporter; import de.hft.stuttgart.citydoctor2.reporting.Reporter;
...@@ -67,6 +80,17 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlValidationReporter; ...@@ -67,6 +80,17 @@ 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.citydoctor2.utils.QualityADEUtils;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.jaxb.Checking;
import de.hft.stuttgart.quality.model.jaxb.ErrorStatistics;
import de.hft.stuttgart.quality.model.jaxb.FeatureStatistics;
import de.hft.stuttgart.quality.model.jaxb.Parameter;
import de.hft.stuttgart.quality.model.jaxb.Requirement;
import de.hft.stuttgart.quality.model.jaxb.RequirementId;
import de.hft.stuttgart.quality.model.jaxb.Statistics;
import de.hft.stuttgart.quality.model.jaxb.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.jaxb.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;
...@@ -93,8 +117,6 @@ public class Checker { ...@@ -93,8 +117,6 @@ public class Checker {
private List<Filter> includeFilters; private List<Filter> includeFilters;
private List<Filter> excludeFilters; private List<Filter> excludeFilters;
private boolean isValidated = false;
private Checks checkConfig; private Checks checkConfig;
private CityDoctorModel model; private CityDoctorModel model;
...@@ -124,11 +146,11 @@ public class Checker { ...@@ -124,11 +146,11 @@ public class Checker {
* @param model the model for which the report is written. * @param model the model for which the report is written.
*/ */
public void writeXmlReport(String xmlOutput) { public void writeXmlReport(String xmlOutput) {
if (!isValidated || xmlOutput == null) { if (!model.isValidated() || xmlOutput == null) {
return; return;
} }
File xmlFile = new File(xmlOutput); File xmlFile = new File(xmlOutput);
if (xmlFile.getParentFile() != null) { if (xmlFile.getParentFile() == null) {
xmlFile.getParentFile().mkdirs(); xmlFile.getParentFile().mkdirs();
} }
Reporter reporter = new XmlValidationReporter(); Reporter reporter = new XmlValidationReporter();
...@@ -140,11 +162,11 @@ public class Checker { ...@@ -140,11 +162,11 @@ public class Checker {
} }
public void writePdfReport(String pdfOutput) { public void writePdfReport(String pdfOutput) {
if (!isValidated || pdfOutput == null) { if (!model.isValidated() || pdfOutput == null) {
return; return;
} }
File pdfFile = new File(pdfOutput); File pdfFile = new File(pdfOutput);
if (pdfFile.getParentFile() != null) { if (pdfFile.getParentFile() == null) {
pdfFile.getParentFile().mkdirs(); pdfFile.getParentFile().mkdirs();
} }
Reporter reporter = new PdfReporter("assets/Logo.png"); Reporter reporter = new PdfReporter("assets/Logo.png");
...@@ -186,6 +208,12 @@ public class Checker { ...@@ -186,6 +208,12 @@ public class Checker {
} }
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, model.getFile()); SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, model.getFile());
if (handler != null) { if (handler != null) {
handleSchematronResults(handler);
}
model.setValidated(createValidationPlan());
}
private void handleSchematronResults(SvrlContentHandler handler) {
model.addGlobalErrors(handler.getGeneralErrors()); model.addGlobalErrors(handler.getGeneralErrors());
Map<String, CityObject> featureMap = new HashMap<>(); Map<String, CityObject> featureMap = new HashMap<>();
model.createFeatureStream().forEach(f -> featureMap.put(f.getGmlId().getGmlString(), f)); model.createFeatureStream().forEach(f -> featureMap.put(f.getGmlId().getGmlString(), f));
...@@ -201,15 +229,19 @@ public class Checker { ...@@ -201,15 +229,19 @@ public class Checker {
model.addGlobalError(se); model.addGlobalError(se);
} }
} else { } else {
handleSchematronErrorsForCityObject(v, co);
}
});
}
private static void handleSchematronErrorsForCityObject(List<SchematronError> v, CityObject co) {
int count = 0; int count = 0;
for (SchematronError se : v) { for (SchematronError se : v) {
CheckError err; CheckError err;
if (AttributeMissingError.ID.getIdString().equals(se.getErrorIdString())) { if (AttributeMissingError.ID.getIdString().equals(se.getErrorIdString())) {
err = new AttributeMissingError(co, se.getChildId(), se.getNameOfAttribute(), err = new AttributeMissingError(co, se.getChildId(), se.getNameOfAttribute(), se.isGeneric());
se.isGeneric());
} else if (AttributeValueWrongError.ID.getIdString().equals(se.getErrorIdString())) { } else if (AttributeValueWrongError.ID.getIdString().equals(se.getErrorIdString())) {
err = new AttributeValueWrongError(co, se.getChildId(), se.getNameOfAttribute(), err = new AttributeValueWrongError(co, se.getChildId(), se.getNameOfAttribute(), se.isGeneric());
se.isGeneric());
} else { } else {
throw new IllegalStateException( throw new IllegalStateException(
"Unknown error ID was given in schematron file: " + se.getErrorIdString()); "Unknown error ID was given in schematron file: " + se.getErrorIdString());
...@@ -218,9 +250,191 @@ public class Checker { ...@@ -218,9 +250,191 @@ public class Checker {
count++; count++;
} }
} }
});
private ValidationPlan createValidationPlan() {
ValidationPlan plan = new ValidationPlan();
List<Checking> filter = createFilter();
for (Entry<CheckId, CheckConfiguration> e : config.getChecks().entrySet()) {
RequirementId reqId = mapToRequirement(e.getKey());
if (reqId == null) {
continue;
}
Requirement req = new Requirement();
req.setName(reqId);
req.setEnabled(e.getValue().isEnabled());
plan.getRequirements().add(req);
CheckPrototype proto = Checks.getCheckPrototypeForId(e.getKey());
Map<String, String> parameters = e.getValue().getParameters();
if (parameters != null) {
for (Entry<String, String> param : parameters.entrySet()) {
Parameter p = new Parameter();
DefaultParameter defaultP = getDefaultParameter(param.getKey(), proto);
if (defaultP != null) {
p.setUom(defaultP.getUnitType().getGmlRepresentation());
}
p.setName(param.getKey());
p.setValue(param.getValue());
req.getParameters().add(p);
}
}
}
Requirement missing = new Requirement();
missing.setName(RequirementId.R_SEM_ATTRIBUTES_EXISTING);
Requirement correct = new Requirement();
correct.setName(RequirementId.R_SEM_ATTRIBUTES_CORRECT);
missing.setEnabled(config.getSchematronFilePath() != null);
correct.setEnabled(config.getSchematronFilePath() != null);
plan.getRequirements().add(missing);
plan.getRequirements().add(correct);
plan.getFilter().addAll(filter);
Parameter numRounding = new Parameter();
numRounding.setName("numberOfRoundingPlaces");
numRounding.setValue("" + config.getNumberOfRoundingPlaces());
Parameter minVertexDistance = new Parameter();
minVertexDistance.setName("minVertexDistance");
minVertexDistance.setUom("m");
minVertexDistance.setValue("" + config.getMinVertexDistance());
Parameter schematronFile = new Parameter();
schematronFile.setName("schematronFile");
schematronFile.setValue(config.getSchematronFilePath());
plan.getGlobalParameters().add(numRounding);
plan.getGlobalParameters().add(minVertexDistance);
plan.getGlobalParameters().add(schematronFile);
return plan;
}
private DefaultParameter getDefaultParameter(String key, CheckPrototype proto) {
for (DefaultParameter param : proto.getDefaultParameter()) {
if (param.getName().equals(key)) {
return param;
}
}
return null;
}
private List<Checking> createFilter() {
List<Checking> filter = new ArrayList<>();
handleInputFilter(filter);
if (excludeFilters != null) {
for (Filter f : excludeFilters) {
if (f instanceof TypeFilter) {
TypeFilter tf = (TypeFilter) f;
FeatureType type = tf.getType();
TopLevelFeatureType tlft = mapToTopLevelFeatureType(type);
if (tlft == null) {
continue;
}
removeFilter(tlft, filter);
}
}
}
return filter;
}
private void handleInputFilter(List<Checking> filter) {
if (includeFilters == null || includeFilters.isEmpty()) {
// no filter means, use all
addAllFilters(filter);
} else {
for (Filter f : includeFilters) {
if (f instanceof TypeFilter) {
TypeFilter tf = (TypeFilter) f;
FeatureType type = tf.getType();
TopLevelFeatureType tlft = mapToTopLevelFeatureType(type);
if (tlft == null) {
continue;
}
filter.add(new Checking(tlft));
}
}
if (filter.isEmpty()) {
// this happens if no type include filter was used
// it is possible only single objects were tested then
// so include everything
addAllFilters(filter);
}
}
}
private void addAllFilters(List<Checking> filter) {
filter.add(new Checking(TopLevelFeatureType.BUILDING));
filter.add(new Checking(TopLevelFeatureType.BRIDGE));
filter.add(new Checking(TopLevelFeatureType.LAND));
filter.add(new Checking(TopLevelFeatureType.TRANSPORTATION));
filter.add(new Checking(TopLevelFeatureType.VEGETATION));
filter.add(new Checking(TopLevelFeatureType.WATER));
}
private void removeFilter(TopLevelFeatureType tlft, List<Checking> filter) {
for (Checking c : filter) {
if (c.getValue().equals(tlft)) {
filter.remove(c);
return;
}
}
}
private TopLevelFeatureType mapToTopLevelFeatureType(FeatureType type) {
switch (type) {
case BRIDGE:
return TopLevelFeatureType.BRIDGE;
case BUILDING:
return TopLevelFeatureType.BUILDING;
case LAND:
return TopLevelFeatureType.LAND;
case TRANSPORTATION:
return TopLevelFeatureType.TRANSPORTATION;
case VEGETATION:
return TopLevelFeatureType.VEGETATION;
case WATER:
return TopLevelFeatureType.WATER;
default:
return null;
}
}
private RequirementId mapToRequirement(CheckId key) {
switch (key.getName()) {
case "C_GE_R_TOO_FEW_POINTS":
return RequirementId.R_GE_R_TOO_FEW_POINTS;
case "C_GE_R_NOT_CLOSED":
return RequirementId.R_GE_R_NOT_CLOSED;
case "C_GE_R_DUPLICATE_POINT":
return RequirementId.R_GE_R_CONSECUTIVE_POINTS_SAME;
case "C_GE_R_SELF_INTERSECTION":
return RequirementId.R_GE_R_SELF_INTERSECTION;
case "C_GE_P_INTERIOR_DISCONNECTED":
return RequirementId.R_GE_P_INTERIOR_DISCONNECTED;
case "C_GE_P_INTERSECTING_RINGS":
return RequirementId.R_GE_P_INTERSECTING_RINGS;
case "C_GE_P_NON_PLANAR":
return RequirementId.R_GE_P_NON_PLANAR;
case "C_GE_S_TOO_FEW_POLYGONS":
return RequirementId.R_GE_S_TOO_FEW_POLYGONS;
case "C_GE_S_NON_MANIFOLD_EDGE":
return RequirementId.R_GE_S_NON_MANIFOLD_EDGE;
case "C_GE_S_POLYGON_WRONG_ORIENTATION":
return RequirementId.R_GE_S_POLYGON_WRONG_ORIENTATION;
case "C_GE_S_ALL_POLYGONS_WRONG_ORIENTATION":
return RequirementId.R_GE_S_ALL_POLYGONS_WRONG_ORIENTATION;
case "C_GE_S_NON_MANIFOLD_VERTEX":
return RequirementId.R_GE_S_NON_MANIFOLD_VERTEX;
case "C_GE_S_SELF_INTERSECTION":
return RequirementId.R_GE_S_SELF_INTERSECTION;
case "C_GE_P_HOLE_OUTSIDE":
return RequirementId.R_GE_P_HOLE_OUTSIDE;
case "C_GE_P_INNER_RINGS_NESTED":
return RequirementId.R_GE_P_INNER_RINGS_NESTED;
case "C_GE_S_NOT_CLOSED":
return RequirementId.R_GE_S_NOT_CLOSED;
case "C_GE_S_MULTIPLE_CONNECTED_COMPONENTS":
return RequirementId.R_GE_S_MULTIPLE_CONNECTED_COMPONENTS;
default:
return null;
} }
isValidated = true;
} }
public ValidationConfiguration getConfig() { public ValidationConfiguration getConfig() {
...@@ -497,33 +711,110 @@ public class Checker { ...@@ -497,33 +711,110 @@ public class Checker {
return hasUnusedDependency; return hasUnusedDependency;
} }
public static void streamCheck(FeatureStream stream, String xmlOutput, String pdfOutput, public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config,
ValidationConfiguration config) throws InterruptedException, IOException { String outputFile) throws IOException, CityGmlParseException {
streamCheck(stream, xmlOutput, pdfOutput, config, "assets/Logo.png", null); streamCheck(inputFile, xmlOutput, pdfOutput, config, "assets/Logo.png", null, outputFile);
} }
public static void streamCheck(FeatureStream stream, String xmlOutput, String pdfOutput, public static void streamCheck(File inputFile, String xmlOutput, String pdfOutput, ValidationConfiguration config,
ValidationConfiguration config, String logoLocation, FeatureCheckedListener l) String logoLocation, FeatureCheckedListener l, String outputFile)
throws InterruptedException, IOException { throws IOException, CityGmlParseException {
Checker c = new Checker(config, null);
try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput); try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput);
BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) { BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) {
XmlStreamReporter xmlReporter = null; Checker c = new Checker(config, null);
if (xmlBos != null) { String fileName = inputFile.getName();
xmlReporter = new XmlStreamReporter(xmlBos, stream.getFileName(), config);
} // create reporter if available
PdfStreamReporter pdfReporter = null; XmlStreamReporter xmlReporter = getXmlReporter(config, xmlBos, fileName);
if (pdfBos != null) { PdfStreamReporter pdfReporter = getPdfReporter(config, logoLocation, pdfBos, fileName);
pdfReporter = new PdfStreamReporter(pdfBos, stream.getFileName(), config, logoLocation);
} // create quality ade structures
CityObject co = null; Validation val = new Validation();
while ((co = stream.next()) != null) { val.setValidationDate(ZonedDateTime.now());
val.setValidationSoftware("CityDoctor " + Localization.getText(Localization.VERSION));
Statistics statistics = new Statistics();
FeatureStatistics buildingStatistics = new FeatureStatistics();
statistics.setNumErrorBuildings(buildingStatistics);
FeatureStatistics bridgeStatistics = new FeatureStatistics();
statistics.setNumErrorBridgeObjects(bridgeStatistics);
FeatureStatistics transportationStatistics = new FeatureStatistics();
statistics.setNumErrorTransportation(transportationStatistics);
FeatureStatistics vegetationStatistics = new FeatureStatistics();
statistics.setNumErrorVegetation(vegetationStatistics);
FeatureStatistics landStatistics = new FeatureStatistics();
statistics.setNumErrorLandObjects(landStatistics);
FeatureStatistics waterStatistics = new FeatureStatistics();
statistics.setNumErrorWaterObjects(waterStatistics);
// map for counting individual error counts
Map<ErrorId, AtomicInteger> errorCount = new HashMap<>();
GMLGeometryFactory gmlFactory = new GMLGeometryFactory();
// execute schematron first
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, inputFile);
CityGmlConsumer con = new CityGmlConsumer() {
@Override
public void accept(CityObject co) {
c.checkFeature(xmlReporter, pdfReporter, co); c.checkFeature(xmlReporter, pdfReporter, co);
if (handler != null) {
List<SchematronError> errors = handler.getFeatureErrors().get(co.getGmlId().getGmlString());
if (errors != null) {
handleSchematronErrorsForCityObject(errors, co);
}
}
// remove existing quality ade datastructure if existing
QualityADEUtils.removeValidationResult(co);
// store quality ade datastructures in cityobject
QualityADEUtils.writeQualityAde(co);
// recreate geometry
co.reCreateGeometries(gmlFactory, config.getParserConfiguration());
// store result in statistics
applyToStatistics(buildingStatistics, bridgeStatistics, transportationStatistics,
vegetationStatistics, landStatistics, waterStatistics, co);
// add errors to statistics
List<CheckError> errorList = new ArrayList<>();
co.collectContainedErrors(errorList);
Set<CheckError> errors = new HashSet<>(errorList);
for (CheckError e : errors) {
errorCount.compute(e.getErrorId(), (k, v) -> {
if (v == null) {
return new AtomicInteger(1);
}
v.incrementAndGet();
return v;
});
}
if (l != null) { if (l != null) {
l.featureChecked(co); l.featureChecked(co);
} }
} }
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, stream.getFile());
@Override
public void accept(CityModel cm) {
QualityADEUtils.removeValidation(cm);
for (Entry<ErrorId, AtomicInteger> e : errorCount.entrySet()) {
ErrorStatistics stats = new ErrorStatistics();
stats.setAmount(e.getValue().get());
stats.setName(QualityADEUtils.mapErrorIdToAdeId(e.getKey()));
statistics.getErrorStatistics().add(stats);
}
val.setStatistics(statistics);
val.setValidationPlan(c.createValidationPlan());
cm.addGenericApplicationPropertyOfCityModel(val);
}
};
// parse and validate
CityGmlParser.streamCityGml(inputFile, config.getParserConfiguration(), con, outputFile);
// write reports if available
writeReport(xmlReporter, handler); writeReport(xmlReporter, handler);
writeReport(pdfReporter, handler); writeReport(pdfReporter, handler);
} catch (CheckReportWriteException e) { } catch (CheckReportWriteException e) {
...@@ -531,6 +822,55 @@ public class Checker { ...@@ -531,6 +822,55 @@ public class Checker {
} }
} }
private static void applyToStatistics(FeatureStatistics buildingStatistics, FeatureStatistics bridgeStatistics,
FeatureStatistics transportationStatistics, FeatureStatistics vegetationStatistics,
FeatureStatistics landStatistics, FeatureStatistics waterStatistics, CityObject co) {
if (co.isValidated()) {
if (co instanceof Building) {
countForFeatureStatistics(buildingStatistics, co);
} else if (co instanceof TransportationObject) {
countForFeatureStatistics(transportationStatistics, co);
} else if (co instanceof BridgeObject) {
countForFeatureStatistics(bridgeStatistics, co);
} else if (co instanceof WaterObject) {
countForFeatureStatistics(waterStatistics, co);
} else if (co instanceof LandObject) {
countForFeatureStatistics(landStatistics, co);
} else if (co instanceof Vegetation) {
countForFeatureStatistics(vegetationStatistics, co);
}
}
}
private static void countForFeatureStatistics(FeatureStatistics featureStatistics, CityObject co) {
featureStatistics.setNumChecked(featureStatistics.getNumChecked() + 1);
if (co.containsAnyError()) {
featureStatistics.setNumErrors(featureStatistics.getNumErrors() + 1);
}
}
private static XmlStreamReporter getXmlReporter(ValidationConfiguration config, BufferedOutputStream xmlBos,
String fileName) {
XmlStreamReporter xmlReporter;
if (xmlBos != null) {
xmlReporter = new XmlStreamReporter(xmlBos, fileName, config);
} else {
xmlReporter = null;
}
return xmlReporter;
}
private static PdfStreamReporter getPdfReporter(ValidationConfiguration config, String logoLocation,
BufferedOutputStream pdfBos, String fileName) {
PdfStreamReporter pdfReporter;
if (pdfBos != null) {
pdfReporter = new PdfStreamReporter(pdfBos, fileName, config, logoLocation);
} else {
pdfReporter = null;
}
return pdfReporter;
}
public static void writeReport(StreamReporter reporter, SvrlContentHandler handler) public static void writeReport(StreamReporter reporter, SvrlContentHandler handler)
throws CheckReportWriteException { throws CheckReportWriteException {
if (reporter != null) { if (reporter != null) {
......
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