Carol,
We have finished the remove column part, another part split column we are still working on it.
The following code is how to implement function like you said:
private void ProcessNewShapeFile(string originalShapefilePath, string newShapefilePath)
{
ShapeFileFeatureLayer originalShapeFileFeatureLayer = new ShapeFileFeatureLayer(originalShapefilePath);
ShapeFileFeatureLayer.BuildIndexFile(originalShapefilePath, BuildIndexMode.DoNotRebuild);
ShapeFileFeatureLayer newShapeFileFeatureLayer = GenerateNewShapeFile(originalShapeFileFeatureLayer, newShapefilePath);
UpdateNewShapeFile(originalShapeFileFeatureLayer, newShapeFileFeatureLayer);
ShapeFileFeatureLayer.BuildRecordIdColumn(newShapefilePath, "RECID", BuildRecordIdMode.Rebuild);
}
private void UpdateNewShapeFile(ShapeFileFeatureLayer originalShapeFileFeatureLayer, ShapeFileFeatureLayer newShapeFileFeatureLayer)
{
newShapeFileFeatureLayer.Open();
newShapeFileFeatureLayer.EditTools.BeginTransaction();
originalShapeFileFeatureLayer.Open();
Collection<DbfColumn> dbfColumns = ((ShapeFileFeatureSource)originalShapeFileFeatureLayer.FeatureSource).GetDbfColumns();
Collection<string> columnNames = new Collection<string>();
foreach (DbfColumn dbfColumn in dbfColumns)
{
if (dbfColumn.ColumnName.Trim() != "OLDROADID1" && dbfColumn.ColumnName.Trim() != "DIR")
{
columnNames.Add(dbfColumn.ColumnName);
}
}
Collection<Feature> features = originalShapeFileFeatureLayer.FeatureSource.GetAllFeatures(columnNames);
foreach (Feature feature in features)
{
newShapeFileFeatureLayer.EditTools.Add(feature);
}
newShapeFileFeatureLayer.EditTools.CommitTransaction();
originalShapeFileFeatureLayer.Close();
newShapeFileFeatureLayer.Close();
}
private ShapeFileFeatureLayer GenerateNewShapeFile(ShapeFileFeatureLayer originalShapeFileFeatureLayer, string newShapefilePath)
{
originalShapeFileFeatureLayer.Open();
ShapeFileType shapeFileType = originalShapeFileFeatureLayer.GetShapeFileType();
Collection<DbfColumn> oringinalDbfColumns = ((ShapeFileFeatureSource)originalShapeFileFeatureLayer.FeatureSource).GetDbfColumns();
Collection<DbfColumn> DbfColumns = new Collection<DbfColumn>();
foreach (DbfColumn oringinalDbfColumn in oringinalDbfColumns)
{
if (oringinalDbfColumn.ColumnName.Trim() != "OLDROADID1" && oringinalDbfColumn.ColumnName.Trim() != "DIR")
{
DbfColumns.Add(oringinalDbfColumn);
}
}
originalShapeFileFeatureLayer.Close();
ShapeFileFeatureSource.CreateShapeFile(shapeFileType, newShapefilePath, DbfColumns);
ShapeFileFeatureLayer newShapeFileFeatureLayer = new ShapeFileFeatureLayer(newShapefilePath, ShapeFileReadWriteMode.ReadWrite);
return newShapeFileFeatureLayer;
}
Please let me know if you have questions.
Thanks
James