|
@@ -65,6 +65,12 @@ export class SdmDihService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * For given region, year and scenario calculates its aggregated index,
|
|
|
|
|
+ * i.e. the Index of Rural Attractiveness (RAI) by combining its sub-indices
|
|
|
|
|
+ * @param regionData - Data for all the factors in a certain region, certain year and certain scenario
|
|
|
|
|
+ * @returns Aggregated index for the region, year and scenario
|
|
|
|
|
+ */
|
|
|
calcAggregatedIndex(regionData) {
|
|
calcAggregatedIndex(regionData) {
|
|
|
let weightedSum = 0;
|
|
let weightedSum = 0;
|
|
|
let sumWeight = 0;
|
|
let sumWeight = 0;
|
|
@@ -90,6 +96,11 @@ export class SdmDihService {
|
|
|
return weightedSum / sumWeight;
|
|
return weightedSum / sumWeight;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * For given region, given year, given scenario and single factor calculates its index value (a sub-index)
|
|
|
|
|
+ * @param factorData - Data for a single factor in a certain region, certain year and certain scenario
|
|
|
|
|
+ * @returns Sub-index value (between 0 and 1)
|
|
|
|
|
+ */
|
|
|
calcFactorIndex(factorData) {
|
|
calcFactorIndex(factorData) {
|
|
|
let sumValue = 0;
|
|
let sumValue = 0;
|
|
|
let n = 0;
|
|
let n = 0;
|
|
@@ -129,7 +140,7 @@ export class SdmDihService {
|
|
|
}
|
|
}
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
const h = r * 0x10000 + g * 0x100 + b * 0x1;
|
|
const h = r * 0x10000 + g * 0x100 + b * 0x1;
|
|
|
- return `rgba(${r}, ${g}, ${b}, 0.7)`;
|
|
|
|
|
|
|
+ return `rgba(${r}, ${g}, ${b}, 1)`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -153,7 +164,7 @@ export class SdmDihService {
|
|
|
}
|
|
}
|
|
|
if (!regionData[factor]) {
|
|
if (!regionData[factor]) {
|
|
|
regionData[factor] = {
|
|
regionData[factor] = {
|
|
|
- weight: 1,
|
|
|
|
|
|
|
+ weight: 1, //TODO: Allow to change weight of factors?
|
|
|
datasets: [],
|
|
datasets: [],
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|