@geogirafe/lib-geoportal 1.1.0-dev.2640619249 → 1.1.0-dev.2640738406

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.
@@ -33,6 +33,7 @@ export type LayerWmsOptions = {
33
33
  maxResolution?: number;
34
34
  };
35
35
  };
36
+ wmsInfoFormat?: string;
36
37
  time?: ITimeOptions;
37
38
  snappingConfig?: ISnappingConfig;
38
39
  timeAttribute?: string;
@@ -41,11 +42,11 @@ export type LayerWmsOptions = {
41
42
  };
42
43
  declare class LayerWms extends Layer implements ILayerWithLegend, ILayerWithFilter, ILayerWithTime {
43
44
  /**
44
- * This class is a used in the state of the application, which will be accessed behind a javascript proxy.
45
+ * This class is used in the state of the application, which will be accessed behind a JavaScript proxy.
45
46
  * This means that each modification made to its properties must come from outside,
46
- * because they have to be made through the proxy, so that the modification can be listen.
47
- * Therefore, this class must not contain any method which is updating a value directly
48
- * For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy
47
+ * because they have to be made through the proxy, so that the modification can be listened to.
48
+ * Therefore, this class must not contain any method which is updating a value directly.
49
+ * For example, any method doing <this.xxx = value> is forbidden here because the modification must be known from the proxy
49
50
  */
50
51
  ogcServer: ServerOgc;
51
52
  minResolution?: number;
@@ -67,6 +68,7 @@ declare class LayerWms extends Layer implements ILayerWithLegend, ILayerWithFilt
67
68
  maxResolution?: number;
68
69
  };
69
70
  };
71
+ wmsInfoFormat?: string;
70
72
  filter?: WfsFilter;
71
73
  timeOptions?: ITimeOptions;
72
74
  snapOptions?: ISnappingConfig;
@@ -89,5 +91,6 @@ declare class LayerWms extends Layer implements ILayerWithLegend, ILayerWithFilt
89
91
  get wmsQueryableOnly(): boolean;
90
92
  private static isGMFTreeItem;
91
93
  private static getOptionsFromGMFTreeItem;
94
+ private static getDefaultWmsInfoFormat;
92
95
  }
93
96
  export default LayerWms;
@@ -9,11 +9,11 @@ import Layer from './layer.js';
9
9
  import { BrainIgnore } from '../../tools/state/brain/decorators.js';
10
10
  class LayerWms extends Layer {
11
11
  /**
12
- * This class is a used in the state of the application, which will be accessed behind a javascript proxy.
12
+ * This class is used in the state of the application, which will be accessed behind a JavaScript proxy.
13
13
  * This means that each modification made to its properties must come from outside,
14
- * because they have to be made through the proxy, so that the modification can be listen.
15
- * Therefore, this class must not contain any method which is updating a value directly
16
- * For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy
14
+ * because they have to be made through the proxy, so that the modification can be listened to.
15
+ * Therefore, this class must not contain any method which is updating a value directly.
16
+ * For example, any method doing <this.xxx = value> is forbidden here because the modification must be known from the proxy
17
17
  */
18
18
  // Base WMS attributes
19
19
  ogcServer;
@@ -33,6 +33,7 @@ class LayerWms extends Layer {
33
33
  queryable = false;
34
34
  queryLayers;
35
35
  queryLayersRanges;
36
+ wmsInfoFormat;
36
37
  filter;
37
38
  timeOptions;
38
39
  snapOptions;
@@ -59,6 +60,7 @@ class LayerWms extends Layer {
59
60
  this.hiDPILegendImages = opts?.hiDPILegendImages;
60
61
  this.printNativeAngle = opts?.printNativeAngle;
61
62
  this.queryable = opts?.queryable ?? false;
63
+ this.wmsInfoFormat = opts?.wmsInfoFormat ?? LayerWms.getDefaultWmsInfoFormat(this.ogcServer);
62
64
  this.queryLayers = opts?.queryLayers;
63
65
  this.queryLayersRanges = opts?.queryLayersRanges || {};
64
66
  this.timeOptions = opts?.time;
@@ -96,6 +98,7 @@ class LayerWms extends Layer {
96
98
  queryable: this.queryable,
97
99
  queryLayers: this.queryLayers,
98
100
  queryLayersRanges: this.queryLayersRanges,
101
+ wmsInfoFormat: this.wmsInfoFormat,
99
102
  time: this.timeOptions,
100
103
  snappingConfig: this.snapOptions,
101
104
  timeAttribute: this.timeAttribute,
@@ -198,6 +201,12 @@ class LayerWms extends Layer {
198
201
  }
199
202
  return opts;
200
203
  }
204
+ static getDefaultWmsInfoFormat(serverOgc) {
205
+ if (serverOgc.type === 'arcgis') {
206
+ return 'application/geo+json';
207
+ }
208
+ return 'application/vnd.ogc.gml';
209
+ }
201
210
  }
202
211
  __decorate([
203
212
  BrainIgnore
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geogirafe.org"
7
7
  },
8
- "version": "1.1.0-dev.2640619249",
8
+ "version": "1.1.0-dev.2640738406",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.1.0-dev.2640619249", "build":"2640619249", "date":"30/06/2026"}
1
+ {"version":"1.1.0-dev.2640738406", "build":"2640738406", "date":"30/06/2026"}
@@ -1,4 +1,5 @@
1
1
  import { Image as ImageLayer } from 'ol/layer.js';
2
+ import Feature from 'ol/Feature.js';
2
3
  import ImageWMS from 'ol/source/ImageWMS.js';
3
4
  import { Map } from 'ol';
4
5
  import LayerWms from '../../models/layers/layerwms.js';
@@ -11,6 +12,8 @@ export default abstract class WmsClient {
11
12
  private readonly ogcServer;
12
13
  private readonly context;
13
14
  private readonly resolutionTolerance;
15
+ private readonly geoJson;
16
+ private readonly wmsGetFeatureInfo;
14
17
  private capabilityPromise;
15
18
  private capabilities;
16
19
  private get state();
@@ -46,7 +49,7 @@ export default abstract class WmsClient {
46
49
  * Selects features based on the specified query and prepares selection parameters.
47
50
  */
48
51
  selectFeaturesByQuery(query: WfsFilter): void;
49
- getFeatureInfo(selectionParam: SelectionParam): Promise<import("ol").Feature<import("ol/geom.js").Geometry, {
52
+ getFeatureInfo(selectionParam: SelectionParam): Promise<Feature<import("ol/geom.js").Geometry, {
50
53
  [x: string]: any;
51
54
  }>[]>;
52
55
  private getFeatureInfoUrl;
@@ -3,6 +3,7 @@ import { Image as ImageLayer } from 'ol/layer.js';
3
3
  import ImageWMS from 'ol/source/ImageWMS.js';
4
4
  import WMSCapabilities from 'ol/format/WMSCapabilities.js';
5
5
  import WMSGetFeatureInfo from 'ol/format/WMSGetFeatureInfo.js';
6
+ import GeoJSON from 'ol/format/GeoJSON.js';
6
7
  import SelectionParam from '../../models/selectionparam.js';
7
8
  import Exception from 'jsts/java/lang/Exception.js';
8
9
  export default class WmsClient {
@@ -10,6 +11,8 @@ export default class WmsClient {
10
11
  ogcServer;
11
12
  context;
12
13
  resolutionTolerance = 5;
14
+ geoJson = new GeoJSON();
15
+ wmsGetFeatureInfo = new WMSGetFeatureInfo();
13
16
  capabilityPromise = null;
14
17
  capabilities = null;
15
18
  get state() {
@@ -314,7 +317,7 @@ export default class WmsClient {
314
317
  const url = olLayer
315
318
  .getSource()
316
319
  ?.getFeatureInfoUrl(coordinate, (olLayer.getMapInternal()?.getView().getResolution() ?? currentResolution) + this.resolutionTolerance, this.state.projection, {
317
- INFO_FORMAT: 'application/vnd.ogc.gml',
320
+ INFO_FORMAT: layer.wmsInfoFormat,
318
321
  FEATURE_COUNT: 300
319
322
  });
320
323
  if (url !== undefined) {
@@ -326,17 +329,27 @@ export default class WmsClient {
326
329
  return urlsAndLayerNames;
327
330
  }
328
331
  handleGetFeatureInfoResponse(response, url, urlsAndLayerNames) {
329
- const gmlFeatures = new WMSGetFeatureInfo().readFeatures(response, {
330
- dataProjection: this.state.projection,
331
- featureProjection: this.state.projection
332
- });
332
+ const infoFormat = URL.parse(url)?.searchParams.get('INFO_FORMAT');
333
+ let features;
334
+ if (infoFormat && (infoFormat.includes('application/geo+json') || infoFormat.includes('application/geojson'))) {
335
+ features = this.geoJson.readFeatures(response, {
336
+ dataProjection: this.state.projection,
337
+ featureProjection: this.state.projection
338
+ });
339
+ }
340
+ else {
341
+ features = this.wmsGetFeatureInfo.readFeatures(response, {
342
+ dataProjection: this.state.projection,
343
+ featureProjection: this.state.projection
344
+ });
345
+ }
333
346
  // Set the feature id with the layer name.
334
- gmlFeatures.forEach((feature) => {
347
+ features.forEach((feature) => {
335
348
  if (!feature.getId()) {
336
349
  feature.setId(urlsAndLayerNames[url]);
337
350
  }
338
351
  });
339
- return gmlFeatures;
352
+ return features;
340
353
  }
341
354
  refreshZIndexes() {
342
355
  // Recalculate source for Layers