Ejemplo n.º 1
0
        //判断是否需要创建要素类
        public static bool CheckFeatCls(bool bIsCut, IFeatureLayer pFeatLayer, ref int lFeatCount, IGeometry pDomainGeometry)
        {
            //pDomainGeometry = null;

            IFeatureSelection pFeatSelection = default(IFeatureSelection);

            if (bIsCut)
            {
                pFeatSelection = ClsSelectAndQuery.GetFeatSelection(ref pFeatLayer, "", esriSelectionResultEnum.esriSelectionResultNew, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry);
                lFeatCount     = pFeatSelection.SelectionSet.Count;
            }
            else
            {
                long lFeatCount2 = (long)lFeatCount;
                ClsSelectAndQuery.GetFeatCursor(pFeatLayer.FeatureClass, "", esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry, true, ref lFeatCount2);
                lFeatCount = (int)lFeatCount2;
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static long OutPutFeat(ref IFeatureClass pDesFeatCls, ref IFeatureClass pOriFeatCls, string sSql, IGeometry pDomainGeometry, bool bIsCut, ref ISpatialReference pSpatialReference, Dictionary <string, string> pDicField, ref LabelX lblInfo, string sInfo)
        {
            //sSql = "";
            //pDomainGeometry = null;
            //bIsCut = false;
            //pSpatialReference = null;
            //pDicField = null;
            //vProgressBar = null;
            //lblInfo = null;
            //sInfo = null;

            long functionReturnValue = 0;
            //DevComponents.DotNetBar.LabelItem
            IFeatureCursor    pWithINFeatCursor = null;
            IFeatureCursor    pCrossFeatCursor  = null;
            IFeatureCursor    pFeatCursor       = default(IFeatureCursor);
            IFeatureLayer     pFeatLayer        = default(IFeatureLayer);
            IFeatureSelection pFeatSelection    = default(IFeatureSelection);

            int lFeatCount = 0;
            int l          = 0;
            int j          = 0;

            bool bInsertRight = true;

            //Insert是否成功

            // ERROR: Not supported in C#: OnErrorStatement


            if (pDesFeatCls == null | pOriFeatCls == null)
            {
                return(functionReturnValue);
            }

            if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                bIsCut = false;
            }

            if (pDomainGeometry == null)
            {
                bIsCut = false;
            }

            //如果需要剪切,则对面要素类和线要素类分成范围内的要素和与范围相交的要素,提高提取效率
            //否则,使用featurecursor进行提取,不进行选择,相对要快

            if (lblInfo != null)
            {
                lblInfo.Text = sInfo + "正在获得满足条件的要素,请稍候.....";
                lblInfo.Refresh();
                Application.DoEvents();
            }

            if (bIsCut)
            {
                pFeatLayer = new FeatureLayer();
                pFeatLayer.FeatureClass = pOriFeatCls;
                pFeatLayer.Name         = pOriFeatCls.AliasName;

                //获得选择集
                pFeatSelection = ClsSelectAndQuery.GetFeatSelection(ref pFeatLayer, sSql, esriSelectionResultEnum.esriSelectionResultNew, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry);
                lFeatCount     = pFeatSelection.SelectionSet.Count;

                //获得位范围内的以及与范围相交的要素集
                ClsSelectAndQuery.ClassifyFeatCursorByGeometry(ref pFeatSelection, pDomainGeometry, ref pWithINFeatCursor, pDesFeatCls.ShapeType);
                // 陈昉  2009-3-12  修改 修改原因 原来的方法不能搜索到包含一此Geometry的要素

                //ClassifyFeatCursorByGeometry(pFeatSelection, pDomainGeometry, pWithINFeatCursor, pCrossFeatCursor, pDesFeatCls.ShapeType)

                if (lblInfo != null)
                {
                    lblInfo.Text = sInfo + "正在输出要素,请稍候.....";
                    lblInfo.Refresh();
                    Application.DoEvents();
                }

                InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pWithINFeatCursor, true, pDomainGeometry, ref pSpatialReference, pDicField);
                //首先把位于图幅内的要素插入

                //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pWithINFeatCursor, True, pDomainGeometry, pSpatialReference, _
                //                              pDicField, vProgressBar)
                //'再把与范围相交的要素插入,(插入时需要进行剪切)
                //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pCrossFeatCursor, True, pDomainGeometry, pSpatialReference, _
                //                              pDicField, vProgressBar)
            }
            else
            {
                //获得需要提取的要素
                long lFeatCount2 = (long)lFeatCount;
                pFeatCursor = ClsSelectAndQuery.GetFeatCursor(pOriFeatCls, sSql, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry, true, ref lFeatCount2);
                lFeatCount  = (int)lFeatCount2;
                if (lblInfo != null)
                {
                    lblInfo.Text = sInfo + "正在输出要素,请稍候.....";
                    lblInfo.Refresh();
                    Application.DoEvents();
                }

                bInsertRight = InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pFeatCursor, false, pDomainGeometry, ref pSpatialReference, pDicField);

                //印骅 20081202 Insert失败,退出函数
                if (bInsertRight == false)
                {
                    functionReturnValue = -1;
                    return(functionReturnValue);
                }
            }
            //杨旭斌于20080825添加,返回提取的要素个数
            functionReturnValue = lFeatCount;

            pWithINFeatCursor = null;
            pCrossFeatCursor  = null;
            return(functionReturnValue);
        }