Commit 267d07c7 authored by Eric Duminil's avatar Eric Duminil
Browse files

Testing that trees are found too.

parent f173e626
No related merge requests found
Showing with 27 additions and 17 deletions
+27 -17
...@@ -62,21 +62,21 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr ...@@ -62,21 +62,21 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
LOGGER.info("Parsing " + citygmlPath); LOGGER.info("Parsing " + citygmlPath);
//TODO: Allow citygmlPath for folders too, and iterate over gmls? //TODO: Allow citygmlPath for folders too, and iterate over gmls?
citygml = new CityGmlIterator(citygmlPath); citygml = new CityGmlIterator(citygmlPath);
for (CityObjectMember buildingXmlNode : citygml) { for (CityObjectMember cityObjectNode : citygml) {
if (cityObjectsCount == 0) { if (cityObjectsCount == 0) {
sb.append(replaceEnvelopeInHeader(citygml.getHeader(), poly.getEnvelopeInternal(), srsName)); sb.append(replaceEnvelopeInHeader(citygml.getHeader(), poly.getEnvelopeInternal(), srsName));
} }
cityObjectsCount += 1; cityObjectsCount += 1;
if (buildingXmlNode.hasCoordinates()) { if (cityObjectNode.hasCoordinates()) {
Coordinate coord = new Coordinate(buildingXmlNode.x, buildingXmlNode.y); Coordinate coord = new Coordinate(cityObjectNode.x, cityObjectNode.y);
Point point = GEOMETRY_FACTORY.createPoint(coord); Point point = GEOMETRY_FACTORY.createPoint(coord);
if (point.within(poly)) { if (point.within(poly)) {
if (buildingXmlNode.isBuilding()) { if (cityObjectNode.isBuilding()) {
foundBuildingsCount++; foundBuildingsCount++;
} else { } else {
foundVegetationCount++; foundVegetationCount++;
} }
sb.append(buildingXmlNode.toString()); sb.append(cityObjectNode.toString());
} }
} }
if (cityObjectsCount % 1000 == 0) { if (cityObjectsCount % 1000 == 0) {
......
...@@ -17,19 +17,19 @@ ...@@ -17,19 +17,19 @@
private void testNoNanInCoordinates(Path citygmlPath) throws XPathParseException { private void testNoNanInCoordinates(Path citygmlPath) throws XPathParseException {
CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath); CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath);
for (CityObjectMember buildingXmlNode : buildingXmlNodes) { for (CityObjectMember cityObjectNode : buildingXmlNodes) {
assertTrue(buildingXmlNode.hasCoordinates(), "Buildings should have coordinates"); assertTrue(cityObjectNode.hasCoordinates(), "Building and vegetations should have coordinates");
assertFalse(Double.isNaN(buildingXmlNode.x), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.x), COORDINATE_SHOULD_BE_A_DOUBLE);
assertFalse(Double.isNaN(buildingXmlNode.y), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.y), COORDINATE_SHOULD_BE_A_DOUBLE);
assertFalse(Double.isNaN(buildingXmlNode.xMax), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.xMax), COORDINATE_SHOULD_BE_A_DOUBLE);
assertFalse(Double.isNaN(buildingXmlNode.yMax), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.yMax), COORDINATE_SHOULD_BE_A_DOUBLE);
assertFalse(Double.isNaN(buildingXmlNode.xMin), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.xMin), COORDINATE_SHOULD_BE_A_DOUBLE);
assertFalse(Double.isNaN(buildingXmlNode.yMin), COORDINATE_SHOULD_BE_A_DOUBLE); assertFalse(Double.isNaN(cityObjectNode.yMin), COORDINATE_SHOULD_BE_A_DOUBLE);
// Some SolitaryVegetationObjects are defined with a single point. // Some SolitaryVegetationObjects are defined with a single point.
assertTrue(buildingXmlNode.xMax >= buildingXmlNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE); assertTrue(cityObjectNode.xMax >= cityObjectNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE);
assertTrue(buildingXmlNode.yMax >= buildingXmlNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE); assertTrue(cityObjectNode.yMax >= cityObjectNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE);
assertTrue(buildingXmlNode.xMin <= buildingXmlNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE); assertTrue(cityObjectNode.xMin <= cityObjectNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE);
assertTrue(buildingXmlNode.yMin <= buildingXmlNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE); assertTrue(cityObjectNode.yMin <= cityObjectNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE);
} }
} }
...@@ -38,6 +38,16 @@ public void testExtractCoordsFromStuttgart() throws XPathParseException { ...@@ -38,6 +38,16 @@ public void testExtractCoordsFromStuttgart() throws XPathParseException {
Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Stuttgart.proj"); Path repo = Paths.get(REGION_CHOOSER_TESTDATA, "Stuttgart.proj");
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);
CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath);
boolean foundBuildings = false;
boolean foundTrees = false;
for (CityObjectMember cityObjectNode : buildingXmlNodes) {
boolean isBuilding = cityObjectNode.isBuilding();
foundBuildings |= isBuilding;
foundTrees |= !isBuilding;
}
assertTrue(foundBuildings, "At least one building should have been found.");
assertTrue(foundTrees, "At least one tree should have been found.");
} }
@Test @Test
......
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