Commit 2ffc83c1 authored by duminil's avatar duminil
Browse files

No need for nF button anymore, automatic product selection.

No related merge requests found
Showing with 56 additions and 49 deletions
+56 -49
......@@ -27,11 +27,10 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener
{
public AsyncExportJob job;
private JSObject nfButton;
private JSObject novaFactoryOpenLayer;
public void processJob(Geometry poly, JSObject nfButton) throws InterruptedException {
this.nfButton = nfButton;
String productName = "WU3"; //NOTE: Others are LB,LBTEST, WU3
public void processJob(Geometry poly, String productName, JSObject novaFactoryOpenLayer) throws InterruptedException {
this.novaFactoryOpenLayer = novaFactoryOpenLayer;
ExportJobDescription description = ExportJobDescription.getDefaultDescriptor();
description.setInitiator("2758");
description.setAccount("Bruse");
......@@ -71,16 +70,16 @@ public void jobStatusChanged(JobStatusEvent event) {
JobStatus status = (JobStatus) event.getSource();
System.out.println(status);
if (status == JobStatus.LOCAL) {
nfButton.call("updateStatus", "REQUEST HAS BEEN PREPARED");
novaFactoryOpenLayer.call("updateStatus", "REQUEST HAS BEEN PREPARED");
} else if (status == JobStatus.SENT) {
nfButton.call("updateStatus", "REQUEST HAS BEEN SENT");
novaFactoryOpenLayer.call("updateStatus", "REQUEST HAS BEEN SENT");
} else if (status == JobStatus.PENDING) {
nfButton.call("updateStatus", "PENDING");
novaFactoryOpenLayer.call("updateStatus", "PENDING");
} else if (status == JobStatus.RUNNING) {
nfButton.call("updateStatus", "SERVER IS BUSY");
novaFactoryOpenLayer.call("updateStatus", "SERVER IS BUSY");
} else if (status == JobStatus.FINISHED) {
try {
nfButton.call("updateStatus", "SERVER IS DONE");
novaFactoryOpenLayer.call("updateStatus", "SERVER IS DONE");
job.downloadResult();
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
......@@ -88,12 +87,12 @@ public void jobStatusChanged(JobStatusEvent event) {
} else if (status == JobStatus.DOWNLOAD) {
try {
File file = job.getResult();
nfButton.call("updateStatus", "DOWNLOADED AS ZIP");
nfButton.call("selectSaveFile", file.toString());
novaFactoryOpenLayer.call("updateStatus", "DOWNLOADED AS ZIP");
novaFactoryOpenLayer.call("selectSaveFile", file.toString());
// System.out.println("CityGML at " + file.getAbsolutePath());
System.out.println("STILL HERE");
//TODO: Call downloadFinished if FAILED
nfButton.call("downloadFinished");
novaFactoryOpenLayer.call("downloadFinished");
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
......
......@@ -74,14 +74,15 @@ public JavaScriptFXBridge() {
}
}
public void downloadRegion(String wktPolygon, JSObject nfButton) throws InterruptedException {
public void downloadRegion(String wktPolygon, String productName, JSObject novaFactoryLayer)
throws InterruptedException {
//TODO: Ask nf Server about available regions
Task<Integer> task = new Task<Integer>() {
@Override
protected Integer call() throws Exception {
ExportJobFromJavaFXRegionChooser nfJob = new ExportJobFromJavaFXRegionChooser();
Geometry poly = wktReader.read(wktPolygon);
nfJob.processJob(poly, nfButton);
nfJob.processJob(poly, productName, novaFactoryLayer);
return 0;
}
};
......@@ -185,7 +186,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException {
// String description = values[2];
String[] srs = values[3].split(" ");
String epsgId = srs[srs.length - 1];
System.out.println(product);
// System.out.println(product);
novafactoryVectors.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product,
epsgId);
}
......
......@@ -35,7 +35,6 @@
<div id="map" class="map" tabindex="0"></div>
<div id="side">
<input id="reset" value="Reset" type="button" class="navi" disabled/>
<input id="nfDownload" value="NovaFactory download" type="button" class="navi" disabled/>
<div id="dataPanel">
</div>
</div>
......
......@@ -2,7 +2,6 @@
//TODO: Try to leave everything in 4326
var reset_btn = $('#reset')[0];
var novafactory_btn = $('#nfDownload')[0];
var dataPanel = $('#dataPanel');
var br = document.createElement('br');
......@@ -22,13 +21,12 @@ var kml_source = new ol.source.KML({
extractStyles : false
})
function polygon_style(color,alpha){
function polygon_style(color, alpha) {
return new ol.style.Style({
fill : new ol.style.Fill({
color : 'rgba(255, 255, 255,'+ alpha +')'
color : 'rgba(255, 255, 255,' + alpha + ')'
}),
stroke : new ol.style.Stroke({
// color : '#777777',
color : color,
width : 2,
lineDash : [ 5, 10 ]
......@@ -38,7 +36,7 @@ function polygon_style(color,alpha){
var kml_layer = new ol.layer.Vector({
source : kml_source,
style : polygon_style('#777777',0.2)
style : polygon_style('#777777', 0.2)
});
var intersections = new ol.source.Vector();
......@@ -47,7 +45,7 @@ var intersections_layer = new ol.layer.Vector({
source : intersections,
style : new ol.style.Style({
fill : new ol.style.Fill({
color : 'rgba(255, 155, 51, 0.5)'
color : 'rgba(255, 155, 51, 0.2)'
})
})
});
......@@ -57,31 +55,36 @@ var novafactory_vectors = new ol.source.Vector({
});
novafactory_vectors.addNovaFactoryProduct = function(xmin, ymin, xmax, ymax, name, epsgId) {
var box = new ol.geom.Polygon([[[xmin,ymin],[xmin,ymax],[xmax,ymax],[xmax,ymin],[xmin,ymin]]]);
box.transform('EPSG:'+epsgId,'EPSG:3857');
this.addFeature(new ol.Feature({
var box = new ol.geom.Polygon(
[ [ [ xmin, ymin ], [ xmin, ymax ], [ xmax, ymax ], [ xmax, ymin ], [ xmin, ymin ] ] ]);
box.transform('EPSG:' + epsgId, 'EPSG:3857');
var feature = new ol.Feature({
geometry : box,
name : name,
}));
});
feature["geoJSON"] = geoJSONformat.writeFeatureObject(feature);
feature["area"] = feature.getGeometry().getArea();
feature["description"] = "novaFACTORY>" + name;
feature["available"] = true;
feature["source"] = "NovaFACTORY";
this.addFeature(feature);
}
//novafactory_vectors.addNovaFactoryProduct(3530000,5434300,3538800,5445010,"WU");
//novafactory_vectors.addNovaFactoryProduct(3510000,5415000,3523100,5422000,"LB");
var novafactory_layer = new ol.layer.Vector({
source : novafactory_vectors,
style : polygon_style('#ff7700',0.1)
style : polygon_style('#ff7700', 0.1)
});
var map = new ol.Map({
target : 'map',
layers : [ osm_layer, kml_layer, novafactory_layer, intersections_layer],
layers : [ osm_layer, kml_layer, novafactory_layer, intersections_layer ],
interactions : ol.interaction.defaults({
keyboard : true
})
});
var geoJSONformat = new ol.format.GeoJSON();
kml_layer.addEventListener("change", function(event) {
map.getView().fitExtent(kml_source.getExtent(), (map.getSize()));
});
......@@ -93,6 +96,7 @@ function updateGMLPolygons() {
var project = feature.get("project");
var name = feature.get("name");
feature["description"] = project + ">" + name;
feature["source"] = "CityGML";
var citygmlHere;
if (fromJavaFX) {
citygmlHere = fxapp.checkIfCityGMLSAreAvailable(project, name);
......@@ -165,8 +169,7 @@ function findIntersections() {
var poly1 = geoJSONformat.writeFeatureObject(sketch);
var intersection_found = false;
intersections.clear();
var i = 0;
kml_source.forEachFeature(function(feature) {
function findIntersection(feature) {
try {
var jsonIntersection = turf.intersect(poly1, feature["geoJSON"]);
if (undefined != jsonIntersection) {
......@@ -182,8 +185,9 @@ function findIntersections() {
var description;
if (feature["available"]) {
description = "<a href=\"#\" onclick=\"downloadRegionFromCityGML(" + i + ");return false;\">"
+ feature["description"] + "</a>";
description = "<a href=\"#\" onclick=\"downloadRegionFrom" + feature["source"] + "(" + i
+ ");return false;\">" + feature["description"] + "</a>";
console.log(description);
} else {
description = feature['description'];
}
......@@ -199,9 +203,13 @@ function findIntersections() {
console.log(feature.get('description') + " - " + err);
}
i++;
})
}
var i = 0;
novafactory_vectors.forEachFeature(findIntersection)
var i = 0;
kml_source.forEachFeature(findIntersection)
if (!intersection_found) {
dataPanel.append("No intersection found with any CityGML<br/>\n");
dataPanel.append("No intersection found with any CityGML or NovaFactory product<br/>\n");
}
}
......@@ -260,9 +268,6 @@ function displayInfo() {
draw.on('drawend', function(e) {
displayInfo();
if (fromJavaFX) {
novafactory_btn.disabled = false;
}
draw.setActive(false);
});
......@@ -276,12 +281,11 @@ $('#reset').click(function() {
featureOverlay.getFeatures().clear();
intersections.clear();
reset_btn.disabled = true;
novafactory_btn.disabled = true;
focusOnMap();
}
});
novafactory_btn.downloadFinished = function() {
novafactory_layer.downloadFinished = function() {
// FIXME: Weird <br>s are inserted between lines
dataPanel.append("NovaFactory : DONE <br/>\n");
this.disabled = false;
......@@ -289,22 +293,26 @@ novafactory_btn.downloadFinished = function() {
$("html").removeClass("wait");
}
novafactory_btn.updateStatus = function(status) {
novafactory_layer.updateStatus = function(status) {
dataPanel.append("NovaFactory : " + status + "<br/>\n");
}
novafactory_btn.selectSaveFile = function(zipFilename) {
novafactory_layer.selectSaveFile = function(zipFilename) {
fxapp.doSomethingWithThisZIP(zipFilename);
}
$('#nfDownload').click(function() {
function downloadRegionFromNovaFACTORY(i) {
$("html").addClass("wait");
novafactory_btn.disabled = true;
// dataPanel.append("NovaFactory BEGIN <br/>\n");
var feature = novafactory_vectors.getFeatures()[i];
// Waiting 100ms in order to let the cursor change
setTimeout(function() {
fxapp.downloadRegion(sketchAsWKT('4326'), novafactory_btn);
fxapp.downloadRegion(sketchAsWKT('4326'), feature.get('name'), novafactory_layer);
setTimeout(function() {
$("html").removeClass("wait");
dataPanel.append("Done<br/>\n");
}, 100);
}, 100);
});
}
function sketchAsWKT(epsgId) {
var epsgId = (typeof epsgId === 'undefined') ? '31467' : epsgId;
......
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