Skip to content

Commit

Permalink
fix applicationIds
Browse files Browse the repository at this point in the history
  • Loading branch information
KatKatKateryna committed Dec 16, 2024
1 parent 2fffed1 commit 50815dc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ArcGIS.Desktop.Mapping;
using Speckle.Converters.ArcGIS3.Extensions;
using Speckle.Sdk.Models.Proxies;

namespace Speckle.Connectors.ArcGIS.HostApp;
Expand Down Expand Up @@ -121,10 +120,8 @@ public void StoreRenderer(ADM.LasDatasetLayer lasLayer)
/// POC: logic probably can be combined with ProcessFeatureLayerColor.
/// </summary>
/// <param name="point"></param>
public void ProcessLasLayerColor(ACD.Analyst3D.LasPoint point)
public void ProcessLasLayerColor(ACD.Analyst3D.LasPoint point, string pointApplicationId)
{
string pointApplicationId = point.GetSpeckleApplicationId();

// get the color from the renderer and point
AC.CIM.CIMColor? color;
switch (StoredTinRenderer)
Expand Down Expand Up @@ -180,10 +177,8 @@ ACD.Analyst3D.LasPoint point
/// <param name="row"></param>
/// <returns></returns>
/// <exception cref="ACD.Exceptions.GeodatabaseException"></exception>
public void ProcessFeatureLayerColor(ACD.Row row)
public void ProcessFeatureLayerColor(ACD.Row row, string rowApplicationId)
{
string rowApplicationId = row.GetSpeckleApplicationId();

// if stored color is not null, this means the renderer was a simple renderer that applies to the entire layer, and was already created.
// just add the row application id to the color proxy.
if (StoredColor is int existingColorProxyId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using ArcGIS.Core.Data.Raster;
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using Microsoft.Extensions.Logging;
Expand All @@ -12,6 +13,7 @@
using Speckle.Converters.ArcGIS3;
using Speckle.Converters.Common;
using Speckle.Sdk;
using Speckle.Sdk.Common.Exceptions;
using Speckle.Sdk.Logging;
using Speckle.Sdk.Models;
using Speckle.Sdk.Models.Collections;
Expand Down Expand Up @@ -212,11 +214,15 @@ await QueuedTask
// Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller.
using (ACD.Row row = rowCursor.Current)
{
// get application id. test for subtypes before defaulting to base type.
Base converted = _rootToSpeckleConverter.Convert(row);
string applicationId = GetSpeckleApplicationId(featureLayer, row);
converted.applicationId = applicationId;

convertedObjects.Add(converted);

// process the object color
_colorUnpacker.ProcessFeatureLayerColor(row);
_colorUnpacker.ProcessFeatureLayerColor(row, applicationId);
}
}
}
Expand All @@ -233,7 +239,10 @@ private async Task<List<Base>> ConvertRasterLayerObjectsAsync(ADM.RasterLayer ra
await QueuedTask
.Run(() =>
{
Base converted = _rootToSpeckleConverter.Convert(rasterLayer.GetRaster());
Raster raster = rasterLayer.GetRaster();
Base converted = _rootToSpeckleConverter.Convert(raster);
string applicationId = GetSpeckleApplicationId(rasterLayer, raster);
converted.applicationId = applicationId;
convertedObjects.Add(converted);
})
.ConfigureAwait(false);
Expand Down Expand Up @@ -262,10 +271,12 @@ await QueuedTask
using (ACD.Analyst3D.LasPoint pt = ptCursor.Current)
{
Base converted = _rootToSpeckleConverter.Convert(pt);
string applicationId = GetSpeckleApplicationId(lasDatasetLayer, pt);
converted.applicationId = applicationId;
convertedObjects.Add(converted);

// process the object color
_colorUnpacker.ProcessLasLayerColor(pt);
_colorUnpacker.ProcessLasLayerColor(pt, applicationId);
}
}
}
Expand All @@ -274,9 +285,29 @@ await QueuedTask
}
catch (ACD.Exceptions.TinException ex)
{
throw new SpeckleException($"3D analyst extension is not enabled for .las layer operations", ex);
throw new SpeckleException("3D analyst extension is not enabled for .las layer operations", ex);
}

return convertedObjects;
}

/// <summary>
/// Retrieves the Speckle application id for Features as a concatenation of the layer URI (applicationId)
/// and the row OID (index of row in layer) or point OID for LasDatasets.
/// </summary>
/// <exception cref="ACD.Exceptions.GeodatabaseException">Throws when this is *not* called on MCT. Use QueuedTask.Run.</exception>
public string GetSpeckleApplicationId(ADM.Layer layer, AC.CoreObjectsBase coreObject)
{
if (coreObject is ACD.Row row)
{
return $"{layer.URI}_{row.GetObjectID()}";
}

if (coreObject is ACD.Analyst3D.LasPoint point)
{
return $"{layer.URI}_{point.PointID}";
}

throw new ConversionNotSupportedException($"Conversion not supported for objects of type '{coreObject.GetType()}'");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<ProjectReference Include="..\..\..\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Speckle.Converters.ArcGIS3.Extensions;
using Speckle.Converters.ArcGIS3.ToSpeckle.Helpers;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
Expand Down Expand Up @@ -37,13 +36,6 @@ private ArcgisObject Convert(AC.CoreObjectsBase target)
// get properties
Dictionary<string, object?> properties = _propertiesExtractor.GetProperties(target);

// get application id. test for subtypes before defaulting to base type.
string applicationId = target is ACD.Row row
? row.GetSpeckleApplicationId()
: target is ACD.Analyst3D.LasPoint point
? point.GetSpeckleApplicationId()
: target.GetSpeckleApplicationId();

ArcgisObject result =
new()
{
Expand All @@ -52,7 +44,7 @@ private ArcgisObject Convert(AC.CoreObjectsBase target)
displayValue = display,
properties = properties,
units = _settingsStore.Current.SpeckleUnits,
applicationId = applicationId
applicationId = ""
};

return result;
Expand Down

0 comments on commit 50815dc

Please sign in to comment.