|
|
@@ -108,24 +108,15 @@ module.exports.loadClusteringInput = async function (inputFileName) {
|
|
|
*/
|
|
|
module.exports.modifyClusteringData = async function ({datasets, data, params, idString, outputFileName}) {
|
|
|
// regional ID must be copied to the output as well
|
|
|
- let allowedDatasets = [idString];
|
|
|
- for (const factor of params.factors) {
|
|
|
- allowedDatasets = [...allowedDatasets, ...factor.datasets];
|
|
|
- }
|
|
|
+ const allowedDatasets = [idString, ...params.datasets.map(ds => ds.id)]
|
|
|
const factorMultipliers = data[0].map((dataset) => {
|
|
|
- if (dataset === idString) return 1;
|
|
|
- const factor = datasets.find(ds => ds.Name === dataset);
|
|
|
- if (!factor) {
|
|
|
- /* If the factor is unknown for this dataset, it will effectivelly turn it off */
|
|
|
- console.log(`Undefined factor for dataset ${dataset}`);
|
|
|
- return 0;
|
|
|
- } else if (!allowedDatasets.includes(dataset)) {
|
|
|
- return 0;
|
|
|
+ if (dataset === idString) return 1
|
|
|
+ if (!allowedDatasets.includes(dataset)) {
|
|
|
+ return 0
|
|
|
} else {
|
|
|
- return params.factors.find(f => f.factor === factor.Factor).weight;
|
|
|
+ return params.datasets.find(ds => ds.id === dataset).weight
|
|
|
}
|
|
|
})
|
|
|
- //console.log(factorMultipliers);
|
|
|
/* The actual modification logic resides here */
|
|
|
const modifiedData = data.map((row, idx) => {
|
|
|
return row.map((value, i) => {
|