Commit 688d4dd3 authored by Eric Duminil's avatar Eric Duminil
Browse files

RegionChooser: Some gmls have missing Z in envelope.

parent 8f7fcb88
......@@ -98,8 +98,14 @@ private static String replaceEnvelopeInHeader(String header, Envelope envelope,
String headerWithoutEnvelope = header;
if (matcher.find()) {
headerWithoutEnvelope = matcher.replaceFirst("");
zMin = Double.valueOf(matcher.group(1).split("\\s+")[2]);
zMax = Double.valueOf(matcher.group(2).split("\\s+")[2]);
String[] mins = matcher.group(1).split("\\s+");
String[] maxs = matcher.group(2).split("\\s+");
if (mins.length > 2) {
zMin = Double.valueOf(mins[2]);
}
if (maxs.length > 2) {
zMax = Double.valueOf(maxs[2]);
}
}
String newEnvelope = "<gml:boundedBy>\r\n" +
" <gml:Envelope srsName=\"" + srsName + "\" srsDimension=\"3\">\r\n" + //NOTE: Would srsDimension="2" be better? Should the original Z get extracted?
......
......@@ -125,15 +125,13 @@ public void testExtract0BuildingsFromWeirdGML() throws Throwable {
assertTrue(emptyGMLString.contains("</core:CityModel")); // Footer
}
//TODO: Add BuildingParts tests with StuttgartAroundCampus.
@Test
public void testExtractBuildingsFromCitygmlWithBuildingParts() throws Throwable {
//NOTE: Small region, with too many spaces between coordinates
public void testExtractBuildingsFromCitygmlWithoutZinEnvelope() throws Throwable {
String wktPolygon = "POLYGON((3512683.1280912133 5404783.732132129,3512719.1608604863 5404714.627650777,3512831.40076119 5404768.344155442,3512790.239106708 5404838.614891164,3512683.1280912133 5404783.732132129))";
Path repo = Paths.get("../TestRepository");
Path citygmlPath = repo.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_around_campus.gml");
Path citygmlPath = repo.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml");
String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, "EPSG:31463")
.toString();
assertEquals(countRegexMatches(emptyGMLString, "<(core:)?cityObjectMember"), 2);
assertEquals(countRegexMatches(emptyGMLString, "<bldg:Building gml:id"), 2);
}
}
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