<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fix Loops or Knots. in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040702#M6384</link>
    <description>&lt;P&gt;Perhaps making a list of vertices with duplicate coordinates could be used for flagging.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
    try
    {
        var fLayer = MapView.Active?.GetSelectedLayers()
            .OfType&amp;lt;FeatureLayer&amp;gt;()
            .Where(lyr =&amp;gt; lyr.ShapeType == esriGeometryType.esriGeometryPolygon)
            .FirstOrDefault();
        if (fLayer == null)
            return;
        await QueuedTask.Run(() =&amp;gt;
        {
            using (var sel = fLayer.GetSelection()) 
            using (var cur = sel.Search())
            {
                if (cur.MoveNext())
                {
                    using (var feat = cur.Current as Feature)
                    {
                        var list = GetSelfIntersects(feat.GetShape() as Polygon);
                        Debug.Print($"{list.Count} duplicate vertices");
                    }
                }
            }
        });
    }
    catch(Exception ex)
    {
        Debug.Print(ex.Message);
    }
}
private List&amp;lt;MapPoint&amp;gt; GetSelfIntersects(Polygon polygon)
{
    // assumes vertices have been snapped
    // (skip this first point, since it will coincide with last point)            
    return polygon.Points.Skip(1)
        // could round here to cluster
        //.GroupBy(pnt =&amp;gt; (Math.Round(pnt.X,2),Math.Round(pnt.Y,2)) 
        .GroupBy(pnt =&amp;gt; (pnt.X, pnt.Y)) // could round here to cluster
        .Where(g =&amp;gt; g.Count() &amp;gt; 1)
        .Select(g =&amp;gt;
        {
            var sr = polygon.SpatialReference;
            return MapPointBuilder.CreateMapPoint(g.Key.X, g.Key.Y, sr);
        })
        .ToList();
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 25 Mar 2021 17:51:19 GMT</pubDate>
    <dc:creator>KirkKuykendall1</dc:creator>
    <dc:date>2021-03-25T17:51:19Z</dc:date>
    <item>
      <title>Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040305#M6376</link>
      <description>&lt;P&gt;I need to find a way to remove Loops or Knots when a user saves a new edit.&amp;nbsp; These polygons that I create are sent to as boundries for images to be gathered and some are being rejected because of these self intersecting loops.&amp;nbsp; They are not self intersecting as they dont have self intersections as two vertices are added.&amp;nbsp; I need a way to either find the loop/knot or remove it automatically.&amp;nbsp; My removing self intersection code doesn't seem to fix this issue.&amp;nbsp; It appears I need to remove the loop entirely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MKa_0-1616608635022.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/9302iDD5F05997666DDCE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MKa_0-1616608635022.png" alt="MKa_0-1616608635022.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        protected void RemoveSelfIntersections()
        {            
            try
            {
                Geometry originalShape = _dataInspector.Shape;
                if (!GeometryEngine.Instance.IsSimpleAsFeature(originalShape))
                {
                    Geometry intersectionShape = GeometryEngine.Instance.SimplifyAsFeature(originalShape, true);
                }
            }
            catch (Exception e)
            {
                
            }

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 17:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040305#M6376</guid>
      <dc:creator>MKa</dc:creator>
      <dc:date>2021-03-24T17:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040458#M6380</link>
      <description>&lt;P&gt;Can you draw a picture of what your desired result would be?&lt;/P&gt;&lt;P&gt;Did you try &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic8692.html" target="_blank" rel="noopener"&gt;creating a polyline&lt;/A&gt; from the points in the polygon?&amp;nbsp; Since the first and last point in the polygon presumably coincide, I'd guess you should make a List of all but the last point in the polygon and then pass that list to CreatePolyline.&amp;nbsp; After that you could to simplify the polyline.&lt;/P&gt;&lt;P&gt;Also there's the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic8288.html" target="_blank" rel="noopener"&gt;SimplifyPolyline method&lt;/A&gt;.&amp;nbsp; I've never used it, I'm waiting until they simplify its documentation before digging into that one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 23:29:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040458#M6380</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-03-24T23:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040649#M6382</link>
      <description>&lt;P&gt;The result would be without that knot in the middle of the drawing.&amp;nbsp; This is where someone either turned around in the area while walking/driving or digitizing.&amp;nbsp; So it made a loop.&amp;nbsp; I am able to add points and remove the self intersection, but i am interested in either flagging or removing this part completely (Filled in with green).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MKa_0-1616688829275.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/9367iDF1F5489F68B36ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MKa_0-1616688829275.png" alt="MKa_0-1616688829275.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 16:14:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040649#M6382</guid>
      <dc:creator>MKa</dc:creator>
      <dc:date>2021-03-25T16:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040702#M6384</link>
      <description>&lt;P&gt;Perhaps making a list of vertices with duplicate coordinates could be used for flagging.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
    try
    {
        var fLayer = MapView.Active?.GetSelectedLayers()
            .OfType&amp;lt;FeatureLayer&amp;gt;()
            .Where(lyr =&amp;gt; lyr.ShapeType == esriGeometryType.esriGeometryPolygon)
            .FirstOrDefault();
        if (fLayer == null)
            return;
        await QueuedTask.Run(() =&amp;gt;
        {
            using (var sel = fLayer.GetSelection()) 
            using (var cur = sel.Search())
            {
                if (cur.MoveNext())
                {
                    using (var feat = cur.Current as Feature)
                    {
                        var list = GetSelfIntersects(feat.GetShape() as Polygon);
                        Debug.Print($"{list.Count} duplicate vertices");
                    }
                }
            }
        });
    }
    catch(Exception ex)
    {
        Debug.Print(ex.Message);
    }
}
private List&amp;lt;MapPoint&amp;gt; GetSelfIntersects(Polygon polygon)
{
    // assumes vertices have been snapped
    // (skip this first point, since it will coincide with last point)            
    return polygon.Points.Skip(1)
        // could round here to cluster
        //.GroupBy(pnt =&amp;gt; (Math.Round(pnt.X,2),Math.Round(pnt.Y,2)) 
        .GroupBy(pnt =&amp;gt; (pnt.X, pnt.Y)) // could round here to cluster
        .Where(g =&amp;gt; g.Count() &amp;gt; 1)
        .Select(g =&amp;gt;
        {
            var sr = polygon.SpatialReference;
            return MapPointBuilder.CreateMapPoint(g.Key.X, g.Key.Y, sr);
        })
        .ToList();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 25 Mar 2021 17:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040702#M6384</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-03-25T17:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040727#M6385</link>
      <description>&lt;P&gt;I will give this a shot.&amp;nbsp; I think in my case two points can not share the same location.&amp;nbsp; So I could do this and flag the field.&amp;nbsp; I will try and implement something like this now and post my solution or what I came up with.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 18:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040727#M6385</guid>
      <dc:creator>MKa</dc:creator>
      <dc:date>2021-03-25T18:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fix Loops or Knots.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040942#M6389</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/93846"&gt;@MKa&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;This is my thought, if you want to remove inner white area from your geometry.&lt;/P&gt;&lt;P&gt;If you list the geometry rings from your polygon, there will be two rings from your example.&lt;/P&gt;&lt;P&gt;Anti-clockwise ring shall be inner white color ring and just remove it.&lt;/P&gt;&lt;P&gt;But for ArcGIS Pro sdk, I noticed that function&amp;nbsp;GetExteriorRings of polygon. you may try and create polygon from these rings, I think this will remove inner white colour ring.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 06:08:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/fix-loops-or-knots/m-p/1040942#M6389</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-26T06:08:09Z</dc:date>
    </item>
  </channel>
</rss>

