@geogirafe/lib-geoportal 1.1.0-dev.2321641404 → 1.1.0-dev.2321895443

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ export default class MFPEncoder {
66
66
  // If all the children have the same ogcServer and the group
67
67
  // has no grandchildren, we keep the layers together
68
68
  if (group.isMixed === false && group.hasGrandChildren === false) {
69
- layers.push(group);
69
+ layers.push(...group.children);
70
70
  }
71
71
  else {
72
72
  const resultLayers = this.getFlatLayers(group.children);
@@ -87,10 +87,14 @@ describe('MFPEncoder', () => {
87
87
  expect(result.dpi).toBe(defaultOptions.dpi);
88
88
  expect(result.scale).toBe(defaultOptions.scale);
89
89
  expect(result.rotation).toBe(180);
90
- expect(result.layers.length).toBe(5);
90
+ expect(result.layers.length).toBe(6);
91
91
  // Test order
92
92
  expect(result.layers[0].name).toBe('Test Vector layer');
93
- expect(result.layers[4].name).toBe('basemap-below');
93
+ expect(result.layers[1].layers[0]).toBe('wms-2');
94
+ expect(result.layers[2].name).toBe('testWmts');
95
+ expect(result.layers[3].layers[0]).toBe('wms-0');
96
+ expect(result.layers[4].layers[0]).toBe('wms-1');
97
+ expect(result.layers[5].name).toBe('basemap-below');
94
98
  });
95
99
  });
96
100
  describe('encodeWmsLayer method', () => {
@@ -132,7 +132,7 @@ export class MFPLegendEncoder {
132
132
  }
133
133
  const layerNames = layerWms.layers?.split(',') ?? [];
134
134
  layerNames.forEach((name) => {
135
- const url = LegendHelper.getWMSLegendURL(layerWms.ogcServer.url, name, {
135
+ const url = LegendHelper.getWMSLegendURL(layerWms.ogcServer, name, {
136
136
  dpi,
137
137
  serverType,
138
138
  scale: this.options?.scale,
@@ -1,6 +1,6 @@
1
1
  import { it, describe, expect, beforeEach, afterAll } from 'vitest';
2
2
  import { MFPLegendEncoder } from './MFPLegendEncoder';
3
- import { createTestGroupLayer, createTestLayerWms, createTestLayerWmts, createTestOgcServer } from '../../../tools/tests/layerhelpers';
3
+ import { createTestGroupLayer, createTestLayerWms, createTestLayerWmsQGis, createTestLayerWmts, createTestOgcServer } from '../../../tools/tests/layerhelpers';
4
4
  import MockHelper from '../../../tools/tests/mockhelper';
5
5
  import { createOlWmtsLayer } from '../../../tools/tests/olhelpers';
6
6
  describe('MFPLegendEncoder', () => {
@@ -199,6 +199,21 @@ describe('MFPLegendEncoder', () => {
199
199
  });
200
200
  });
201
201
  });
202
+ describe('encodeLayerWmsLegendClasses QGis', () => {
203
+ let layer;
204
+ beforeEach(() => {
205
+ layer = createTestLayerWmsQGis();
206
+ });
207
+ it('should return MFPLegendClass for QGisServer (including LAYERTITLE)', () => {
208
+ layer.layers = 'foo';
209
+ const result = encoder.encodeLayerWmsLegendClasses(layer);
210
+ expect(result?.name).toEqual('testWmsQGis');
211
+ // One layer = no subclass, complete directly the current class.
212
+ expect(result?.icons).toEqual([
213
+ 'https://ogc.test.url?FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&LAYER=foo&LAYERTITLE=False&SCALE=10000'
214
+ ]);
215
+ });
216
+ });
202
217
  it('getLegendClassForWMS', () => {
203
218
  const layerName = 'LayerName';
204
219
  const icon_dpi = {
package/models/gmf.d.ts CHANGED
@@ -79,7 +79,7 @@ export interface GMFServerOgc {
79
79
  urlWfs?: string;
80
80
  oapifSupport?: boolean;
81
81
  urlOapif?: string;
82
- type: string;
82
+ type: 'mapserver' | 'qgisserver' | 'georama' | 'geoserver' | 'arcgis' | 'other';
83
83
  imageType: string;
84
84
  attributes?: GMFServerOgcAttributes;
85
85
  }
@@ -6,7 +6,7 @@ export default class ServerOgc {
6
6
  urlWfs?: string;
7
7
  oapifSupport: boolean;
8
8
  urlOapif?: string;
9
- type: string;
9
+ type: 'mapserver' | 'qgisserver' | 'georama' | 'geoserver' | 'arcgis' | 'other';
10
10
  imageType: string;
11
11
  aliases: Record<string, string>;
12
12
  constructor(name: string, elem: GMFServerOgc);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geomapfish.dev"
7
7
  },
8
- "version": "1.1.0-dev.2321641404",
8
+ "version": "1.1.0-dev.2321895443",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.1.0-dev.2321641404", "build":"2321641404", "date":"12/02/2026"}
1
+ {"version":"1.1.0-dev.2321895443", "build":"2321895443", "date":"12/02/2026"}
@@ -1,14 +1,15 @@
1
1
  import TileLayer from 'ol/layer/Tile.js';
2
2
  import WMTS from 'ol/source/WMTS.js';
3
+ import ServerOgc from '../models/serverogc.js';
3
4
  declare class LegendHelper {
4
5
  /**
5
6
  * Get the WMS legend URL.
6
- * @param url The base url of the wms service.
7
+ * @param serverOgc The base url of the wms service.
7
8
  * @param layerName The name of a wms layer.
8
9
  * @param options to create the legend url.
9
10
  * @returns The legend URL or undefined.
10
11
  */
11
- static readonly getWMSLegendURL: (url: string | undefined, layerName: string, options?: WMSLegendURLOptions) => string | undefined;
12
+ static readonly getWMSLegendURL: (serverOgc: ServerOgc, layerName: string, options?: WMSLegendURLOptions) => string | undefined;
12
13
  /**
13
14
  * Retrieves the legend URL for a given WMTS tile layer.
14
15
  * @param {TileLayer<WMTS>} olayer - The OpenLayers tile layer object.
@@ -2,13 +2,13 @@ import { appendParams } from 'ol/uri.js';
2
2
  class LegendHelper {
3
3
  /**
4
4
  * Get the WMS legend URL.
5
- * @param url The base url of the wms service.
5
+ * @param serverOgc The base url of the wms service.
6
6
  * @param layerName The name of a wms layer.
7
7
  * @param options to create the legend url.
8
8
  * @returns The legend URL or undefined.
9
9
  */
10
- static getWMSLegendURL = (url, layerName, options) => {
11
- if (!url) {
10
+ static getWMSLegendURL = (serverOgc, layerName, options) => {
11
+ if (!serverOgc.url) {
12
12
  return undefined;
13
13
  }
14
14
  const queryString = {
@@ -19,6 +19,9 @@ class LegendHelper {
19
19
  REQUEST: 'GetLegendGraphic',
20
20
  LAYER: layerName
21
21
  };
22
+ if (serverOgc.type === 'qgisserver') {
23
+ queryString.LAYERTITLE = 'False';
24
+ }
22
25
  const scale = options?.scale;
23
26
  const legendRule = options?.legendRule;
24
27
  const legendWidth = options?.legendWidth;
@@ -55,7 +58,7 @@ class LegendHelper {
55
58
  if (additionalQueryString) {
56
59
  Object.assign(queryString, additionalQueryString);
57
60
  }
58
- return appendParams(url, queryString);
61
+ return appendParams(serverOgc.url, queryString);
59
62
  };
60
63
  /**
61
64
  * Retrieves the legend URL for a given WMTS tile layer.
@@ -33,7 +33,7 @@ export const DEMO_LAYERS = {
33
33
  urlWfs: '',
34
34
  oapifSupport: true,
35
35
  urlOapif: 'https://geomapfish-demo-2-9.camptocamp.com/mapserv_proxy/QGIS_Server/wfs3',
36
- type: 'gmf',
36
+ type: 'qgisserver',
37
37
  imageType: ''
38
38
  })
39
39
  }
@@ -11,7 +11,7 @@ const server = new ServerOgc('test', {
11
11
  urlWfs: '',
12
12
  oapifSupport: true,
13
13
  urlOapif: mockUrl,
14
- type: 'default',
14
+ type: 'qgisserver',
15
15
  imageType: ''
16
16
  });
17
17
  let context;
@@ -12,7 +12,7 @@ const server = new ServerOgc('test', {
12
12
  urlWfs: '',
13
13
  oapifSupport: true,
14
14
  urlOapif: mockUrl,
15
- type: 'default',
15
+ type: 'qgisserver',
16
16
  imageType: ''
17
17
  });
18
18
  const collectionId = 'test-collection';
@@ -29,7 +29,7 @@ describe('OgcApiFeaturesManager', () => {
29
29
  urlWfs: '',
30
30
  oapifSupport: true,
31
31
  urlOapif: "'https://testUrl.com",
32
- type: 'default',
32
+ type: 'qgisserver',
33
33
  imageType: ''
34
34
  })
35
35
  };
@@ -4,7 +4,9 @@ import GroupLayer, { GroupLayerOptions } from '../../models/layers/grouplayer';
4
4
  import ServerOgc from '../../models/serverogc';
5
5
  import Basemap from '../../models/basemaps/basemap';
6
6
  export declare function createTestOgcServer(): ServerOgc;
7
+ export declare function createTestOgcServerQGis(): ServerOgc;
7
8
  export declare function createTestLayerWms(options?: LayerWmsOptions): LayerWms;
9
+ export declare function createTestLayerWmsQGis(options?: LayerWmsOptions): LayerWms;
8
10
  export declare function createTestLayerWmts(options?: LayerWmtsOptions, ogcServer?: ServerOgc): LayerWmts;
9
11
  export declare function createTestGroupLayer(options?: GroupLayerOptions): GroupLayer;
10
12
  export declare function createTestBasemap(): Basemap;
@@ -11,12 +11,26 @@ export function createTestOgcServer() {
11
11
  imageType: 'image/png'
12
12
  });
13
13
  }
14
+ export function createTestOgcServerQGis() {
15
+ return new ServerOgc('testOgcServer', {
16
+ url: 'https://ogc.test.url',
17
+ wfsSupport: false,
18
+ type: 'qgisserver',
19
+ imageType: 'image/png'
20
+ });
21
+ }
14
22
  export function createTestLayerWms(options) {
15
23
  const ogcServer = createTestOgcServer();
16
24
  const layerWms = new LayerWms(1, 'testWms', 1, ogcServer, options);
17
25
  layerWms.activeState = 'on';
18
26
  return layerWms;
19
27
  }
28
+ export function createTestLayerWmsQGis(options) {
29
+ const ogcServer = createTestOgcServerQGis();
30
+ const layerWms = new LayerWms(1, 'testWmsQGis', 1, ogcServer, options);
31
+ layerWms.activeState = 'on';
32
+ return layerWms;
33
+ }
20
34
  export function createTestLayerWmts(options, ogcServer) {
21
35
  const layerWmts = new LayerWmts(1, 'testWmts', 1, 'https://test.ch', 'testWmts', options, ogcServer);
22
36
  layerWmts.activeState = 'on';
@@ -58,6 +58,9 @@ export default class WmsLegendHelper {
58
58
  graphicUrl += '&HEIGHT=' + this.context.configManager.Config.treeview.defaultIconSize.height;
59
59
  graphicUrl += '&WIDTH=' + this.context.configManager.Config.treeview.defaultIconSize.width;
60
60
  }
61
+ if (layer.ogcServer.type === 'qgisserver') {
62
+ graphicUrl += '&LAYERTITLE=False';
63
+ }
61
64
  legends[l] = graphicUrl;
62
65
  }
63
66
  return legends;