Commit e218f4b4 authored by duminil's avatar duminil
Browse files

Import SimStadtModel from RegionChooser.

parent bd4ca534
......@@ -11,5 +11,6 @@
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/Proj4J.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/SimStadtRepository"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -14,7 +14,11 @@
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javax.xml.stream.XMLStreamException;
import netscape.javascript.JSObject;
import org.xml.sax.SAXParseException;
import eu.simstadt.admin.SimStadtModel;
import eu.simstadt.admin.SimStadtProject;
public class RegionChooserFX extends Application
......@@ -50,12 +54,25 @@ public void downloadRegion(String wktPolygon) {
System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon);
}
public void downloadRegionFromCityGML(String wktPolygon, String project, String citygml) {
public int downloadRegionFromCityGML(String wktPolygon, String project, String citygml)
throws SAXParseException, XMLStreamException {
//Browser.this.getScene().getRoot().setCursor(Cursor.WAIT);
System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon + " from \n" + project + ">" + citygml);
SimStadtModel model = SimStadtProject.loadModelWithoutSchemaValidation(citygmlPath(project, citygml).toFile());
return model.getCityDoctorBuildings().size();
}
public boolean checkIfCityGMLSAreAvailable(String project, String citygml) {
return Files.isReadable(repo.resolve(project + ".simstadt").resolve(citygml));
return Files.isReadable(citygmlPath(project, citygml));
}
public void log(String text)
{
System.out.println(text);
}
private Path citygmlPath(String project, String citygml) {
return repo.resolve(project + ".simstadt").resolve(citygml);
}
}
......@@ -74,6 +91,10 @@ public Browser() {
if (newState == State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("fxapp", new JavaScriptFXBridge());
webEngine.executeScript("console.log = function(message)\n" +
"{\n" +
" fxapp.log(message);\n" +
"};");
}
});
//add the web view to the scene
......
......@@ -67,7 +67,7 @@ kml_layer.addEventListener("change", function(event) {
feature["description"] = project + ">" + name;
var citygmlHere;
if (fromJavaFX) {
citygmlHere = fxapp.checkIfCityGMLSAreAvailable(project,name);
citygmlHere = fxapp.checkIfCityGMLSAreAvailable(project, name);
}
feature["available"] = citygmlHere;
});
......@@ -174,8 +174,19 @@ function findIntersections() {
}
function downloadRegionFromCityGML(i) {
$("html").addClass("wait");
var feature = kml_source.getFeatures()[i];
fxapp.downloadRegionFromCityGML(sketchAsWKT(), feature.get("project"), feature.get("name"));
// Waiting 100ms in order to let the cursor change
setTimeout(function() {
var start = new Date().getTime();
var buildings_count = fxapp.downloadRegionFromCityGML(sketchAsWKT(), feature.get("project"), feature
.get("name"));
var end = new Date().getTime();
var time = end - start;
console.log('DL Execution time: ' + time);
$('#dataPanel').append("Imported buildings : " + buildings_count);
$("html").removeClass("wait");
}, 100);
}
function displayInfo() {
......
html.wait, html.wait * { cursor: wait !important; }
html,body{
margin:0;
padding:0;
......
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