程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> ArcEngine實現捕捉節點,arcengine捕捉節點

ArcEngine實現捕捉節點,arcengine捕捉節點

編輯:C#入門知識

ArcEngine實現捕捉節點,arcengine捕捉節點


來自:http://blog.sina.com.cn/s/blog_4d0b75870100o960.html

//獲取最近的結點,然後在  OnMouseMove中顯示

//pnt:鼠標移動點

//mapSize:設置的地理范圍

public static IPoint GetNearestVertex(IActiveView actview, IPoint pnt, double mapSize)
        {
            IPoint vetex = null;
            IPoint hitPnt=new PointClass();
            IHitTest hitTest = null;
            IPointCollection pntColl =new MultipointClass();
            IProximityOperator prox = null;
            double hitdis=0;
            int hitpartindex=0,hitsegindex=0;
            Boolean rside = false;
            IFeatureCache2 featCache = new FeatureCacheClass();
            double pixelSize = ConvertMapUnitsToPixels(actview, mapSize);  //將地理范圍轉化為像素
            featCache.Initialize(pnt, pixelSize);  //初始化緩存
            for (int i = 0; i < actview.FocusMap.LayerCount; i++)
            {

                 //只有點、線、面並且可視的圖層才加入緩存
                IFeatureLayer featLayer =(IFeatureLayer) actview.FocusMap.get_Layer(i);
                if (featLayer != null && featLayer.Visible == true &&
                    (featLayer.FeatureClass.ShapeType==esriGeometryType.esriGeometryPolyline ||
                    featLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon ||
                    featLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint))
                {
                    featCache.AddFeatures(featLayer.FeatureClass, null);
                    for (int j = 0; j < featCache.Count; j++)
                    {
                        IFeature feat = featCache.get_Feature(j);
                        hitTest =(IHitTest ) feat.Shape;

//捕捉節點,另外可以設置esriGeometryHitPartType,捕捉邊線點,中間點等。
                        if (hitTest.HitTest(pnt, mapSize, esriGeometryHitPartType.esriGeometryPartVertex, hitPnt, ref hitdis, ref hitpartindex, ref hitsegindex, ref rside))
                        {
                            object obj=Type.Missing ;
                            pntColl.AddPoint(hitPnt,ref obj,ref obj);
                            break;
                        }
                    }
                }
            }
            prox =(IProximityOperator)pnt;
            double minDis=0, dis=0;
            for (int i = 0; i < pntColl.PointCount; i++)
            {
                IPoint tmpPnt=pntColl.get_Point(i);
                dis= prox.ReturnDistance(tmpPnt);
                if (i == 0)
                {
                    minDis = dis;
                    vetex = tmpPnt;
                }
                else
                {
                    if (dis < minDis)
                    {
                        minDis = dis;
                        vetex = tmpPnt;
                    }
                }
            }
            return vetex;
        }


ArcEngine中怎把兩個節點之間的線高亮顯示出來,用的是c#進行的二次開發

動態分段可以做,有點小復雜,需要做數據處理;
具體做法可以參考:bbs.esrichina-bj.cn/ESRI/thread-56565-1-1.html
你可以把你實現的功能過程(你如何得到那兩個節點的?高亮就行?)說出來,這樣可以進一步探討其它的方法!
 

我用arcengine開發提取線的節點,用經緯度賦值坐標,但點的位置發生了偏移,居然不在線上,問為何

不懂,另請高手吧。
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved