码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGis 大数据量的拷贝

时间:2021-01-11 11:06:09      阅读:0      评论:0      收藏:0      [点我收藏+]

标签: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;
            }
        }

 

ArcGis 大数据量的拷贝

标签:tar   upper   tco   exception   大数   cep   turn   foreach   each   

原文地址:https://www.cnblogs.com/baimy/p/14251517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!