5

ArcEngine 10 .Net 4 c#

I'm currently allowing user to select a point on a polyline and creating a point on the line. I am using snapping tool.

I just want to make sure that when the user clicks on the screen, the point feedback that I get lies on top of the polyline.

I was wondering if there is a method that I can check if the IPOINT is ON any of the polylines in the polyline layer.

  • 2
    Sadly I think you mean .NET 3.5. 4.0 is not supported with ArcEngine – patrick Jun 14 '11 at 15:46
  • 1
    Do you mean on the polyline or on the symbology used to draw the polyline? – Kirk Kuykendall Jun 14 '11 at 18:21
4

There's probably an easier way to do it but this is what I do.

//layer is what layer you are checking
ESRI.ArcGIS.Carto.IIdentify identify1 = layer as IIdentify; 

//idGeo is IGeometry you want to query -in your case a point, but I'm using a square here    
IArray array = identify1.Identify(idGeo);  

if (array != null)
{
    object obj = array.get_Element(0);
    IFeatureIdentifyObj fobj = obj as IFeatureIdentifyObj;
    IRowIdentifyObject irow = fobj as IRowIdentifyObject;
    IFeature feature = irow.Row as IFeature;
    IGeometry geometry1 = feature.Shape;
    IPointCollection pc = geometry1 as IPointCollection;
    if(pc != null && pc.PointCount > 0) //then its a polyline
}
0

You could probably use the iHitTest interface for this. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//002m0000021v000000

I only use VB so I don't have an example handy. Here is a version 9.3 example: http://resources.esri.com/help/9.3/ArcGISEngine/arcobjects/esriGeometry/IHittest_HitTest_Example.htm

0

If you are using arcgis, simply create a new topology layer, set the rule as points are covered by line, then the topology tool will validate the data you provided and show errors if there is one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.