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

RegionChooser: Moving test files.

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