From 25fa2639ec079b54e4539ccc96dd87617ed5b6fb Mon Sep 17 00:00:00 2001 From: Filip Leitner Date: Fri, 2 Feb 2024 12:45:30 +0100 Subject: [PATCH 1/3] fix(permalink): Dont need to proxify /share requests --- .../src/components/compositions/compositions.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/hslayers/src/components/compositions/compositions.service.ts b/projects/hslayers/src/components/compositions/compositions.service.ts index 05465269ef..327092c9c3 100644 --- a/projects/hslayers/src/components/compositions/compositions.service.ts +++ b/projects/hslayers/src/components/compositions/compositions.service.ts @@ -360,8 +360,7 @@ export class HsCompositionsService { */ async parsePermalinkLayers(permalink: string): Promise { await this.hsMapService.loaded(); - const layersUrl = this.hsUtilsService.proxify(permalink); - const response: any = await lastValueFrom(this.http.get(layersUrl)); + const response: any = await lastValueFrom(this.http.get(permalink)); if (response.success == true) { const data: any = {}; data.data = {}; From 7b34fd4d17d105ca1e6f398fab9ef7a0c1be522b Mon Sep 17 00:00:00 2001 From: Filip Leitner Date: Mon, 5 Feb 2024 09:00:51 +0100 Subject: [PATCH 2/3] fix: Preserve composition layer order - in terms of zindex --- .../hslayers/src/common/layer-extensions.ts | 16 ++++++++++++++ .../compositions-parser.service.ts | 2 ++ .../compositions/compositions.service.ts | 2 -- .../layermanager/layermanager.component.ts | 5 ++++- .../layermanager/layermanager.service.ts | 21 +++++++------------ 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/projects/hslayers/src/common/layer-extensions.ts b/projects/hslayers/src/common/layer-extensions.ts index bd10085714..bd2f1669e5 100644 --- a/projects/hslayers/src/common/layer-extensions.ts +++ b/projects/hslayers/src/common/layer-extensions.ts @@ -31,6 +31,7 @@ const GREYSCALE = 'greyscale'; const HS_LAYMAN_SYNCHRONIZING = 'hsLaymanSynchronizing'; const HS_QML = 'qml'; const HS_SLD = 'sld'; +const IGNORE_PATH_ZINDEX = 'ignorePathZIndex'; const INFO_FORMAT = 'info_format'; const INLINE_LEGEND = 'inlineLegend'; const LAYMAN_LAYER_DESCRIPTOR = 'laymanLayerDescriptor'; @@ -679,6 +680,21 @@ export function setSwipeSide( layer.set(SWIPE_SIDE, side); } +/** + * When set to true, prevents z-index to be set based on highest value of layer in + * the same layer (which is default). Used for layers from compositions (basic, permalik) + */ +export function setIgnorePathZIndex( + layer: Layer, + ignorePathZIndex: boolean, +) { + layer.set(IGNORE_PATH_ZINDEX, ignorePathZIndex); +} + +export function getIgnorePathZIndex(layer: Layer) { + return layer.get(IGNORE_PATH_ZINDEX); +} + export const HsLayerExt = { getAccessRights, setAccessRights, diff --git a/projects/hslayers/src/components/compositions/compositions-parser.service.ts b/projects/hslayers/src/components/compositions/compositions-parser.service.ts index 4d707b7b6e..292a8d7521 100644 --- a/projects/hslayers/src/components/compositions/compositions-parser.service.ts +++ b/projects/hslayers/src/components/compositions/compositions-parser.service.ts @@ -36,6 +36,7 @@ import { import { getTitle, setFromBaseComposition, + setIgnorePathZIndex, setMetadata, setSwipeSide, } from '../../common/layer-extensions'; @@ -767,6 +768,7 @@ export class HsCompositionsParserService { resultLayer = await resultLayer; //createWMTSLayer returns Promise which needs to be resolved first setMetadata(resultLayer, lyr_def.metadata); setSwipeSide(resultLayer, lyr_def.swipeSide); + setIgnorePathZIndex(resultLayer, true); } return resultLayer; } diff --git a/projects/hslayers/src/components/compositions/compositions.service.ts b/projects/hslayers/src/components/compositions/compositions.service.ts index 327092c9c3..ee8105120b 100644 --- a/projects/hslayers/src/components/compositions/compositions.service.ts +++ b/projects/hslayers/src/components/compositions/compositions.service.ts @@ -13,7 +13,6 @@ import {HsCompositionsMapService} from './compositions-map.service'; import {HsCompositionsMickaService} from './endpoints/compositions-micka.service'; import {HsCompositionsParserService} from './compositions-parser.service'; import {HsConfig} from '../../config.service'; -import {HsCoreService} from '../core/core.service'; import {HsEndpoint} from '../../common/endpoints/endpoint.interface'; import {HsEventBusService} from '../core/event-bus.service'; import {HsLanguageService} from '../language/language.service'; @@ -36,7 +35,6 @@ export class HsCompositionsService { constructor( private http: HttpClient, private hsMapService: HsMapService, - private hsCore: HsCoreService, private hsCompositionsParserService: HsCompositionsParserService, private hsConfig: HsConfig, private hsUtilsService: HsUtilsService, diff --git a/projects/hslayers/src/components/layermanager/layermanager.component.ts b/projects/hslayers/src/components/layermanager/layermanager.component.ts index 5aa88b10ab..6be59ff622 100644 --- a/projects/hslayers/src/components/layermanager/layermanager.component.ts +++ b/projects/hslayers/src/components/layermanager/layermanager.component.ts @@ -32,6 +32,7 @@ import { getActive, getAttribution, getFromBaseComposition, + getIgnorePathZIndex, getShowInLayerManager, getThumbnail, getTitle, @@ -182,7 +183,9 @@ export class HsLayerManagerComponent .on('add', (e) => { this.hsLayerManagerService.applyZIndex( e.element as Layer, - true, + //z-index of composition layers should be the same as order of layers in composition. + //ignoring fodler structure + !getIgnorePathZIndex(e.element as Layer), ); if (getShowInLayerManager(e.element) == false) { return; diff --git a/projects/hslayers/src/components/layermanager/layermanager.service.ts b/projects/hslayers/src/components/layermanager/layermanager.service.ts index 5a3217bdf5..b99741cf0f 100644 --- a/projects/hslayers/src/components/layermanager/layermanager.service.ts +++ b/projects/hslayers/src/components/layermanager/layermanager.service.ts @@ -507,24 +507,20 @@ export class HsLayerManagerService { let curfolder = this.data.folders; const zIndex = lyr.getZIndex(); for (let i = 0; i < parts.length; i++) { - let found = null; - for (const folder of curfolder.sub_folders) { - if (folder.name == parts[i]) { - found = folder; - } - } - if (found === null) { + const found = curfolder.sub_folders.find( + (folder) => folder.name === parts[i], + ); + if (!found) { //TODO: Need to describe how hsl_path works here + const hsl_path = `${curfolder.hsl_path}${curfolder.hsl_path !== '' ? '/' : ''}${parts[i]}`; + const coded_path = `${curfolder.coded_path}${curfolder.sub_folders.length}-`; const new_folder = { sub_folders: [], indent: i, layers: [], name: parts[i], - hsl_path: - curfolder.hsl_path + - (curfolder.hsl_path != '' ? '/' : '') + - parts[i], - coded_path: curfolder.coded_path + curfolder.sub_folders.length + '-', + hsl_path, + coded_path, visible: true, zIndex: zIndex, }; @@ -543,7 +539,6 @@ export class HsLayerManagerService { /** * Remove layer from layer folder structure a clean empty folder - * @private * @param lyr - Layer to remove from layer folder */ cleanFolders(lyr: Layer): void { From b7a9c35f31dcf83f8f8e8c19c8155ff44c0e5104 Mon Sep 17 00:00:00 2001 From: Filip Leitner Date: Mon, 5 Feb 2024 09:30:02 +0100 Subject: [PATCH 3/3] refactor: Update layer position list when composition is loaded --- .../components/compositions/compositions-parser.service.ts | 1 + .../src/components/compositions/compositions.service.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/projects/hslayers/src/components/compositions/compositions-parser.service.ts b/projects/hslayers/src/components/compositions/compositions-parser.service.ts index 292a8d7521..eed3636909 100644 --- a/projects/hslayers/src/components/compositions/compositions-parser.service.ts +++ b/projects/hslayers/src/components/compositions/compositions-parser.service.ts @@ -475,6 +475,7 @@ export class HsCompositionsParserService { this.hsLayoutService.setMainPanel('layermanager'); } this.composition_edited = false; + this.hsLayerManagerService.updateLayerListPositions(); this.hsEventBusService.compositionLoads.next(responseData); } diff --git a/projects/hslayers/src/components/compositions/compositions.service.ts b/projects/hslayers/src/components/compositions/compositions.service.ts index ee8105120b..f9883c363f 100644 --- a/projects/hslayers/src/components/compositions/compositions.service.ts +++ b/projects/hslayers/src/components/compositions/compositions.service.ts @@ -16,6 +16,7 @@ import {HsConfig} from '../../config.service'; import {HsEndpoint} from '../../common/endpoints/endpoint.interface'; import {HsEventBusService} from '../core/event-bus.service'; import {HsLanguageService} from '../language/language.service'; +import {HsLayerManagerService} from '../layermanager/layermanager.service'; import {HsLogService} from '../../common/log/log.service'; import {HsMapCompositionDescriptor} from './models/composition-descriptor.model'; import {HsShareUrlService} from '../permalink/share-url.service'; @@ -47,6 +48,7 @@ export class HsCompositionsService { private hsCompositionsMapService: HsCompositionsMapService, private hsEventBusService: HsEventBusService, private hsToastService: HsToastService, + private hsLayerManagerService: HsLayerManagerService, ) { this.hsEventBusService.compositionEdits.subscribe(() => { this.hsCompositionsParserService.composition_edited = true; @@ -374,6 +376,7 @@ export class HsCompositionsService { this.hsMapService.addLayer(layers[i], DuplicateHandling.RemoveOriginal); } this.hsMapService.fitExtent(response.data.nativeExtent); + this.hsLayerManagerService.updateLayerListPositions(); } else { this.$log.log('Error loading permalink layers'); } @@ -411,6 +414,7 @@ export class HsCompositionsService { this.hsMapService.addLayer(layers[i], DuplicateHandling.IgnoreNew); } localStorage.removeItem('hs_layers'); + this.hsLayerManagerService.updateLayerListPositions(); } }