I am trying to insert a feature in an empty feature class that was created as a polygon feature class
but when i watch the feature class object during debugging i found that it has an esriGeometryAny as a shape type.
so i get this error "No support for this geometry type" at this line
ESRI.ArcGIS.Geodatabase.IFeatureCursor insertCursor = destinationFeatureClass.Insert(false);
Here is the code:
protected virtual void MigrateAfterMerge(MigrationFeatureClassSource source)
{
Stopwatch stopWatch = new Stopwatch();
TimeSpan timeSpan;
String elapsedTime;
try
{
stopWatch.Start();
String groupFieldName = GetGrouByFieldName(source);
if (groupFieldName != "")
{
List<String> distinctValues = GetDistinctGroupFieldValues(source);
ESRI.ArcGIS.Geodatabase.IFeatureClass sourceFeatureClass = source.DataSource.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(source.SourceTableName);
ESRI.ArcGIS.Geodatabase.IFeatureClass destinationFeatureClass = Globals.GlobalsInstance.StandardDB.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(m_tableName);
String whereClause = "";
ESRI.ArcGIS.Geodatabase.IFeatureCursor insertCursor = destinationFeatureClass.Insert(false);
if (distinctValues != null)
{
foreach (String distinctValue in distinctValues)
{
if (distinctValue != "")
{
whereClause += groupFieldName + " = '" + distinctValue + "'";
ESRI.ArcGIS.Geometry.IPolygon unionedFeatures = Spatial_Operations.SpatialOperations.MergePolygonsWithCondition(sourceFeatureClass, whereClause);
ESRI.ArcGIS.Geodatabase.IFeatureBuffer destinationFeatureBuffer = CreateRecordInStandardDBFromMergeSource(destinationFeatureClass, source, unionedFeatures, ProcessValue(distinctValue, source));
insertCursor.InsertFeature(destinationFeatureBuffer);
}
}
// Flush the buffer to the geodatabase.
insertCursor.Flush();
stopWatch.Stop();
timeSpan = stopWatch.Elapsed;
elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds,
timeSpan.Milliseconds / 10);
Logger.LoggerInstance.LogOperationStatus(m_tableName + " - Migerating data from " + source.SourceName + " to standard DB succeeded", SyncOperationStatus.Succeded, m_tableName, DateTime.Now, elapsedTime);
}
}
}
catch (Exception ex)
{
stopWatch.Stop();
timeSpan = stopWatch.Elapsed;
elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds,
timeSpan.Milliseconds / 10);
Logger.LoggerInstance.LogOperationStatus(m_tableName + " - Migerating data from " + source.SourceName + " to standard DB failed.", SyncOperationStatus.Failed, m_tableName, DateTime.Now, elapsedTime);
Logger.LoggerInstance.LogError(ex.Message, DateTime.Now, "MigrateAfterMerge", "MigrationFeatureClass", m_tableName);
throw new Exception(ex.Message);
}
}
When adding a feature to your feature class (programmatically), ensure that the geometry type is ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon.
Creating Features
You can perform a validation of your newly created feature(s) before actually using the featureclass to create an insert cursor:
Validating Features