Commit 68891bca authored by duminil's avatar duminil
Browse files

RegionChooser: CityGML can have pos or posList

parent 90070463
......@@ -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;
......
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);
}
}
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