public InverseDirectionDLG(IEditProperties2 EditorProperties)
        {
            InitializeComponent();
            m_ToolTip1         = new System.Windows.Forms.ToolTip();
            m_EditorProperties = EditorProperties;
            Utilities Utils = new Utilities();

            string sDesktopVers = Utils.GetDesktopVersionFromRegistry();

            if (sDesktopVers.Trim() == "")
            {
                sDesktopVers = "Desktop10.1";
            }
            else
            {
                sDesktopVers = "Desktop" + sDesktopVers;
            }
            string sValues =
                Utils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
                                       "AddIn.FabricQualityControl_InverseDirection");

            IAngularConverter pAngConv = new AngularConverterClass();

            if (m_EditorProperties != null)
            {
                esriDirectionUnits pUnits      = m_EditorProperties.DirectionUnits;
                string             sAngleUnits = pUnits.ToString();
                sAngleUnits             = sAngleUnits.Replace("esriDU", "");
                sAngleUnits             = sAngleUnits.Replace("Minutes", " Minutes ");
                sAngleUnits             = sAngleUnits.Replace("Decimal", "Decimal ");
                this.lblAngleUnits.Text = sAngleUnits;
            }

            if (sValues.Trim() == "")
            {
                sValues = "False,0.000000,True,True,180,True,0.3,True";
            }
            string[] Values = sValues.Split(',');
            try
            {
                string sTxt1 = Values[1];
                if (m_EditorProperties != null)
                {
                    int iPrec = m_EditorProperties.AngularUnitPrecision;
                    pAngConv.SetString(Values[1], esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDUDecimalDegrees); //registry always stores in DD
                    sTxt1 = pAngConv.GetString(esriDirectionType.esriDTNorthAzimuth, m_EditorProperties.DirectionUnits, m_EditorProperties.AngularUnitPrecision);
                }

                this.optManualEnteredDirnOffset.Checked = (Values[0].Trim() == "True");
                this.txtDirectionOffset.Text            = sTxt1;
                this.optComputeDirnOffset.Checked       = (Values[2].Trim() == "True");
                this.chkDirectionDifference.Checked     = (Values[3].Trim() == "True");
                this.txtDirectionDifference.Text        = Values[4];
                this.chkSubtendedDistance.Checked       = (Values[5].Trim() == "True");
                this.txtSubtendedDist.Text    = Values[6];
                this.chkReportResults.Checked = (Values[7].Trim() == "True");
            }
            catch
            { }
        }
        public InverseDirectionDLG(IEditProperties2 EditorProperties)
        {
            InitializeComponent();
              m_ToolTip1 = new System.Windows.Forms.ToolTip();
              m_EditorProperties = EditorProperties;
              Utilities Utils = new Utilities();

              string sDesktopVers = Utils.GetDesktopVersionFromRegistry();
              if (sDesktopVers.Trim() == "")
            sDesktopVers = "Desktop10.1";
              else
            sDesktopVers = "Desktop" + sDesktopVers;
              string sValues =
              Utils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
            "AddIn.FabricQualityControl_InverseDirection");

              IAngularConverter pAngConv = new AngularConverterClass();
              if (m_EditorProperties != null)
              {
            esriDirectionUnits pUnits = m_EditorProperties.DirectionUnits;
            string sAngleUnits = pUnits.ToString();
            sAngleUnits = sAngleUnits.Replace("esriDU", "");
            sAngleUnits = sAngleUnits.Replace("Minutes", " Minutes ");
            sAngleUnits = sAngleUnits.Replace("Decimal", "Decimal ");
            this.lblAngleUnits.Text = sAngleUnits;
              }

              if (sValues.Trim() == "")
            sValues = "False,0.000000,True,True,180,True,0.3,True";
              string[] Values = sValues.Split(',');
              try
              {
            string sTxt1 = Values[1];
            if (m_EditorProperties != null)
            {
              int iPrec = m_EditorProperties.AngularUnitPrecision;
              pAngConv.SetString(Values[1], esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDUDecimalDegrees); //registry always stores in DD
              sTxt1 = pAngConv.GetString(esriDirectionType.esriDTNorthAzimuth, m_EditorProperties.DirectionUnits, m_EditorProperties.AngularUnitPrecision);
            }

            this.optManualEnteredDirnOffset.Checked = (Values[0].Trim() == "True");
            this.txtDirectionOffset.Text = sTxt1;
            this.optComputeDirnOffset.Checked = (Values[2].Trim() == "True");
            this.chkDirectionDifference.Checked = (Values[3].Trim() == "True");
            this.txtDirectionDifference.Text = Values[4];
            this.chkSubtendedDistance.Checked = (Values[5].Trim() == "True");
            this.txtSubtendedDist.Text = Values[6];
            this.chkReportResults.Checked = (Values[7].Trim() == "True");
              }
              catch
              { }
        }
예제 #3
0
        protected override void OnClick()
        {
            ICadastralEditor   pCadEd         = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            IParcelEditManager pParcEditorMan = (IParcelEditManager)pCadEd;

            ICadastralPacketManager pCadPacketMan = (ICadastralPacketManager)pCadEd;

            //bool bStartedWithPacketOpen = pCadPacketMan.PacketOpen;

            if (pParcEditorMan == null)
            {
                return;
            }

            IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

            if (pEd.EditState == esriEditState.esriStateNotEditing)
            {
                MessageBox.Show("Please start editing and try again.");
                return;
            }

            IParcelConstruction       pConstr                   = pParcEditorMan.ParcelConstruction;
            IParcelConstruction4      pConstr4                  = pConstr as IParcelConstruction4;
            ICadastralPoints          pCadastralPts             = pConstr4 as ICadastralPoints;
            ICadastralEditorSettings2 pCadastralEditorSettings2 = pCadEd as ICadastralEditorSettings2;

            ICadastralFixedPoints pFixedPoints = pCadastralPts as ICadastralFixedPoints;
            IPointCalculation     pPointCalc   = new PointCalculationClass();

            if (pConstr == null)
            {
                return;
            }

            IGSLine pParcelLine = null;
            IMetricUnitConverter pMetricUnitConv = (IMetricUnitConverter)pCadEd;
            IGSPoint             pStartPoint     = null;
            List <int>           lstPointIds     = new List <int>();

            List <IVector3D> Traverse = new List <IVector3D>();

            //get rotation here
            IParcelConstructionData    pConstrData = pConstr4.ConstructionData;
            IConstructionParentParcels pConstructionParentParcels = pConstrData as IConstructionParentParcels;

            ICadastralUndoRedo pCadUndoRedo = pConstr as ICadastralUndoRedo;

            try
            {
                int iParcelID = -1;
                if (pConstructionParentParcels.ParentParcelCount > 0)
                {
                    pConstructionParentParcels.GetParentParcel(0, ref iParcelID);
                }

                ICadastralParcel pCadaParcel = pCadPacketMan.JobPacket as ICadastralParcel;

                IGSParcel pGSParcel = null;

                if (pCadaParcel != null)
                {
                    pGSParcel = pCadaParcel.GetParcel(iParcelID);
                }
                //if in measurement view then rotation is 0
                double TheRotation = 0;

                if (pGSParcel == null)
                {
                    pGSParcel = pConstr.Parcel;
                }

                if (!pCadastralEditorSettings2.MeasurementView)
                {
                    TheRotation = pGSParcel.Rotation;//radians
                }
                if (TheRotation == 123456789)
                {
                    TheRotation = 0;
                }

                pPointCalc.Rotation = TheRotation;
                IGSPoint pClosingPoint = null;

                #region simple method as fall-back
                bool bUseSimpleStackSelection = false;
                if (bUseSimpleStackSelection)
                {
                    //bool bLineSelectionSequence = false;
                    //IGSLine pLastSelectedGSLineInGrid = null;
                    //for (int i = 0; i < pConstr.LineCount; i++)
                    //{
                    //  if (pConstr.GetLineSelection(i))
                    //  {
                    //    if (pConstr.GetLine(i, ref pParcelLine))
                    //    {
                    //      if (!bLineSelectionSequence) //first line
                    //      {
                    //        pStartPoint = pCadastralPts.GetPoint(pParcelLine.FromPoint);
                    //        pToPoint = pCadastralPts.GetPoint(pParcelLine.ToPoint);
                    //      }

                    //      pPointCalc.AddLine(pParcelLine);

                    //      pLastSelectedGSLineInGrid = pParcelLine;
                    //      pToPoint = pCadastralPts.GetPoint(pParcelLine.ToPoint);
                    //      lstPointIds.Add(pToPoint.Id);

                    //    }
                    //    bLineSelectionSequence = true;

                    //    double dBear = pParcelLine.Bearing; //Azimuth of IVector3D is north azimuth radians zero degrees north
                    //    double dDist = pParcelLine.Distance;
                    //    IVector3D vec = new Vector3DClass();
                    //    vec.PolarSet(dBear, 0, dDist); ////Azimuth of IVector3D is north azimuth radians zero degrees north
                    //    Traverse.Add(vec);
                    //  }
                    //  else
                    //  {
                    //    if (bLineSelectionSequence && pConstr.GetLine(i, ref pParcelLine) && HasLineSelectionAfter(pConstr, i))
                    //    //if there was a prior selection and this line is a complete line, and there is no later selection
                    //    {
                    //      MessageBox.Show("Please select a continuous set of lines for closure.");
                    //      return;
                    //    }
                    //  }
                    //}
                    //pClosingPoint = pCadastralPts.GetPoint(pLastSelectedGSLineInGrid.ToPoint);
                }
                else
                #endregion

                {//build a forward star for the selected lines
                    IEnumCELines pCELines     = new EnumCELinesClass();
                    IEnumGSLines pEnumGSLines = (IEnumGSLines)pCELines;
                    ILongArray   pLongArray   = new LongArrayClass();
                    int          iFirstToNode = -1;
                    for (int i = 0; i < pConstr.LineCount; i++)
                    {
                        if (pConstr.GetLineSelection(i))
                        {
                            if (pConstr.GetLine(i, ref pParcelLine))
                            {
                                if (iFirstToNode < 0)
                                {
                                    iFirstToNode = pParcelLine.ToPoint;
                                }
                                pLongArray.Add(i);
                                pCELines.Add(pParcelLine);
                            }
                        }
                    }

                    if (pCELines.Count == 0)
                    {
                        MessageBox.Show("No lines selected. Please select a continuous set of lines for closure." + Environment.NewLine +
                                        "Line selection should not have branches.", "Traverse");
                        return;
                    }

                    IParcelLineFunctions3 ParcelLineFx = new ParcelFunctionsClass();
                    IGSForwardStar        pFwdStar     = ParcelLineFx.CreateForwardStar(pEnumGSLines);
                    //forward star object is now created for all the selected lines,
                    //need to first re-sequence the lines, and test for branching and discontinuity

                    int           iBranches = 0; int iTracedLines = 0;
                    int           iLoops = 0; int iTerminals = 0;
                    List <int>    LineIDList = new List <int>();
                    List <int>    FromList   = new List <int>();
                    List <int>    ToList     = new List <int>();
                    List <string> FromToLine = new List <string>();

                    bool bTraceSucceeded = TraceLines(ref pFwdStar, iFirstToNode, ref iBranches, ref iTracedLines,
                                                      ref iLoops, ref iTerminals, ref FromToLine, ref FromList, ref ToList, 0);

                    if (iBranches > 0)
                    {
                        MessageBox.Show("Please select a continuous set of lines for closure." + Environment.NewLine +
                                        "Line selection should not have branches.", "Traverse");
                        return;
                    }

                    if (iTracedLines < pLongArray.Count)
                    {
                        MessageBox.Show("Please select a continuous set of lines for closure." + Environment.NewLine +
                                        "Selected Lines should be connected in a single sequence without branches.", "Traverse");
                        return;
                    }

                    //if it's a single loop check to see if the sequence needs to be reversed
                    //CW or CCW based on bearings
                    if (iLoops == 1)
                    {
                        bool bIsReversed = false;
                        foreach (int i in FromList)
                        {
                            if (i < 0)
                            {
                                bIsReversed = true;
                            }
                            else
                            {
                                bIsReversed = false;
                                break;
                            }
                        }
                        if (bIsReversed)
                        {//all courses are running reversed, so reverse the whole sequence
                            FromToLine.Clear();
                            FromList.Reverse();
                            ToList.Reverse();
                            int    iNewFrom   = -ToList[ToList.Count - 1];
                            int    iNewTo     = -FromList[ToList.Count - 1];
                            string sNewFromTo = iNewFrom.ToString() + "," + iNewTo.ToString();
                            FromToLine.Add(sNewFromTo);
                            for (int i = 1; i < ToList.Count; i++)
                            {
                                iNewFrom   = -ToList[i - 1];
                                iNewTo     = -FromList[i - 1];
                                sNewFromTo = iNewFrom.ToString() + "," + iNewTo.ToString();
                                FromToLine.Add(sNewFromTo);
                            }
                        }
                    }

                    LineIDList.Clear();
                    FromList.Clear();
                    ToList.Clear();
                    pLongArray.RemoveAll();

                    pCadUndoRedo.StartUndoRedoSession("Adjust Traverse");

                    if (iLoops == 0)
                    {
                        //re-sequence using TraceLines function based on either end point, because the order of
                        //selected construction lines in grid don't control start or end point
                        FromToLine.Clear();
                        int iTerminus = -1;
                        iTracedLines = 0;
                        iBranches    = 0;
                        iLoops       = 0; iTerminals = 0;
                        FindTerminusForSequence(ref pFwdStar, iFirstToNode, ref iTerminus, 0);
                        if (iTerminus == -1)
                        {
                            pCadUndoRedo.WriteUndoRedoSession(false);
                            return;
                        }
                        TraceLines(ref pFwdStar, iTerminus, ref iBranches, ref iTracedLines, ref iLoops, ref iTerminals,
                                   ref FromToLine, ref FromList, ref ToList, 0);
                    }

                    List <IVector3D> SequencedTraverse = new List <IVector3D>();
                    IGSLine          pGSLineInPath     = null;
                    foreach (string s in FromToLine)
                    {
                        string[] sFromTo = s.Split(',');
                        int      iFrom   = Convert.ToInt32(sFromTo[0]);
                        int      iTo     = Convert.ToInt32(sFromTo[1]);

                        bool bReversed = pFwdStar.GetLine(iFrom, iTo, ref pGSLineInPath);
                        if (bReversed)
                        {
                            IGSLine pGSLine180 = new GSLineClass();
                            pGSLine180.FromPoint = pGSLineInPath.ToPoint;
                            pGSLine180.ToPoint   = pGSLineInPath.FromPoint;
                            pGSLine180.Bearing   = pGSLineInPath.Bearing + Math.PI;
                            pGSLine180.Distance  = pGSLineInPath.Distance;

                            IVector3D vec180 = new Vector3DClass();
                            vec180.PolarSet(pGSLine180.Bearing, 0, pGSLine180.Distance); //Azimuth of IVector3D is north azimuth radians zero degrees north
                            Traverse.Add(vec180);
                            lstPointIds.Add(pGSLine180.ToPoint);
                            pPointCalc.AddLine(pGSLine180);
                        }
                        else
                        {
                            double    dBear = pGSLineInPath.Bearing;
                            double    dDist = pGSLineInPath.Distance;
                            IVector3D vec   = new Vector3DClass();
                            vec.PolarSet(dBear, 0, dDist); //Azimuth of IVector3D is north azimuth radians zero degrees north
                            Traverse.Add(vec);
                            lstPointIds.Add(pGSLineInPath.ToPoint);
                            pPointCalc.AddLine(pGSLineInPath);
                        }

                        if (pStartPoint == null)
                        {
                            if (bReversed)
                            {
                                pStartPoint = pCadastralPts.GetPoint(pGSLineInPath.ToPoint);
                            }
                            else
                            {
                                pStartPoint = pCadastralPts.GetPoint(pGSLineInPath.FromPoint);
                            }
                        }

                        if (bReversed)
                        {
                            pClosingPoint = pCadastralPts.GetPoint(pGSLineInPath.FromPoint);
                        }
                        else
                        {
                            pClosingPoint = pCadastralPts.GetPoint(pGSLineInPath.ToPoint);
                        }
                    }
                }

                if (pStartPoint == null)
                {
                    pCadUndoRedo.WriteUndoRedoSession(false);
                    return;
                }
                IPoint pStart = new PointClass();
                pStart.X = pStartPoint.X;
                pStart.Y = pStartPoint.Y;

                string sAdjustMethod = "Compass";
                esriParcelAdjustmentType eAdjMethod = esriParcelAdjustmentType.esriParcelAdjustmentCompass;

                if (pCadastralEditorSettings2.ParcelAdjustment == esriParcelAdjustmentType.esriParcelAdjustmentNone ||
                    pCadastralEditorSettings2.ParcelAdjustment == esriParcelAdjustmentType.esriParcelAdjustmentCompass)
                {
                    eAdjMethod = esriParcelAdjustmentType.esriParcelAdjustmentCompass;
                }
                else if (pCadastralEditorSettings2.ParcelAdjustment == esriParcelAdjustmentType.esriParcelAdjustmentCrandall)
                {
                    sAdjustMethod = "Crandall";
                    eAdjMethod    = pCadastralEditorSettings2.ParcelAdjustment;
                }
                else if (pCadastralEditorSettings2.ParcelAdjustment == esriParcelAdjustmentType.esriParcelAdjustmentTransit)
                {
                    sAdjustMethod = "Transit";
                    eAdjMethod    = pCadastralEditorSettings2.ParcelAdjustment;
                }

                pPointCalc.CalculatePoints(eAdjMethod, pStartPoint.Id, pStartPoint, pClosingPoint.Id, pClosingPoint, true);
                ITraverseClosure pClose = pPointCalc.Closure;
                List <string>    lstCoursesFromTo = new List <string>();
                List <IVector3D> AdjustedTraverse = new List <IVector3D>();
                double           dAdjustedPointX = 0; double dAdjustedPointY = 0;
                double           dPreviousPointX = 0; double dPreviousPointY = 0;

                for (int i = 0; i < pClose.CourseCount; i++)
                {
                    IGSPoint pPt = pCadastralPts.GetPoint(lstPointIds[i]);
                    dAdjustedPointY = pPointCalc.GetCalculatedPoint(lstPointIds[i], ref dAdjustedPointX);
                    string    sFromTo       = "";
                    IVector3D pAdjustedLine = new Vector3DClass();
                    if (i == 0)
                    {
                        sFromTo = pStartPoint.Id.ToString() + "-" + lstPointIds[i].ToString();
                        pAdjustedLine.SetComponents(dAdjustedPointX - pStartPoint.X, dAdjustedPointY - pStartPoint.Y, 0);
                    }
                    else
                    {
                        sFromTo = lstPointIds[i - 1].ToString() + "-" + lstPointIds[i].ToString();
                        pAdjustedLine.SetComponents(dAdjustedPointX - dPreviousPointX, dAdjustedPointY - dPreviousPointY, 0);
                    }
                    lstCoursesFromTo.Add(sFromTo);

                    IVector3D Z_Axis = new Vector3DClass();
                    Z_Axis.SetComponents(0, 0, 100);

                    pAdjustedLine.Rotate(TheRotation, Z_Axis);
                    AdjustedTraverse.Add(pAdjustedLine);

                    dPreviousPointX = dAdjustedPointX;
                    dPreviousPointY = dAdjustedPointY;

                    pPt.X = dAdjustedPointX;
                    pPt.Y = dAdjustedPointY;

                    if (!pCadastralEditorSettings2.MeasurementView)
                    {
                        pFixedPoints.SetFixedPoint(lstPointIds[i], true);
                    }
                }

                double  dMisclosureDistance = pClose.MisclosureDistance; double dMisclosureBearing = pClose.MisclosureDirection;
                IVector MiscloseVector = new Vector3DClass();

                IEditProperties2 pEdProps = pEd as IEditProperties2;

                IAngularConverter pAngConv = new AngularConverterClass();
                pAngConv.SetAngle(dMisclosureBearing, esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDURadians);
                //int iPrec = 7;
                //if (pConstr.Parcel.Plan.AngleUnits == esriDirectionUnits.esriDUDegreesMinutesSeconds)
                //  iPrec = 0;

                string sMiscloseBearing = pAngConv.GetString(pEdProps.DirectionType, pEdProps.DirectionUnits, pEdProps.AngularUnitPrecision);

                Utilities UTIL   = new Utilities();
                string    sRatio = "High Accuracy";

                if (pClose.RelativeErrorRatio < 10000)
                {
                    sRatio = "1:" + pClose.RelativeErrorRatio.ToString("0");
                }

                if (dMisclosureDistance >= 0.001)
                {
                    sMiscloseBearing = UTIL.FormatDirectionDashesToDegMinSecSymbols(sMiscloseBearing);
                }
                else
                {
                    sMiscloseBearing = "----";
                }

                ICadastralUnitConversion pCadUnitConverter = new CadastralUnitConversionClass();
                double dMetersPerUnit = pCadUnitConverter.ConvertDouble(1, pConstr.Parcel.Plan.DistanceUnits, esriCadastralDistanceUnits.esriCDUMeter);

                string sReport = "Closure:" + Environment.NewLine +
                                 "        error:  " + sRatio + Environment.NewLine +
                                 "        distance:  " + (dMisclosureDistance / dMetersPerUnit).ToString("0.000") + Environment.NewLine +
                                 "        bearing:  " + sMiscloseBearing + Environment.NewLine +
                                 "        xdist:  " + (pClose.MisclosureX / dMetersPerUnit).ToString("0.000") + Environment.NewLine +
                                 "        ydist:  " + (pClose.MisclosureY / dMetersPerUnit).ToString("0.000") + Environment.NewLine +
                                 "        courses: " + (pClose.CourseCount) + Environment.NewLine +
                                 Environment.NewLine + "Adjustment:" + Environment.NewLine +
                                 "        method: " + sAdjustMethod;

                dlgTraverseResults dlgTraverseResults = new dlgTraverseResults();
                AddTraverseInfoToGrid(pConstr.Parcel.Plan, dlgTraverseResults.dataGridView1, Traverse, AdjustedTraverse, lstCoursesFromTo);
                dlgTraverseResults.txtMiscloseReport.Text = sReport;
                DialogResult dRes = dlgTraverseResults.ShowDialog();
                if (dRes == DialogResult.Cancel)
                {
                    //since we cancelled, set the points back
                    foreach (int i in lstPointIds)
                    {
                        pFixedPoints.SetFixedPoint(i, false);
                    }
                    pCadUndoRedo.WriteUndoRedoSession(false);
                }
                else
                {
                    pCadUndoRedo.WriteUndoRedoSession(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + "Line number:" + ex.LineNumber().ToString()
                                + " in " + ex.TargetSite.Name, "Traverse");
                pCadUndoRedo.WriteUndoRedoSession(false);
            }
        }
예제 #4
0
        // modified form constructor to accept the app and editor objects passed by ref
        public SpiralCurveDialog(ref IApplication pApp, ref IEditor pEditor)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            try
            {
                m_pApp = pApp;

                m_pEditor = pEditor;
                m_pEditProp2 = (IEditProperties2)m_pEditor;

                // REGEX strings that will be used for DMS units
                m_RegexUnitsDMS = new ArrayList();
                m_RegexUnitsDMS.Add(@" *(\d+)\.(\d\d)(\d\d\d\d) *");
                m_RegexUnitsDMS.Add(@" *(\d+)\/(\d+)\/(\d+\.?\d*) *");
                m_RegexUnitsDMS.Add(@" * *(\d+)\^(\d+)\'(\d+\.?\d*)\" + quote + " *");
                m_RegexUnitsDMS.Add(@" *(\d+)\-(\d+)\-(\d+\.?\d*) *");

                // REGEX string that will be used for DD, radians, Gons, etc..
                m_RegexUnitsDecimals = @" *(\d+\.?\d+) *";

                // REGEX object for validating the length with units
                m_RegexUnitsMeasure = new Regex(@"(\d*\.?\d+) *(" + String.Join("|", this.AllowedUnits) + ") *$");

                // validate the spatial reference of the edit data frame;
                m_SRValid = SpatialRefValid();
            }
            catch
            {

            }
        }
        public InverseDistanceDlg(IEditProperties2 EditorProperties, IMap TheMap)
        {
            InitializeComponent();

            m_ToolTip1 = new System.Windows.Forms.ToolTip();

            m_EditorProperties = EditorProperties;
            m_Map = TheMap;

            m_ElevationLayer2FieldNames = new  Dictionary <int, string>();
            m_ElevationLayerNames       = new List <string>();
            getElevationTableAndField(ref m_ElevationLayer2FieldNames, ref m_ElevationLayerNames);

            Utilities Utils = new Utilities();

            string sDesktopVers = Utils.GetDesktopVersionFromRegistry();

            if (sDesktopVers.Trim() == "")
            {
                sDesktopVers = "Desktop10.1";
            }
            else
            {
                sDesktopVers = "Desktop" + sDesktopVers;
            }
            string sValues =
                Utils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
                                       "AddIn.FabricQualityControl_InverseDistance");

            if (sValues.Trim() == "")
            {
                sValues = "True,1.5,True,False,1.0000000,True,0,0.00,<None>,True,m"; //Defaults
            }
            string[] Values = sValues.Split(',');
            int      k      = 0;

            foreach (string FieldsList in m_ElevationLayer2FieldNames.Values)
            {
                string[] FieldName  = FieldsList.Split(',');
                string   sLayerName = m_ElevationLayerNames[k++];
                for (int i = 0; i < FieldName.Length; i++)
                {
                    string sElevationSource = String.Format("[{0}] in layer {1}", FieldName[i], sLayerName);
                    cboElevField.Items.Add(sElevationSource);
                }
            }

            try
            {
                Point p = new Point();
                txtHeightParameter.Location = txtElevationLyr.Location;
                p.X = txtHeightParameter.Location.X + 10 + txtHeightParameter.Width;
                p.Y = txtHeightParameter.Location.Y;
                cboUnits.Location = p;

                Point p2 = new Point();
                p2.X = lblHeightInput.Location.X;
                p2.Y = txtElevationLyr.Location.Y;
                txtHeightParameter.Location = p2;

                cboUnits.SelectedItem                  = "m"; //default to meters, but change later if needed
                txtHeightParameter.Visible             = false;
                cboUnits.Visible                       = txtHeightParameter.Visible;
                this.chkDistanceDifference.Checked     = (Values[0].Trim() == "True");
                this.txtDistDifference.Text            = Values[1];
                this.chkApplyScaleFactor.Checked       = (Values[2].Trim() == "True");
                this.optUserEnteredScaleFactor.Checked = (Values[3].Trim() == "True");
                this.txtScaleFactor.Text               = string.Format(Values[4], "0.000000000000000");
                this.optComputeForMe.Checked           = (Values[5].Trim() == "True");
                this.cboScaleMethod.SelectedIndex      = Convert.ToInt32(Values[6]);
                this.txtHeightParameter.Text           = Values[7];

                this.txtElevationLyr.Text     = "   " + Values[8];
                this.chkReportResults.Checked = (Values[9].Trim() == "True");

                m_sInitialUnit = m_sUnit = Values[10].Trim();
                if (m_sUnit != "m")
                {
                    cboUnits.SelectedItem = m_sUnit;
                }

                btnUnits.Visible = (cboScaleMethod.SelectedIndex == 1) && optComputeForMe.Checked && !txtElevationLyr.Text.Contains("<None>");
            }
            catch
            {}
        }
        public InterpolateZDlg(IEditProperties2 EditorProperties, IMap TheMap)
        {
            InitializeComponent();

            m_ToolTip1 = new System.Windows.Forms.ToolTip();

            m_EditorProperties = EditorProperties;
            m_Map = TheMap;

            m_TinLayer2FieldNames = new Dictionary <int, string>();
            m_TinLayerNames       = new List <string>();

            Utilities Utils = new Utilities();

            Utils.getTINLayer(ref m_TinLayer2FieldNames, ref m_TinLayerNames);

            m_RasterLayer2FieldNames = new Dictionary <int, string>();
            m_RasterLayerNames       = new List <string>();
            Utils.getRasterDEMLayer(ref m_RasterLayer2FieldNames, ref m_RasterLayerNames);

            cboLayerNameTIN.Items.Add("<None>");
            cboLayerNameTIN.SelectedIndex = 0;

            cboLayerNameDEM.Items.Add("<None>");
            cboLayerNameDEM.SelectedIndex = 0;

            if (m_TinLayerNames.Count > 0)
            {
                foreach (string sLayer in m_TinLayerNames)
                {
                    cboLayerNameTIN.Items.Add(sLayer);
                }
            }

            if (m_RasterLayerNames.Count > 0)
            {
                foreach (string sLayer in m_RasterLayerNames)
                {
                    cboLayerNameDEM.Items.Add(sLayer);
                }
            }


            string sDesktopVers = Utils.GetDesktopVersionFromRegistry();

            if (sDesktopVers.Trim() == "")
            {
                sDesktopVers = "Desktop10.1";
            }
            else
            {
                sDesktopVers = "Desktop" + sDesktopVers;
            }
            string sValues =
                Utils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
                                       "AddIn.FabricQualityControl_InterpolateZ");

            if (sValues.Trim() == "")
            {
                sValues = "True,False,0,m,1,<None>,False,0,True"; //Defaults
            }
            string[] Values = sValues.Split(',');
            int      k      = 0;

            try
            {
                Point p = new Point();
                txtHeightParameter.Location = txtElevationLyr.Location;
                p.X = txtHeightParameter.Location.X + 10 + txtHeightParameter.Width;
                p.Y = txtHeightParameter.Location.Y;
                cboUnits.Location = p;


                cboUnits.SelectedItem      = "m"; //default to meters, but change later if needed
                txtHeightParameter.Visible = false;
                cboUnits.Visible           = txtHeightParameter.Visible;

                btnChange.Top  = txtElevationLyr.Top;
                btnChange.Left = txtElevationLyr.Right + 3;

                this.optClearElevations.Checked = (Values[0].Trim() == "True");
                this.optAssignZValues.Checked   = (Values[1].Trim() == "True");
                this.txtHeightParameter.Text    = Values[2];
                m_sInitialUnit = m_sUnit = Values[3].Trim();
                if (m_sUnit != "m")
                {
                    cboUnits.SelectedItem = m_sUnit;
                }
                //try {this.cboElevationSource.SelectedIndex = Convert.ToInt32(Values[4]);}
                //catch { this.cboElevationSource.SelectedIndex = 0; }
                cboElevationSource.SelectedIndex = cboElevationSource.FindStringExact(Values[4]);
                this.txtElevationLyr.Text        = Values[5];

                this.chkElevationDifference.Checked = (Values[6].Trim() == "True");
                this.txtElevationDifference.Text    = Values[7];

                this.chkReportResults.Checked = (Values[8].Trim() == "True");



                if (this.cboElevationSource.SelectedIndex == 1 && m_TinLayerNames.Count > 0) //TIN layer
                {
                    this.txtElevationLyr.Text = m_TinLayerNames[0];
                }
                else if (this.cboElevationSource.SelectedIndex == 2 && m_RasterLayerNames.Count > 0) //DEM layer
                {
                    this.txtElevationLyr.Text = m_RasterLayerNames[0];
                }


                if (this.cboElevationSource.SelectedIndex > 0)
                {
                    this.button1.Enabled = !txtElevationLyr.Text.Contains("<None>");
                }

                btnUnits.Visible = (cboElevationSource.SelectedIndex == 1) && !txtElevationLyr.Text.Contains("<None>");
                optClearElevations_CheckedChanged(null, null);
            }
            catch
            {
                this.cboElevationSource.SelectedIndex = 0;
            }
        }
        protected override void OnClick()
        {
            IEditor  pEd  = (IEditor)ArcMap.Editor;
            IEditor2 pEd2 = (IEditor2)ArcMap.Editor;

            IEditProperties  pEdProps1 = pEd as IEditProperties;
            IEditProperties2 pEdProps2 = pEd as IEditProperties2;

            IEditSketch2       pSketch2 = ArcMap.Editor as IEditSketch2;
            ISegmentCollection pSegColl = pSketch2.Geometry as ISegmentCollection;

            double dLineDirection = 0;

            ISketchTool sketchTool = ArcMap.Application.CurrentTool.Command as ISketchTool;

            if (sketchTool.Constraint == esriSketchConstraint.esriConstraintAngle)
            {
                dLineDirection = sketchTool.AngleConstraint;
            }
            else
            {
                ILine pRubberBandLine = new LineClass();
                pRubberBandLine.PutCoords(pSketch2.LastPoint, pEd2.Location);
                dLineDirection = pRubberBandLine.Angle;
            }

            IAngularConverter pAngConv = new AngularConverterClass();

            pAngConv.SetAngle(dLineDirection, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians);

            int iSegCnt = pSegColl.SegmentCount;
            dlgSpiralParameters SpiralEntryDialog = new dlgSpiralParameters();

            string sBearing = pAngConv.GetString(pEdProps2.DirectionType, pEdProps2.DirectionUnits, pEdProps2.AngularUnitPrecision);

            SpiralEntryDialog.txtDirection.Text = sBearing;
            //Display the dialog
            DialogResult pDialogResult = SpiralEntryDialog.ShowDialog();

            esriCurveDensifyMethod DensifyMethod = esriCurveDensifyMethod.esriCurveDensifyByAngle; //default
            double dDensifyParameter             = 2 * Math.PI / 180;                              //2 degrees //default

            if (SpiralEntryDialog.optCustomDensification.Checked)
            {
                DensifyMethod = (esriCurveDensifyMethod)SpiralEntryDialog.cboDensificationType.SelectedIndex;
                if (DensifyMethod == esriCurveDensifyMethod.esriCurveDensifyByAngle)
                {
                    dDensifyParameter = Convert.ToDouble(SpiralEntryDialog.numAngleDensification.Value) * Math.PI / 180;
                }
                else
                {
                    if (!Double.TryParse(SpiralEntryDialog.txtDensifyValue.Text, out dDensifyParameter))
                    {
                        dDensifyParameter = 2;
                    }
                }
            }

            if (pDialogResult != DialogResult.OK)
            {
                return;
            }

            if (SpiralEntryDialog.txtStartRadius.Text.ToLower().Trim() == "infinity" && SpiralEntryDialog.txtEndRadius.Text.ToLower().Trim() == "infinity")
            {
                return;
            }


            double dSpiralRadius1 = Double.MaxValue; //default to infinity
            double dFromCurvature = 0;

            if (SpiralEntryDialog.txtStartRadius.Text.ToLower() != "infinity")
            {
                if (Double.TryParse(SpiralEntryDialog.txtStartRadius.Text, out dSpiralRadius1))
                {
                    dFromCurvature = 1 / dSpiralRadius1;
                }
                else
                {
                    return;
                }
            }

            double dSpiralRadius2 = Double.MaxValue; //default to infinity
            double dToCurvature   = 0;

            if (SpiralEntryDialog.txtEndRadius.Text.ToLower() != "infinity")
            {
                if (Double.TryParse(SpiralEntryDialog.txtEndRadius.Text, out dSpiralRadius2))
                {
                    dToCurvature = 1 / dSpiralRadius2;
                }
                else
                {
                    return;
                }
            }

            bool bIsCCW = (dSpiralRadius1 > dSpiralRadius2) ? SpiralEntryDialog.optRight.Checked : SpiralEntryDialog.optLeft.Checked;

            bool bSpecialCaseCircularArc = (dSpiralRadius1 == dSpiralRadius2);

            if (!pAngConv.SetString(SpiralEntryDialog.txtDirection.Text, pEdProps2.DirectionType, pEdProps2.DirectionUnits))
            {
                return;
            }

            double dNorthAzimuthRadians = pAngConv.GetAngle(esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDURadians);

            IVector3D pVec = new Vector3DClass();

            pVec.PolarSet(dNorthAzimuthRadians, 0, 500);

            IPoint pTangentPoint = new PointClass();

            pTangentPoint.PutCoords(pSketch2.LastPoint.X + pVec.XComponent, pSketch2.LastPoint.Y + pVec.YComponent);

            //double dStreamingTol = pEdProps1.StreamTolerance;
            //if (dStreamingTol == 0)
            //  dStreamingTol = 0.001 * 5000; //metric

            //double dSpiralOffsetGeometryPrecision = 0.001 * 250; //metric 0.25 m

            IPolyline6 theSpiralPolyLine = null;
            double     dExitTangent      = 0;

            if (SpiralEntryDialog.cboPathLengthParameter.SelectedIndex == 0)
            {
                double dSpiralArcLength;
                if (!Double.TryParse(SpiralEntryDialog.txtPathLengthParameter.Text, out dSpiralArcLength))
                {
                    return;
                }

                if (bSpecialCaseCircularArc)
                {
                    ILine pInTangentLine = new LineClass();
                    pInTangentLine.PutCoords(pSketch2.LastPoint, pTangentPoint);

                    ISegment pTangentSegment = (ISegment)pInTangentLine;
                    IConstructCircularArc2 pCircArcConstr = new ESRI.ArcGIS.Geometry.CircularArcClass() as IConstructCircularArc2;
                    pCircArcConstr.ConstructTangentRadiusArc(pTangentSegment, false, bIsCCW, dSpiralRadius1, dSpiralArcLength);
                    ICircularArc pArcSegment = pCircArcConstr as ICircularArc;

                    //Get chord Line from tangent curve constructor
                    ILine pChordLine = new LineClass();
                    pChordLine.PutCoords(pArcSegment.FromPoint, pArcSegment.ToPoint);
                    double dPolarRadians = pChordLine.Angle; //to get the chord azimuth

                    pCircArcConstr.ConstructBearingRadiusArc(pSketch2.LastPoint, dPolarRadians, bIsCCW, dSpiralRadius1, dSpiralArcLength);

                    dExitTangent = pArcSegment.ToAngle + Math.PI / 2;

                    ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
                    object             obj           = Type.Missing;
                    segCollection.AddSegment((ISegment)pArcSegment, ref obj, ref obj);
                    theSpiralPolyLine = segCollection as IPolyline6;
                }
                else
                {
                    theSpiralPolyLine = ConstructSpiralbyLength(pSketch2.LastPoint, pTangentPoint, dFromCurvature, dToCurvature, bIsCCW, dSpiralArcLength,
                                                                DensifyMethod, dDensifyParameter, out dExitTangent);
                }
            }

            if (SpiralEntryDialog.cboPathLengthParameter.SelectedIndex == 1)
            {
                if (!pAngConv.SetString(SpiralEntryDialog.txtPathLengthParameter.Text, esriDirectionType.esriDTPolar, pEdProps2.DirectionUnits))
                {
                    return;
                }
                double dSpiralDeltaAngle = pAngConv.GetAngle(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians);

                if (bSpecialCaseCircularArc)
                {
                    ILine pInTangentLine = new LineClass();
                    pInTangentLine.PutCoords(pSketch2.LastPoint, pTangentPoint);

                    ISegment pTangentSegment = (ISegment)pInTangentLine;
                    IConstructCircularArc2 pCircArcConstr = new ESRI.ArcGIS.Geometry.CircularArcClass() as IConstructCircularArc2;
                    pCircArcConstr.ConstructTangentRadiusAngle(pTangentSegment, false, bIsCCW, dSpiralRadius1, dSpiralDeltaAngle);
                    ICircularArc pArcSegment = pCircArcConstr as ICircularArc;

                    //Get chord Line from tangent curve constructor
                    ILine pChordLine = new LineClass();
                    pChordLine.PutCoords(pArcSegment.FromPoint, pArcSegment.ToPoint);
                    double dPolarRadians = pChordLine.Angle; //to get the chord azimuth

                    pCircArcConstr.ConstructBearingRadiusAngle(pSketch2.LastPoint, dPolarRadians, bIsCCW, dSpiralRadius1, dSpiralDeltaAngle);

                    dExitTangent = pArcSegment.ToAngle + Math.PI / 2;

                    ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
                    object             obj           = Type.Missing;
                    segCollection.AddSegment((ISegment)pArcSegment, ref obj, ref obj);
                    theSpiralPolyLine = segCollection as IPolyline6;
                }
                else
                {
                    theSpiralPolyLine = ConstructSpiralbyDeltaAngle(pSketch2.LastPoint, pTangentPoint, dFromCurvature, dToCurvature, bIsCCW, dSpiralDeltaAngle,
                                                                    DensifyMethod, dDensifyParameter, out dExitTangent);
                }
            }

            if (theSpiralPolyLine == null)
            {
                MessageBox.Show("A spiral could not be created with the entered parameters.");
                return;
            }

            ISegmentCollection pSpiralSegCollection = theSpiralPolyLine as ISegmentCollection;
            //Start a sketch operation and insert the new envelope into the sketch
            ISketchOperation2 sketchOp = new SketchOperationClass();

            sketchOp.Start(ArcMap.Editor);
            sketchOp.MenuString = "Add Spiral";
            pSegColl.AddSegmentCollection(pSpiralSegCollection);
            IGeometry geom = pSegColl as IGeometry;

            pSketch2.Geometry = geom;

            //set the angle constraint to the exit tangent of the spiral
            sketchTool.Constraint      = esriSketchConstraint.esriConstraintAngle;
            sketchTool.AngleConstraint = dExitTangent;

            sketchOp.Finish(ArcMap.Document.ActiveView.Extent, esriSketchOperationType.esriSketchOperationGeneral, null);
        }
예제 #8
0
        protected override void OnClick()
        {
            m_bNoUpdates = false;
            m_sReport    = "Direction Inverse Report:";
            IEditor m_pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

            if (m_pEd.EditState == esriEditState.esriStateNotEditing)
            {
                MessageBox.Show("Please start editing first, and try again.", "Start Editing");
                return;
            }

            UID pUID = new UIDClass();

            pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
            ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
            ICadastralEditor            pCadEd     = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

            //check if there is a Manual Mode "modify" job active ===========
            ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;

            if (pCadPacMan.PacketOpen)
            {
                MessageBox.Show("The Delete Parcels command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
                                "Delete Selected Parcels");
                return;
            }

            try
            {
                IEditProperties2 pEditorProps2 = (IEditProperties2)m_pEd;

                IArray           LineLyrArr;
                IMap             pMap       = m_pEd.Map;
                ICadastralFabric pCadFabric = null;
                //ISpatialReference pSpatRef = m_pEd.Map.SpatialReference;
                //IProjectedCoordinateSystem2 pPCS = null;
                IActiveView pActiveView = ArcMap.Document.ActiveView;

                //double dMetersPerUnit = 1;

                //if (pSpatRef == null)
                //  ;
                //else if (pSpatRef is IProjectedCoordinateSystem2)
                //{
                //  pPCS = (IProjectedCoordinateSystem2)pSpatRef;
                //  string sUnit = pPCS.CoordinateUnit.Name;
                //  if (sUnit.Contains("Foot") && sUnit.Contains("US"))
                //    sUnit = "U.S. Feet";

                //  dMetersPerUnit = pPCS.CoordinateUnit.MetersPerUnit;
                //}

                IAngularConverter pAngConv = new AngularConverterClass();
                Utilities         Utils    = new Utilities();

                if (!Utils.GetFabricSubLayers(pMap, esriCadastralFabricTable.esriCFTLines, out LineLyrArr))
                {
                    return;
                }

                //if we're in an edit session then grab the target fabric
                if (m_pEd.EditState == esriEditState.esriStateEditing)
                {
                    pCadFabric = pCadEd.CadastralFabric;
                }

                if (pCadFabric == null)
                {//find the first fabric in the map
                    if (!Utils.GetFabricFromMap(pMap, out pCadFabric))
                    {
                        MessageBox.Show
                            ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
                        return;
                    }
                }
                List <int> lstLineIds = new List <int>();

                IFeatureClass pFabricLinesFC = (IFeatureClass)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLines);
                int           idxParcelIDFld = pFabricLinesFC.Fields.FindField("ParcelID");
                int           idxCENTERPTID  = pFabricLinesFC.Fields.FindField("CenterPointID");
                int           idxRADIUS      = pFabricLinesFC.Fields.FindField("Radius");
                bool          bFieldsPresent = true;
                if (idxParcelIDFld == -1)
                {
                    bFieldsPresent = false;
                }
                if (idxCENTERPTID == -1)
                {
                    bFieldsPresent = false;
                }
                if (idxRADIUS == -1)
                {
                    bFieldsPresent = false;
                }

                if (!bFieldsPresent)
                {
                    MessageBox.Show("Fields missing.");
                    return;
                }

                Dictionary <int, List <string> > dictLineToCurveNeighbourData = new Dictionary <int, List <string> >();
                m_pFIDSetParcels = new FIDSet();
                for (int i = 0; i < LineLyrArr.Count; i++)
                {
                    IFeatureSelection pFeatSel = LineLyrArr.Element[i] as IFeatureSelection;
                    ISelectionSet     pSelSet  = pFeatSel.SelectionSet;
                    ICursor           pCursor  = null;
                    pSelSet.Search(null, false, out pCursor);
                    IFeature pLineFeat = pCursor.NextRow() as IFeature;

                    while (pLineFeat != null)
                    {
                        if (!lstLineIds.Contains(pLineFeat.OID))
                        {
                            IGeometry          pGeom    = pLineFeat.ShapeCopy;
                            ISegmentCollection pSegColl = pGeom as ISegmentCollection;
                            ISegment           pSeg     = null;
                            if (pSegColl.SegmentCount == 1)
                            {
                                pSeg = pSegColl.get_Segment(0);
                            }
                            else
                            {
                                //todo: but for now, only deals with single segment short segments
                                Marshal.ReleaseComObject(pLineFeat);
                                pLineFeat = pCursor.NextRow() as IFeature;
                                continue;
                            }

                            //check geometry for circular arc
                            if (pSeg is ICircularArc)
                            {
                                object       dVal1    = pLineFeat.get_Value(idxRADIUS);
                                object       dVal2    = pLineFeat.get_Value(idxCENTERPTID);
                                ICircularArc pCircArc = pSeg as ICircularArc;
                                if (dVal1 != DBNull.Value && dVal2 != DBNull.Value)
                                {
                                    Marshal.ReleaseComObject(pLineFeat);
                                    pLineFeat = pCursor.NextRow() as IFeature;
                                    continue;
                                }
                            }

                            //query near lines
                            int           iFoundTangent            = 0;
                            List <string> sCurveInfoFromNeighbours = new List <string>();

                            if (Utils.HasTangentCurveMatchFeatures(pFabricLinesFC, (IPolycurve)pGeom, "", 1.5, 0.033, 1, (pSeg.Length * 1.1),
                                                                   out iFoundTangent, ref sCurveInfoFromNeighbours))
                            {
                                lstLineIds.Add(pLineFeat.OID);
                                int j = (int)pLineFeat.get_Value(idxParcelIDFld);
                                m_pFIDSetParcels.Add(j);
                                dictLineToCurveNeighbourData.Add(pLineFeat.OID, sCurveInfoFromNeighbours);
                            }
                            if (iFoundTangent == 1) //if there's only one tangent look further afield
                            {
                                int iFoundLinesCount = 0;
                                int iFoundParallel   = 0;
                                if (Utils.HasParallelCurveMatchFeatures(pFabricLinesFC, (IPolycurve)pGeom, "", 1.5, 70,
                                                                        out iFoundLinesCount, out iFoundParallel, ref sCurveInfoFromNeighbours))
                                {
                                    if (!dictLineToCurveNeighbourData.ContainsKey(pLineFeat.OID))
                                    {
                                        dictLineToCurveNeighbourData.Add(pLineFeat.OID, sCurveInfoFromNeighbours);
                                    }
                                }
                            }
                        }
                        Marshal.ReleaseComObject(pLineFeat);
                        pLineFeat = pCursor.NextRow() as IFeature;
                    }
                    Marshal.ReleaseComObject(pCursor);
                }

                #region line to curve candidate analysis
                if (lstLineIds.Count == 0)
                {
                    return;
                }

                RefineToBestRadiusAndCenterPoint(dictLineToCurveNeighbourData);

                #endregion

                if (dictLineToCurveNeighbourData.Count == 0)
                {
                    return;
                }

                bool             bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
                IWorkspace       pWS               = m_pEd.EditWorkspace;
                IProgressDialog2 pProgressorDialog = null;
                IMouseCursor     pMouseCursor      = new MouseCursorClass();
                pMouseCursor.SetCursor(2);
                if (!Utils.SetupEditEnvironment(pWS, pCadFabric, m_pEd, out bIsFileBasedGDB,
                                                out bIsUnVersioned, out bUseNonVersionedDelete))
                {
                    return;
                }


                #region Create Cadastral Job
                string sTime = "";
                if (!bIsUnVersioned && !bIsFileBasedGDB)
                {
                    //see if parcel locks can be obtained on the selected parcels. First create a job.
                    DateTime localNow = DateTime.Now;
                    sTime = Convert.ToString(localNow);
                    ICadastralJob pJob = new CadastralJobClass();
                    pJob.Name        = sTime;
                    pJob.Owner       = System.Windows.Forms.SystemInformation.UserName;
                    pJob.Description = "Convert lines to curves";
                    try
                    {
                        Int32 jobId = pCadFabric.CreateJob(pJob);
                    }
                    catch (COMException ex)
                    {
                        if (ex.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_ALREADY_EXISTS)
                        {
                            MessageBox.Show("Job named: '" + pJob.Name + "', already exists");
                        }
                        else
                        {
                            MessageBox.Show(ex.Message);
                        }
                        return;
                    }
                }
                #endregion

                #region Test for Edit Locks
                ICadastralFabricLocks pFabLocks = (ICadastralFabricLocks)pCadFabric;

                //only need to get locks for parcels that have lines that are to be changed


                int[]      pParcelIds     = new int[m_pFIDSetParcels.Count()];
                ILongArray pParcelsToLock = new LongArrayClass();
                Utils.FIDsetToLongArray(m_pFIDSetParcels, ref pParcelsToLock, ref pParcelIds, m_pStepProgressor);

                if (!bIsUnVersioned && !bIsFileBasedGDB)
                {
                    pFabLocks.LockingJob = sTime;
                    ILongArray pLocksInConflict    = null;
                    ILongArray pSoftLcksInConflict = null;

                    if (m_bShowProgressor && !bIsFileBasedGDB)
                    {
                        m_pStepProgressor.Message = "Testing for edit locks on parcels...";
                    }

                    try
                    {
                        pFabLocks.AcquireLocks(pParcelsToLock, true, ref pLocksInConflict, ref pSoftLcksInConflict);
                    }
                    catch (COMException pCOMEx)
                    {
                        if (pCOMEx.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_LOCK_ALREADY_EXISTS ||
                            pCOMEx.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_CURRENTLY_EDITED)
                        {
                            MessageBox.Show("Edit Locks could not be acquired on all selected parcels.");
                            // since the operation is being aborted, release any locks that were acquired
                            pFabLocks.UndoLastAcquiredLocks();
                        }
                        else
                        {
                            MessageBox.Show(pCOMEx.Message + Environment.NewLine + Convert.ToString(pCOMEx.ErrorCode));
                        }

                        return;
                    }
                }
                #endregion

                if (m_pEd.EditState == esriEditState.esriStateEditing)
                {
                    try
                    {
                        m_pEd.StartOperation();
                    }
                    catch
                    {
                        m_pEd.AbortOperation();//abort any open edit operations and try again
                        m_pEd.StartOperation();
                    }
                }
                if (bUseNonVersionedDelete)
                {
                    if (!Utils.StartEditing(pWS, bIsUnVersioned))
                    {
                        return;
                    }
                }

                ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
                pSchemaEd.ReleaseReadOnlyFields((ITable)pFabricLinesFC, esriCadastralFabricTable.esriCFTLines); //release for edits

                m_pQF = new QueryFilter();

                // m_pEd.StartOperation();

                List <string> sInClauseList = Utils.InClauseFromOIDsList(lstLineIds, 995);
                foreach (string InClause in sInClauseList)
                {
                    m_pQF.WhereClause = pFabricLinesFC.OIDFieldName + " IN (" + InClause + ")";
                    if (!UpdateCircularArcValues((ITable)pFabricLinesFC, m_pQF, bIsUnVersioned, dictLineToCurveNeighbourData))
                    {
                        ;
                    }
                }
                m_pEd.StopOperation("Insert missing circular arc information.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                m_pEd.AbortOperation();
            }
            finally
            {
            }
        }