|
@@ -9,6 +9,8 @@ import attractivenessConfig from '../attractiveness.config.json';
|
|
|
import clusteringMethods from '../data/clustering_methods.json';
|
|
import clusteringMethods from '../data/clustering_methods.json';
|
|
|
import {AdjusterEventService} from './adjuster-event.service';
|
|
import {AdjusterEventService} from './adjuster-event.service';
|
|
|
import {AdjusterLoaderComponent} from './adjuster-loader.component';
|
|
import {AdjusterLoaderComponent} from './adjuster-loader.component';
|
|
|
|
|
+import {AttractivenessClustersService} from './attractiveness-clusters.service';
|
|
|
|
|
+import {AttractivenessIndexService} from './attractiveness-index.service';
|
|
|
import {nuts} from '../nuts';
|
|
import {nuts} from '../nuts';
|
|
|
//import {factors} from './factors.js';
|
|
//import {factors} from './factors.js';
|
|
|
|
|
|
|
@@ -36,6 +38,8 @@ export class AdjusterService {
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
public adjusterEventService: AdjusterEventService,
|
|
public adjusterEventService: AdjusterEventService,
|
|
|
|
|
+ public attractivenessIndexService: AttractivenessIndexService,
|
|
|
|
|
+ public attractivenessClustersService: AttractivenessClustersService,
|
|
|
public hsDialogContainerService: HsDialogContainerService,
|
|
public hsDialogContainerService: HsDialogContainerService,
|
|
|
public hsUtilsService: HsUtilsService,
|
|
public hsUtilsService: HsUtilsService,
|
|
|
public httpClient: HttpClient
|
|
public httpClient: HttpClient
|
|
@@ -115,7 +119,7 @@ export class AdjusterService {
|
|
|
codeRecordRelations[a.code.toUpperCase()] = a;
|
|
codeRecordRelations[a.code.toUpperCase()] = a;
|
|
|
});
|
|
});
|
|
|
console.time('forEach-Index');
|
|
console.time('forEach-Index');
|
|
|
- this.processIndex(codeRecordRelations);
|
|
|
|
|
|
|
+ this.attractivenessIndexService.processIndex(codeRecordRelations);
|
|
|
console.timeEnd('forEach-Index');
|
|
console.timeEnd('forEach-Index');
|
|
|
this._raiInProcess = false;
|
|
this._raiInProcess = false;
|
|
|
this.adjusterEventService.loaded.next({
|
|
this.adjusterEventService.loaded.next({
|
|
@@ -146,7 +150,7 @@ export class AdjusterService {
|
|
|
// more memory consuming, but much faster then find()
|
|
// more memory consuming, but much faster then find()
|
|
|
const codeRecordRelations = {};
|
|
const codeRecordRelations = {};
|
|
|
clusterData.forEach((c) => {
|
|
clusterData.forEach((c) => {
|
|
|
- codeRecordRelations[c['nuts_id']] = c;
|
|
|
|
|
|
|
+ codeRecordRelations[c['nuts_id'].toUpperCase()] = c;
|
|
|
});
|
|
});
|
|
|
console.time('forEach-Cluster');
|
|
console.time('forEach-Cluster');
|
|
|
/*const clusters = [];
|
|
/*const clusters = [];
|
|
@@ -156,7 +160,7 @@ export class AdjusterService {
|
|
|
}
|
|
}
|
|
|
}*/
|
|
}*/
|
|
|
//for (const method of this.methods) {
|
|
//for (const method of this.methods) {
|
|
|
- this.processClusters(codeRecordRelations);
|
|
|
|
|
|
|
+ this.attractivenessClustersService.processClusters(codeRecordRelations);
|
|
|
//TODO: method.layer.getSource().legend_categories = this.adjusterLegendService.createClusterLegend(
|
|
//TODO: method.layer.getSource().legend_categories = this.adjusterLegendService.createClusterLegend(
|
|
|
// this.numberOfClusters
|
|
// this.numberOfClusters
|
|
|
//);
|
|
//);
|
|
@@ -238,74 +242,6 @@ export class AdjusterService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- processIndex(codeRecordRelations: Record<string, unknown>): void {
|
|
|
|
|
- /*if (obce.getFeatures()?.length < 1) {
|
|
|
|
|
- obce.once('changefeature', () => this.processIndex(codeRecordRelations));
|
|
|
|
|
- return;
|
|
|
|
|
- }*/
|
|
|
|
|
- let errs = 0;
|
|
|
|
|
- //let logs = 0;
|
|
|
|
|
- nuts.nuts3IndexSource.forEachFeature((feature) => {
|
|
|
|
|
- // Pair each feature with its attractivity data
|
|
|
|
|
- const featureData =
|
|
|
|
|
- codeRecordRelations[feature.get('NUTS_ID').toUpperCase()];
|
|
|
|
|
- if (!featureData) {
|
|
|
|
|
- if (errs < 20) {
|
|
|
|
|
- errs++;
|
|
|
|
|
- console.warn(
|
|
|
|
|
- `No data for feature ${feature.get('NUTS_ID').toUpperCase()}`
|
|
|
|
|
- );
|
|
|
|
|
- console.log(feature);
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- /*logs++;
|
|
|
|
|
- if (logs % 100 == 0) {
|
|
|
|
|
- console.log(`processed ${logs} items`);
|
|
|
|
|
- }*/
|
|
|
|
|
- Object.keys(featureData).forEach((key, index) => {
|
|
|
|
|
- if (key !== 'nuts_id') {
|
|
|
|
|
- feature.set(key, featureData[key], true); //true stands for "silent" - important for performance!
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- // Since we are updating the features silently, we now have to refresh manually
|
|
|
|
|
- nuts.nuts3IndexSource.getFeatures()[0].dispatchEvent('change');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- processClusters(codeRecordRelations: Record<string, unknown>): void {
|
|
|
|
|
- let errs = 0;
|
|
|
|
|
- //let logs = 0;
|
|
|
|
|
- nuts.nuts3ClustersSource.forEachFeature((feature) => {
|
|
|
|
|
- // Pair each feature with its clustering data
|
|
|
|
|
- const featureData = codeRecordRelations[feature.get('NUTS_ID')];
|
|
|
|
|
- /*const featureData = clusterData.find(
|
|
|
|
|
- // NOTE: Do NOT add triple equal sign!
|
|
|
|
|
- (item) => item['lau2'] == feature.get('nationalCode')
|
|
|
|
|
- );*/
|
|
|
|
|
- if (!featureData) {
|
|
|
|
|
- if (errs < 20) {
|
|
|
|
|
- errs++;
|
|
|
|
|
- console.warn(`No data for feature ${feature.get('NUTS_ID')}`);
|
|
|
|
|
- console.log(feature);
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- /*logs++;
|
|
|
|
|
- if (logs % 100 == 0) {
|
|
|
|
|
- console.log(`processed ${logs} items`);
|
|
|
|
|
- }*/
|
|
|
|
|
- //feature.set(method.codename, featureData[method.codename], true);
|
|
|
|
|
- Object.keys(featureData).forEach(function (key, index) {
|
|
|
|
|
- if (key !== 'nuts_id') {
|
|
|
|
|
- feature.set(key, featureData[key], true); //true stands for "silent" - important for performance!
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- // Since we are updating the features silently, we now have to refresh manually
|
|
|
|
|
- nuts.nuts3ClustersSource.getFeatures()[0].dispatchEvent('change');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
clustersLoaded(): boolean {
|
|
clustersLoaded(): boolean {
|
|
|
return this._clustersLoaded;
|
|
return this._clustersLoaded;
|
|
|
}
|
|
}
|