美文网首页
4. arcengine拓扑:要素类复制实现

4. arcengine拓扑:要素类复制实现

作者: 清远_03d9 | 来源:发表于2019-08-19 14:27 被阅读0次

    1. 方法实现

    using ESRI.ArcGIS.Geoprocessor;
    using ESRI.ArcGIS.Geoprocessing;
    using ESRI.ArcGIS.DataManagementTools;
    using ESRI.ArcGIS.AnalysisTools;
    public static bool CopyFeatureClass(string inputPaths, string outputPath)
            {
                Geoprocessor gp = null;
                IGeoProcessorResult result = null;
                try
                {
                    Copy pCopy = new Copy(inputPaths, outputPath);
                    gp = new Geoprocessor();
                    gp.OverwriteOutput = true;
                    gp.TemporaryMapLayers = false;
                    result = (IGeoProcessorResult)gp.Execute(pCopy, null);
                    if (result != null)
                        return true;
                    else
                        return false;
                   
                }
                catch
                {
                    string str = ReturnMessages(gp);
                    return false;
                }
                finally
                {
                    if (gp != null)
                    {
    
                        gp = null;
    
                    }
                    GC.Collect();
                    GC.WaitForFullGCComplete();
                }
            }
    
            /// <summary>
            /// 处理错误信息
            /// </summary>
            /// <param name="gp"></param>
            /// <returns></returns>
            private static string ReturnMessages(Geoprocessor gp)
            {
                string ms = "";
                if (gp.MessageCount > 0)
                {
                    for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
                    {
                        ms += "$" + gp.GetMessage(Count) + "\n\n";
                    }
                }
    
                if (ms.Contains("Succeeded") || ms.Contains("成功"))
                {
                    //MarkConfig(true);
                    return "";
                }
                return ms;
            }
    

    2. 使用方式

    CopyFeatureClass(strpath + "\\" + GT_COMMONNOUN.NJQ + "_" + strMC + "_" + strDM, strpath + "\\" + GT_COMMONNOUN.hz_njq);
    

    相关文章

      网友评论

          本文标题:4. arcengine拓扑:要素类复制实现

          本文链接:https://www.haomeiwen.com/subject/huussctx.html