From cf8c7a829562c6bf5f4b904c99f02441c1739699 Mon Sep 17 00:00:00 2001
From: BujarMuharemi <bujar.muharemi.28@gmail.com>
Date: Tue, 11 Jan 2022 15:38:35 +0100
Subject: [PATCH] removed roofview

---
 public/js/globe.js | 56 ++++++++++++++++++++++++----------------------
 public/main.html   |  3 ++-
 2 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/public/js/globe.js b/public/js/globe.js
index e863868..0586b98 100644
--- a/public/js/globe.js
+++ b/public/js/globe.js
@@ -9,43 +9,45 @@ var viewer = new Cesium.Viewer('cesiumContainer', {
     animation: false,
     sceneModePicker: false,
     geocoder: false,
-    sceneMode : Cesium.SceneMode.SCENE3D
+    sceneMode: Cesium.SceneMode.SCENE3D
 });
 
 viewer.scene.globe.depthTestAgainstTerrain = true;
 //--------------------hover over surfaces--------------------
 var singleChart = document.getElementById('singleChartContainer');
 
+var roofViewActivated = false;
 
 //load address
 var request = new XMLHttpRequest();
-request.onreadystatechange = function(){
-    if(this.readyState == 4 && this.status == 200){
-
-var coordinate = JSON.parse(request.responseText);
-var lat = coordinate.results[0].geometry.lat;
-var lng = coordinate.results[0].geometry.lng;
-console.log(lat + "  " + lng);
-fly(lat, lng);
+request.onreadystatechange = function() {
+    if (this.readyState == 4 && this.status == 200) {
+
+        var coordinate = JSON.parse(request.responseText);
+        var lat = coordinate.results[0].geometry.lat;
+        var lng = coordinate.results[0].geometry.lng;
+        console.log(lat + "  " + lng);
+        fly(lat, lng);
     }
 }
-function searchaddress(){
+
+function searchaddress() {
     var query = document.getElementById('SearchAddress').value;
-    request.open("GET",'https://api.opencagedata.com/geocode/v1/json?key=c73da14969e6408ab4535b3ad6dc43ea&pretty=1&no_annotations=1&q=' + query, true);
-  request.send();
+    request.open("GET", 'https://api.opencagedata.com/geocode/v1/json?key=c73da14969e6408ab4535b3ad6dc43ea&pretty=1&no_annotations=1&q=' + query, true);
+    request.send();
 }
 
-function fly( lat,  lng){
+function fly(lat, lng) {
     var pinBuilder = new Cesium.PinBuilder();
 
-var bluePin = viewer.entities.add({
-  name: "Blank blue pin",
-  position: Cesium.Cartesian3.fromDegrees(lng, lat),
-  billboard: {
-    image: pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
-    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
-  },
-});
+    var bluePin = viewer.entities.add({
+        name: "Blank blue pin",
+        position: Cesium.Cartesian3.fromDegrees(lng, lat),
+        billboard: {
+            image: pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
+            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
+        },
+    });
     viewer.zoomTo(bluePin);
 
     viewer.flyTo(bluePin);
@@ -235,7 +237,7 @@ var pickRoofType
 var pickUValue
 
 var shadowHourValue = 0;
-var SurfacePvPotential=[];
+var SurfacePvPotential = [];
 
 
 //Color a feature on selection and show metadata in the InfoBox
@@ -338,13 +340,13 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
 
                             }
                         }
-                        
+
                         //coloring surfaces on pv potential
                         for (const [key, value] of Object.entries(pvPotentialSurfaces)) { //looping threw the shadowdata array                            
                             if (value["id"] === t.getProperty("gml_id")) { //checking if the ids of the current surface match the id in the shadowdata array
                                 //console.log("hour:",chosenDate.hour);
-                                console.log(value);   
-                                SurfacePvPotential = value["attributes"]["pvPotential"]["totalInvestment"];                            
+                                //console.log(value);   
+                                SurfacePvPotential = value["attributes"]["pvPotential"]["totalInvestment"];
                             }
                         }
                     }
@@ -376,7 +378,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
                 "<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>totalInvestment</th><td>" + SurfacePvPotential  + "</td></tr>" +
+                "<tr><th>totalInvestment</th><td>" + SurfacePvPotential + "</td></tr>" +
 
                 "</tbody></table>";
 
@@ -439,7 +441,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
 
         //Roof View
         //BUG: shows random attributes ui element ??
-        else if (document.getElementById("roof").checked) {
+        else if (document.getElementById("roof").checked && roofViewActivated) {
             console.log("clicked when in roof view and on click");
 
             //looping threw all surfaces
diff --git a/public/main.html b/public/main.html
index 47bc7fc..e10ea3b 100644
--- a/public/main.html
+++ b/public/main.html
@@ -254,9 +254,10 @@
 						<div class="lang" key="surfaceview">Surface-View</div>
 						<label class="drinkcard-cc surface" for="surface"></label>
 
+						<!-- deprecated: Used for roof-view
 						<input id="roof" type="radio" name="credit-card" value="roof">
 						<div class="lang" key="roofview">Roof-View</div>
-						<label class="drinkcard-cc surface" for="roof"></label>
+						<label class="drinkcard-cc surface" for="roof"></label> -->
 
 					</div>
 				</div>
-- 
GitLab