Commit 231adb59 authored by Eric Duminil's avatar Eric Duminil
Browse files

RegionChooser: Moving test files.

parent 839a34de
......@@ -3,67 +3,66 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Test;
import com.ximpleware.NavException;
import com.ximpleware.XPathEvalException;
import com.ximpleware.XPathParseException;
public class CitygmlParserTests
{
private void testNoNanInCoordinates(Path citygmlPath)
throws NumberFormatException, XPathParseException, NavException, XPathEvalException, IOException {
private static final String REGION_CHOOSER_TESTDATA = "../RegionChooser/test/testdata";
private static final String COORDINATES_SHOULD_BE_PLAUSIBLE = "Min/Max Coordinates should be plausible";
private static final String COORDINATE_SHOULD_BE_A_DOUBLE = "Coordinate should be a double";
private void testNoNanInCoordinates(Path citygmlPath) throws XPathParseException {
CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath);
for (BuildingXmlNode buildingXmlNode : buildingXmlNodes) {
assertTrue("Buildings should have coordinates", buildingXmlNode.hasCoordinates());
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.x));
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.y));
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.xMax));
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.yMax));
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.xMin));
assertFalse("Coordinate should be a double", Double.isNaN(buildingXmlNode.yMin));
assertTrue("Coordinates Min/Max should be plausible", buildingXmlNode.xMax > buildingXmlNode.x);
assertTrue("Coordinates Min/Max should be plausible", buildingXmlNode.yMax > buildingXmlNode.y);
assertTrue("Coordinates Min/Max should be plausible", buildingXmlNode.xMin < buildingXmlNode.x);
assertTrue("Coordinates Min/Max should be plausible", buildingXmlNode.yMin < buildingXmlNode.y);
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.x));
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.y));
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.xMax));
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.yMax));
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.xMin));
assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.yMin));
assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.xMax > buildingXmlNode.x);
assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.yMax > buildingXmlNode.y);
assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.xMin < buildingXmlNode.x);
assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.yMin < buildingXmlNode.y);
}
}
@Test
public void testExtractCoordsFromStuttgart()
throws NumberFormatException, XPathParseException, NavException, XPathEvalException, IOException {
Path repo = Paths.get("../RegionChooser/test/testdata");
public void testExtractCoordsFromStuttgart() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Stuttgart.proj");
Path citygmlPath = repo.resolve("Stuttgart_LOD0_LOD1_buildings_and_trees.gml");
testNoNanInCoordinates(citygmlPath);
}
@Test
public void testExtractCoordsFromGruenbuehl() throws Throwable {
Path repo = Paths.get("../RegionChooser/test/testdata");
public void testExtractCoordsFromGruenbuehl() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Gruenbuehl.proj");
Path citygmlPath = repo.resolve("20140218_Gruenbuehl_LOD2_1building.gml");
testNoNanInCoordinates(citygmlPath);
}
@Test
public void testExtractCoordsFromMunich() throws Throwable {
Path repo = Paths.get("../RegionChooser/test/testdata");
public void testExtractCoordsFromMunich() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Muenchen.proj");
Path citygmlPath = repo.resolve("Munich_v_1_0_0.gml");
testNoNanInCoordinates(citygmlPath);
}
@Test
public void testExtractCoordsFromNYC() throws Throwable {
Path repo = Paths.get("../RegionChooser/test/testdata");
public void testExtractCoordsFromNYC() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "NewYork.proj");
Path citygmlPath = repo.resolve("ManhattanSmall.gml");
testNoNanInCoordinates(citygmlPath);
}
@Test
public void testExtractNoCoordsFromEmptyBuilding() throws Throwable {
Path repo = Paths.get("../RegionChooser/test/testdata");
public void testExtractNoCoordsFromEmptyBuilding() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Stuttgart.proj");
Path citygmlPath = repo.resolve("Stöckach_empty_buildings.gml");
CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath);
int counter = 0;
......
......@@ -2,6 +2,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -10,6 +11,7 @@
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import com.ximpleware.XPathParseException;
import eu.simstadt.geo.GeoUtils;
......@@ -19,8 +21,8 @@
private static final Path repository = Paths.get("../RegionChooser/test/testdata");
@Test
public void testExtractConvexHullFromOneBuilding() throws Throwable {
Path citygmlPath = repository.resolve("20140218_Gruenbuehl_LOD2_1building.gml");
public void testExtractConvexHullFromOneBuilding() throws IOException, XPathParseException {
Path citygmlPath = repository.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml");
Geometry hull = ConvexHullCalculator.calculateFromCityGML(citygmlPath);
assertEquals(hull.getCoordinates().length, 4 + 1); // Convex hull of a building should be a closed rectangle
Point someBuildingPoint = gf.createPoint(new Coordinate(9.216845, 48.878196)); // WGS84
......@@ -28,8 +30,8 @@ public void testExtractConvexHullFromOneBuilding() throws Throwable {
}
@Test
public void testExtractConvexHullFromOneSmallRegion() throws Throwable {
Path citygmlPath = repository.resolve("Gruenbuehl_LOD2_ALKIS_1010.gml");
public void testExtractConvexHullFromOneSmallRegion() throws IOException, XPathParseException {
Path citygmlPath = repository.resolve("Gruenbuehl.proj/Gruenbuehl_LOD2_ALKIS_1010.gml");
Geometry hull = ConvexHullCalculator.calculateFromCityGML(citygmlPath);
assertTrue(hull.getCoordinates().length > 4); // Convex hull should have at least 4 corners
// Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(3515883.6668538367, 5415843.300640578)); // Original coordinates, GSK3
......@@ -38,8 +40,8 @@ public void testExtractConvexHullFromOneSmallRegion() throws Throwable {
}
@Test
public void testExtractConvexHullFromStoeckachNoBuildingPart() throws Throwable {
Path citygmlPath = repository.resolve("Stöckach_überarbeitete GML-NoBuildingPart.gml");
public void testExtractConvexHullFromStoeckachNoBuildingPart() throws IOException, XPathParseException {
Path citygmlPath = repository.resolve("Stuttgart.proj/Stöckach_überarbeitete GML-NoBuildingPart.gml");
Geometry hull = ConvexHullCalculator.calculateFromCityGML(citygmlPath);
assertTrue(hull.getCoordinates().length > 4); // Convex hull should have at least 4 corners
Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(9.195212, 48.789062)); // WGS84
......@@ -47,8 +49,8 @@ public void testExtractConvexHullFromStoeckachNoBuildingPart() throws Throwable
}
@Test
public void testExtractConvexHullFromEveryCitygmlInRepository() throws Throwable {
int minHullCount = 7;
public void testExtractConvexHullFromEveryCitygmlInRepository() throws IOException {
int minHullCount = 6;
//NOTE: Should cache be deleted first?
// Files.walk(repository.resolve(".cache/hulls"), 1).forEach(System.out::println);
long gmlCount = GeoUtils.everyCityGML(repository).count();
......
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