Commit e79395ee authored by Riegel's avatar Riegel
Browse files

Feat: Add zipfile handling to GUI controller

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 54 additions and 0 deletions
+54 -0
...@@ -12,6 +12,7 @@ import de.hft.stuttgart.citydoctor2.gui.tree.*; ...@@ -12,6 +12,7 @@ import de.hft.stuttgart.citydoctor2.gui.tree.*;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler; import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler;
import de.hft.stuttgart.citydoctor2.parser.*; import de.hft.stuttgart.citydoctor2.parser.*;
import de.hft.stuttgart.citydoctor2.utils.Localization; import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.chart.XYChart.Data; import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series; import javafx.scene.chart.XYChart.Series;
...@@ -27,6 +28,7 @@ import org.citygml4j.core.model.core.CityModel; ...@@ -27,6 +28,7 @@ import org.citygml4j.core.model.core.CityModel;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
...@@ -42,6 +44,7 @@ public class CityDoctorController { ...@@ -42,6 +44,7 @@ public class CityDoctorController {
private CityDoctorModel model; private CityDoctorModel model;
private ParserConfiguration currentConfig; private ParserConfiguration currentConfig;
private String sourceFile; private String sourceFile;
private CityGmlZipArchive zipArchive;
private Checker currentChecker; private Checker currentChecker;
...@@ -82,6 +85,10 @@ public class CityDoctorController { ...@@ -82,6 +85,10 @@ public class CityDoctorController {
mainWindow.resetSearchBar(); mainWindow.resetSearchBar();
mainWindow.resetFilterComboBox(); mainWindow.resetFilterComboBox();
}); });
if (path.endsWith(".zip")) {
loadCityGmlZipFile(path, numberOfRoundingPlaces, l, useValidation, lowMemory);
return;
}
currentChecker = null; currentChecker = null;
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory);
GMLValidationHandler handler = null; GMLValidationHandler handler = null;
...@@ -138,6 +145,53 @@ public class CityDoctorController { ...@@ -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() { private void setupFeatureTabs() {
mainWindow.setDisableOfFeatureTab(FeatureType.BUILDING, model.getBuildings().isEmpty()); mainWindow.setDisableOfFeatureTab(FeatureType.BUILDING, model.getBuildings().isEmpty());
mainWindow.setDisableOfFeatureTab(FeatureType.VEGETATION, model.getVegetation().isEmpty()); mainWindow.setDisableOfFeatureTab(FeatureType.VEGETATION, model.getVegetation().isEmpty());
......
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