Commit 89cc09dc authored by duminil's avatar duminil
Browse files

Structure to extract zip file to citygml.

parent 4527f190
...@@ -31,14 +31,15 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener ...@@ -31,14 +31,15 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener
public void processJob(Geometry poly, JSObject nfButton) throws InterruptedException { public void processJob(Geometry poly, JSObject nfButton) throws InterruptedException {
this.nfButton = nfButton; this.nfButton = nfButton;
String productName = "WU3"; //NOTE: Others are LB,LBTEST, WU3
ExportJobDescription description = ExportJobDescription.getDefaultDescriptor(); ExportJobDescription description = ExportJobDescription.getDefaultDescriptor();
description.setInitiator("2758"); description.setInitiator("2758");
description.setAccount("Bruse"); description.setAccount("Bruse");
description.setProduct("WU3"); // description.setProduct("WU3");
description.setProduct(productName);
description.setJobnumber("Bruse_0815"); description.setJobnumber("Bruse_0815");
//FIXME: Zipped GMLs coming from nF don't have any defined srsName //FIXME: Zipped GMLs coming from nF don't have any defined srsName
//FIXME: Save files somewhere else
ArrayList<Coord> regionPolygon = new ArrayList<>(); ArrayList<Coord> regionPolygon = new ArrayList<>();
...@@ -49,7 +50,7 @@ public void processJob(Geometry poly, JSObject nfButton) throws InterruptedExcep ...@@ -49,7 +50,7 @@ public void processJob(Geometry poly, JSObject nfButton) throws InterruptedExcep
description.setRegionPolygon(regionPolygon); description.setRegionPolygon(regionPolygon);
Layer layer = Layer.getDefaultLayer(); Layer layer = Layer.getDefaultLayer();
layer.setProduct("WU3"); layer.setProduct(productName);
layer.setName("GML"); layer.setName("GML");
description.addLayer(layer); description.addLayer(layer);
...@@ -63,15 +64,6 @@ public void processJob(Geometry poly, JSObject nfButton) throws InterruptedExcep ...@@ -63,15 +64,6 @@ public void processJob(Geometry poly, JSObject nfButton) throws InterruptedExcep
} catch (InvalidJobDescriptorException ex) { } catch (InvalidJobDescriptorException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
// // Wait for timeout, failure or that all tests pass
// long timeout = 1000 * 60 * 3l; // 3 minutes maximum
// long interval = 10000l;
// while (!job.hasFinished() && !job.hasFailed() && timeout > 0) {
// Thread.sleep(interval);
// timeout -= interval;
// System.out.println("+");
// }
} }
@Override @Override
...@@ -79,16 +71,16 @@ public void jobStatusChanged(JobStatusEvent event) { ...@@ -79,16 +71,16 @@ public void jobStatusChanged(JobStatusEvent event) {
JobStatus status = (JobStatus) event.getSource(); JobStatus status = (JobStatus) event.getSource();
System.out.println(status); System.out.println(status);
if (status == JobStatus.LOCAL) { if (status == JobStatus.LOCAL) {
nfButton.call("updateStatus", "Local"); nfButton.call("updateStatus", "REQUEST HAS BEEN PREPARED");
} else if (status == JobStatus.SENT) { } else if (status == JobStatus.SENT) {
nfButton.call("updateStatus", "SENT"); nfButton.call("updateStatus", "REQUEST HAS BEEN SENT");
} else if (status == JobStatus.PENDING) { } else if (status == JobStatus.PENDING) {
nfButton.call("updateStatus", "PENDING"); nfButton.call("updateStatus", "PENDING");
} else if (status == JobStatus.RUNNING) { } else if (status == JobStatus.RUNNING) {
nfButton.call("updateStatus", "RUNNING"); nfButton.call("updateStatus", "SERVER IS BUSY");
} else if (status == JobStatus.FINISHED) { } else if (status == JobStatus.FINISHED) {
try { try {
nfButton.call("updateStatus", "FINISHED"); nfButton.call("updateStatus", "SERVER IS DONE");
job.downloadResult(); job.downloadResult();
} catch (FailedTransmissionException ex) { } catch (FailedTransmissionException ex) {
ex.printStackTrace(); ex.printStackTrace();
...@@ -96,8 +88,12 @@ public void jobStatusChanged(JobStatusEvent event) { ...@@ -96,8 +88,12 @@ public void jobStatusChanged(JobStatusEvent event) {
} else if (status == JobStatus.DOWNLOAD) { } else if (status == JobStatus.DOWNLOAD) {
try { try {
File file = job.getResult(); File file = job.getResult();
nfButton.call("updateStatus", "DOWNLOAD"); nfButton.call("updateStatus", "DOWNLOADED AS ZIP");
System.out.println("CityGML at " + file.getAbsolutePath()); nfButton.call("selectSaveFile", file.toString());
// System.out.println("CityGML at " + file.getAbsolutePath());
System.out.println("STILL HERE");
//TODO: Call downloadFinished if FAILED
nfButton.call("downloadFinished");
} catch (FailedTransmissionException ex) { } catch (FailedTransmissionException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
......
...@@ -79,13 +79,17 @@ protected Integer call() throws Exception { ...@@ -79,13 +79,17 @@ protected Integer call() throws Exception {
ExportJobFromJavaFXRegionChooser nfJob = new ExportJobFromJavaFXRegionChooser(); ExportJobFromJavaFXRegionChooser nfJob = new ExportJobFromJavaFXRegionChooser();
Geometry poly = wktReader.read(wktPolygon); Geometry poly = wktReader.read(wktPolygon);
nfJob.processJob(poly, nfButton); nfJob.processJob(poly, nfButton);
nfButton.call("downloadFinished");
return 0; return 0;
} }
}; };
new Thread(task).start(); new Thread(task).start();
} }
public void doSomethingWithThisZIP(String zipFilename) {
System.out.println("Extract zipFile " + zipFilename + " to " + "unkownlocation");
}
public void downloadRegionFromCityGML(String wktPolygon, String project, String citygml, JSObject featureOverlay) public void downloadRegionFromCityGML(String wktPolygon, String project, String citygml, JSObject featureOverlay)
throws IOException, ParseException throws IOException, ParseException
{ {
......
...@@ -140,7 +140,7 @@ public void jobStatusChanged(JobStatusEvent event) { ...@@ -140,7 +140,7 @@ public void jobStatusChanged(JobStatusEvent event) {
try { try {
File file = job.getResult(); File file = job.getResult();
assertTrue(file.canRead()); assertTrue(file.canRead());
System.out.println("CityGML at " + file.getAbsolutePath()); // System.out.println("CityGML at " + file.getAbsolutePath());
} catch (FailedTransmissionException ex) { } catch (FailedTransmissionException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
......
...@@ -244,15 +244,16 @@ function findIntersections() { ...@@ -244,15 +244,16 @@ function findIntersections() {
function downloadRegionFromCityGML(i) { function downloadRegionFromCityGML(i) {
// TODO: Disable all links // TODO: Disable all links
// TODO: DRY
$("html").addClass("wait"); $("html").addClass("wait");
var feature = kml_source.getFeatures()[i]; var feature = kml_source.getFeatures()[i];
// Waiting 100ms in order to let the cursor change // Waiting 100ms in order to let the cursor change
setTimeout(function() { setTimeout(function() {
// var start = new Date().getTime(); // var start = new Date().getTime();
fxapp.downloadRegionFromCityGML(sketchAsWKT(), feature.get("project"), feature.get("name"), vectorSource); fxapp.downloadRegionFromCityGML(sketchAsWKT(), feature.get("project"), feature.get("name"), vectorSource);
// var end = new Date().getTime(); // var end = new Date().getTime();
// var time = end - start; // var time = end - start;
// console.log('DL Execution time: ' + time); // console.log('DL Execution time: ' + time);
setTimeout(function() { setTimeout(function() {
$("html").removeClass("wait"); $("html").removeClass("wait");
dataPanel.append("Done<br/>\n"); dataPanel.append("Done<br/>\n");
...@@ -261,7 +262,7 @@ function downloadRegionFromCityGML(i) { ...@@ -261,7 +262,7 @@ function downloadRegionFromCityGML(i) {
} }
function displayInfo() { function displayInfo() {
// var start = new Date().getTime(); // var start = new Date().getTime();
dataPanel.empty(); dataPanel.empty();
var geom = /** @type {ol.geom.Polygon} */ var geom = /** @type {ol.geom.Polygon} */
(sketch.getGeometry().clone().transform(sourceProj, 'EPSG:4326')); (sketch.getGeometry().clone().transform(sourceProj, 'EPSG:4326'));
...@@ -289,9 +290,9 @@ function displayInfo() { ...@@ -289,9 +290,9 @@ function displayInfo() {
dataPanel.append("Area" + "<br/>\n"); dataPanel.append("Area" + "<br/>\n");
dataPanel.append((Math.round(area / 1000) / 10).toString() + " ha<br/><br/>\n"); dataPanel.append((Math.round(area / 1000) / 10).toString() + " ha<br/><br/>\n");
findIntersections(); findIntersections();
// var end = new Date().getTime(); // var end = new Date().getTime();
// var time = end - start; // var time = end - start;
// console.log('Execution time: ' + time); // console.log('Execution time: ' + time);
} }
draw.on('drawend', function(e) { draw.on('drawend', function(e) {
...@@ -318,26 +319,35 @@ $('#reset').click(function() { ...@@ -318,26 +319,35 @@ $('#reset').click(function() {
}); });
novafactory_btn.downloadFinished = function() { novafactory_btn.downloadFinished = function() {
//FIXME: Weird <br>s are inserted between lines // FIXME: Weird <br>s are inserted between lines
dataPanel.append("NovaFactory : DONE <br/>\n"); dataPanel.append("NovaFactory : DONE <br/>\n");
this.disabled = false; this.disabled = false;
// FIXME: Doesn't stop waiting cursor
$("html").removeClass("wait");
} }
novafactory_btn.updateStatus = function(status) { novafactory_btn.updateStatus = function(status) {
dataPanel.append("NovaFactory : "+status+"<br/>\n"); dataPanel.append("NovaFactory : " + status + "<br/>\n");
}
novafactory_btn.selectSaveFile = function(zipFilename) {
fxapp.doSomethingWithThisZIP(zipFilename);
} }
$('#nfDownload').click(function() { $('#nfDownload').click(function() {
$("html").addClass("wait");
novafactory_btn.disabled = true; novafactory_btn.disabled = true;
dataPanel.append("NovaFactory BEGIN <br/>\n"); // dataPanel.append("NovaFactory BEGIN <br/>\n");
fxapp.downloadRegion(sketchAsWKT('4326'), novafactory_btn); setTimeout(function() {
fxapp.downloadRegion(sketchAsWKT('4326'), novafactory_btn);
}, 100);
}); });
function sketchAsWKT(epsgId) { function sketchAsWKT(epsgId) {
var epsgId = (typeof epsgId === 'undefined') ? '31467' : epsgId; var epsgId = (typeof epsgId === 'undefined') ? '31467' : epsgId;
var wktFormat = new ol.format.WKT(); var wktFormat = new ol.format.WKT();
return wktFormat.writeFeature(sketch, { return wktFormat.writeFeature(sketch, {
dataProjection : ol.proj.get('EPSG:'+epsgId), dataProjection : ol.proj.get('EPSG:' + epsgId),
featureProjection : ol.proj.get('EPSG:3857') featureProjection : ol.proj.get('EPSG:3857')
}) })
} }
......
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