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

RegionChooser: Try to import Citygml directly.

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