Commit 71e88cba authored by duminil's avatar duminil
Browse files

RegionChooser : Display NovaFactory bounding boxes.

parent cbacf844
package eu.simstadt.regionchooser;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
......@@ -7,6 +8,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -37,6 +39,7 @@
public class RegionChooserFX extends Application
{
private Scene scene;
protected final static Logger LOGGER = Logger.getLogger(RegionChooserFX.class.getName());
@Override
public void start(Stage stage) {
......@@ -169,6 +172,26 @@ public void log(String text)
private Path citygmlPath(String project, String citygml) {
return repo.resolve(project + ".simstadt").resolve(citygml);
}
public void importNovaFactoryBoundingBoxes() throws IOException {
JSObject novafactoryVectors = (JSObject) webEngine.executeScript("novafactory_vectors");
BufferedReader nf_csv = Files.newBufferedReader(Paths
.get("../RegionChooser/website/data/novafactory_products.csv"));
nf_csv.readLine();
String sCurrentLine;
while ((sCurrentLine = nf_csv.readLine()) != null) {
String[] values = sCurrentLine.trim().split(",");
String product = values[1];
// String description = values[2];
String[] srs = values[3].split(" ");
String epsgId = srs[srs.length - 1];
System.out.println(product);
novafactoryVectors.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product,
epsgId);
}
nf_csv.close();
}
}
final WebView browser = new WebView();
......@@ -191,6 +214,12 @@ public Browser() {
"{\n" +
" fxapp.log(message);\n" +
"};");
try {
fxapp.importNovaFactoryBoundingBoxes();
} catch (Exception ex) {
RegionChooserFX.LOGGER.warning("NovaFactory CSV not found or corrupt");
ex.printStackTrace();
}
// try {
// fxapp.selectRegionDirectlyFromCityGML(
// Paths.get("../TestRepository").resolve("Gruenbuehl.simstadt")
......
......@@ -22,20 +22,23 @@ var kml_source = new ol.source.KML({
extractStyles : false
})
var polygon_style =new ol.style.Style({
function polygon_style(color,alpha){
return new ol.style.Style({
fill : new ol.style.Fill({
color : 'rgba(255, 255, 255, 0.2)'
color : 'rgba(255, 255, 255,'+ alpha +')'
}),
stroke : new ol.style.Stroke({
color : '#777777',
// color : '#777777',
color : color,
width : 2,
lineDash : [ 5, 10 ]
}),
})
}
var kml_layer = new ol.layer.Vector({
source : kml_source,
style : polygon_style
style : polygon_style('#777777',0.2)
});
var intersections = new ol.source.Vector();
......@@ -53,22 +56,21 @@ var novafactory_vectors = new ol.source.Vector({
features : []
});
novafactory_vectors.addMarker = function(xmin, ymin, xmax, ymax, name) {
var p1 = new ol.geom.Point(ol.proj.transform([ xmin, ymin ], 'EPSG:31467', 'EPSG:3857'))
var p2 = new ol.geom.Point(ol.proj.transform([ xmin, ymax ], 'EPSG:31467', 'EPSG:3857'))
var p3 = new ol.geom.Point(ol.proj.transform([ xmax, ymax ], 'EPSG:31467', 'EPSG:3857'))
var p4 = new ol.geom.Point(ol.proj.transform([ xmax, ymin ], 'EPSG:31467', 'EPSG:3857'))
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({
geometry : new ol.geom.Polygon([[p1,p2,p3,p4,p1]]),
geometry : box,
name : name,
}));
}
novafactory_vectors.addMarker(3530000,5434300,3538800,5445010,"WU");
//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
style : polygon_style('#ff7700',0.1)
});
var map = new ol.Map({
......
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