Commit fd1b29d4 authored by Eric Duminil's avatar Eric Duminil
Browse files

Small refactor

parent 48f9e849
Showing with 11 additions and 4 deletions
+11 -4
......@@ -50,9 +50,9 @@ public JavaScriptFXBridge() {
/**
* Launches a background thread in which the hull gets extracted for every CityGML file. The hull gets sent back
* to the JS app in order to be displayed.
*
*
* NOTE: To be very honest, I don't really understand concurrency in JavaFX. Eric
*
*
*/
public void refreshHulls() {
//NOTE: Could add progress bar?
......@@ -76,6 +76,9 @@ public Void call() throws IOException {
new Thread(task).start();
}
/**
* This method is called from Javascript, with a prepared wktPolygon written in local coordinates.
*/
public void downloadRegionFromCityGMLs(String wktPolygon, String project, String csvCitygmls, String srsName)
throws IOException, ParseException, XPathParseException, NavException {
// It doesn't seem possible to pass arrays or list from JS to Java. So csvCitygmls contains names separated by ;
......@@ -85,8 +88,12 @@ public void downloadRegionFromCityGMLs(String wktPolygon, String project, String
File buildingIdsFile = selectSaveFileWithDialog(project,
csvCitygmls.replace(";", "_").replace(".gml", ""), "selected_region");
if (buildingIdsFile != null) {
try (BufferedWriter writer = Files.newBufferedWriter(buildingIdsFile.toPath())) {
writeStringBuilderToFile(sb, buildingIdsFile.toPath());
}
private void writeStringBuilderToFile(StringBuilder sb, Path outputFile) throws IOException {
if (outputFile != null) {
try (BufferedWriter writer = Files.newBufferedWriter(outputFile)) {
char[] chars = new char[BUFFER];
for (int aPosStart = 0; aPosStart < sb.length(); aPosStart += BUFFER) {
int chunk = Math.min(BUFFER, sb.length() - aPosStart);
......
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