Commit ba84ea11 authored by Eric Duminil's avatar Eric Duminil
Browse files

RegionChooser: Trying to add features directly.

parent 19bb3024
......@@ -66,6 +66,7 @@ public String refreshHulls() throws IOException {
.filter(p -> p.toString().contains(".cache") && p.toString().endsWith(".xyz"))
.forEach(p -> {
System.out.println("Parsing " + p);
jsApp.call("addCityGmlHull", p.toString());
try {
List<String> lines = Files.readAllLines(p);
for (String line : lines) {
......@@ -186,7 +187,6 @@ private Path citygmlPath(String project, String citygml) {
}
public void importNovaFactoryBoundingBoxes() throws IOException {
JSObject regionChooserJS = (JSObject) webEngine.executeScript("regionChooser");
BufferedReader nf_csv = new BufferedReader(new InputStreamReader(
RegionChooserFX.class.getResourceAsStream("website/data/novafactory_products.csv")));
nf_csv.readLine();
......@@ -198,7 +198,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException {
String[] srs = values[3].split(" ");
String epsgId = srs[srs.length - 1];
// System.out.println(product);
regionChooserJS.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product,
jsApp.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product,
epsgId);
}
nf_csv.close();
......@@ -208,6 +208,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
final JavaScriptFXBridge fxapp = new JavaScriptFXBridge();
private JSObject jsApp;
public RegionChooserBrowser() {
//apply the styles
......@@ -218,9 +219,9 @@ public RegionChooserBrowser() {
webEngine.getLoadWorker().stateProperty().addListener(
(ObservableValue<? extends State> ov, State oldState, State newState) -> {
if (newState == State.SUCCEEDED) {
JSObject regionChooserJS = (JSObject) webEngine.executeScript("regionChooser");
regionChooserJS.call("setFxApp", fxapp);
regionChooserJS.call("ready");
jsApp = (JSObject) webEngine.executeScript("regionChooser");
jsApp.call("setFxApp", fxapp);
jsApp.call("ready");
try {
fxapp.importNovaFactoryBoundingBoxes();
} catch (Exception ex) {
......
......@@ -8,10 +8,9 @@
content="Google Map V3 Polygon Creator for Simstadt">
<link rel="stylesheet" type="text/css" href="style/style.css">
<!-- Firebug for js console: -->
<!--
-->
<!-- Firebug for js console:
<script type='text/javascript' src='script/firebug-lite-compressed.js'></script>
-->
<script type="text/javascript" src="script/proj4.js"></script>
<script type="text/javascript" src="script/jquery-1.4.2.min.js"></script>
<!-- OpenLayers v3.4.0. API doc : http://openlayers.org/en/v3.4.0/apidoc/ -->
......@@ -23,7 +22,7 @@
<script src="script/turf.js" type="text/javascript"></script>
</head>
<body>
<input id="refresh_hulls" value="Refresh" type="button" class="navi" />
<input id="refresh_hulls" value="Refresh" type="button" class="navi" disabled />
<div id="header">
<ul>
<li class="title">Simstadt Region Chooser</li>
......
......@@ -10,6 +10,7 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
//var regionChooser = (function(){
var publicScope = {};
var refresh_btn = $('#refresh_hulls')[0];
var reset_btn = $('#reset')[0];
var dataPanel = $('#dataPanel');
var wgs84Sphere = new ol.Sphere(6378137);
......@@ -62,6 +63,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
features : []
});
publicScope.addCityGmlHull = function(p) {
dataPanel.append(p + "<br/>\n")
};
publicScope.addNovaFactoryProduct = function(xmin, ymin, xmax, ymax, name, epsgId) {
var box = new ol.geom.Polygon(
[ [ [ xmin, ymin ], [ xmin, ymax ], [ xmax, ymax ], [ xmax, ymin ], [ xmin, ymin ] ] ]);
......@@ -354,6 +359,7 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
console.log = function(message){
fxapp.log(message);
}
refresh_btn.disabled = false;
console.log("READY!");
}
......
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