|
@@ -68,7 +68,7 @@ export class AdjusterService {
|
|
|
}),
|
|
}),
|
|
|
})
|
|
})
|
|
|
.toPromise()
|
|
.toPromise()
|
|
|
- .then((attractivenessData: any) => {
|
|
|
|
|
|
|
+ .then((attractivenessData: any[]) => {
|
|
|
console.log(attractivenessData);
|
|
console.log(attractivenessData);
|
|
|
//this.attractivity = attractivenessData;
|
|
//this.attractivity = attractivenessData;
|
|
|
/*let max = 0;
|
|
/*let max = 0;
|
|
@@ -77,13 +77,21 @@ export class AdjusterService {
|
|
|
max = a.aggregate;
|
|
max = a.aggregate;
|
|
|
}
|
|
}
|
|
|
});*/
|
|
});*/
|
|
|
|
|
+ // Spread the 'aggregate' value between 0 and 1
|
|
|
|
|
+ const min = attractivenessData.reduce((a, b) =>
|
|
|
|
|
+ a.aggregate < b.aggregate ? a : b
|
|
|
|
|
+ ).aggregate;
|
|
|
const max = attractivenessData.reduce((a, b) =>
|
|
const max = attractivenessData.reduce((a, b) =>
|
|
|
a.aggregate > b.aggregate ? a : b
|
|
a.aggregate > b.aggregate ? a : b
|
|
|
).aggregate;
|
|
).aggregate;
|
|
|
- const normalizer = 1 / max;
|
|
|
|
|
|
|
+ const coefficient = 1 / (max - min);
|
|
|
|
|
+ const constant = -min * coefficient;
|
|
|
attractivenessData.forEach((a) => {
|
|
attractivenessData.forEach((a) => {
|
|
|
- a.aggregate *= normalizer;
|
|
|
|
|
|
|
+ a.aggregate *= coefficient;
|
|
|
|
|
+ a.aggregate += constant;
|
|
|
});
|
|
});
|
|
|
|
|
+ console.log(attractivenessData);
|
|
|
|
|
+ // Store relation between region and its data in a hash-table-like structure
|
|
|
const codeRecordRelations = {};
|
|
const codeRecordRelations = {};
|
|
|
attractivenessData.forEach((a) => {
|
|
attractivenessData.forEach((a) => {
|
|
|
codeRecordRelations[a.code] = a;
|
|
codeRecordRelations[a.code] = a;
|
|
@@ -99,12 +107,14 @@ export class AdjusterService {
|
|
|
// NOTE: Do NOT add triple equal sign!
|
|
// NOTE: Do NOT add triple equal sign!
|
|
|
(item) => item['code'] == feature.get('nationalCode')
|
|
(item) => item['code'] == feature.get('nationalCode')
|
|
|
);*/
|
|
);*/
|
|
|
- if (!featureData && errs < 20) {
|
|
|
|
|
- errs++;
|
|
|
|
|
- console.warn(
|
|
|
|
|
- `No data for feature ${feature.get('nationalCode')}`
|
|
|
|
|
- );
|
|
|
|
|
- console.log(feature);
|
|
|
|
|
|
|
+ if (!featureData) {
|
|
|
|
|
+ if (errs < 20) {
|
|
|
|
|
+ errs++;
|
|
|
|
|
+ console.warn(
|
|
|
|
|
+ `No data for feature ${feature.get('nationalCode')}`
|
|
|
|
|
+ );
|
|
|
|
|
+ console.log(feature);
|
|
|
|
|
+ }
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
logs++;
|
|
logs++;
|