Saturday, 22 July 2017

arcgis 10.0 - Does anyone know a function to determine if a Point lies on a polyline?


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.



Answer



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
}

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...