From d8296f271fa4ef69af428a6c9a4a7ab82b165259 Mon Sep 17 00:00:00 2001
From: BujarMuharemi <bujar.muharemi.28@gmail.com>
Date: Mon, 17 Jan 2022 22:43:27 +0100
Subject: [PATCH] fixed shadow coloring;fixed showing of chosen att.

---
 public/js/colorPalettes.js |  4 ++--
 public/js/globe.js         | 23 ++++++++++++++---------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/public/js/colorPalettes.js b/public/js/colorPalettes.js
index 10ddff4..5540167 100644
--- a/public/js/colorPalettes.js
+++ b/public/js/colorPalettes.js
@@ -5,8 +5,8 @@ var pvPotentialPallet = ['#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0',
 pvPotentialPallet = pvPotentialPallet.reverse();
 
 //color pallet      white->black
-var colorPalette = ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525'];
-const shadowPalette = colorPalette.reverse();
+var colorPalette = ['#bdbdbd', '#969696', '#737373', '#525252', '#252525'];
+const shadowPalette = colorPalette;
 
 //returns the responding color from the shadowPalette, depending on the inputShadowValue(0 to 1 in float)
 function getShadowPalette(inputShadowValue) {
diff --git a/public/js/globe.js b/public/js/globe.js
index ae8a3e9..0fc7010 100644
--- a/public/js/globe.js
+++ b/public/js/globe.js
@@ -347,9 +347,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
                                 if (chosenAttributeRadioBtnFlag === "shadowValue") {
                                     t.color = Cesium.Color.fromCssColorString(getColorFromPalette(shadowHourValue, "shadowValue")); //coloring the surface
                                 }
-
                                 //t.color = Cesium.Color.fromCssColorString(getShadowPalette(shadowHourValue)); //coloring the surface
-
                             }
                         }
                         console.log(pvPotentialSurfaces);
@@ -358,14 +356,14 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
                         
                         console.log("minie maus", minAndMaxPvPotentials);
                         for (const [key, value] of Object.entries(pvPotentialSurfaces)) {
-                            if (value["id"] === t.getProperty("gml_id")) { //checking if the ids of the current surface match the id in the shadowdata array
+                            if (value["id"] === t.getProperty("gml_id") && chosenAttributeRadioBtnFlag !== "shadowValue") { //checking if the ids of the current surface match the id in the shadowdata array
                                 //console.log("hour:",chosenDate.hour);    
-                                var normalizedPvValue;
+                                var normalizedPvValue="";
                                 chosenPvPotentialValue = value["attributes"]["pvPotential"][chosenAttributeRadioBtnFlag];
                                 console.log("chosenPvPotentialValue",chosenPvPotentialValue);
                                 
                                 normalizedPvValue = getNormalizedValue(chosenPvPotentialValue);
-                                console.log("normalisierter", normalizedPvValue);
+                                console.log("normalisierter", normalizedPvValue);                                
                                 t.color = Cesium.Color.fromCssColorString(getColorFromPalette(normalizedPvValue, "pvPotential")); //coloring the surface
                                 SurfacePvPotential = chosenPvPotentialValue;
             
@@ -390,7 +388,16 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
                 });
             }
 
-            var shadowhourvaluepercent = 100 - (shadowHourValue * 100)
+            var chosenAttribute2Show = "";
+            var shadowhourvaluepercent = shadowHourValue * 100;
+            console.log("shadowHourValue:",shadowHourValue*100,"\n shadowhourvaluepercent:",shadowhourvaluepercent);
+
+            if(chosenAttributeRadioBtnFlag==="shadowValue"){
+                chosenAttribute2Show ="<tr><th>shadow value</th><td>" + shadowhourvaluepercent.toFixed(1) + "%" + "</td></tr>";
+            }else{
+                chosenAttribute2Show = "<tr><th>"+chosenAttributeRadioBtnFlag+"</th><td>" + SurfacePvPotential + "</td></tr>";
+            }
+            
             //set feature infobox description (surface view)
             var featureName = pickedFeature.getProperty("name");
             selectedEntity.name = featureName;
@@ -402,9 +409,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
                 "<tr><th>u_Value</th><td>" + pickUValue + "</td></tr>" +
                 "<tr><th>description</th><td>" + pickedFeature.getProperty("description") + "</td></tr>" +
                 "<tr><th>feature_type</th><td>" + pickedFeature.getProperty("feature_type") + "</td></tr>" +
-                "<tr><th>shadow value</th><td>" + shadowhourvaluepercent.toFixed(1) + "%" + "</td></tr>" +
-                "<tr><th>"+chosenAttributeRadioBtnFlag+"</th><td>" + SurfacePvPotential + "</td></tr>" +
-
+                chosenAttribute2Show;
                 "</tbody></table>";
 
 
-- 
GitLab