Commit 22cecee7 authored by Eric Duminil's avatar Eric Duminil
Browse files

no more id

parent 35144651
...@@ -11,11 +11,9 @@ const regionChooser = (function(){ ...@@ -11,11 +11,9 @@ const regionChooser = (function(){
const dataPanel = $('#dataPanel'); const dataPanel = $('#dataPanel');
const wgs84Sphere = new ol.Sphere(6378137); const wgs84Sphere = new ol.Sphere(6378137);
var features_by_project; var features_by_project;
var gmlId;
publicScope.init = function(){ publicScope.init = function(){
//NOTE: Only called from JavaFX. At startup, or when Repo has been changed. //NOTE: Only called from JavaFX. At startup, or when Repo has been changed.
gmlId = 0;
kml_source.clear(); kml_source.clear();
document.getElementById("select_repository").style.visibility = "visible"; document.getElementById("select_repository").style.visibility = "visible";
} }
...@@ -49,7 +47,6 @@ const regionChooser = (function(){ ...@@ -49,7 +47,6 @@ const regionChooser = (function(){
publicScope.addCityGmlHull = function(kmlString) { publicScope.addCityGmlHull = function(kmlString) {
options = {featureProjection: ol.proj.get('EPSG:3857')}; options = {featureProjection: ol.proj.get('EPSG:3857')};
feature = kmlFormat.readFeature(kmlString, options); feature = kmlFormat.readFeature(kmlString, options);
feature.setId(gmlId++);
kml_source.addFeature(feature); kml_source.addFeature(feature);
dataPanel.append('.'); dataPanel.append('.');
srsName = feature.get("srsName"); srsName = feature.get("srsName");
...@@ -200,13 +197,17 @@ const regionChooser = (function(){ ...@@ -200,13 +197,17 @@ const regionChooser = (function(){
publicScope.isDownloadPossible = function(){ publicScope.isDownloadPossible = function(){
kml_source.getFeatures().forEach(f => refreshStyle(f, "original")); kml_source.getFeatures().forEach(f => refreshStyle(f, "original"));
//TODO: Dry selectedFeatures = getSelectedGMLs();
var selectedFeatures = Array.from(document.querySelectorAll("input.select_citygml")).filter(c => c.checked).map(c => c.feature);
selectedFeatures.forEach(f => refreshStyle(f, "selected")); selectedFeatures.forEach(f => refreshStyle(f, "selected"));
document.getElementById("download_region_button").disabled = (selectedFeatures.length == 0); document.getElementById("download_region_button").disabled = (selectedFeatures.length == 0);
} }
function getSelectedGMLs(){
return Array.from(document.querySelectorAll("input.select_citygml")).filter(c => c.checked).map(c => c.feature);
}
function findIntersection(feature, polygon) { function findIntersection(feature, polygon) {
try { try {
return turf.intersect(polygon, feature["geoJSON"]); return turf.intersect(polygon, feature["geoJSON"]);
...@@ -244,17 +245,8 @@ const regionChooser = (function(){ ...@@ -244,17 +245,8 @@ const regionChooser = (function(){
dataPanel.append(text + "<br/>\n"); dataPanel.append(text + "<br/>\n");
} }
getCheckedPolygons = function(checkbox_ids){ publicScope.downloadRegionFromCityGMLs = function(features) {
return checkbox_ids.map(checkbox_id => {
var i = Number(checkbox_id.replace("citygml_", ""));
return kml_source.getFeatureById(i);
})
}
publicScope.downloadRegionFromCityGMLs = function(checkbox_ids) {
//FIXME: Somehow, no feedback comes after large files are downloaded. :( //FIXME: Somehow, no feedback comes after large files are downloaded. :(
var features = getCheckedPolygons(checkbox_ids);
var project = features[0].get("project"); var project = features[0].get("project");
var srsName = features[0].get("srsName"); var srsName = features[0].get("srsName");
...@@ -399,15 +391,11 @@ const regionChooser = (function(){ ...@@ -399,15 +391,11 @@ const regionChooser = (function(){
publicScope.downloadFromSelectedCityGMLs = function() { publicScope.downloadFromSelectedCityGMLs = function() {
document.getElementById("download_region_button").disabled = true; document.getElementById("download_region_button").disabled = true;
var checkedBoxes = Array.from(document.querySelectorAll("input.select_citygml")).filter(c => c.checked); let selectedGMLs = getSelectedGMLs();
// CheckBoxes isn't empty, because otherwise the button cannot be clicked.
var checkbox_ids = checkedBoxes.map(c => c.id);
var features = getCheckedPolygons(checkbox_ids);
features.forEach(f => f.setStyle(utils.polygon_style("#ffff00", 0.8))); selectedGMLs.forEach(f => f.setStyle(utils.polygon_style("#ffff00", 0.8)));
publicScope.downloadRegionFromCityGMLs(checkedBoxes.map(c => c.id)); publicScope.downloadRegionFromCityGMLs(selectedGMLs);
} }
publicScope.selectAllOrNone = function(allOrNone) { publicScope.selectAllOrNone = function(allOrNone) {
......
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