5

I am trying to create a polyline from the points that I query from a polygon. I have a polygon, and I am getting its edges, casting them to segments, and then use QueryNormal to get the mid point for that edge. I get 2 different points from 2 edges, I want to create a curve from those 2 points, not a straight line, but follow the polygon path from one point to another. the pictures below explain things better. I tried using the topological operator and cut but thats not doing what I want, I tried using the polygon.Split() but also that does not give me what I want. Is it possible to split a polygon based on points?

Here is what I want, I have a polygon and I want to use the points to create the curve

New Edits:- After being able to get the subcurve using the 2 input point distances, it is always giving me the longest part of the polyCurve, here is apicture of what its doing, where I want the short path as per the picture above. enter image description here

  • if you already know the points what is stopping you from create a polyline? – elasticrash Aug 26 '15 at 16:27
  • Creating a Polyline from 2 points will draw a straight line between those 2 points, which is not what I am looking for. However I think I got it figured out using the SplitAtDistance() method which basically allows me to start counting the segments starting from my input start point leading to the end point and can create a polyLine from those multiple segments. I am trying that today. – ZZZ Aug 26 '15 at 22:30
3

This how I would do it:

  • Create your two points
  • Cast polygon into ICurve
  • Use the ICurve.QueryPointAndDistance Method and get the DistanceAlongCurve value for each point
  • Use ICurve.GetSubcurve Method to extract the red curve you have identified in your image.
  • I managed to solve it by splitting the Polygon at the points created along the polygon and then get those segments that were split and create a curve from them. However I do prefer your solution since it gives me the distance along the polygon. I thought the method inserted points at certain distances didnt know it actually gave back the distance of the points :). thank you – ZZZ Aug 27 '15 at 13:03
  • Is it possible to control the direction of the curve I get from GetSubCurve() method ? It is ALMOST ALWAYS giving me the long part of the curb so in my case up top its giving me the long part of the curve, regardless of which point starts, its always giving me the long subcurve where I want the shortest :). any ideas ? – ZZZ Aug 31 '15 at 14:46
  • That would suggest to me that the polygons are not being created in a consistent way? Are these polygons built outside the ArcMap environment? Try running the check geometry then repair tool on the dataset. Your code should not be running ok for some and not ok for others. If it was wrong it should be consistently wrong... – Hornbydd Aug 31 '15 at 17:40
  • nope those polygons are being created as geomatry objects. I am getting back the longest path for some reason regardless of the points position on the polygon. . – ZZZ Sep 1 '15 at 21:15
  • I got it to work using the IRing interface, thanks for your help. – ZZZ Sep 3 '15 at 8:45
2

I solved the problem, by getting the polygons exterior ring, IRing interface has the method GetSubcurveEx, this method is perfect for my case since I can specify which direction I want the subcurve to follow. I can specify clockwise or counter clockwise, so I got both directions and simply picked the shortest. Here is how I done it.

       ExteriorPolygonRing.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, terminalPointOnParcel, false,outPoint, ref pointDistance, ref fromcr, ref rightSide);
       ExteriorPolygonRing.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, handHoleParcelEdgePoint, false,outPoint2, ref pointDistance2, ref fromcr2, ref rightSide);
        var clockWisePath = polyRing.GetSubcurveEx(pointDistance, pointDistance2, false, true, true);
        var counterClockWisePath = polyRing.GetSubcurveEx(pointDistance, pointDistance2, false, false, true);

        if (clockWisePath.Length < counterClockWisePath.Length) {
            return clockWisePath;
        }
        return counterClockWisePath;
    }

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.