@eeacms/volto-arcgis-block 0.1.381 → 0.1.382

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [0.1.382](https://github.com/eea/volto-arcgis-block/compare/0.1.381...0.1.382) - 28 August 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - (feat): clean extent for CDSE working [Unai Bolivar - [`676f76f`](https://github.com/eea/volto-arcgis-block/commit/676f76fd3b0a3bba9d451ea513ee95f47c1d4cbe)]
12
+ - (feat): extent is working for WMTS requests [Unai Bolivar - [`96f1fff`](https://github.com/eea/volto-arcgis-block/commit/96f1fffd898b238da5cece8b83fbd9489b240d68)]
13
+ - (feat): using wfs data to determine graphic position in map viewer. [Unai Bolivar - [`2e4e923`](https://github.com/eea/volto-arcgis-block/commit/2e4e923d6e6e8a8e0c39cbe9e2585b9f5ff550cb)]
7
14
  ### [0.1.381](https://github.com/eea/volto-arcgis-block/compare/0.1.380...0.1.381) - 20 August 2025
8
15
 
9
16
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.381",
3
+ "version": "0.1.382",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -2027,6 +2027,9 @@ class MenuWidget extends React.Component {
2027
2027
  ViewService: viewService,
2028
2028
  StaticImageLegend: layer.StaticImageLegend,
2029
2029
  LayerTitle: layer.Title,
2030
+ customLayerParameters: {
2031
+ SHOWLOGO: false,
2032
+ },
2030
2033
  });
2031
2034
  } else {
2032
2035
  this.layers[
@@ -2804,6 +2807,8 @@ class MenuWidget extends React.Component {
2804
2807
  }
2805
2808
 
2806
2809
  async toggleLayer(elem) {
2810
+ if (!elem) return;
2811
+ this.url = this.layers[elem.id]?.ViewService || this.layers[elem.id]?.url;
2807
2812
  const userService =
2808
2813
  this.state.wmsUserServiceLayers.find(
2809
2814
  (layer) => layer.LayerId === elem.id,
@@ -2929,41 +2934,50 @@ class MenuWidget extends React.Component {
2929
2934
  if (!userService) this.checkForHotspots(elem, productContainerId);
2930
2935
  // Auto-fit extent once for OGC WMS layers on manual toggle
2931
2936
  try {
2932
- const layer = this.layers[elem.id];
2933
- const viewService = layer?.ViewService || '';
2934
- if (
2935
- viewService &&
2936
- viewService.toLowerCase().includes('wms') &&
2937
- viewService.toLowerCase().includes('/ogc/') &&
2938
- !layer._ogcExtentApplied &&
2939
- !this.extentInitiated
2940
- ) {
2941
- let url;
2942
- const serviceLayer = this.state.wmsUserServiceLayers.find(
2943
- (l) => l.LayerId === elem.id,
2944
- );
2945
- if (!serviceLayer) {
2946
- this.findCheckedDataset(elem);
2947
- url = this.url;
2948
- } else {
2949
- url = serviceLayer.ViewService;
2950
- }
2951
- if (url) {
2952
- await this.getCapabilities(url, 'wms');
2953
- const BBoxes = this.parseBBOXCDSE(this.xml);
2954
- if (BBoxes && BBoxes['dataset']) {
2955
- const myExtent = new Extent({
2956
- xmin: BBoxes['dataset'].xmin,
2957
- ymin: BBoxes['dataset'].ymin,
2958
- xmax: BBoxes['dataset'].xmax,
2959
- ymax: BBoxes['dataset'].ymax,
2960
- });
2961
- this.view.goTo(myExtent);
2962
- layer._ogcExtentApplied = true;
2963
- }
2964
- }
2937
+ const isCDSE = !!this.url && this.url.toLowerCase().includes('/ogc/');
2938
+ if (isCDSE) {
2939
+ const cdseGeometry = await this.getCDSEWFSGeoCoordinates(this.url);
2940
+ const extent = await this.createExtentFromCoordinates(cdseGeometry);
2941
+ this.view.goTo(extent);
2942
+ // layer._ogcExtentApplied = true;
2965
2943
  }
2966
2944
  } catch (e) {}
2945
+ // try {
2946
+ // const layer = this.layers[elem.id];
2947
+ // const viewService = layer?.ViewService || '';
2948
+ // if (
2949
+ // viewService &&
2950
+ // viewService.toLowerCase().includes('wms') &&
2951
+ // viewService.toLowerCase().includes('/ogc/') &&
2952
+ // !layer._ogcExtentApplied &&
2953
+ // !this.extentInitiated
2954
+ // ) {
2955
+ // let url;
2956
+ // const serviceLayer = this.state.wmsUserServiceLayers.find(
2957
+ // (l) => l.LayerId === elem.id,
2958
+ // );
2959
+ // if (!serviceLayer) {
2960
+ // this.findCheckedDataset(elem);
2961
+ // url = this.url;
2962
+ // } else {
2963
+ // url = serviceLayer.ViewService;
2964
+ // }
2965
+ // if (url) {
2966
+ // await this.getCapabilities(url, 'wms');
2967
+ // const BBoxes = this.parseBBOXCDSE(this.xml);
2968
+ // if (BBoxes && BBoxes['dataset']) {
2969
+ // const myExtent = new Extent({
2970
+ // xmin: BBoxes['dataset'].xmin,
2971
+ // ymin: BBoxes['dataset'].ymin,
2972
+ // xmax: BBoxes['dataset'].xmax,
2973
+ // ymax: BBoxes['dataset'].ymax,
2974
+ // });
2975
+ // this.view.goTo(myExtent);
2976
+ // layer._ogcExtentApplied = true;
2977
+ // }
2978
+ // }
2979
+ // }
2980
+ // } catch (e) {}
2967
2981
  } else {
2968
2982
  sessionStorage.removeItem('downloadButtonClicked');
2969
2983
  sessionStorage.removeItem('timeSliderTag');
@@ -2995,6 +3009,7 @@ class MenuWidget extends React.Component {
2995
3009
  this.activeLayersToHotspotData(elem.id);
2996
3010
  }
2997
3011
  this.renderHotspot();
3012
+ this.url = null;
2998
3013
  }
2999
3014
 
3000
3015
  getHotspotLayerIds() {
@@ -3418,6 +3433,85 @@ class MenuWidget extends React.Component {
3418
3433
  return BBoxes;
3419
3434
  }
3420
3435
 
3436
+ async createExtentFromCoordinates(coordinates) {
3437
+ if (!coordinates) return null;
3438
+ let pts;
3439
+ if (
3440
+ Array.isArray(coordinates) &&
3441
+ coordinates[0] &&
3442
+ Array.isArray(coordinates[0]) &&
3443
+ Array.isArray(coordinates[0][0])
3444
+ ) {
3445
+ pts = coordinates[0];
3446
+ } else if (
3447
+ Array.isArray(coordinates) &&
3448
+ coordinates[0] &&
3449
+ typeof coordinates[0] === 'object' &&
3450
+ 'latitude' in coordinates[0] &&
3451
+ 'longitude' in coordinates[0]
3452
+ ) {
3453
+ pts = coordinates.map((c) => [c.longitude, c.latitude]);
3454
+ } else if (
3455
+ Array.isArray(coordinates) &&
3456
+ coordinates[0] &&
3457
+ Array.isArray(coordinates[0]) &&
3458
+ typeof coordinates[0][0] === 'number'
3459
+ ) {
3460
+ pts = coordinates;
3461
+ } else {
3462
+ return null;
3463
+ }
3464
+ let xmin = Infinity,
3465
+ ymin = Infinity,
3466
+ xmax = -Infinity,
3467
+ ymax = -Infinity;
3468
+ for (let i = 0; i < pts.length; i++) {
3469
+ const p = pts[i];
3470
+ if (!Array.isArray(p) || p.length < 2) continue;
3471
+ const x = p[0];
3472
+ const y = p[1];
3473
+ if (x < xmin) xmin = x;
3474
+ if (x > xmax) xmax = x;
3475
+ if (y < ymin) ymin = y;
3476
+ if (y > ymax) ymax = y;
3477
+ }
3478
+ if (
3479
+ !isFinite(xmin) ||
3480
+ !isFinite(ymin) ||
3481
+ !isFinite(xmax) ||
3482
+ !isFinite(ymax)
3483
+ )
3484
+ return null;
3485
+ return new Extent({
3486
+ xmin: xmin,
3487
+ ymin: ymin,
3488
+ xmax: xmax,
3489
+ ymax: ymax,
3490
+ spatialReference: { wkid: 3857 },
3491
+ });
3492
+ }
3493
+
3494
+ async getCDSEWFSGeoCoordinates(url) {
3495
+ if (!url) return {};
3496
+ const match = /\/ogc\/(?:wmts|wms)\/([^/?]+)/i.exec(url);
3497
+ if (!match) return {};
3498
+ const fetchUrl = `https://sh.dataspace.copernicus.eu/ogc/wfs/${match[1]}?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=byoc-4bd995a1-dc49-4176-a285-b1d0084ba51a&COUNT=100&BBOX=-21039383,-22375217,21039383,22375217&OUTPUTFORMAT=application/json`;
3499
+ try {
3500
+ const res = await fetch(fetchUrl);
3501
+ const data = await res.json();
3502
+ if (
3503
+ data &&
3504
+ data.features &&
3505
+ data.features[0] &&
3506
+ data.features[0].geometry &&
3507
+ data.features[0].geometry.coordinates
3508
+ )
3509
+ return data.features[0].geometry.coordinates;
3510
+ } catch (e) {
3511
+ return {};
3512
+ }
3513
+ }
3514
+
3421
3515
  parseBBOXCDSE(xml) {
3422
3516
  if (!xml || typeof xml.getElementsByTagName !== 'function') return {};
3423
3517
  const all = Array.from(xml.getElementsByTagName('*'));
@@ -3710,13 +3804,16 @@ class MenuWidget extends React.Component {
3710
3804
  }
3711
3805
  let isCDSE = this.url?.toLowerCase().includes('/ogc/') ? true : false;
3712
3806
  let BBoxes = {};
3713
- if (this.url?.toLowerCase().endsWith('mapserver')) {
3807
+ if (isCDSE) {
3808
+ const cdseGeometry = await this.getCDSEWFSGeoCoordinates(this.url);
3809
+ const extent = await this.createExtentFromCoordinates(cdseGeometry);
3810
+ this.view.goTo(extent);
3811
+ return;
3812
+ } else if (this.url?.toLowerCase().endsWith('mapserver')) {
3714
3813
  BBoxes = await this.parseBBOXMAPSERVER(this.layers[elem.id]);
3715
3814
  } else if (this.url?.toLowerCase().includes('wms') || serviceLayer) {
3716
3815
  await this.getCapabilities(this.url, 'wms');
3717
- BBoxes = isCDSE
3718
- ? this.parseBBOXCDSE(this.xml)
3719
- : this.parseBBOXWMS(this.xml);
3816
+ this.parseBBOXWMS(this.xml);
3720
3817
  } else if (this.url?.toLowerCase().includes('wmts')) {
3721
3818
  await this.getCapabilities(this.url, 'wmts');
3722
3819
  BBoxes = this.parseBBOXWMTS(this.xml);