Commit 4f76b33f authored by duminil's avatar duminil
Browse files

Bit more robust.

No related merge requests found
Showing with 14 additions and 1 deletion
+14 -1
......@@ -37,7 +37,7 @@ public Point getCenterOfMass() throws XPathParseException, NumberFormatException
int coordinatesOffset = (int) offsetAndLength;
int coordinatesLength = (int) (offsetAndLength >> 32);
String posList = navigator.toRawString(coordinatesOffset, coordinatesLength);
String[] coordinates = posList.split(" ");
String[] coordinates = posList.trim().split("\\s+");
for (int k = 0; k < coordinates.length; k = k + 3) {
coordinatesCount++;
xTotal += Double.valueOf(coordinates[k]);
......
......@@ -67,4 +67,17 @@ public void testExtract0BuildingsWithWrongCoordinates() throws Throwable {
assertTrue(emptyGMLString.contains("<CityModel")); // Header
assertTrue(emptyGMLString.contains("</CityModel")); // Footer
}
@Test
public void testExtract0BuildingsFromWeirdGML() throws Throwable {
//NOTE: Small region, with too many spaces between coordinates
String wktPolygon = "POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))";
Path repo = Paths.get("../TestRepository");
Path citygmlPath = repo.resolve("NewYork.proj/broken_nyc_lod2.gml");
String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, "EPSG:32118")
.toString();
assertEquals(countRegexMatches(emptyGMLString, "<(core:)?cityObjectMember"), 0);
assertTrue(emptyGMLString.contains("<core:CityModel")); // Header
assertTrue(emptyGMLString.contains("</core:CityModel")); // Footer
}
}
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