From bce72df7d3cd58f40d83ba69c0fb9a250270b193 Mon Sep 17 00:00:00 2001 From: jshjelse <jshjelse@stud.ntnu.no> Date: Mon, 23 Oct 2023 08:46:53 +0200 Subject: [PATCH] Ferdigstilt --- javascript/fileHandler.js | 7 ++----- javascript/turfFormatConverter.js | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/javascript/fileHandler.js b/javascript/fileHandler.js index f30c3b5..6b7c335 100644 --- a/javascript/fileHandler.js +++ b/javascript/fileHandler.js @@ -31,16 +31,13 @@ function handleFile() { } } - console.log(JSON.stringify(data)); - - //newLayer.addData(data); + newLayer.addData(data); }) } - /* + overlayMaps[selectedFile.name] = newLayer; updateSidebar(); handleLayer(selectedFile.name); - */ } diff --git a/javascript/turfFormatConverter.js b/javascript/turfFormatConverter.js index 6afbca4..617d02d 100644 --- a/javascript/turfFormatConverter.js +++ b/javascript/turfFormatConverter.js @@ -51,7 +51,7 @@ function isInputMultiPolygon(layer) { } function turnList(liste) { - var more = false; + /*var more = false; try { var test = liste[0][0][0]; if (test != null) { @@ -64,17 +64,17 @@ function turnList(liste) { if (more) { var newList = []; - + console.log("JA") for (var i = 0; i < layer.length; i++) { newList.push(turnList(liste[i])); } - } else { - var newList = []; + } else {*/ + var newList = []; - for (var i = liste.length - 1; i > -1; i--) { - newList.push(liste[i]); - } + for (var i = liste.length - 1; i > -1; i--) { + newList.push(liste[i]); } + //} return newList; } @@ -111,14 +111,14 @@ function inputMultiLine(layer) { for (var i = 0; i < k; i++) { if (liste[i]["geometry"]["coordinates"].length == 1) { liste[i]["geometry"]["type"] = "LineString"; - liste[i]["geometry"]["coordinates"] = turnList(liste[i]["geometry"]["coordinates"][0][0]); + liste[i]["geometry"]["coordinates"] = liste[i]["geometry"]["coordinates"][0]; } else if (liste[i]["geometry"]["coordinates"].length > 1) { var coordinates = liste[i]["geometry"]["coordinates"]; liste[i]["geometry"]["type"] = "LineString"; - liste[i]["geometry"]["coordinates"] = turnList(coordinates[0][0]); + liste[i]["geometry"]["coordinates"] = coordinates[0]; for (var j = 1; j < coordinates.length; j++) { - newElement = {"type": liste[i]["type"], "properties": liste[i]["properties"], "geometry": {"type": "Polygon", "coordinates": turnList(coordinates[j][0])}}; + newElement = {"type": liste[i]["type"], "properties": liste[i]["properties"], "geometry": {"type": "LineString", "coordinates": coordinates[j]}}; liste.push(newElement); } } -- GitLab