Commit 46e379ee authored by Eric Duminil's avatar Eric Duminil
Browse files

RegionChooser: refreshHulls seems to be working now, with visual feedback!

parent 915ca2ab
......@@ -23,6 +23,7 @@
import com.ximpleware.XPathParseException;
import eu.simstadt.geo.fast_xml_parser.ConvexHullCalculator;
import eu.simstadt.nf4j.ExportJobFromJavaFXRegionChooser;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.concurrent.Worker.State;
......@@ -50,15 +51,45 @@ public JavaScriptFXBridge() {
Preferences userPrefs = Preferences.userRoot().node("/eu/simstadt/desktop");
String repoString = userPrefs.get("RECENT_REPOSITORY", null);
if (repoString == null) {
//TODO: Add a FileDialog?
repo = Paths.get("../TestRepository");
} else {
repo = Paths.get(repoString);
}
}
public void refreshHulls() throws IOException {
ConvexHullCalculator.extractHullsForEveryCityGML(repo,
(hullKML -> jsApp.call("addCityGmlHull", hullKML)));
/**
* 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.
*
*/
public void refreshHulls() {
//NOTE: Could add progress bar?
Task<Void> task = new Task<Void>() {
@Override
public Void call() throws IOException {
ConvexHullCalculator.extractHullsForEveryCityGML(repo,
(hullKML -> {
Platform.runLater(new Runnable() {
@Override
public void run() {
jsApp.call("addCityGmlHull", hullKML);
}
});
}));
return null;
}
};
task.setOnRunning(e -> {
jsApp.call("display", "Importing citgyml. Please wait.");
});
task.setOnSucceeded(e -> {
jsApp.call("ready");
});
new Thread(task).start();
}
public void downloadRegion(String wktPolygon, String productName, JSObject novaFactoryLayer)
......@@ -199,7 +230,7 @@ public RegionChooserBrowser() {
if (newState == State.SUCCEEDED) {
jsApp = (JSObject) webEngine.executeScript("regionChooser");
jsApp.call("setFxApp", fxapp);
jsApp.call("ready");
fxapp.refreshHulls();
try {
fxapp.importNovaFactoryBoundingBoxes();
} catch (Exception ex) {
......
......@@ -51,7 +51,7 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
var kml_layer = new ol.layer.Vector({
source : kml_source,
style : polygon_style('#007700', 0.2) //TODO: Change me back to 777
style : polygon_style('#447744', 0.2)
});
var intersections = new ol.source.Vector();
......@@ -71,7 +71,7 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
publicScope.addCityGmlHull = function(kmlString) {
options = {featureProjection: ol.proj.get('EPSG:3857')};
feature = kmlFormat.readFeature(kmlString, options)
feature = kmlFormat.readFeature(kmlString, options);
kml_source.addFeature(feature);
dataPanel.append('.');
};
......@@ -236,6 +236,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
}
}
publicScope.display = function(text){
dataPanel.append(text + "<br/>\n");
}
publicScope.downloadRegionFromCityGML = function(i) {
// TODO: Disable all links
// TODO: DRY
......@@ -355,15 +359,13 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
publicScope.setFxApp = function(app){
fxapp = app;
console.log = function(message){
fxapp.log(message);
}
}
// Executed by JavaFX when whole page is loaded.
publicScope.ready = function() {
console.log = function(message){
fxapp.log(message);
}
dataPanel.append("Importing citgyml. Please wait.<br/>\n");
fxapp.refreshHulls();
updateGMLPolygons();
dataPanel.empty();
$("html").removeClass("wait");
......
Markdown is supported
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