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

RegionChooser: Try to import Citygml directly.

parent cccda702
...@@ -6,12 +6,10 @@ ...@@ -6,12 +6,10 @@
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
...@@ -23,6 +21,7 @@ ...@@ -23,6 +21,7 @@
import com.ximpleware.NavException; import com.ximpleware.NavException;
import com.ximpleware.XPathEvalException; import com.ximpleware.XPathEvalException;
import com.ximpleware.XPathParseException; import com.ximpleware.XPathParseException;
import eu.simstadt.geo.fast_xml_parser.ConvexHullCalculator;
import eu.simstadt.nf4j.ExportJobFromJavaFXRegionChooser; import eu.simstadt.nf4j.ExportJobFromJavaFXRegionChooser;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task; import javafx.concurrent.Task;
...@@ -62,28 +61,30 @@ public void refreshHulls() throws IOException { ...@@ -62,28 +61,30 @@ public void refreshHulls() throws IOException {
Path url = Paths.get("just_a_test.kml"); Path url = Paths.get("just_a_test.kml");
String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml>\n" + " <Document>\n"; String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml>\n" + " <Document>\n";
String footer = " </Document>\n" + "</kml>"; String footer = " </Document>\n" + "</kml>";
try (BufferedWriter bw = Files.newBufferedWriter(url)) { ConvexHullCalculator.extractHullsForEveryCityGML(repo,
bw.write(header); (hullKML -> jsApp.call("addCityGmlHull", header + hullKML + footer)));
Files.walk(repo) // try (BufferedWriter bw = Files.newBufferedWriter(url)) {
.filter(Files::isRegularFile) // bw.write(header);
.filter(p -> p.toString().contains(".cache") && p.toString().endsWith(".xyz")) // Files.walk(repo)
.forEach(p -> { // .filter(Files::isRegularFile)
System.out.println("Parsing " + p); // .filter(p -> p.toString().contains(".cache") && p.toString().endsWith(".kml"))
try { // .forEach(p -> {
String hullKML = new String(Files.readAllBytes(p), StandardCharsets.UTF_8); // System.out.println("Parsing " + p);
jsApp.call("addCityGmlHull", header + hullKML + footer); // try {
List<String> lines = Files.readAllLines(p); // String hullKML = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
for (String line : lines) { // jsApp.call("addCityGmlHull", header + hullKML + footer);
bw.write(line + "\n"); // List<String> lines = Files.readAllLines(p);
} // for (String line : lines) {
} catch (IOException ex) { // bw.write(line + "\n");
ex.printStackTrace(); // }
} // } catch (IOException ex) {
}); // ex.printStackTrace();
bw.write(footer); // }
} catch (Exception ex) { // });
ex.printStackTrace(); // bw.write(footer);
} // } catch (Exception ex) {
// ex.printStackTrace();
// }
// Paths.get("src/eu/simstadt/regionchooser/website").relativize(url).toString(); // Paths.get("src/eu/simstadt/regionchooser/website").relativize(url).toString();
} }
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<link rel="stylesheet" type="text/css" href="style/style.css"> <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/firebug-lite-compressed.js'></script>
<script type="text/javascript" src="script/proj4.js"></script> <script type="text/javascript" src="script/proj4.js"></script>
<script type="text/javascript" src="script/jquery-1.4.2.min.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/ --> <!-- OpenLayers v3.4.0. API doc : http://openlayers.org/en/v3.4.0/apidoc/ -->
......
...@@ -15,6 +15,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388 ...@@ -15,6 +15,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
var reset_btn = $('#reset')[0]; var reset_btn = $('#reset')[0];
var dataPanel = $('#dataPanel'); var dataPanel = $('#dataPanel');
var wgs84Sphere = new ol.Sphere(6378137); var wgs84Sphere = new ol.Sphere(6378137);
if (fromJavaFX){
$("html").addClass("wait");
}
var osm_layer = new ol.layer.Tile({ var osm_layer = new ol.layer.Tile({
source: new ol.source.OSM() source: new ol.source.OSM()
...@@ -66,11 +70,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388 ...@@ -66,11 +70,10 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
}); });
publicScope.addCityGmlHull = function(kmlString) { publicScope.addCityGmlHull = function(kmlString) {
kml_source.addFeature(kmlFormat.readFeature(kmlString, options = {featureProjection: ol.proj.get('EPSG:3857')};
{ feature = kmlFormat.readFeature(kmlString, options)
featureProjection: ol.proj.get('EPSG:3857') kml_source.addFeature(feature);
} dataPanel.append('.');
));
}; };
publicScope.addNovaFactoryProduct = function(xmin, ymin, xmax, ymax, name, epsgId) { publicScope.addNovaFactoryProduct = function(xmin, ymin, xmax, ymax, name, epsgId) {
...@@ -97,8 +100,8 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388 ...@@ -97,8 +100,8 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
var map = new ol.Map({ var map = new ol.Map({
target : 'map', target : 'map',
//layers : [ osm_layer, kml_layer, novafactory_layer, intersections_layer ], layers : [ osm_layer, kml_layer, novafactory_layer, intersections_layer ],
layers : [ kml_layer, novafactory_layer, intersections_layer ], //TODO: Put OSM back. Was too slow for testing //layers : [ kml_layer, novafactory_layer, intersections_layer ], //TODO: Put OSM back. Was too slow for testing
interactions : ol.interaction.defaults({ interactions : ol.interaction.defaults({
keyboard : true keyboard : true
}) })
...@@ -310,8 +313,8 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388 ...@@ -310,8 +313,8 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
$('#refresh_hulls').click(function() { $('#refresh_hulls').click(function() {
kml_source.clear(); kml_source.clear();
url = fxapp.refreshHulls(); fxapp.refreshHulls();
console.log('Loading ' + url); updateGMLPolygons();
//kml_source = read_kml(url); //kml_source = read_kml(url);
//kml_layer.setSource(kml_source); //kml_layer.setSource(kml_source);
}); });
...@@ -368,9 +371,11 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388 ...@@ -368,9 +371,11 @@ proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.3876388
fxapp.log(message); fxapp.log(message);
} }
refresh_btn.disabled = false; refresh_btn.disabled = false;
console.log(kml_source.getFeatures()); dataPanel.append('Importing citgyml. Please wait.');
fxapp.refreshHulls(); fxapp.refreshHulls();
updateGMLPolygons(); updateGMLPolygons();
dataPanel.empty();
$("html").removeClass("wait");
console.log("READY!"); 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