@eeacms/volto-arcgis-block 0.1.129 → 0.1.130

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,12 @@ 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.130](https://github.com/eea/volto-arcgis-block/compare/0.1.129...0.1.130) - 25 April 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-1733 (feat): Full extent button added in the Map viewer [Urkorue - [`7eb1a4d`](https://github.com/eea/volto-arcgis-block/commit/7eb1a4d5bbe36153261d761b0e2f34cc145340b7)]
12
+ - CLMS-1733 (feat): Latest changes. Not completed [Urkorue - [`8b53227`](https://github.com/eea/volto-arcgis-block/commit/8b5322726416ba84704df4ee9a786a173fc86613)]
7
13
  ### [0.1.129](https://github.com/eea/volto-arcgis-block/compare/0.1.128...0.1.129) - 24 April 2023
8
14
 
9
15
  #### :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.129",
3
+ "version": "0.1.130",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -8,7 +8,7 @@ import AreaWidget from './AreaWidget';
8
8
  import TimesliderWidget from './TimesliderWidget';
9
9
  import { Toast } from '@plone/volto/components';
10
10
  import { toast } from 'react-toastify';
11
- var WMSLayer, WMTSLayer, FeatureLayer, BaseTileLayer, esriRequest;
11
+ var WMSLayer, WMTSLayer, FeatureLayer, BaseTileLayer, esriRequest, Extent;
12
12
 
13
13
  const popupSettings = {
14
14
  basic: true,
@@ -346,6 +346,8 @@ class MenuWidget extends React.Component {
346
346
  this.layers = this.props.layers;
347
347
  this.activeLayersJSON = {};
348
348
  this.layerGroups = {};
349
+ this.xml = null;
350
+ this.dataBBox = null;
349
351
 
350
352
  // add zoomend listener to map to show/hide zoom in message
351
353
  this.view.watch('stationary', (isStationary) => {
@@ -410,6 +412,7 @@ class MenuWidget extends React.Component {
410
412
  'esri/layers/FeatureLayer',
411
413
  'esri/layers/BaseTileLayer',
412
414
  'esri/request',
415
+ 'esri/geometry/Extent',
413
416
  ]).then(
414
417
  ([
415
418
  _WMSLayer,
@@ -417,12 +420,14 @@ class MenuWidget extends React.Component {
417
420
  _FeatureLayer,
418
421
  _BaseTileLayer,
419
422
  _esriRequest,
423
+ _Extent,
420
424
  ]) => {
421
425
  WMSLayer = _WMSLayer;
422
426
  WMTSLayer = _WMTSLayer;
423
427
  FeatureLayer = _FeatureLayer;
424
428
  BaseTileLayer = _BaseTileLayer;
425
429
  esriRequest = _esriRequest;
430
+ Extent = _Extent;
426
431
  },
427
432
  );
428
433
  }
@@ -1933,7 +1938,164 @@ class MenuWidget extends React.Component {
1933
1938
  );
1934
1939
  }
1935
1940
  }
1941
+ findCheckedDatasetNoServiceToVisualize(elem) {
1942
+ let parentId = elem.getAttribute('parentid');
1943
+ let selectedDataset = document.querySelector('[id="' + parentId + '"]');
1944
+ this.compCfg.forEach((component) => {
1945
+ component.Products.forEach((product) => {
1946
+ product.Datasets.forEach((dataset) => {
1947
+ if (dataset.DatasetTitle.includes(selectedDataset.title)) {
1948
+ return dataset.MarkAsDownloadableNoServiceToVisualize;
1949
+ }
1950
+ });
1951
+ });
1952
+ });
1953
+ }
1954
+ findCheckedDataset(elem) {
1955
+ let parentId = elem.getAttribute('parentid');
1956
+ let selectedDataset = document.querySelector('[id="' + parentId + '"]');
1957
+ this.compCfg.forEach((component) => {
1958
+ component.Products.forEach((product) => {
1959
+ product.Datasets.forEach((dataset) => {
1960
+ if (dataset.DatasetTitle.includes(selectedDataset.title)) {
1961
+ this.url = dataset.ViewService;
1962
+ }
1963
+ });
1964
+ });
1965
+ });
1966
+ }
1967
+ parseBBOXWMS(xml) {
1968
+ const layerParentNode = xml.querySelectorAll('Layer');
1969
+ let layersChildren = Array.from(layerParentNode).filter(
1970
+ (v) => v.querySelectorAll('Layer').length === 0,
1971
+ );
1972
+ let layerParent = Array.from(layerParentNode).filter(
1973
+ (v) => v.querySelectorAll('Layer').length !== 0,
1974
+ );
1975
+ let BBoxes = {};
1976
+ for (let i in layersChildren) {
1977
+ let layerGeoGraphic = {};
1978
+ if (
1979
+ layersChildren[i].querySelector('EX_GeographicBoundingBox') !== null
1980
+ ) {
1981
+ // If the layer has BBOX
1982
+ layerGeoGraphic = layersChildren[i].querySelector(
1983
+ 'EX_GeographicBoundingBox',
1984
+ );
1985
+ } else {
1986
+ // If the layer has no BBOX, it was assigned dataset BBOX
1987
+ layerGeoGraphic = layerParent[0].querySelector(
1988
+ 'EX_GeographicBoundingBox',
1989
+ );
1990
+ }
1991
+ BBoxes[layersChildren[i].querySelector('Name').innerText] = {
1992
+ xmin: Number(
1993
+ layerGeoGraphic.querySelector('westBoundLongitude').innerText,
1994
+ ),
1995
+ ymin: Number(
1996
+ layerGeoGraphic.querySelector('southBoundLatitude').innerText,
1997
+ ),
1998
+ xmax: Number(
1999
+ layerGeoGraphic.querySelector('eastBoundLongitude').innerText,
2000
+ ),
2001
+ ymax: Number(
2002
+ layerGeoGraphic.querySelector('northBoundLatitude').innerText,
2003
+ ),
2004
+ };
2005
+ }
2006
+ return BBoxes;
2007
+ } // function parseWMS
2008
+ // Web Map Tiled Services WMTS
2009
+ parseBBOXWMTS(xml) {
2010
+ const layerParentNode = xml.querySelectorAll('Layer');
2011
+ let layersChildren = Array.from(layerParentNode).filter(
2012
+ (v) => v.querySelectorAll('Layer').length === 0,
2013
+ );
2014
+ let layerParent = Array.from(layerParentNode).filter(
2015
+ (v) => v.querySelectorAll('Layer').length !== 0,
2016
+ );
2017
+ let BBoxes = {};
2018
+ for (let i in layersChildren) {
2019
+ let LowerCorner,
2020
+ UpperCorner = [];
2021
+ if (
2022
+ this.parseCapabilities(layersChildren[i], 'ows:LowerCorner').length !==
2023
+ 0
2024
+ ) {
2025
+ // If the layer has BBOX
2026
+ LowerCorner = this.parseCapabilities(
2027
+ layersChildren[i],
2028
+ 'ows:LowerCorner',
2029
+ )[0].innerText.split(' ');
2030
+ UpperCorner = this.parseCapabilities(
2031
+ layersChildren[i],
2032
+ 'ows:UpperCorner',
2033
+ )[0].innerText.split(' ');
2034
+ } else {
2035
+ // If the layer has no BBOX, it was assigned dataset BBOX
2036
+ LowerCorner = this.parseCapabilities(
2037
+ layerParent,
2038
+ 'ows:LowerCorner',
2039
+ )[0].innerText.split(' ');
2040
+ UpperCorner = this.parseCapabilities(
2041
+ layerParent,
2042
+ 'ows:UpperCorner',
2043
+ )[0].innerText.split(' ');
2044
+ }
2045
+ BBoxes[
2046
+ this.parseCapabilities(layersChildren[i], 'ows:Title')[0].innerText
2047
+ ] = {
2048
+ xmin: Number(LowerCorner[0]),
2049
+ ymin: Number(LowerCorner[1]),
2050
+ xmax: Number(UpperCorner[0]),
2051
+ ymax: Number(UpperCorner[1]),
2052
+ };
2053
+ }
2054
+ return BBoxes;
2055
+ }
2056
+
2057
+ parseCapabilities(xml, tag) {
2058
+ return xml.getElementsByTagName(tag);
2059
+ }
1936
2060
 
2061
+ getCapabilities = (url, serviceType) => {
2062
+ // Get the coordinates of the click on the view
2063
+ return esriRequest(url, {
2064
+ responseType: 'html',
2065
+ sync: 'true',
2066
+ query: {
2067
+ request: 'GetCapabilities',
2068
+ service: serviceType,
2069
+ },
2070
+ })
2071
+ .then((response) => {
2072
+ const xmlDoc = response.data;
2073
+ const parser = new DOMParser();
2074
+ this.xml = parser.parseFromString(xmlDoc, 'text/html');
2075
+ //this.xml = response.data; // assign the response data to this.xml
2076
+ })
2077
+ .catch(() => {});
2078
+ };
2079
+ async fullExtent(elem) {
2080
+ this.findCheckedDataset(elem);
2081
+ let BBoxes = {};
2082
+ if (this.url.toLowerCase().includes('wms')) {
2083
+ await this.getCapabilities(this.url, 'wms');
2084
+ BBoxes = this.parseBBOXWMS(this.xml);
2085
+ } else if (this.url.toLowerCase().includes('wmts')) {
2086
+ await this.getCapabilities(this.url, 'wmts');
2087
+ BBoxes = this.parseBBOXWMTS(this.xml);
2088
+ }
2089
+ const firstLayer = BBoxes[Object.keys(BBoxes)[0]];
2090
+ let myExtent = new Extent({
2091
+ xmin: firstLayer.xmin,
2092
+ ymin: firstLayer.ymin,
2093
+ xmax: firstLayer.xmax,
2094
+ ymax: firstLayer.ymax,
2095
+ // spatialReference: 4326 // by default wkid 4326
2096
+ });
2097
+ this.view.goTo(myExtent);
2098
+ }
1937
2099
  /**
1938
2100
  * Method to show Active Layers of the map
1939
2101
  * @param {*} elem From the click event
@@ -1956,6 +2118,23 @@ class MenuWidget extends React.Component {
1956
2118
  {elem.title}
1957
2119
  </div>
1958
2120
  <div className="active-layer-options" key={'c_' + elem.id}>
2121
+ {!this.findCheckedDatasetNoServiceToVisualize(elem) && (
2122
+ <span
2123
+ className="map-menu-icon active-layer-extent"
2124
+ onClick={() => this.fullExtent(elem)}
2125
+ onKeyDown={() => this.fullExtent(elem)}
2126
+ tabIndex="0"
2127
+ role="button"
2128
+ >
2129
+ <Popup
2130
+ trigger={
2131
+ <FontAwesomeIcon icon={['fas', 'expand-arrows-alt']} />
2132
+ }
2133
+ content="Full extent"
2134
+ {...popupSettings}
2135
+ />
2136
+ </span>
2137
+ )}
1959
2138
  {elem.parentElement.dataset.timeseries === 'true' && (
1960
2139
  <span
1961
2140
  className="map-menu-icon active-layer-time"