|
@@ -16,13 +16,14 @@ import {AdjusterEventService} from './adjuster-event.service';
|
|
|
import {AdjusterLegendService} from './adjuster-legend.service';
|
|
import {AdjusterLegendService} from './adjuster-legend.service';
|
|
|
import {AdjusterPresetsService, Factor} from './adjuster-presets.service';
|
|
import {AdjusterPresetsService, Factor} from './adjuster-presets.service';
|
|
|
import {obce, obceIndexLayer, osmLayer} from '../app.config';
|
|
import {obce, obceIndexLayer, osmLayer} from '../app.config';
|
|
|
|
|
+import {RDFSubject} from './ontology.model';
|
|
|
|
|
|
|
|
@Injectable({providedIn: 'root'})
|
|
@Injectable({providedIn: 'root'})
|
|
|
export class AdjusterService {
|
|
export class AdjusterService {
|
|
|
/** To be read from a config file */
|
|
/** To be read from a config file */
|
|
|
allowedClusteringMethods: Array<string>;
|
|
allowedClusteringMethods: Array<string>;
|
|
|
/** To be read from a config file */
|
|
/** To be read from a config file */
|
|
|
- initialWeights;
|
|
|
|
|
|
|
+ initialWeights: {[factorId: string]: number};
|
|
|
/** To be read from a config file */
|
|
/** To be read from a config file */
|
|
|
serviceBaseUrl: string;
|
|
serviceBaseUrl: string;
|
|
|
/** Used in the UI as a selector */
|
|
/** Used in the UI as a selector */
|
|
@@ -66,6 +67,7 @@ export class AdjusterService {
|
|
|
);
|
|
);
|
|
|
this.numberOfClusters = 9;
|
|
this.numberOfClusters = 9;
|
|
|
|
|
|
|
|
|
|
+ /* Get the ontology file from the service */
|
|
|
this.loadOntology();
|
|
this.loadOntology();
|
|
|
|
|
|
|
|
/* Wait for all layers to be ready */
|
|
/* Wait for all layers to be ready */
|
|
@@ -78,7 +80,7 @@ export class AdjusterService {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- /* Ensure that all layers and also the loader component are ready */
|
|
|
|
|
|
|
+ /* Ensure that all layers, the loader component and the presets from ontology are ready */
|
|
|
forkJoin({
|
|
forkJoin({
|
|
|
lyr: this.adjusterEventService.layerReady,
|
|
lyr: this.adjusterEventService.layerReady,
|
|
|
load: this.adjusterEventService.loaderReady,
|
|
load: this.adjusterEventService.loaderReady,
|
|
@@ -96,8 +98,7 @@ export class AdjusterService {
|
|
|
return {
|
|
return {
|
|
|
id: group.id,
|
|
id: group.id,
|
|
|
labels: group.labels,
|
|
labels: group.labels,
|
|
|
- //FIXME: load weights from file
|
|
|
|
|
- weight: 0.5,
|
|
|
|
|
|
|
+ weight: this.resetFactorWeights(group.id),
|
|
|
datasets: this.adjusterPresetsService.getGroupDatasets(group.id)
|
|
datasets: this.adjusterPresetsService.getGroupDatasets(group.id)
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -356,7 +357,7 @@ export class AdjusterService {
|
|
|
|
|
|
|
|
async loadOntology() {
|
|
async loadOntology() {
|
|
|
try {
|
|
try {
|
|
|
- const onto = await this.$http.get(this.serviceBaseUrl + 'ontology/').toPromise();
|
|
|
|
|
|
|
+ const onto = await this.$http.get<RDFSubject[]>(this.serviceBaseUrl + 'ontology/').toPromise();
|
|
|
this.adjusterEventService.ontologyLoads.next(onto);
|
|
this.adjusterEventService.ontologyLoads.next(onto);
|
|
|
this.adjusterEventService.ontologyLoads.complete();
|
|
this.adjusterEventService.ontologyLoads.complete();
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -443,6 +444,10 @@ export class AdjusterService {
|
|
|
method.layer.getSource().getFeatures()[0].dispatchEvent('change');
|
|
method.layer.getSource().getFeatures()[0].dispatchEvent('change');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ resetFactorWeights(factorId: string): number {
|
|
|
|
|
+ return this.initialWeights[factorId] ?? 0.5;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
clustersLoaded(): boolean {
|
|
clustersLoaded(): boolean {
|
|
|
return this._clustersLoaded;
|
|
return this._clustersLoaded;
|
|
|
}
|
|
}
|