Commit 6fce842e authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Remove obsolete code

parent d4d32018
...@@ -487,23 +487,6 @@ public class CityGmlParser { ...@@ -487,23 +487,6 @@ public class CityGmlParser {
} }
} }
} }
// cgmlModel = mapper.getModel().getCityModel();
//
// // remove those that should have been parsed
// if (logger.isInfoEnabled() && verbose){
// logger.info("Resolving HRefs");
// }
//// List<AbstractCityObject> parsedCityObjects = mapper.getModel().createFeatureStream().filter(Objects::nonNull)
//// .map(CityObject::getGmlObject).toList();
//// mapper.getModel().createFeatureStream().filter(Objects::nonNull)
//// .map(CityObject::getGmlObject).forEach(acos::remove);
// mapper.getModel().getFeatureIds().forEach(id -> {acos.removeIf(aco -> aco.getId().equals(id.getGmlString()));});
//// acos.removeAll(parsedCityObjects);
// // re-add all not parsed objects
// for (AbstractCityObject aco : acos) {
// cgmlModel.getCityObjectMembers().add(new AbstractCityObjectProperty(aco));
// }
// After parsing is complete, try to resolve deferred RelativeGeometries
ImplicitGeometryHolder.resolveDeferredObjects(mapper.getModel().getCache()); ImplicitGeometryHolder.resolveDeferredObjects(mapper.getModel().getCache());
if (logger.isInfoEnabled() && verbose) { if (logger.isInfoEnabled() && verbose) {
......
package de.hft.stuttgart.citydoctor2.zip;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class ZipTest {
ParserConfiguration config = new ParserConfiguration(8, false);
@Test
public void testUnzipping() throws MalformedZipFileException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/mock_archive.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
checkMockArchive(cgmlArch);
}
private void checkMockArchive(CityGmlZipArchive cgmlArch) {
assertEquals(5, cgmlArch.getEntries().size());
for (CityGmlZipEntry entry : cgmlArch.getEntries()) {
assertNotNull(entry);
assertTrue(entry.getEntrySubPath().matches("^mock[1-5].gml$"));
assertNull(entry.getErrorType());
assertNotNull(entry.getModel());
assertEquals(1, entry.getModel().getNumberOfFeatures());
}
}
@Test
public void testZipping() throws IOException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/mock_archive.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
Path tmpDir = null;
try {
tmpDir = Files.createTempDirectory("testTmp");
tmpDir.toFile().deleteOnExit();
String expPath = tmpDir + "/export.zip";
cgmlArch.exportToZipFile(expPath);
CityGmlZipArchive cgmlExport = CityGmlZipArchive.register(expPath);
assertNotNull(cgmlExport);
cgmlExport.mountArchive(config);
checkMockArchive(cgmlExport);
} finally {
if (tmpDir != null) {
FileUtils.deleteDirectory(tmpDir.toFile());
}
}
}
@Test
public void testEpsgParsing() throws MalformedZipFileException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/epsg.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
CityGmlZipEntry entry = cgmlArch.getEntry("epsg1.gml");
assertNotNull(entry);
String srsName = entry.getModel().getCityModel().getBoundedBy().getEnvelope().getSrsName().split(":")[6];
assertEquals("25832", srsName);
entry = cgmlArch.getEntry("epsg2.gml");
assertNotNull(entry);
srsName = entry.getModel().getCityModel().getBoundedBy().getEnvelope().getSrsName().split(":")[6];
assertEquals("7415", srsName);
}
@Test
public void testXMLValidation() throws MalformedZipFileException {
ParserConfiguration valConfig = new ParserConfiguration(8, true);
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/validate.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(valConfig);
assertNull(cgmlArch.getEntry("valCorrect.gml").getErrorType());
assertEquals(ZipEntryErrorType.INVALID_CITY_GML_FILE, cgmlArch.getEntry("valFaulty.gml").getErrorType());
}
@Test
public void testImplicitParsing() throws MalformedZipFileException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/implicit.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
CityDoctorModel mainModel = cgmlArch.getEntry("Main_model.gml").getModel();
assertEquals(18, mainModel.getGenericCityObjects().toList().size());
}
}
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