Skip to content

Commit

Permalink
AGIS: put methods under the native struct (#5)
Browse files Browse the repository at this point in the history
* add tests with base test class

* update locks

* pin coverage to 4.4.0

* this is a subjob with uses, pass the secrets

* fix secret passing

* try quotes

* try a different glob

* Try simplier glob

* try something else

* try ubuntu for uploads

* update build.sh

* fix target

* update test only target

* Try ExcludeFromCodeCoverage

* better usage of codecov

* What Kat did in specklesystems/speckle-sharp#3546

* Some clean up
  • Loading branch information
adamhathcock authored Jul 5, 2024
1 parent 49a0af8 commit 6e6e2fc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private List<GisFeature> RecoverOutdatedGisFeatures(VectorLayer target)

public FeatureClass Convert(VectorLayer target)
{
ACG.GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target);
ACG.GeometryType geomType = GISLayerGeometryType.GetNativeLayerGeometryType(target);

FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath =
new(_contextStack.Current.Document.SpeckleDatabasePath);
Expand All @@ -85,7 +85,7 @@ public FeatureClass Convert(VectorLayer target)
string wktString = string.Empty;
if (target.crs is not null && target.crs.wkt is not null)
{
wktString = target.crs.wkt.ToString();
wktString = target.crs.wkt;
}
ACG.SpatialReference spatialRef = ACG.SpatialReferenceBuilder.CreateSpatialReference(wktString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,32 @@ public class VectorLayerToHostConverter : IToHostTopLevelConverter, ITypedConver
private readonly ITypedConverter<VectorLayer, FeatureClass> _featureClassConverter;
private readonly ITypedConverter<VectorLayer, Table> _tableConverter;
private readonly ITypedConverter<VectorLayer, LasDatasetLayer> _pointcloudLayerConverter;
private readonly IFeatureClassUtils _featureClassUtils;

public VectorLayerToHostConverter(
ITypedConverter<VectorLayer, FeatureClass> featureClassConverter,
ITypedConverter<VectorLayer, Table> tableConverter,
ITypedConverter<VectorLayer, LasDatasetLayer> pointcloudLayerConverter,
IFeatureClassUtils featureClassUtils
ITypedConverter<VectorLayer, LasDatasetLayer> pointcloudLayerConverter
)
{
_featureClassConverter = featureClassConverter;
_tableConverter = tableConverter;
_pointcloudLayerConverter = pointcloudLayerConverter;
_featureClassUtils = featureClassUtils;
}

public object Convert(Base target) => Convert((VectorLayer)target);

public string Convert(VectorLayer target)
{
// pointcloud layers need to be checked separately, because there is no ArcGIS Geometry type
// for Pointcloud. In ArcGIS it's a completely different layer class, so "GetLayerGeometryType"
// for Pointcloud. In ArcGIS it's a completely different layer class, so "GetNativeLayerGeometryType"
// will return "Invalid" type
if (target.geomType == GISLayerGeometryType.POINTCLOUD)
{
return _pointcloudLayerConverter.Convert(target).Name;
}

// check if Speckle VectorLayer should become a FeatureClass, StandaloneTable or PointcloudLayer
ACG.GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target);
ACG.GeometryType geomType = GISLayerGeometryType.GetNativeLayerGeometryType(target);
if (geomType != ACG.GeometryType.Unknown) // feature class
{
return _featureClassConverter.Convert(target).GetName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel;
public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter<FeatureLayer, VectorLayer>
{
private readonly ITypedConverter<Row, GisFeature> _gisFeatureConverter;
private readonly IFeatureClassUtils _featureClassUtils;
private readonly IArcGISFieldUtils _fieldsUtils;
private readonly IConversionContextStack<ArcGISDocument, Unit> _contextStack;

public VectorLayerToSpeckleConverter(
ITypedConverter<Row, GisFeature> gisFeatureConverter,
IFeatureClassUtils featureClassUtils,
IArcGISFieldUtils fieldsUtils,
IConversionContextStack<ArcGISDocument, Unit> contextStack
)
{
_gisFeatureConverter = gisFeatureConverter;
_featureClassUtils = featureClassUtils;
_fieldsUtils = fieldsUtils;
_contextStack = contextStack;
}

Expand All @@ -36,20 +30,6 @@ public Base Convert(object target)
return Convert((FeatureLayer)target);
}

private string AssignSpeckleGeometryType(esriGeometryType nativeGeometryType)
{
return nativeGeometryType switch
{
esriGeometryType.esriGeometryMultipoint => GISLayerGeometryType.POINT,
esriGeometryType.esriGeometryPoint => GISLayerGeometryType.POINT,
esriGeometryType.esriGeometryLine => GISLayerGeometryType.POLYLINE,
esriGeometryType.esriGeometryPolyline => GISLayerGeometryType.POLYLINE,
esriGeometryType.esriGeometryPolygon => GISLayerGeometryType.POLYGON,
esriGeometryType.esriGeometryMultiPatch => GISLayerGeometryType.MULTIPATCH,
_ => GISLayerGeometryType.NONE,
};
}

public VectorLayer Convert(FeatureLayer target)
{
VectorLayer speckleLayer = new();
Expand Down Expand Up @@ -93,7 +73,7 @@ public VectorLayer Convert(FeatureLayer target)
speckleLayer.attributes = allLayerAttributes;

// get a simple geometry type
string spekleGeometryType = AssignSpeckleGeometryType(target.ShapeType);
string spekleGeometryType = GISLayerGeometryType.LayerGeometryTypeToSpeckle(target.ShapeType);
speckleLayer.geomType = spekleGeometryType;

// search the rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using Objects.GIS;
using Speckle.Core.Logging;
using Speckle.Core.Models;
using Speckle.InterfaceGenerator;
using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription;

namespace Speckle.Converters.ArcGIS3.Utils;

[GenerateAutoInterface]
public class ArcGISFieldUtils : IArcGISFieldUtils
{
private readonly ICharacterCleaner _characterCleaner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Core.Models;
using Speckle.InterfaceGenerator;
using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription;

namespace Speckle.Converters.ArcGIS3.Utils;

[GenerateAutoInterface]
public class FeatureClassUtils : IFeatureClassUtils
{
private readonly IArcGISFieldUtils _fieldsUtils;
Expand Down Expand Up @@ -110,23 +112,4 @@ public void AddNonGISFeaturesToFeatureClass(
}
}
}

public ACG.GeometryType GetLayerGeometryType(VectorLayer target)
{
string? originalGeomType = target.geomType != null ? target.geomType : target.nativeGeomType;
return originalGeomType switch
{
GISLayerGeometryType.NONE => ACG.GeometryType.Unknown,
GISLayerGeometryType.POINT => ACG.GeometryType.Multipoint,
GISLayerGeometryType.POLYGON => ACG.GeometryType.Polygon,
GISLayerGeometryType.POLYLINE => ACG.GeometryType.Polyline,
GISLayerGeometryType.MULTIPATCH => ACG.GeometryType.Multipatch,
GISLayerGeometryType.POLYGON3D => ACG.GeometryType.Multipatch,
_
=> throw new ArgumentOutOfRangeException(
nameof(target),
$"Geometry type '{originalGeomType}' is not recognized."
),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class GISAttributeFieldType
public const string DATEONLY = "DateOnly";
public const string TIMEONLY = "TimeOnly";
public const string TIMESTAMPOFFSET = "TimeStampOffset";
public const string BOOL = "Bool"; // not supported in ArcGIS, only in QGIS

public static string FieldTypeToSpeckle(FieldType fieldType)
{
Expand Down Expand Up @@ -55,6 +56,7 @@ public static FieldType FieldTypeToNative(object fieldType)
DATEONLY => FieldType.DateOnly,
TIMEONLY => FieldType.TimeOnly,
TIMESTAMPOFFSET => FieldType.String, // sending and receiving as stings
BOOL => FieldType.String, // not supported in ArcGIS, converting to string
_ => throw new ArgumentOutOfRangeException(nameof(fieldType)),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using ArcGIS.Core.CIM;

namespace Speckle.Converters.ArcGIS3.Utils;

public static class GISLayerGeometryType
Expand All @@ -9,4 +11,33 @@ public static class GISLayerGeometryType
public const string POLYGON3D = "Polygon3d";
public const string MULTIPATCH = "Multipatch";
public const string POINTCLOUD = "Pointcloud";

public static string LayerGeometryTypeToSpeckle(esriGeometryType nativeGeometryType)
{
return nativeGeometryType switch
{
esriGeometryType.esriGeometryMultipoint => GISLayerGeometryType.POINT,
esriGeometryType.esriGeometryPoint => GISLayerGeometryType.POINT,
esriGeometryType.esriGeometryLine => GISLayerGeometryType.POLYLINE,
esriGeometryType.esriGeometryPolyline => GISLayerGeometryType.POLYLINE,
esriGeometryType.esriGeometryPolygon => GISLayerGeometryType.POLYGON,
esriGeometryType.esriGeometryMultiPatch => GISLayerGeometryType.MULTIPATCH,
_ => GISLayerGeometryType.NONE,
};
}

public static ACG.GeometryType GetNativeLayerGeometryType(Objects.GIS.VectorLayer target)
{
string? originalGeomType = target.geomType != null ? target.geomType : target.nativeGeomType;
return originalGeomType switch
{
GISLayerGeometryType.NONE => ACG.GeometryType.Unknown,
GISLayerGeometryType.POINT => ACG.GeometryType.Multipoint,
GISLayerGeometryType.POLYGON => ACG.GeometryType.Polygon,
GISLayerGeometryType.POLYLINE => ACG.GeometryType.Polyline,
GISLayerGeometryType.MULTIPATCH => ACG.GeometryType.Multipatch,
GISLayerGeometryType.POLYGON3D => ACG.GeometryType.Multipatch,
_ => throw new ArgumentOutOfRangeException(nameof(target)),
};
}
}

This file was deleted.

This file was deleted.

0 comments on commit 6e6e2fc

Please sign in to comment.