Polyline Midpoint

875
2
12-06-2017 12:42 PM
AndyWright
Occasional Contributor

Is there an easy way to get the midpoint of a user-digitized polyline graphic?  I've been looking through the API docs and there doesn't seem to be a direct path to get that map point.

0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

The next update is right around the corner, and it adds a new "CreatePointAlong" method to GeometryEngine, so you can do this:

Polyline pl = new Polyline(...)

var length = Esri.ArcGISRuntime.Geometry.GeometryEngine.Length(pl);
var midPoint = Esri.ArcGISRuntime.Geometry.GeometryEngine.CreatePointAlong(pl, length / 2);

So keep an eye on the nuget package update very soon...

If you can't wait, you'll have to do it "oldschool" by measuring segment by segment adding up the distance, until you exceed it, then use trigonometry to calculate the fraction along that segment to get to the point.

0 Kudos
AndyWright
Occasional Contributor

Thanks Morten ...

0 Kudos