diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java index bce70ff1a19ac892890e5b67be87d409a706e6cd..5bd8e4220ea57117a9cc8b2555530801e9e419a6 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java @@ -12,6 +12,7 @@ import de.hft.stuttgart.citydoctor2.gui.tree.*; import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler; import de.hft.stuttgart.citydoctor2.parser.*; import de.hft.stuttgart.citydoctor2.utils.Localization; +import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive; import javafx.application.Platform; import javafx.scene.chart.XYChart.Data; import javafx.scene.chart.XYChart.Series; @@ -27,6 +28,7 @@ import org.citygml4j.core.model.core.CityModel; import org.xml.sax.SAXParseException; import java.io.File; +import java.io.IOException; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; @@ -42,6 +44,7 @@ public class CityDoctorController { private CityDoctorModel model; private ParserConfiguration currentConfig; private String sourceFile; + private CityGmlZipArchive zipArchive; private Checker currentChecker; @@ -82,6 +85,10 @@ public class CityDoctorController { mainWindow.resetSearchBar(); mainWindow.resetFilterComboBox(); }); + if (path.endsWith(".zip")) { + loadCityGmlZipFile(path, numberOfRoundingPlaces, l, useValidation, lowMemory); + return; + } currentChecker = null; currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); GMLValidationHandler handler = null; @@ -138,6 +145,53 @@ public class CityDoctorController { } } + private void loadCityGmlZipFile(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation, + boolean lowMemory) throws CityGmlParseException, InvalidGmlFileException { + currentChecker = null; + currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); + zipArchive = CityGmlZipArchive.register(path); + + Platform.runLater(() -> { + try { + ZipEntryPicker picker = new ZipEntryPicker(mainWindow.getMainStage(), this); + picker.show(); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + /** + model = CityGmlParser.parseCityGmlFile(path, currentConfig, l, handler, true); + if (!validationIssues.isEmpty()) { + StringJoiner sj = new StringJoiner("\n"); + validationIssues.stream().forEach(sj::add); + throw new InvalidGmlFileException(sj.toString()); + } + mainWindow.getClickHandler().setConfig(currentConfig); + sourceFile = path; + renderer.reset(); + Platform.runLater(() -> { + mainWindow.addFileNameToTitle(path); + mainWindow.getCheckButton().setDisable(false); + mainWindow.getLod1Btn().setDisable(false); + mainWindow.getLod2Btn().setDisable(false); + mainWindow.getLod3Btn().setDisable(false); + mainWindow.getLod4Btn().setDisable(false); + mainWindow.getWorldBtn().setDisable(false); + mainWindow.getSaveBtn().setDisable(false); + mainWindow.getResetCameraBtn().setDisable(false); + mainWindow.getHideRoofBtn().setDisable(false); + mainWindow.getNorthArrow().setVisible(true); + mainWindow.alignNorthArrow(); + setupFeatureTabs(); + buildTrees(); + }); + **/ + } + + public CityGmlZipArchive getZipArchive() { + return zipArchive; + } + private void setupFeatureTabs() { mainWindow.setDisableOfFeatureTab(FeatureType.BUILDING, model.getBuildings().isEmpty()); mainWindow.setDisableOfFeatureTab(FeatureType.VEGETATION, model.getVegetation().isEmpty());