标签:tar upper tco exception 大数 cep turn foreach each
public static IFeatureClass FeatureToFeature(IFeatureClass SourFeature,IFeatureClass TargetFeature, List<ColumnInternationMapping> columnMapp,bool IsOut) { try { using (ComReleaser releaser = new ComReleaser()) { IFeatureCursor cursor = TargetFeature.Insert(true); IFeatureBuffer newFeature = null; releaser.ManageLifetime(cursor); IFeatureCursor s_Cursor = SourFeature.Search(null, false); releaser.ManageLifetime(s_Cursor); IFeature feature = null; while ((feature = s_Cursor.NextFeature()) != null) { if (newFeature == null) newFeature = TargetFeature.CreateFeatureBuffer(); newFeature.Shape = feature.ShapeCopy; if (columnMapp == null && columnMapp.Count == 0) { for (int i=0;i< feature.Fields.FieldCount;i++) { if (feature.Fields.Field[i].Name.ToUpper() == "OBJECTID" || feature.Fields.Field[i].Name.ToUpper().Contains("SHAPE")) { continue; } newFeature.set_Value(newFeature.Fields.FindField(feature.Fields.Field[i].Name), feature.get_Value(i)); } } else if (columnMapp != null && columnMapp.Count>0) { foreach (ColumnInternationMapping item in columnMapp) { if (string.IsNullOrWhiteSpace(item.SourceColumn) || string.IsNullOrWhiteSpace(item.TargetColumn) || newFeature.Fields.FindField(item.TargetColumn)<0 || feature.Fields.FindField(item.SourceColumn)<0) continue; newFeature.set_Value(newFeature.Fields.FindField(item.TargetColumn), feature.get_Value(feature.Fields.FindField(item.SourceColumn))); } } cursor.InsertFeature(newFeature); } if (newFeature != null) cursor.Flush(); IFeatureClassManage fcManage = TargetFeature as IFeatureClassManage; fcManage.UpdateExtent(); } if (IsOut) { return TargetFeature; } return null; } catch (Exception ex) { return null; } }
标签:tar upper tco exception 大数 cep turn foreach each
原文地址:https://www.cnblogs.com/baimy/p/14251517.html