ArcEngine implements capturing nodes and arcengine captures nodes.
From: http://blog.sina.com.cn/s/blog_4d0b75870100o960.html
// Obtain the nearest node and display it in OnMouseMove
// Pnt: move the cursor
// MapSize: Specifies the geographic range.
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); // converts a geographical range to a pixel
FeatCache. Initialize (pnt, pixelSize); // Initialize the cache
For (int I = 0; I <actview. FocusMap. LayerCount; I ++)
{
// Cache is added only for vertices, lines, and surfaces and visible layers.
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;
// Capture nodes. You can also set esriGeometryHitPartType, Edge Point capturing, and intermediate point.
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;
}
In ArcEngine, how does one highlight the line between two nodes by using the second development in c #?
Dynamic Segmentation can be done, which is a little complicated and requires data processing;
For more information, see bbs.esrichina-bj.cn/ESRI/thread-56565-1-1.html.
You can implement the function process (How do you get the two nodes? Just highlight it ?) So that we can further explore other methods!
I used arcengine to develop a line extraction node, and assigned coordinates using longitude and latitude values. However, when the point location is offset, It is not online. Why?
Do not understand, Please master it.