Skip to content
Snippets Groups Projects
Commit 78a8be3c authored by zdenko.vuk@ijs.si's avatar zdenko.vuk@ijs.si
Browse files

This is a combination of 2 commits.

made some further cleanup

renamed a variable
parent 42fbbeca
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ const color_value_undefined = "#9efcff33"; ...@@ -18,7 +18,7 @@ const color_value_undefined = "#9efcff33";
export function getColor( export function getColor(
properties: any, properties: any,
pro: any, pro: any,
ograjice: number[], brinkValues: number[],
isCapacityEqual9999: boolean isCapacityEqual9999: boolean
): string { ): string {
if (isCapacityEqual9999 == true) { if (isCapacityEqual9999 == true) {
...@@ -42,23 +42,23 @@ export function getColor( ...@@ -42,23 +42,23 @@ export function getColor(
if (value == undefined) return color_value_undefined; if (value == undefined) return color_value_undefined;
return value > ograjice[4] return value > brinkValues[4]
? color_0 ? color_0
: value > ograjice[3] : value > brinkValues[3]
? color_1 ? color_1
: value > ograjice[2] : value > brinkValues[2]
? color_2 ? color_2
: value > ograjice[1] : value > brinkValues[1]
? color_3 ? color_3
: value > ograjice[0] : value > brinkValues[0]
? color_4 ? color_4
: color_5; : color_5;
} }
export function getColorOgrajiceHighToLow( export function getColorHighToLow(
properties: any, properties: any,
pro: any, pro: any,
ograjice: number[], brinkValues: number[],
isCapacityEqual9999: boolean isCapacityEqual9999: boolean
): string { ): string {
if (isCapacityEqual9999 == true) { if (isCapacityEqual9999 == true) {
...@@ -82,15 +82,15 @@ export function getColorOgrajiceHighToLow( ...@@ -82,15 +82,15 @@ export function getColorOgrajiceHighToLow(
if (value == undefined) return color_value_undefined; if (value == undefined) return color_value_undefined;
return value > ograjice[4] return value > brinkValues[4]
? color_5 ? color_5
: value > ograjice[3] : value > brinkValues[3]
? color_4 ? color_4
: value > ograjice[2] : value > brinkValues[2]
? color_3 ? color_3
: value > ograjice[1] : value > brinkValues[1]
? color_2 ? color_2
: value > ograjice[0] : value > brinkValues[0]
? color_1 ? color_1
: color_0; : color_0;
} }
......
...@@ -41,7 +41,7 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -41,7 +41,7 @@ export class ResultsMapComponent implements OnInit, OnChanges {
grayscale: number = 50; grayscale: number = 50;
loadGeojsons: Object[] = []; loadGeojsons: Object[] = [];
maxKeyValues: Object = {}; maxKeyValues: Object = {};
ograjiceValues: Object = {}; brinkValues: Object = {};
newBrinkValuesForm = new FormGroup({ newBrinkValuesForm = new FormGroup({
legend_0: new FormControl(undefined), legend_0: new FormControl(undefined),
legend_1: new FormControl(undefined), legend_1: new FormControl(undefined),
...@@ -357,22 +357,22 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -357,22 +357,22 @@ export class ResultsMapComponent implements OnInit, OnChanges {
}); });
} else { } else {
if (this.newBrinkValuesApplied) { if (this.newBrinkValuesApplied) {
let ograjice = []; let l = [];
ograjice.push(this.newBrinkValuesForm.get("legend_0").value); l.push(this.newBrinkValuesForm.get("legend_0").value);
ograjice.push(this.newBrinkValuesForm.get("legend_1").value); l.push(this.newBrinkValuesForm.get("legend_1").value);
ograjice.push(this.newBrinkValuesForm.get("legend_2").value); l.push(this.newBrinkValuesForm.get("legend_2").value);
ograjice.push(this.newBrinkValuesForm.get("legend_3").value); l.push(this.newBrinkValuesForm.get("legend_3").value);
ograjice.push(this.newBrinkValuesForm.get("legend_4").value); l.push(this.newBrinkValuesForm.get("legend_4").value);
this.ograjiceValues[keys[f]] = ograjice; this.brinkValues[keys[f]] = l;
if (keys[f] == "capacity") { if (keys[f] == "capacity") {
tmp = L.geoJSON(<any>jsonFile, { tmp = L.geoJSON(<any>jsonFile, {
style: (feature) => ({ style: (feature) => ({
weight: this.geoJsonStyleWeight, weight: this.geoJsonStyleWeight,
color: MapColors.getColorOgrajiceHighToLow( color: MapColors.getColorHighToLow(
feature["properties"]["capacity"], feature["properties"]["capacity"],
keys[f], keys[f],
ograjice, l,
parseInt(feature["properties"]["capacity"]) == 9999 parseInt(feature["properties"]["capacity"]) == 9999
? true ? true
: false : false
...@@ -397,7 +397,7 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -397,7 +397,7 @@ export class ResultsMapComponent implements OnInit, OnChanges {
feature["properties"]["cityWide"]["traffic"][keys[f]] || feature["properties"]["cityWide"]["traffic"][keys[f]] ||
feature["properties"][keys[f]], feature["properties"][keys[f]],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -413,10 +413,10 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -413,10 +413,10 @@ export class ResultsMapComponent implements OnInit, OnChanges {
tmp = L.geoJSON(<any>jsonFile, { tmp = L.geoJSON(<any>jsonFile, {
style: (feature) => ({ style: (feature) => ({
weight: this.geoJsonStyleWeight, weight: this.geoJsonStyleWeight,
color: MapColors.getColorOgrajiceHighToLow( color: MapColors.getColorHighToLow(
feature["properties"], feature["properties"],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -435,7 +435,7 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -435,7 +435,7 @@ export class ResultsMapComponent implements OnInit, OnChanges {
color: MapColors.getColor( color: MapColors.getColor(
feature["properties"], feature["properties"],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -450,22 +450,22 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -450,22 +450,22 @@ export class ResultsMapComponent implements OnInit, OnChanges {
} }
} else { } else {
// default, newBrinkValuesForm not applied // default, newBrinkValuesForm not applied
let ograjice = []; let l = [];
ratiosBetweenGrades.forEach((r) => { ratiosBetweenGrades.forEach((r) => {
ograjice.push( l.push(
this.roundMyNumbers(this.maxKeyValues[`maxValue_${keys[f]}`] / r) this.roundMyNumbers(this.maxKeyValues[`maxValue_${keys[f]}`] / r)
); );
}); });
this.ograjiceValues[keys[f]] = ograjice; this.brinkValues[keys[f]] = l;
if (keys[f] == "capacity") { if (keys[f] == "capacity") {
tmp = L.geoJSON(<any>jsonFile, { tmp = L.geoJSON(<any>jsonFile, {
style: (feature) => ({ style: (feature) => ({
weight: this.geoJsonStyleWeight, weight: this.geoJsonStyleWeight,
color: MapColors.getColorOgrajiceHighToLow( color: MapColors.getColorHighToLow(
feature["properties"]["capacity"], feature["properties"]["capacity"],
keys[f], keys[f],
ograjice, l,
parseInt(feature["properties"]["capacity"]) == 9999 parseInt(feature["properties"]["capacity"]) == 9999
? true ? true
: false : false
...@@ -490,7 +490,7 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -490,7 +490,7 @@ export class ResultsMapComponent implements OnInit, OnChanges {
feature["properties"]["cityWide"]["traffic"][keys[f]] || feature["properties"]["cityWide"]["traffic"][keys[f]] ||
feature["properties"][keys[f]], feature["properties"][keys[f]],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -506,10 +506,10 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -506,10 +506,10 @@ export class ResultsMapComponent implements OnInit, OnChanges {
tmp = L.geoJSON(<any>jsonFile, { tmp = L.geoJSON(<any>jsonFile, {
style: (feature) => ({ style: (feature) => ({
weight: this.geoJsonStyleWeight, weight: this.geoJsonStyleWeight,
color: MapColors.getColorOgrajiceHighToLow( color: MapColors.getColorHighToLow(
feature["properties"], feature["properties"],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -528,7 +528,7 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -528,7 +528,7 @@ export class ResultsMapComponent implements OnInit, OnChanges {
color: MapColors.getColor( color: MapColors.getColor(
feature["properties"], feature["properties"],
keys[f], keys[f],
ograjice, l,
false false
), ),
opacity: this.geoJsonStyleOpacity, opacity: this.geoJsonStyleOpacity,
...@@ -722,28 +722,28 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -722,28 +722,28 @@ export class ResultsMapComponent implements OnInit, OnChanges {
"<p style='background:white; display: inline; font-size:17px'> <span style='color:" + "<p style='background:white; display: inline; font-size:17px'> <span style='color:" +
MapColors.getColorForLegend(0) + MapColors.getColorForLegend(0) +
"'>&#9632</span> <" + "'>&#9632</span> <" +
this.ograjiceValues[legendType][0] + this.brinkValues[legendType][0] +
"</p>"; "</p>";
for (let i = 1; i < 6; i++) { for (let i = 1; i < 6; i++) {
div.innerHTML += div.innerHTML +=
"<p style='background:white; display: inline; font-size:17px'> <span style='color:" + "<p style='background:white; display: inline; font-size:17px'> <span style='color:" +
MapColors.getColorForLegend(i) + MapColors.getColorForLegend(i) +
"'>&#9632</span> " + "'>&#9632</span> " +
this.ograjiceValues[legendType][i - 1] + this.brinkValues[legendType][i - 1] +
(this.ograjiceValues[legendType][i] (this.brinkValues[legendType][i]
? "&ndash;" + this.ograjiceValues[legendType][i] + "</p>" ? "&ndash;" + this.brinkValues[legendType][i] + "</p>"
: "+</p>"); : "+</p>");
this.newBrinkValuesForm this.newBrinkValuesForm
.get(`legend_${i - 1}`) .get(`legend_${i - 1}`)
.setValue(`${this.ograjiceValues[legendType][i - 1]}`); .setValue(`${this.brinkValues[legendType][i - 1]}`);
} }
} else { } else {
div.innerHTML += div.innerHTML +=
"<p style='background:white; display: inline; font-size:17px'> <span style='color:" + "<p style='background:white; display: inline; font-size:17px'> <span style='color:" +
MapColors.getColorForLegendHighToLow(0) + MapColors.getColorForLegendHighToLow(0) +
"'>&#9632</span> <" + "'>&#9632</span> <" +
this.ograjiceValues[legendType][0] + this.brinkValues[legendType][0] +
"</p>"; "</p>";
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
...@@ -751,14 +751,14 @@ export class ResultsMapComponent implements OnInit, OnChanges { ...@@ -751,14 +751,14 @@ export class ResultsMapComponent implements OnInit, OnChanges {
"<p style='background:white; display: inline; font-size:17px'> <span style='color:" + "<p style='background:white; display: inline; font-size:17px'> <span style='color:" +
MapColors.getColorForLegendHighToLow(i + 1) + MapColors.getColorForLegendHighToLow(i + 1) +
"'>&#9632</span> " + "'>&#9632</span> " +
this.ograjiceValues[legendType][i] + this.brinkValues[legendType][i] +
(this.ograjiceValues[legendType][i + 1] (this.brinkValues[legendType][i + 1]
? "&ndash;" + this.ograjiceValues[legendType][i + 1] + "</p>" ? "&ndash;" + this.brinkValues[legendType][i + 1] + "</p>"
: "+</p>"); : "+</p>");
this.newBrinkValuesForm this.newBrinkValuesForm
.get(`legend_${i}`) .get(`legend_${i}`)
.setValue(`${this.ograjiceValues[legendType][i]}`); .setValue(`${this.brinkValues[legendType][i]}`);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment