GISGeomatics(GIS,GPS,RS,Surveying)GIS文章集

3. arcengine拓扑:将要素类的要素追加到另一个要素类

2019-08-19  本文已影响1人  清远_03d9

1. 向现有要素类中追加fc要素类的要素

  /// <summary>
        /// 面追加
        /// </summary>
        /// <param name="fc"></param>
        /// <param name="outputName"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static bool AppEndFeatureClass(string fc, string outputName)
        {
            Geoprocessor gp = null;
            IGeoProcessorResult result = null;
            Append pCheckCeom = null;
            try
            {
                pCheckCeom = new Append();
                pCheckCeom.inputs = fc;
                pCheckCeom.target = outputName;
                pCheckCeom.schema_type = "NO_TEST";
                gp = new Geoprocessor();
                gp.OverwriteOutput = true;
                gp.TemporaryMapLayers = false;
                result = (IGeoProcessorResult)gp.Execute(pCheckCeom, null);
                object sev = 2;
                string messages = gp.GetMessages(ref sev);
                if (result != null)
                    return true;
                else
                    return false;
            }
            catch
            {
                string str = ReturnMessages(gp);
                return false;
            }
            finally
            {
                if (pCheckCeom != null)
                {

                    pCheckCeom = null;

                }
                if (result != null)
                {

                    result = null;

                }
                if (gp != null)
                {

                    gp = null;

                }
                GC.Collect();
                GC.WaitForFullGCComplete();
            }
        }


        ///方法2
        /// <summary>
        /// 面追加
        /// </summary>
        /// <param name="fc"></param>
        /// <param name="outputName"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static bool AppEndFeatureClass(IFeatureClass fc, IFeatureClass outputName)
        {
            Geoprocessor gp = null;
            IGeoProcessorResult result = null;
            Append pCheckCeom = null;
            try
            {
                pCheckCeom = new Append();
                pCheckCeom.inputs = fc;
                pCheckCeom.target = outputName;
                pCheckCeom.schema_type = "NO_TEST";
                gp = new Geoprocessor();
                gp.OverwriteOutput = true;
                gp.TemporaryMapLayers = false;
                result = (IGeoProcessorResult)gp.Execute(pCheckCeom, null);
                object sev = 2;
                string messages = gp.GetMessages(ref sev);
                if (result != null)
                    return true;
                else
                    return false;
            }
            catch
            {
                string str = ReturnMessages(gp);
                return false;
            }
            finally
            {
                if (pCheckCeom != null)
                {

                    pCheckCeom = null;

                }
                if (result != null)
                {

                    result = null;

                }
                if (gp != null)
                {

                    gp = null;

                }
                GC.Collect();
                GC.WaitForFullGCComplete();
            }
        }
上一篇下一篇

猜你喜欢

热点阅读