Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(arcgis): overhaul of arcgis connector and converter patterns to enable data extraction #439

Conversation

clairekuang
Copy link
Member

@clairekuang clairekuang commented Dec 7, 2024

Description & motivation

This pr is a big refactor of the arcgis connector to enable data extraction workflows (sending ArcgisObject: IDataObject). It includes the following changes to align arcgis with all other data extractor patterns:

  • Objects of CoreObjectBase type are now passed to the single TopLevelConverter. Previously, this was a mixture of objevcts and layers
  • All layer logic is handled in the connector. Previously, LasDatasetLayers were passed to the converter. These are now passing individual points to the converter, instead of sending the layer as a pointcloud
  • DisplayValueExtractor and PropertiesExtractor classes added to the converter to assist in object creation in the top level converter.
  • ColorUnpacker class added to connector to handle color proxy creation during mapmember iteration
  • CRS information is added to the root collection, instead of to every single layer

Some async logic was refactored in the connector to improve safety.
Some poor conversion logic in the converters was removed to improve performance.
Reduced complexity in root object builder, removed pragma warning disable.

Note: receive needs an equally large refactor to handle DataObjects only. This pr will disable the receive binding until that refactor is completed. Metrics from qgis v2 show that sending is much more common than receiving (~2500 incidents vs 220). Arcgis currently has 1 MAU.

Changes:

  • arcgis converter and connector

To-do before merge:

  • Test sending
  • disable receiving
  • add send caching

Screenshots:

In arcgis file:
{FFD12B3F-01CA-4259-9CE9-D54A4AB3B829}

With this pr:
{73FAAA63-AA1D-464D-BA4D-BD0798042B93}
https://latest.speckle.systems/projects/2295cb26a0/models/874439f06c

Validation of changes:

Tested sending the sample arcgis file. Note: our pro license does not include 3d extensions, meaning I couldn't test point clouds.

Copy link

linear bot commented Dec 7, 2024

Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.43%. Comparing base (9bab0ff) to head (792edea).
Report is 1 commits behind head on arcgis_refactor.

Additional details and impacted files
@@               Coverage Diff               @@
##           arcgis_refactor    #439   +/-   ##
===============================================
  Coverage             9.43%   9.43%           
===============================================
  Files                  223     223           
  Lines                 4208    4208           
  Branches               487     487           
===============================================
  Hits                   397     397           
  Misses                3795    3795           
  Partials                16      16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@clairekuang clairekuang changed the base branch from dev to arcgis_refactor December 7, 2024 19:17
@clairekuang clairekuang marked this pull request as draft December 7, 2024 19:17
@clairekuang clairekuang marked this pull request as ready for review December 10, 2024 09:35
Copy link
Member

@oguzhankoral oguzhankoral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Few change requests
  • Mostly questions

@clairekuang happy to do live PR review together over my comments

}

return gisLayer;
parentCollection.elements.Add(collection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we pass parentCollection to just add it at the end of function. I would put it outside and rename function CreateAddMapMemberCollection for single responsibilty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -16,14 +16,12 @@
<Compile Include="$(MSBuildThisFileDirectory)HostApp\CSiSendCollectionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\CSiRootObjectBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\CSiPluginBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\SpeckleFormBase.cs">
<SubType>Form</SubType>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, why removed underlying Form? maybe missing context here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove all csi related changes

@@ -0,0 +1,21 @@
namespace Speckle.Converters.ArcGIS3.Extensions;

public static class SpeckleApplicationIdExtensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like these classes over host apps which application ids are mystery

@@ -8,17 +8,14 @@ public class GeometryToHostConverter : ITypedConverter<IReadOnlyList<Base>, ACG.
{
private readonly ITypedConverter<List<SOG.Polyline>, ACG.Polyline> _polylineConverter;
private readonly ITypedConverter<List<SOG.Point>, ACG.Multipoint> _multipointConverter;
private readonly ITypedConverter<List<SOG.Polygon>, ACG.Polygon> _polygonConverter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity what is the difference Polygon and Polyline apart from isClosed prop

break;

default:
yield break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we log?


for (int i = 0; i < points.Count; i++)
{
if (i >= 2 && (i + 1) % 3 == 0) // every 3 new points is a new triangle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar thoughts as above comment

}

private SOG.Mesh GetMeshFromTriangleFanPatch(List<ACG.MapPoint> points)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to know what are they and from what to what we are trying to convert. mostly it is a question for @KatKatKateryna. could you document these scenarios on figma by giving some examples with shapes or real scenarios?

GeometryEngine.Instance.Project(target, _settingsStore.Current.ActiveCRSoffsetRotation.SpatialReference)
is not MapPoint reprojectedPt
ACG.GeometryEngine.Instance.Project(target, _settingsStore.Current.ActiveCRSoffsetRotation.SpatialReference)
is not ACG.MapPoint reprojectedPt
)
{
throw new ValidationException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know this was pre-existing but curious what is the ValidationException, don't we suppose to use some conversion typed exceptions

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conditions a bit confusing but...

{
if (target["attributes"] is Base attributes)
if (target["fields"] is Dictionary<string, string> attributes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we attach properties to collections in arcgis?

Copy link
Member Author

@clairekuang clairekuang Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, some applications like arcgis and navis have meaningful properties on collections (not just objects) - we don't have a convention for handling this, could be some DataCollection: Collection (IDataCollection:IProperties) class in the future

@oguzhankoral oguzhankoral merged commit ac4d9f2 into arcgis_refactor Dec 12, 2024
5 checks passed
@oguzhankoral oguzhankoral deleted the claire/cnx-830-refactor-and-cleanup-arcgis-to-enable-data-workflows branch December 12, 2024 15:37
Copy link
Contributor

@KatKatKateryna KatKatKateryna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

["name"] = sr.Name,
["unit"] = sr.Unit.Name,
["centralMeridian"] = sr.CentralMeridian,
["wkt"] = sr.Wkt,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Authority ID ("Wkid" property) seems to be removed, and I believe should be added back (it's a universal identifier of the coordinate system, and will always exist unless the user created a custom CRS)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the same time, CentralMeridian doesn't seem to be that important

clairekuang added a commit that referenced this pull request Dec 17, 2024
* registed layer unpacker

* nested layers logic moved to layerUnpacker

* killed VectorLayerConverter

* exposed Feature converter and Attributes in RootObjBuilder

* send clean GisObject

* refactor Rasters and PointClouds

* send everything through 1 converter

* proper object type

* clean GIS objects and conversions

* better layer names on Receive

* fix raster position on send

* switching to GIS layer, removing native geometry type checks (but keeping field check)

* fix revit materials on child objects

* remove IGisFeature interface

* typo

* remove empty converter

* switch from attributes to properties

* add required keyword

* required attribute fix

* attach dynamic "geometry" field to converted Polygons

* refactor(arcgis): overhaul of arcgis connector and converter patterns to enable data extraction (#439)

* rework 1

* additional restructuring of root object builder and converters

* finalizes classes and patterns for converter and connector

* fixes build errors

* Update ArcGISHostObjectBuilder.cs

* fixes some polygon conversions

* refactor color manager to separate color unpacker

* Delete GISLayerGeometryType.cs

* disables receive

* pr review issues

* Update ArcGISRootObjectBuilder.cs

* Update ArcGISRootObjectBuilder.cs

* Update ArcGISRootObjectBuilder.cs

* Update ArcGISRootObjectBuilder.cs

* fixed color bugs

* Update ArcGISLayerUnpacker.cs

* don't cache repeated layers

* Revert "don't cache repeated layers"

This reverts commit 48af025.

* remove flattened layers from root commit builder

* Revert "remove flattened layers from root commit builder"

This reverts commit e0e7b1f.

* layer order and duplication fixed

* fix applicationIds

* fix raster appId

* yield; add comment

* move appId to extensions

---------

Co-authored-by: Claire Kuang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants