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

no more id

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