2

I am trying to get the number of curves/bends of a polyline. I know that I can accomplish this by getting the vertices of the polyline, and check the from and to and compare their angles, if they match then no bend, if they don't match then that's a bend/curve. I am hoping that arcobjects might have an existing function that accomplishes that, any ideas ? the pictures below shows the required.

Example

public static int GetNumberOfCurves(this Ipolyline crntEdge)
{
// what I can do here is cast the polyline into IPointCollection
// get each point and get the from and to and compare the angles. 
// but I am hoping there is something within the Apis that can get thosen curves
}
  • I doubt there is an IBendiness interface, so you'll likely need to code this yourself. You should also consider whether a curve with two major inflection points through 40 vertices is 39 bends or three. – Vince Sep 29 '15 at 12:58
  • 1
    I don't think that there is. If you don't want to loop through all points, use ITopologicalOperator.Simplify() then count the number of vertices -2 – radouxju Sep 29 '15 at 13:29
  • I'd use IConstructAngle.ConstructThreePoint for points 1 through n-2, to see if they are smaller than some threshold angle. – Kirk Kuykendall Sep 29 '15 at 20:54
2

I think this needs to be programmed. A straight up count of vertices will not identify the situation shown below when you have segments in a constant direction. So in the example below you would identify 6 bends.

Example

Key interfaces would be ISegmentCollection to enumerate over each segment, cast these into ILine and then use the Angle property on successive segments to determine if there is a change in direction between each vertex.

You could short circuit the processing and test the polyline to see if it has only one segment which means it cannot have a bend. Another "pre-processing" test is to compute sinuosity (Length of polyline divided by straight line distance between nodes), if that is 1 then you know the polyline (which may be composed of 3 or more vertices) is completely straight and has no bends, so no need to test it.

Well that's how I would have done it, I'm sure there is a smarter way of doing it?

  • That is exactly what I had in mind, except my solution would have taken a longer approach since I was gonna cast the polyline into point collection, I forgot that there was an angle property in Iline so this makes it even quicker. thanks – ZZZ Sep 30 '15 at 6:25

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.