From 68891bca6553ae2695ab077b74bf8ad6aaf1d438 Mon Sep 17 00:00:00 2001 From: duminil <duminil@2c044af0-2e85-064f-a0c3-7471430cffcd> Date: Fri, 21 Apr 2017 13:11:49 +0000 Subject: [PATCH] RegionChooser: CityGML can have pos or posList --- .../citygml_parser/BuildingXmlNode.java | 2 +- .../test/CitygmlParserTests.java | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java b/src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java index d37a761..7264d21 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 b1402ca..ab3fc86 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); } } -- GitLab