From 4866a1438ca85b007152c85157780cb9d1873a8c Mon Sep 17 00:00:00 2001
From: zdenevuk <zdenko.vuk@ijs.si>
Date: Wed, 14 Dec 2022 15:53:40 +0100
Subject: [PATCH]  This is a combination of 2 commits.

made some improvements.

fixed a couple of inverted ones
---
 .../results-map/results-map.component.ts      | 176 +++++++++++++-----
 1 file changed, 130 insertions(+), 46 deletions(-)

diff --git a/src/app/pages/simulation-wizard/results-map/results-map.component.ts b/src/app/pages/simulation-wizard/results-map/results-map.component.ts
index 3ddac4d1..bfdc25c3 100644
--- a/src/app/pages/simulation-wizard/results-map/results-map.component.ts
+++ b/src/app/pages/simulation-wizard/results-map/results-map.component.ts
@@ -460,54 +460,64 @@ export class ResultsMapComponent implements OnChanges {
           features: [],
         });
       } else {
-        if (keys[f] == "capacity") {
-          tmp = L.geoJSON(<any>jsonFile, {
-            style: (feature) => ({
-              weight: this.geoJsonStyleWeight,
-              color: MapColors.getColorHighToLow(
-                feature["properties"]["capacity"],
-                keys[f],
-                this.maxKeyValues[`maxValue_${keys[f]}`],
-                ratiosBetweenGrades,
-                parseInt(feature["properties"]["capacity"]) == 9999
-                  ? true
-                  : false
-              ),
-              opacity: this.geoJsonStyleOpacity,
-            }),
-            onEachFeature: (feature, layer) =>
-              layer.on({
-                mouseover: (e) => this.highlightFeature(e, feature.properties),
-                mouseout: (e) => this.resetFeature(e, feature.properties),
+        if (this.newBrinkValuesApplied) {
+          if (keys[f] == "capacity") {
+            console.log(
+              "%c this has yet to be done, exception for capacity",
+              "background: maroon; color: black; font-weight: bold;"
+            );
+            tmp = L.geoJSON(<any>jsonFile, {
+              style: (feature) => ({
+                weight: this.geoJsonStyleWeight,
+                color: MapColors.getColorHighToLow(
+                  feature["properties"]["capacity"],
+                  keys[f],
+                  this.maxKeyValues[`maxValue_${keys[f]}`],
+                  ratiosBetweenGrades,
+                  parseInt(feature["properties"]["capacity"]) == 9999
+                    ? true
+                    : false
+                ),
+                opacity: this.geoJsonStyleOpacity,
               }),
-          });
-        } else if (
-          keys[f] == "dailyInternalBikeTravels" ||
-          keys[f] == "pedestrianTravelTime"
-        ) {
-          tmp = L.geoJSON(<any>jsonFile, {
-            style: (feature) => ({
-              weight: this.geoJsonStyleWeight,
-              color: MapColors.getColorHighToLow(
-                feature["properties"]["cityWide"]["traffic"][keys[f]] ||
-                  feature["properties"][keys[f]],
-                keys[f],
-                this.maxKeyValues[`maxValue_${keys[f]}`],
-                ratiosBetweenGrades,
-                parseInt(feature["properties"]["capacity"]) == 9999
-                  ? true
-                  : false
-              ),
-              opacity: this.geoJsonStyleOpacity,
-            }),
-            onEachFeature: (feature, layer) =>
-              layer.on({
-                mouseover: (e) => this.highlightFeature(e, feature.properties),
-                mouseout: (e) => this.resetFeature(e, feature.properties),
+              onEachFeature: (feature, layer) =>
+                layer.on({
+                  mouseover: (e) =>
+                    this.highlightFeature(e, feature.properties),
+                  mouseout: (e) => this.resetFeature(e, feature.properties),
+                }),
+            });
+          } else if (
+            keys[f] == "dailyInternalBikeTravels" ||
+            keys[f] == "pedestrianTravelTime"
+          ) {
+            console.log(
+              "%c this has yet to be done, exception for dailyInternalBikeTravels or pedestrianTravelTime",
+              "background: sienna; color: black; font-weight: bold;"
+            );
+            tmp = L.geoJSON(<any>jsonFile, {
+              style: (feature) => ({
+                weight: this.geoJsonStyleWeight,
+                color: MapColors.getColorHighToLow(
+                  feature["properties"]["cityWide"]["traffic"][keys[f]] ||
+                    feature["properties"][keys[f]],
+                  keys[f],
+                  this.maxKeyValues[`maxValue_${keys[f]}`],
+                  ratiosBetweenGrades,
+                  parseInt(feature["properties"]["capacity"]) == 9999
+                    ? true
+                    : false
+                ),
+                opacity: this.geoJsonStyleOpacity,
               }),
-          });
-        } else {
-          if (this.newBrinkValuesApplied) {
+              onEachFeature: (feature, layer) =>
+                layer.on({
+                  mouseover: (e) =>
+                    this.highlightFeature(e, feature.properties),
+                  mouseout: (e) => this.resetFeature(e, feature.properties),
+                }),
+            });
+          } else {
             tmp = L.geoJSON(<any>jsonFile, {
               style: (feature) => ({
                 weight: this.geoJsonStyleWeight,
@@ -528,6 +538,80 @@ export class ResultsMapComponent implements OnChanges {
                   mouseout: (e) => this.resetFeature(e, feature.properties),
                 }),
             });
+          }
+        } else {
+          // default, newBrinkValues not applied
+          if (keys[f] == "capacity") {
+            tmp = L.geoJSON(<any>jsonFile, {
+              style: (feature) => ({
+                weight: this.geoJsonStyleWeight,
+                color: MapColors.getColorHighToLow(
+                  feature["properties"]["capacity"],
+                  keys[f],
+                  this.maxKeyValues[`maxValue_${keys[f]}`],
+                  ratiosBetweenGrades,
+                  parseInt(feature["properties"]["capacity"]) == 9999
+                    ? true
+                    : false
+                ),
+                opacity: this.geoJsonStyleOpacity,
+              }),
+              onEachFeature: (feature, layer) =>
+                layer.on({
+                  mouseover: (e) =>
+                    this.highlightFeature(e, feature.properties),
+                  mouseout: (e) => this.resetFeature(e, feature.properties),
+                }),
+            });
+          } else if (
+            keys[f] == "dailyInternalBikeTravels" ||
+            keys[f] == "pedestrianTravelTime"
+          ) {
+            tmp = L.geoJSON(<any>jsonFile, {
+              style: (feature) => ({
+                weight: this.geoJsonStyleWeight,
+                color: MapColors.getColorHighToLow(
+                  feature["properties"]["cityWide"]["traffic"][keys[f]] ||
+                    feature["properties"][keys[f]],
+                  keys[f],
+                  this.maxKeyValues[`maxValue_${keys[f]}`],
+                  ratiosBetweenGrades,
+                  parseInt(feature["properties"]["capacity"]) == 9999
+                    ? true
+                    : false
+                ),
+                opacity: this.geoJsonStyleOpacity,
+              }),
+              onEachFeature: (feature, layer) =>
+                layer.on({
+                  mouseover: (e) =>
+                    this.highlightFeature(e, feature.properties),
+                  mouseout: (e) => this.resetFeature(e, feature.properties),
+                }),
+            });
+          } else if (legendInverted.indexOf(keys[f]) > -1) {
+            // default but  inverted
+            tmp = L.geoJSON(<any>jsonFile, {
+              style: (feature) => ({
+                weight: this.geoJsonStyleWeight,
+                color: MapColors.getColorHighToLow(
+                  feature["properties"] || feature["properties"][keys[f]],
+                  keys[f],
+                  this.maxKeyValues[`maxValue_${keys[f]}`],
+                  ratiosBetweenGrades,
+                  parseInt(feature["properties"]["capacity"]) == 9999
+                    ? true
+                    : false
+                ),
+                opacity: this.geoJsonStyleOpacity,
+              }),
+              onEachFeature: (feature, layer) =>
+                layer.on({
+                  mouseover: (e) =>
+                    this.highlightFeature(e, feature.properties),
+                  mouseout: (e) => this.resetFeature(e, feature.properties),
+                }),
+            });
           } else {
             tmp = L.geoJSON(<any>jsonFile, {
               style: (feature) => ({
-- 
GitLab