From f9706ea99a595376854a65125ebfe39cf14b7eb6 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 21 Jun 2024 12:45:37 +0100 Subject: [PATCH 1/9] introduce ObjectID constructor --- .../Operations/Receive/HostObjectBuilder.cs | 37 +++++++++++++------ .../Utils/ObjectID.cs | 30 +++++++++++++++ 2 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 3e22f2d85d..7bb6014e3e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -11,6 +11,7 @@ using Speckle.Core.Models.GraphTraversal; using Speckle.Converters.ArcGIS3; using RasterLayer = Objects.GIS.RasterLayer; +using Speckle.Connectors.ArcGIS.Utils; namespace Speckle.Connectors.ArcGIS.Operations.Receive; @@ -151,23 +152,37 @@ CancellationToken cancellationToken private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List results) { - // prioritize individual hostAppGeometry type, if available: - if (trackerItem.HostAppGeom != null) + if (trackerItem.MappedLayerURI == null) { results.Add( - new(Status.SUCCESS, trackerItem.Base, trackerItem.MappedLayerURI, trackerItem.HostAppGeom.GetType().ToString()) + new(Status.ERROR, trackerItem.Base, null, null, new ArgumentException("Created Layer URI not found")) ); } else { - results.Add( - new( - Status.SUCCESS, - trackerItem.Base, - trackerItem.MappedLayerURI, - trackerItem.HostAppMapMember?.GetType().ToString() - ) - ); + ObjectID objectId = new(trackerItem.MappedLayerURI, trackerItem.DatasetRow); + if (trackerItem.HostAppGeom != null) // individual hostAppGeometry + { + results.Add( + new( + Status.SUCCESS, + trackerItem.Base, + objectId.ObjectIdToString(), + trackerItem.HostAppGeom.GetType().ToString() + ) + ); + } + else // hostApp Layers + { + results.Add( + new( + Status.SUCCESS, + trackerItem.Base, + objectId.ObjectIdToString(), + trackerItem.HostAppMapMember?.GetType().ToString() + ) + ); + } } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs new file mode 100644 index 0000000000..b723792583 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs @@ -0,0 +1,30 @@ +namespace Speckle.Connectors.ArcGIS.Utils; + +public struct ObjectID +{ + private const string FEATURE_ID_SEPARATOR = "__speckleFeatureId__"; + public string MappedLayerURI { get; } + public int? FeatureId { get; } + + public ObjectID(string encodedId) + { + List stringParts = encodedId.Split(FEATURE_ID_SEPARATOR).ToList(); + MappedLayerURI = stringParts[0]; + FeatureId = null; + if (stringParts.Count > 1) + { + FeatureId = Convert.ToInt32(stringParts[1]); + } + } + + public ObjectID(string layerId, int? featureId) + { + MappedLayerURI = layerId; + FeatureId = featureId; + } + + public readonly string ObjectIdToString() + { + return $"{MappedLayerURI}{FEATURE_ID_SEPARATOR}{FeatureId}"; + } +} From 05adfe9615cda0b5fd016bad7a0805a0db33094a Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 21 Jun 2024 13:32:51 +0100 Subject: [PATCH 2/9] adapt BasicBindings highlight to use ObjectId struct --- .../Bindings/BasicConnectorBinding.cs | 54 ++++++++++++------- .../Operations/Receive/HostObjectBuilder.cs | 18 +++++-- .../Utils/ObjectID.cs | 15 +++++- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 649691a526..9788b458f6 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -2,6 +2,7 @@ using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -58,7 +59,8 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public void RemoveModel(ModelCard model) => _store.RemoveModel(model); - public void HighlightObjects(List objectIds) => HighlightObjectsOnView(objectIds); + public void HighlightObjects(List objectIds) => + HighlightObjectsOnView(objectIds.Select(x => new ObjectID(x)).ToList()); public void HighlightModel(string modelCardId) { @@ -69,16 +71,16 @@ public void HighlightModel(string modelCardId) return; } - var objectIds = new List(); + var objectIds = new List(); if (model is SenderModelCard senderModelCard) { - objectIds = senderModelCard.SendFilter.NotNull().GetObjectIds(); + objectIds = senderModelCard.SendFilter.NotNull().GetObjectIds().Select(x => new ObjectID(x)).ToList(); } if (model is ReceiverModelCard receiverModelCard) { - objectIds = receiverModelCard.BakedObjectIds.NotNull(); + objectIds = receiverModelCard.BakedObjectIds.NotNull().Select(x => new ObjectID(x)).ToList(); } if (objectIds is null) @@ -88,42 +90,44 @@ public void HighlightModel(string modelCardId) HighlightObjectsOnView(objectIds); } - private async void HighlightObjectsOnView(List objectIds) + private async void HighlightObjectsOnView(List objectIds) { MapView mapView = MapView.Active; await QueuedTask .Run(() => { - List mapMembers = GetMapMembers(objectIds, mapView); + List objectIdAndmapMembers = GetMapMembers(objectIds, mapView); ClearSelectionInTOC(); ClearSelection(); - SelectMapMembersInTOC(mapMembers); - SelectMapMembers(mapMembers); + SelectMapMembersInTOC(objectIdAndmapMembers); + SelectMapMembers(objectIdAndmapMembers); mapView.ZoomToSelected(); }) .ConfigureAwait(false); } - private List GetMapMembers(List objectIds, MapView mapView) + private List GetMapMembers(List objectIds, MapView mapView) { - List mapMembers = new(); + List objectIdAndmapMembers = new(); - foreach (string objectId in objectIds) + foreach (ObjectID objectId in objectIds) { - MapMember mapMember = mapView.Map.FindLayer(objectId); + MapMember mapMember = mapView.Map.FindLayer(objectId.MappedLayerURI); if (mapMember is null) { - mapMember = mapView.Map.FindStandaloneTable(objectId); + mapMember = mapView.Map.FindStandaloneTable(objectId.MappedLayerURI); } if (mapMember is null) { continue; } - mapMembers.Add(mapMember); + + ObjectID newObjectId = new(objectId.MappedLayerURI, objectId.FeatureId, mapMember); + objectIdAndmapMembers.Add(newObjectId); } - return mapMembers; + return objectIdAndmapMembers; } private void ClearSelection() @@ -143,10 +147,16 @@ private void ClearSelectionInTOC() MapView.Active.ClearTOCSelection(); } - private void SelectMapMembers(List mapMembers) + private void SelectMapMembers(List objectIdAndmapMembers) { - foreach (var member in mapMembers) + foreach (ObjectID objectId in objectIdAndmapMembers) { + if (objectId.MapMember == null) + { + continue; + } + + MapMember member = objectId.MapMember; if (member is FeatureLayer layer) { layer.Select(); @@ -154,13 +164,19 @@ private void SelectMapMembers(List mapMembers) } } - private void SelectMapMembersInTOC(List mapMembers) + private void SelectMapMembersInTOC(List objectIdAndmapMembers) { List layers = new(); List tables = new(); - foreach (MapMember member in mapMembers) + foreach (ObjectID objectId in objectIdAndmapMembers) { + if (objectId.MapMember == null) + { + continue; + } + + MapMember member = objectId.MapMember; if (member is Layer layer) { if (member is not GroupLayer) // group layer selection clears other layers selection diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 7bb6014e3e..cddcbf3dfc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -117,7 +117,13 @@ CancellationToken cancellationToken else if (trackerItem.DatasetId == null) { results.Add( - new(Status.ERROR, trackerItem.Base, null, null, new ArgumentException("Unknown error: Dataset not created")) + new( + Status.ERROR, + trackerItem.Base, + null, + null, + new ArgumentException($"Unknown error: Dataset not created for {trackerItem.Base.speckle_type}") + ) ); } else if (bakedMapMembers.TryGetValue(trackerItem.DatasetId, out MapMember? value)) @@ -155,12 +161,18 @@ private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List Date: Fri, 21 Jun 2024 13:49:53 +0100 Subject: [PATCH 3/9] select individual features --- .../Bindings/BasicConnectorBinding.cs | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 9788b458f6..888b40f71c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,4 +1,6 @@ using System.Reflection; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; @@ -101,7 +103,7 @@ await QueuedTask ClearSelectionInTOC(); ClearSelection(); SelectMapMembersInTOC(objectIdAndmapMembers); - SelectMapMembers(objectIdAndmapMembers); + SelectMapMembersAndFeatures(objectIdAndmapMembers); mapView.ZoomToSelected(); }) .ConfigureAwait(false); @@ -147,7 +149,7 @@ private void ClearSelectionInTOC() MapView.Active.ClearTOCSelection(); } - private void SelectMapMembers(List objectIdAndmapMembers) + private void SelectMapMembersAndFeatures(List objectIdAndmapMembers) { foreach (ObjectID objectId in objectIdAndmapMembers) { @@ -159,7 +161,32 @@ private void SelectMapMembers(List objectIdAndmapMembers) MapMember member = objectId.MapMember; if (member is FeatureLayer layer) { - layer.Select(); + // select full layer if featureID not specified + if (objectId.FeatureId == null) + { + layer.Select(); + } + else + { + using (RowCursor rowCursor = layer.Search()) + { + int index = 0; + while (rowCursor.MoveNext()) + { + if (index == objectId.FeatureId) + { + //Get the shape from the row and set extent + using (var feature = rowCursor.Current as Feature) + { + Geometry? geometry = feature?.GetShape(); + MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.Add); + } + break; + } + index += 1; + } + } + } } } } From 1d3987d516451de14f8dbf7027d1cc2b5868efbf Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 24 Jun 2024 11:59:38 +0100 Subject: [PATCH 4/9] update missing tracker Items --- .../Operations/Receive/HostObjectBuilder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index cddcbf3dfc..e704cdc105 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -128,13 +128,19 @@ CancellationToken cancellationToken } else if (bakedMapMembers.TryGetValue(trackerItem.DatasetId, out MapMember? value)) { + // add layer and layer URI to tracker + trackerItem.AddConvertedMapMember(value); + trackerItem.AddLayerURI(value.URI); + conversionTracker[item.Key] = trackerItem; // only add a report item AddResultsFromTracker(trackerItem, results); } else { - // add layer and layer URI to tracker + // add layer to Map MapMember mapMember = AddDatasetsToMap(trackerItem, createdLayerGroups); + + // add layer and layer URI to tracker trackerItem.AddConvertedMapMember(mapMember); trackerItem.AddLayerURI(mapMember.URI); conversionTracker[item.Key] = trackerItem; @@ -158,7 +164,7 @@ CancellationToken cancellationToken private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List results) { - if (trackerItem.MappedLayerURI == null) + if (trackerItem.MappedLayerURI == null) // should not happen { results.Add( new( From e405a1dc14fa6c878525c181e0778b7e5ee78b00 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 24 Jun 2024 13:31:49 +0100 Subject: [PATCH 5/9] query features by ID for selection --- .../Bindings/BasicConnectorBinding.cs | 47 +++++++------------ .../Operations/Receive/HostObjectBuilder.cs | 4 +- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 888b40f71c..c1ce59e4fc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,6 +1,5 @@ using System.Reflection; using ArcGIS.Core.Data; -using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; @@ -99,11 +98,11 @@ private async void HighlightObjectsOnView(List objectIds) await QueuedTask .Run(() => { - List objectIdAndmapMembers = GetMapMembers(objectIds, mapView); + List objectIdAndMapMembers = GetMapMembers(objectIds, mapView); ClearSelectionInTOC(); ClearSelection(); - SelectMapMembersInTOC(objectIdAndmapMembers); - SelectMapMembersAndFeatures(objectIdAndmapMembers); + SelectMapMembersInTOC(objectIdAndMapMembers); + SelectMapMembersAndFeatures(objectIdAndMapMembers); mapView.ZoomToSelected(); }) .ConfigureAwait(false); @@ -111,11 +110,11 @@ await QueuedTask private List GetMapMembers(List objectIds, MapView mapView) { - List objectIdAndmapMembers = new(); + List objectIdAndMapMembers = new(); foreach (ObjectID objectId in objectIds) { - MapMember mapMember = mapView.Map.FindLayer(objectId.MappedLayerURI); + MapMember mapMember = mapView.Map.FindLayer(objectId.MappedLayerURI, true); if (mapMember is null) { mapMember = mapView.Map.FindStandaloneTable(objectId.MappedLayerURI); @@ -126,10 +125,10 @@ private List GetMapMembers(List objectIds, MapView mapView) } ObjectID newObjectId = new(objectId.MappedLayerURI, objectId.FeatureId, mapMember); - objectIdAndmapMembers.Add(newObjectId); + objectIdAndMapMembers.Add(newObjectId); } - return objectIdAndmapMembers; + return objectIdAndMapMembers; } private void ClearSelection() @@ -149,9 +148,9 @@ private void ClearSelectionInTOC() MapView.Active.ClearTOCSelection(); } - private void SelectMapMembersAndFeatures(List objectIdAndmapMembers) + private void SelectMapMembersAndFeatures(List objectIdAndMapMembers) { - foreach (ObjectID objectId in objectIdAndmapMembers) + foreach (ObjectID objectId in objectIdAndMapMembers) { if (objectId.MapMember == null) { @@ -161,42 +160,28 @@ private void SelectMapMembersAndFeatures(List objectIdAndmapMembers) MapMember member = objectId.MapMember; if (member is FeatureLayer layer) { - // select full layer if featureID not specified if (objectId.FeatureId == null) { + // select full layer if featureID not specified layer.Select(); } else { - using (RowCursor rowCursor = layer.Search()) - { - int index = 0; - while (rowCursor.MoveNext()) - { - if (index == objectId.FeatureId) - { - //Get the shape from the row and set extent - using (var feature = rowCursor.Current as Feature) - { - Geometry? geometry = feature?.GetShape(); - MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.Add); - } - break; - } - index += 1; - } - } + // query features by ID + var objectIDfield = layer.GetFeatureClass().GetDefinition().GetObjectIDField(); + QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {objectId.FeatureId + 1}" }; + using (Selection onlyOneSelection = layer.Select(anotherQueryFilter, SelectionCombinationMethod.New)) { } } } } } - private void SelectMapMembersInTOC(List objectIdAndmapMembers) + private void SelectMapMembersInTOC(List objectIdAndMapMembers) { List layers = new(); List tables = new(); - foreach (ObjectID objectId in objectIdAndmapMembers) + foreach (ObjectID objectId in objectIdAndMapMembers) { if (objectId.MapMember == null) { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index e704cdc105..4ef18a0041 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -131,7 +131,7 @@ CancellationToken cancellationToken // add layer and layer URI to tracker trackerItem.AddConvertedMapMember(value); trackerItem.AddLayerURI(value.URI); - conversionTracker[item.Key] = trackerItem; + conversionTracker[item.Key] = trackerItem; // not necessary atm, but needed if we use conversionTracker further // only add a report item AddResultsFromTracker(trackerItem, results); } @@ -143,7 +143,7 @@ CancellationToken cancellationToken // add layer and layer URI to tracker trackerItem.AddConvertedMapMember(mapMember); trackerItem.AddLayerURI(mapMember.URI); - conversionTracker[item.Key] = trackerItem; + conversionTracker[item.Key] = trackerItem; // not necessary atm, but needed if we use conversionTracker further // add layer URI to bakedIds bakedObjectIds.Add(trackerItem.MappedLayerURI == null ? "" : trackerItem.MappedLayerURI); From 79e22de5120999af588ddf903235721ef837a04c Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 18:28:19 +0100 Subject: [PATCH 6/9] separate struct for MapMembers --- .../Bindings/BasicConnectorBinding.cs | 47 +++++++------------ .../Operations/Receive/HostObjectBuilder.cs | 2 +- .../Utils/MapMemberFeature.cs | 16 +++++++ .../Utils/ObjectID.cs | 6 +-- 4 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index c1ce59e4fc..2958aebdbe 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -98,19 +98,19 @@ private async void HighlightObjectsOnView(List objectIds) await QueuedTask .Run(() => { - List objectIdAndMapMembers = GetMapMembers(objectIds, mapView); + List mapMembersFeatures = GetMapMembers(objectIds, mapView); ClearSelectionInTOC(); ClearSelection(); - SelectMapMembersInTOC(objectIdAndMapMembers); - SelectMapMembersAndFeatures(objectIdAndMapMembers); + SelectMapMembersInTOC(mapMembersFeatures); + SelectMapMembersAndFeatures(mapMembersFeatures); mapView.ZoomToSelected(); }) .ConfigureAwait(false); } - private List GetMapMembers(List objectIds, MapView mapView) + private List GetMapMembers(List objectIds, MapView mapView) { - List objectIdAndMapMembers = new(); + List mapMembersFeatures = new(); foreach (ObjectID objectId in objectIds) { @@ -119,16 +119,13 @@ private List GetMapMembers(List objectIds, MapView mapView) { mapMember = mapView.Map.FindStandaloneTable(objectId.MappedLayerURI); } - if (mapMember is null) + if (mapMember is not null) { - continue; + MapMemberFeature mapMembersFeat = new(mapMember, objectId.FeatureId); + mapMembersFeatures.Add(mapMembersFeat); } - - ObjectID newObjectId = new(objectId.MappedLayerURI, objectId.FeatureId, mapMember); - objectIdAndMapMembers.Add(newObjectId); } - - return objectIdAndMapMembers; + return mapMembersFeatures; } private void ClearSelection() @@ -148,19 +145,14 @@ private void ClearSelectionInTOC() MapView.Active.ClearTOCSelection(); } - private void SelectMapMembersAndFeatures(List objectIdAndMapMembers) + private void SelectMapMembersAndFeatures(List mapMembersFeatures) { - foreach (ObjectID objectId in objectIdAndMapMembers) + foreach (MapMemberFeature mapMemberFeat in mapMembersFeatures) { - if (objectId.MapMember == null) - { - continue; - } - - MapMember member = objectId.MapMember; + MapMember member = mapMemberFeat.MapMember; if (member is FeatureLayer layer) { - if (objectId.FeatureId == null) + if (mapMemberFeat.FeatureId == null) { // select full layer if featureID not specified layer.Select(); @@ -169,26 +161,21 @@ private void SelectMapMembersAndFeatures(List objectIdAndMapMembers) { // query features by ID var objectIDfield = layer.GetFeatureClass().GetDefinition().GetObjectIDField(); - QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {objectId.FeatureId + 1}" }; + QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {mapMemberFeat.FeatureId + 1}" }; using (Selection onlyOneSelection = layer.Select(anotherQueryFilter, SelectionCombinationMethod.New)) { } } } } } - private void SelectMapMembersInTOC(List objectIdAndMapMembers) + private void SelectMapMembersInTOC(List mapMembersFeatures) { List layers = new(); List tables = new(); - foreach (ObjectID objectId in objectIdAndMapMembers) + foreach (MapMemberFeature mapMemberFeat in mapMembersFeatures) { - if (objectId.MapMember == null) - { - continue; - } - - MapMember member = objectId.MapMember; + MapMember member = mapMemberFeat.MapMember; if (member is Layer layer) { if (member is not GroupLayer) // group layer selection clears other layers selection diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 4ef18a0041..91d1cfa2f8 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -178,7 +178,7 @@ private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List Date: Fri, 28 Jun 2024 21:30:37 +0100 Subject: [PATCH 7/9] add comments --- .../Bindings/BasicConnectorBinding.cs | 3 +++ .../Operations/Receive/HostObjectBuilder.cs | 1 + .../Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs | 5 +++-- .../ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 2958aebdbe..bda82ed7de 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -110,6 +110,7 @@ await QueuedTask private List GetMapMembers(List objectIds, MapView mapView) { + // find the layer on the map (from the objectID) and add the featureID is available List mapMembersFeatures = new(); foreach (ObjectID objectId in objectIds) @@ -161,6 +162,8 @@ private void SelectMapMembersAndFeatures(List mapMembersFeatur { // query features by ID var objectIDfield = layer.GetFeatureClass().GetDefinition().GetObjectIDField(); + + // FeatureID range starts from 0, but auto-assigned IDs in the layer start from 1 QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {mapMemberFeat.FeatureId + 1}" }; using (Selection onlyOneSelection = layer.Select(anotherQueryFilter, SelectionCombinationMethod.New)) { } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 91d1cfa2f8..953a6b2abb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -178,6 +178,7 @@ private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List Date: Fri, 28 Jun 2024 21:34:15 +0100 Subject: [PATCH 8/9] formatting --- .../Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs index 48edf163e5..026e5165dc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs @@ -2,7 +2,7 @@ namespace Speckle.Connectors.ArcGIS.Utils; -// bind together a layer object on the map, and auto-assigned ID if the specific feature +// bind together a layer object on the map, and auto-assigned ID if the specific feature public readonly struct MapMemberFeature { public int? FeatureId { get; } // unique feature id (start from 0) of a feature in the layer @@ -13,5 +13,4 @@ public MapMemberFeature(MapMember mapMember, int? featureId) MapMember = mapMember; FeatureId = featureId; } - } From 610884182bca91361584392375fab9bee9a9f271 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 23:41:13 +0100 Subject: [PATCH 9/9] formatting --- .../Bindings/BasicConnectorBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index bda82ed7de..961ceb1576 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -162,7 +162,7 @@ private void SelectMapMembersAndFeatures(List mapMembersFeatur { // query features by ID var objectIDfield = layer.GetFeatureClass().GetDefinition().GetObjectIDField(); - + // FeatureID range starts from 0, but auto-assigned IDs in the layer start from 1 QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {mapMemberFeat.FeatureId + 1}" }; using (Selection onlyOneSelection = layer.Select(anotherQueryFilter, SelectionCombinationMethod.New)) { }