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

AGIS: put methods under the native struct #3546

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ IFeatureClassUtils featureClassUtils
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 @@ -6,7 +6,6 @@
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using Speckle.Converters.ArcGIS3.Utils;
using ArcGIS.Core.CIM;

namespace Speckle.Converters.ArcGIS3.Layers;

Expand Down Expand Up @@ -36,20 +35,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 +78,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 @@ -110,19 +110,4 @@ public void AddFeaturesToTable(Table newFeatureClass, List<GisFeature> gisFeatur
}
}
}

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)),
};
}
}
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)),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ public interface IFeatureClassUtils
List<(FieldDescription, Func<Base, object?>)> fieldsAndFunctions
);
void AddFeaturesToTable(Table newFeatureClass, List<GisFeature> gisFeatures, List<FieldDescription> fields);
public ACG.GeometryType GetLayerGeometryType(VectorLayer target);
}
Loading