Skip to content

Commit

Permalink
remove flattened layers from root commit builder
Browse files Browse the repository at this point in the history
  • Loading branch information
KatKatKateryna committed Dec 12, 2024
1 parent cfa4f47 commit e0e7b1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ public class ArcGISLayerUnpacker
/// </summary>
public Dictionary<string, Collection> CollectionCache { get; } = new();

public List<ADM.MapMember> RemoveNestedMapMembers(IReadOnlyList<ADM.MapMember> mapMembers)
{
List<ADM.MapMember> rootLayers = new();
foreach (ADM.MapMember mapMember in mapMembers)
{
if (mapMember is ADM.Layer layer)
{
if (layer.Parent is ADM.Map)
{
rootLayers.Add(mapMember);
}
}
}

return rootLayers;
}

/// <summary>
/// Mapmembers can be layers containing objects, or LayerContainers containing other layers.
/// Unpacks selected mapMembers and creates their corresponding collection on the root collection.
Expand All @@ -33,7 +50,9 @@ Collection parentCollection
Collection containerCollection = CreateAndCacheMapMemberCollection(mapMember, true);
parentCollection.elements.Add(containerCollection);

await UnpackSelectionAsync(container.Layers, containerCollection).ConfigureAwait(false);
List<ADM.MapMember> unpackedLayers = await UnpackSelectionAsync(container.Layers, containerCollection)
.ConfigureAwait(false);
objects.AddRange(unpackedLayers);
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ public async Task<RootObjectBuilderResult> Build(
List<ADM.MapMember> unpackedLayers;
using (var _ = _activityFactory.Start("Unpacking selection"))
{
List<MapMember> rootLayers = _layerUnpacker.RemoveNestedMapMembers(layers);
unpackedLayers = await QueuedTask
.Run(() => _layerUnpacker.UnpackSelectionAsync(layers, rootCollection))
.Run(() => _layerUnpacker.UnpackSelectionAsync(rootLayers, rootCollection))
.ConfigureAwait(false);
}

Expand Down

0 comments on commit e0e7b1f

Please sign in to comment.