diff --git a/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java b/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java index d37a761265f546dcd4bd28aa6a0f918eff2f71d7..7264d215d2801bbb720c9395a47d4fb1906c1165 100644 --- a/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java +++ b/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java @@ -31,7 +31,7 @@ public Point getCenterOfMass() throws XPathParseException, NumberFormatException double xTotal = 0; double yTotal = 0; - coordinatesFinder.selectXPath(".//posList"); + coordinatesFinder.selectXPath(".//posList|.//pos"); while (coordinatesFinder.evalXPath() != -1) { long offsetAndLength = navigator.getContentFragment(); int coordinatesOffset = (int) offsetAndLength; diff --git a/test/eu/simstadt/regionchooser/test/CitygmlParserTests.java b/test/eu/simstadt/regionchooser/test/CitygmlParserTests.java index b1402ca9339c4d56402840af20b5f684625a4efe..ab3fc8612c18fdd597e257611e57fd4fc8c6f619 100644 --- a/test/eu/simstadt/regionchooser/test/CitygmlParserTests.java +++ b/test/eu/simstadt/regionchooser/test/CitygmlParserTests.java @@ -1,19 +1,21 @@ package eu.simstadt.regionchooser.test; import static org.junit.Assert.assertFalse; +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; import eu.simstadt.regionchooser.citygml_parser.BuildingXmlNode; import eu.simstadt.regionchooser.citygml_parser.CityGmlIterator; public class CitygmlParserTests { - @Test - public void testExtractCoordsFromStuttgart() throws Throwable { - Path repo = Paths.get("../TestRepository"); - Path citygmlPath = repo.resolve("Stuttgart.proj/Stuttgart_buildings_and_trees.gml"); + private void testNoNanInCoordinates(Path citygmlPath) + throws NumberFormatException, XPathParseException, NavException, XPathEvalException, IOException { CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath); for (BuildingXmlNode buildingXmlNode : buildingXmlNodes) { double x = buildingXmlNode.getCenterOfMass().getX(); @@ -21,5 +23,28 @@ public void testExtractCoordsFromStuttgart() throws Throwable { assertFalse("Coordinate should be a double", Double.isNaN(x)); assertFalse("Coordinate should be a double", Double.isNaN(y)); } + + } + + @Test + public void testExtractCoordsFromStuttgart() + throws NumberFormatException, XPathParseException, NavException, XPathEvalException, IOException { + Path repo = Paths.get("../TestRepository"); + Path citygmlPath = repo.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"); + testNoNanInCoordinates(citygmlPath); + } + + @Test + public void testExtractCoordsFromGruenbuehl() throws Throwable { + Path repo = Paths.get("../TestRepository"); + Path citygmlPath = repo.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"); + testNoNanInCoordinates(citygmlPath); + } + + @Test + public void testExtractCoordsFromMunich() throws Throwable { + Path repo = Paths.get("../TestRepository"); + Path citygmlPath = repo.resolve("Muenchen.proj/Munich_v_1_0_0.gml"); + testNoNanInCoordinates(citygmlPath); } }