<?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: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation in ArcGIS Parcel Fabric Questions</title>
    <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1116134#M511</link>
    <description>&lt;P&gt;With 2.9 we now have new SDK documentation content on COGO API topics:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-COGO" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-COGO&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Nov 2021 22:00:54 GMT</pubDate>
    <dc:creator>TimHodson</dc:creator>
    <dc:date>2021-11-11T22:00:54Z</dc:date>
    <item>
      <title>Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1029699#M240</link>
      <description>&lt;P&gt;How do you trigger the "Update COGO Attributes" programmatically immediately after the edit operation&amp;nbsp;CopyLineFeaturesToParcelType?&lt;/P&gt;&lt;P&gt;I've tried this code, see attachement "Sample.txt"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case, the CanExecute is never true in both cases...&lt;/P&gt;&lt;P&gt;Note that the GridToGroundCorrection is ON, and both the Scale Factor and Offset direction are set, and my feature class is COGO Enabled.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 19:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1029699#M240</guid>
      <dc:creator>PascalVezina</dc:creator>
      <dc:date>2021-02-23T19:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030348#M242</link>
      <description>&lt;P&gt;Hi Pascal,&lt;/P&gt;&lt;P&gt;Below is a snippet of code to programmatically assign the COGO values. The function called &lt;EM&gt;GetCOGOFromGeometry&lt;/EM&gt; is not yet complete, but this should help to get you started on the right track.&lt;/P&gt;&lt;P&gt;Note, all of this and more will be covered in the Dev Summit during the session called: ArcGIS Pro SDK for .NET: Introduction to the Parcel Fabric API, on &lt;A href="https://www.esri.com/en-us/about/events/devsummit/agenda/agenda/detail?Type=Esri+Technical+Session&amp;amp;Topic=Pro%2FDesktop&amp;amp;date=2021-04-08" target="_self"&gt;8th April&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;As you are probably aware, there is also SDK content &lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Parcel-Fabric" target="_self"&gt;here&lt;/A&gt;. I just mention it for the benefit of others reading this post.&lt;/P&gt;&lt;P&gt;Once it's ready I will also share the code for the function.&lt;/P&gt;&lt;P&gt;-Tim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;          
          ParcelEditToken peToken = editOper.CopyLineFeaturesToParcelType(srcFeatLyr, ids, 
            destLineL, destPolygonL);

          if(!editOper.Execute())
            return editOper.ErrorMessage;

          //collect ground to grid correction values
          var mapView = MapView.Active;
          if (mapView?.Map == null)
            return "";
          var pSpatRef = mapView.Map.SpatialReference;
          var cimDefinition = mapView.Map?.GetDefinition();
          if (cimDefinition == null) return "";
          var cimG2G = cimDefinition.GroundToGridCorrection;

          double dScaleFactor = cimG2G.GetConstantScaleFactor();
          double dDirectionOffsetCorrection = cimG2G.GetDirectionOffset();

          var editOper2 = editOper.CreateChainedOperation();
          var FeatSetCreated = peToken.CreatedFeatures;

          Dictionary&amp;lt;string, object&amp;gt; ParcelLineAttributes = new Dictionary&amp;lt;string, object&amp;gt;();

          if (FeatSetCreated != null)
          {
            foreach (KeyValuePair&amp;lt;MapMember, List&amp;lt;long&amp;gt;&amp;gt; kvp in FeatSetCreated)
            {
              if (kvp.Key == destPolygonL)
                continue; //skip polygons, we just want to work with the lines
              foreach (long oid in kvp.Value)
              {
                var insp = kvp.Key.Inspect(oid);
                Polyline lineGeom = (Polyline)insp["SHAPE"];

                object[] COGODirectionDistanceRadiusArcLength;

                if (!GetCOGOFromGeometry(lineGeom, pSpatRef, dScaleFactor, dDirectionOffsetCorrection, out COGODirectionDistanceRadiusArcLength))
                { 
                  editOper2.Abort();
                  return ""; 
                }
                ParcelLineAttributes.Add("Direction", COGODirectionDistanceRadiusArcLength[0]);
                ParcelLineAttributes.Add("Distance", COGODirectionDistanceRadiusArcLength[1]);
                ParcelLineAttributes.Add("Radius", COGODirectionDistanceRadiusArcLength[2]);
                ParcelLineAttributes.Add("ArcLength", COGODirectionDistanceRadiusArcLength[3]);
                ParcelLineAttributes.Add("Rotation", dDirectionOffsetCorrection);
                ParcelLineAttributes.Add("Scale", dScaleFactor);
                ParcelLineAttributes.Add("IsCOGOGround", 1);

                editOper2.Modify(kvp.Key, oid, ParcelLineAttributes);
                ParcelLineAttributes.Clear();
              }
              editOper2.Execute();
            }
          }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 23:19:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030348#M242</guid>
      <dc:creator>TimHodson</dc:creator>
      <dc:date>2021-03-02T23:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030444#M243</link>
      <description>&lt;P&gt;Good day Tim,&lt;BR /&gt;Thank you for the reply.&lt;BR /&gt;This function&amp;nbsp;GetCOGOFromGeometry will be available in the next API release 2.7.2 or 2.8?&lt;BR /&gt;Regards,&lt;BR /&gt;Pascal&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:27:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030444#M243</guid>
      <dc:creator>PascalVezina</dc:creator>
      <dc:date>2021-02-25T14:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030534#M244</link>
      <description>&lt;P&gt;Pascal, the function will be shared either today, tomorrow, or early next week. It is written, but needs some testing. Note that you have access to the full geometry API, and the lines in the parcel fabric are standard line features. For example, below is a code snippet to return the info for the straight line between the first and last vertex of the feature.&lt;/P&gt;&lt;P&gt;-Tim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ICollection&amp;lt;Segment&amp;gt; LineSegments = new List&amp;lt;Segment&amp;gt;();
myLineFeature.GetAllSegments(ref LineSegments);
int numSegments = LineSegments.Count;

IList&amp;lt;Segment&amp;gt; iList = LineSegments as IList&amp;lt;Segment&amp;gt;;
Segment FirstSeg = iList[0];
Segment LastSeg = iList[numSegments - 1];
var pLine = LineBuilder.CreateLineSegment(FirstSeg.StartCoordinate, LastSeg.EndCoordinate);
var dDirectionPolarRadians = pLine.Angle;
var dDistance = pLine.Length;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 16:52:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1030534#M244</guid>
      <dc:creator>TimHodson</dc:creator>
      <dc:date>2021-02-25T16:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1031245#M246</link>
      <description>&lt;P&gt;hi Pascal,&lt;/P&gt;&lt;P&gt;Here are the functions. Note there is a slight signature change with addition of the spatial reference parameter. I edited, in place, the calling code in the previous comment:&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;    private bool GetCOGOFromGeometry(Polyline myLineFeature, SpatialReference MapSR, double ScaleFactor, double DirectionOffset, out object[] COGODirectionDistanceRadiusArcLength)
    {
      COGODirectionDistanceRadiusArcLength = new object[4] { DBNull.Value,DBNull.Value,DBNull.Value, DBNull.Value };
      try
      {
        COGODirectionDistanceRadiusArcLength[0] = DBNull.Value;
        COGODirectionDistanceRadiusArcLength[1] = DBNull.Value;

        var GeomSR= myLineFeature.SpatialReference;
        if (GeomSR.IsGeographic &amp;amp;&amp;amp; MapSR.IsGeographic)
          return false; //no SDK support for Geodesics till 2.8

        double UnitConversion = 1;

        if (GeomSR.IsGeographic &amp;amp;&amp;amp; MapSR.IsProjected)
        { //only need to project if dataset is in a GCS.
          UnitConversion = MapSR.Unit.ConversionFactor; // Meters per unit. Only need this for converting to metric for GCS datasets.
          myLineFeature = GeometryEngine.Instance.Project(myLineFeature, MapSR) as Polyline;
        }

        EllipticArcSegment pCircArc;
        ICollection&amp;lt;Segment&amp;gt; LineSegments = new List&amp;lt;Segment&amp;gt;();
        myLineFeature.GetAllSegments(ref LineSegments);
        int numSegments = LineSegments.Count;

        IList&amp;lt;Segment&amp;gt; iList = LineSegments as IList&amp;lt;Segment&amp;gt;;
        Segment FirstSeg = iList[0];
        Segment LastSeg = iList[numSegments - 1];
        var pLine = LineBuilder.CreateLineSegment(FirstSeg.StartCoordinate, LastSeg.EndCoordinate);
        COGODirectionDistanceRadiusArcLength[0] =
PolarRadiansToNorthAzimuthDecimalDegrees(pLine.Angle - DirectionOffset*Math.PI/180);
        COGODirectionDistanceRadiusArcLength[1] = pLine.Length * UnitConversion / ScaleFactor;
        //check if the last segment is a circular arc
        var pCircArcLast = LastSeg as EllipticArcSegment;
        if (pCircArcLast == null)
          return true; //we already know there is no circluar arc COGO
                       //Keep a copy of the center point
        var LastCenterPoint = pCircArcLast.CenterPoint;
        COGODirectionDistanceRadiusArcLength[2] = pCircArcLast.IsCounterClockwise ?
                -pCircArcLast.SemiMajorAxis : Math.Abs(pCircArcLast.SemiMajorAxis); //radius
        double dArcLengthSUM = 0;
        //use 30 times xy tolerance for circular arc segment tangency test
        double dTangencyToleranceTest = MapSR.XYTolerance * 30; //around 3cms if using default XY Tolerance - recommended

        for (int i = 0; i &amp;lt; numSegments; i++)
        {
          pCircArc = iList[i] as EllipticArcSegment;
          if (pCircArc == null)
          {
            COGODirectionDistanceRadiusArcLength[2] = DBNull.Value; //radius
            COGODirectionDistanceRadiusArcLength[3] = DBNull.Value; //arc length
            return true;
          }
          var tolerance = LineBuilder.CreateLineSegment(LastCenterPoint, pCircArc.CenterPoint).Length;
          if (tolerance &amp;gt; dTangencyToleranceTest)
          {
            COGODirectionDistanceRadiusArcLength[2] = DBNull.Value; //radius
            COGODirectionDistanceRadiusArcLength[3] = DBNull.Value; //arc length
            return true;
          }
          dArcLengthSUM += pCircArc.Length; //arc length sum
        }
        //now check to see if the radius and arclength survived and if so, clear the distance
        if (COGODirectionDistanceRadiusArcLength[2] != DBNull.Value)
          COGODirectionDistanceRadiusArcLength[1] = DBNull.Value;

        COGODirectionDistanceRadiusArcLength[3] = dArcLengthSUM * UnitConversion / ScaleFactor;
        COGODirectionDistanceRadiusArcLength[2] = (double)COGODirectionDistanceRadiusArcLength[2] * UnitConversion / ScaleFactor;
        
        return true;
      }
      catch
      {
        return false;
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the second function for direction unit/format conversions from polar to north azimuth:&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;    private static double PolarRadiansToNorthAzimuthDecimalDegrees(double InPolarRadians)
    {
      var AngConv = DirectionUnitFormatConversion.Instance;
      var ConvDef = new ConversionDefinition()
      {
        DirectionTypeIn = ArcGIS.Core.SystemCore.DirectionType.Polar,
        DirectionUnitsIn = ArcGIS.Core.SystemCore.DirectionUnits.Radians,
        DirectionTypeOut = ArcGIS.Core.SystemCore.DirectionType.NorthAzimuth,
        DirectionUnitsOut = ArcGIS.Core.SystemCore.DirectionUnits.DecimalDegrees
      };
      return AngConv.ConvertToDouble(InPolarRadians, ConvDef);
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 23:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1031245#M246</guid>
      <dc:creator>TimHodson</dc:creator>
      <dc:date>2021-03-02T23:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1116134#M511</link>
      <description>&lt;P&gt;With 2.9 we now have new SDK documentation content on COGO API topics:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-COGO" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-COGO&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 22:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1116134#M511</guid>
      <dc:creator>TimHodson</dc:creator>
      <dc:date>2021-11-11T22:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically update COGO attributes after CopyLineFeaturesToParcelType edit operation</title>
      <link>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1387141#M1577</link>
      <description>&lt;P&gt;For the latest code for Update COGO, including access and use of the map’s ground to grid corrections, see the Parcel Utilities Add-in.&lt;/P&gt;&lt;P&gt;Install: &lt;A href="https://arcg.is/0f5reS" target="_blank"&gt;https://arcg.is/0f5reS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Code: &lt;A href="https://github.com/Esri/parcel-fabric-pro-addins/tree/main/ParcelsAddin" target="_blank"&gt;https://github.com/Esri/parcel-fabric-pro-addins/tree/main/ParcelsAddin&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TimHodson_0-1708998074233.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95909i45235E5A58172B77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TimHodson_0-1708998074233.png" alt="TimHodson_0-1708998074233.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The configuration settings are designed to protect against the overwriting of good COGO:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TimHodson_1-1708998074235.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95910iA9AF0E88A8701DAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TimHodson_1-1708998074235.png" alt="TimHodson_1-1708998074235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;These settings are saved between Pro sessions.&lt;/P&gt;&lt;P&gt;-Tim&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 01:43:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-update-cogo-attributes-after/m-p/1387141#M1577</guid>
      <dc:creator>TimHodson</dc:creator>
      <dc:date>2024-02-27T01:43:21Z</dc:date>
    </item>
  </channel>
</rss>

