Example #1
0
        /// <summary>
        /// 判断鼠标点击处有无巷道要素
        /// </summary>
        /// <param name="m_hookHelper"></param>
        /// <param name="pMousePoint">鼠标点</param>
        /// <param name="pFeatureLayer">导线点图层</param>
        /// <param name="theFeature">返回离鼠标最近的导线点</param>
        public void TestExistPointFeature(IHookHelper m_hookHelper, IPoint pMousePoint, IFeatureLayer pFeatureLayer, ref IFeature theFeature)
        {
            ArrayList             pSelected = new ArrayList();
            IFeatureClass         pFeatureClass;
            ISelectionEnvironment pSelectionEnvironment;
            IFeature             pFeature = null;
            IGeometry            pGeometry;
            ITopologicalOperator pTopolagicalOperator;
            double dLength;

            IEnvelope pSrchEnv;

            pSelectionEnvironment = new SelectionEnvironmentClass();
            dLength         = pSelectionEnvironment.SearchTolerance;
            pGeometry       = pMousePoint;
            dLength         = DataEditCommon.ConvertPixelDistanceToMapDistance(m_hookHelper.ActiveView, dLength);
            pSrchEnv        = pMousePoint.Envelope;
            pSrchEnv.Width  = dLength;
            pSrchEnv.Height = dLength;
            pSrchEnv.CenterAt(pMousePoint);

            pTopolagicalOperator = (ITopologicalOperator)pGeometry;
            IGeometry pBuffer = pTopolagicalOperator.Buffer(dLength);

            pGeometry = pBuffer;

            IFeature pFeat = null;
            IMap     pMap  = m_hookHelper.FocusMap;

            pFeatureClass = pFeatureLayer.FeatureClass;
            IIdentify2 pID = pFeatureLayer as IIdentify2;
            //IArray pArray = pID.Identify(pSrchEnv, null);
            IArray pArray = pID.Identify(pGeometry, null);
            IFeatureIdentifyObj pFeatIdObj;
            IRowIdentifyObject  pRowObj;

            if (pArray != null)
            {
                for (int j = 0; j < pArray.Count; j++)
                {
                    if (pArray.Element[j] is IFeatureIdentifyObj)
                    {
                        pFeatIdObj = pArray.Element[j] as IFeatureIdentifyObj;
                        pRowObj    = pFeatIdObj as IRowIdentifyObject;
                        pFeature   = pRowObj.Row as IFeature;
                        pSelected.Add(pFeature);
                    }
                }
                pArray.RemoveAll();
            }
            theFeature = pFeature;

            return;

            //GetClosestFeatureInCollection(m_hookHelper, dLength, pSelected, pMousePoint, ref pFeat);
            //if (pFeat != null)
            //    theFeature = pFeat;
            //else
            //    theFeature = null;
        }