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