Skip to content

Commit

Permalink
Externalise the map interface methods to an angular service. day2
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed Dec 11, 2024
1 parent 34ce9fe commit 17a6837
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 503 deletions.
75 changes: 75 additions & 0 deletions projects/arlas-map/src/lib/arlas-map-logic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,79 @@ export abstract class ArlasMapFunctionalService {
}


public updateLayoutVisibility(visualisationName: string, visualisationSetsConfig: VisualisationSetConfig[], map: AbstractArlasMapGL) {
const visuStatus = !this.visualisationsSets.status.get(visualisationName);
visualisationSetsConfig.find(v => v.name === visualisationName).enabled = visuStatus;
if (!visuStatus) {
const layersSet = new Set(this.visualisationsSets.visualisations.get(visualisationName));
this.visualisationsSets.visualisations.forEach((ls, v) => {
if (v !== visualisationName) {
ls.forEach(ll => {
if (layersSet && layersSet.has(ll)) {
layersSet.delete(ll);
}
});
}
});
layersSet.forEach(ll => {
this.mapService.setLayerVisibility(ll, false, map);
});
}
this.visualisationsSets.status.set(visualisationName, visuStatus);
const layers = new Set<string>();
this.visualisationsSets.visualisations.forEach((ls, v) => {
if (this.visualisationsSets.status.get(v)) {
ls.forEach(l => {
layers.add(l);
this.mapService.setLayerVisibility(l, true, map);
});
}
});
return layers;
}

public updateVisibility(visibilityStatus: Map<string, boolean>, visualisationSetsConfig: VisualisationSetConfig[], map: AbstractArlasMapGL) {
visibilityStatus.forEach((visibilityStatus, l) => {
let layerInVisualisations = false;
if (!visibilityStatus) {
visualisationSetsConfig.forEach(v => {
const ls = new Set(v.layers);
if (!layerInVisualisations) {
layerInVisualisations = ls.has(l);
}
});
if (layerInVisualisations) {
this.mapService.setLayerVisibility(l, false, map);
}
} else {
let oneVisualisationEnabled = false;
visualisationSetsConfig.forEach(v => {
const ls = new Set(v.layers);
if (!layerInVisualisations) {
layerInVisualisations = ls.has(l);
}
if (ls.has(l) && v.enabled) {
oneVisualisationEnabled = true;
this.mapService.setLayerVisibility(l, true, map);
}
});
if (!oneVisualisationEnabled && layerInVisualisations) {
this.mapService.setLayerVisibility(l, false, map);
}
}
});
}


public findVisualisationSetLayer(visuName: string, visualisationSetsConfig: VisualisationSetConfig[]) {
return visualisationSetsConfig.find(v => v.name === visuName).layers;
}
public setVisualisationSetLayers(visuName: string, layers: string[], visualisationSetsConfig: VisualisationSetConfig[]) {
const f = visualisationSetsConfig.find(v => v.name === visuName);
if (f) {
f.layers = layers;
}
}


}

Check failure on line 292 in projects/arlas-map/src/lib/arlas-map-logic.service.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test & Documentation

Newline required at end of file but not found
Loading

0 comments on commit 17a6837

Please sign in to comment.