Hello all
We are trying to create layer with field with type double using the new DDL
The field in in layer in sql server.
It looks like the code ignore the scale and precision.
Trying to do the same with GP tool (Add Field) works.
Is this a bug, feature or something that will come in the next version?
Thanks
Hi @mody_buchbinder , Could you please send us a code snippet that causing the issue? We are not able to reproduce the scenario that doesn't honor the scale and precision provided through DDL.
Version info of Pro and SQL Server are also helpful for further diagnosis.
The following field description successfully created a double field with scale and precision in our test.
FieldDescription doubleFieldDescription = new FieldDescription("TestDoubleField", FieldType.Double) { Scale = 3, Precision = 9 };
Thanks for reporting this. I was able to duplicate this problem. I will report the issue to the Geodatabase team.
I stand corrected. The Geodatabase team pointed out the error in my test add-in where I chose a scale larger than the precision. Once I fixed that error I get the proper result:
I used the following code snippet to create the feature class. The 'selectedFeatureLayer' is a feature layer I get from the TOC in order to get my database connection.
var selectedLayerTable = selectedFeatureLayer.GetTable();
var testName = $@"Point{DateTime.Now:HHmmss}";
var hasZ = false;
var hasM = false;
// Create a ShapeDescription object
var shapeDescription = new ShapeDescription(GeometryType.Point, SpatialReferences.WebMercator)
{
HasM = hasM,
HasZ = hasZ
};
var objectIDFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("ObjectID", FieldType.OID);
var stringFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheString", FieldType.String);
var intFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheInteger", FieldType.Integer);
var dblFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDouble", FieldType.Double)
{
Precision = 9,
Scale = 5
};
var dateFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDate", FieldType.Date);
using (var geoDb = selectedLayerTable.GetDatastore() as Geodatabase)
{
var fcName = $@"{testName}";
try
{
// Assemble a list of all of our field descriptions
var fieldDescriptions = new List<ArcGIS.Core.Data.DDL.FieldDescription>() {
objectIDFieldDescription,
stringFieldDescription,
intFieldDescription,
dblFieldDescription,
dateFieldDescription
};
// Create a FeatureClassDescription object to describe the feature class to create
var fcDescription =
new FeatureClassDescription(fcName, fieldDescriptions, shapeDescription);
// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geoDb);
// Add the creation of the Cities feature class to our list of DDL tasks
schemaBuilder.Create(fcDescription);
// Execute the DDL
bool success = schemaBuilder.Build();
}
catch (Exception ex)
{
MessageBox.Show($@"Exception: {ex}");
}
}
Hello @Wolf
Here is the code, note that the database is a memory database.
And yet the result is:
private async Task CreateParcelTempLayers(Polygon parcelGeometry, bool shouldGeneralize)
{
var memoryConnectionProperties = new MemoryConnectionProperties();
var map = MapView.Active.Map;
using var geodatabase = SchemaBuilder.CreateGeodatabase(memoryConnectionProperties);
BuildEdgesLayer(map, geodatabase);
}
// and bellow
private void BuildEdgesLayer(Map map, Geodatabase geodatabase)
{
var shapeDescription = new ShapeDescription(GeometryType.Polyline, map.SpatialReference);
var fieldDescriptions = new[]
{
new FieldDescription(m_FromVertexToVertex, FieldType.String){Length = 50},
new FieldDescription(m_EdgeLength, FieldType.Double)
{
Scale = 2,
Precision = 9,
AliasName = ReportsManagerResources.ReportsManagerProxy_BuildEdgesLayer_DistancesAlias
},
};
var featureClassDescription =
new FeatureClassDescription(m_ParcelEdgesLayerName, fieldDescriptions, shapeDescription);
var schemaBuilder = new SchemaBuilder(geodatabase);
schemaBuilder.Create(featureClassDescription);
var success = schemaBuilder.Build();
}
Would love to hear your feedback
Thanks for reporting this, an ArcGIS Pro Geodatabase team member was able to duplicate this problem when using a memory Geodatabase. The issue will be fixed in an upcoming Pro release.