diff --git a/CHANGES.md b/CHANGES.md index 11c3df634ff..9c70246a026 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,8 @@ - Fixed broken point dragging interaction for user drawing in 3D mode. - Fixed rectangle drawing in 2D mode. - Added EPSG:7855 to `Proj4Definitions`. +- Fix multi level nesting in ArcGIS Mapserver. +- [The next improvement] #### 8.3.2 - 2023-08-11 diff --git a/lib/Models/Catalog/Esri/ArcGisMapServerCatalogGroup.ts b/lib/Models/Catalog/Esri/ArcGisMapServerCatalogGroup.ts index f6fa4feb4ef..4f7c837b4cb 100644 --- a/lib/Models/Catalog/Esri/ArcGisMapServerCatalogGroup.ts +++ b/lib/Models/Catalog/Esri/ArcGisMapServerCatalogGroup.ts @@ -49,6 +49,19 @@ export class MapServerStratum extends LoadableStratum( ) as this; } + /** returns an array of the parent layers id's */ + findParentLayers(layerId: number): number[] { + const parentLayerIds: number[] = []; + const layer = this.layers.find((l) => l.id === layerId); + if (layer !== undefined) { + parentLayerIds.push(layer.id); + if (layer.parentLayerId !== -1) { + parentLayerIds.push(...this.findParentLayers(layer.parentLayerId)); + } + } + return parentLayerIds; + } + @computed get name() { if ( this._mapServer.documentInfo && @@ -189,12 +202,14 @@ export class MapServerStratum extends LoadableStratum( return; } const id = this._catalogGroup.uniqueId; - //if parent layer is not -1 then this is sublayer so we define its ID like that - const layerId = - id + - "/" + - (layer.parentLayerId !== -1 ? layer.parentLayerId + "/" : "") + - layer.id; + let layerId = id + "/" + layer.id; + + const parentLayers = this.findParentLayers(layer.id); + + if (parentLayers.length > 0) { + layerId = id + "/" + parentLayers.reverse().join("/"); + } + let model: ArcGisMapServerCatalogItem | ArcGisMapServerCatalogGroup; // Treat layer as a group if it has type "Group Layer" - or has subLayers @@ -220,6 +235,7 @@ export class MapServerStratum extends LoadableStratum( ArcGisMapServerCatalogItem, layerId ); + if (existingModel === undefined) { model = new ArcGisMapServerCatalogItem( layerId, diff --git a/lib/ReactViews/DataCatalog/DataCatalogGroup.jsx b/lib/ReactViews/DataCatalog/DataCatalogGroup.jsx index 71deee9d1b6..99b77f8b2fa 100644 --- a/lib/ReactViews/DataCatalog/DataCatalogGroup.jsx +++ b/lib/ReactViews/DataCatalog/DataCatalogGroup.jsx @@ -101,6 +101,7 @@ class DataCatalogGroup extends React.Component { render() { const group = this.props.group; const { t } = this.props; + return (