//Returns the XY distance in meters between two points.
        private bool DistanceBetweenPoints(IGTPoint oP1, IGTPoint oP2, ref double dDistance)
        {
            bool returnValue = false;

            try
            {
                //Create a line to measure
                IGTPolylineGeometry oPolyLineGeometry = GTClassFactory.Create <IGTPolylineGeometry>();
                oPolyLineGeometry.Points.Add(oP1);
                oPolyLineGeometry.Points.Add(oP2);
                //Get the length
                if (!MeasurePolyline(oPolyLineGeometry, ref dDistance))
                {
                    return(returnValue);
                }
                oPolyLineGeometry = null;
                returnValue       = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(Application.ApplicationWindow, ex.Message, Convert.ToString(modCPTRes.G3E_I_APP_NAME), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                returnValue = false;
            }

            return(returnValue);
        }
        //Returns the length(in meters) of a polyline geometry.
        private bool MeasurePolyline(IGTPolylineGeometry oPolyLineGeometry, ref double dLength)
        {
            bool returnValue = false;

            try
            {
                IGTMeasureService oMeasurementSvc = GTClassFactory.Create <IGTMeasureService>();
                int intMeasRefSpace = Convert.ToInt16(m_Application.GetPreference(GTPreferenceConstants.gtpcMeasurementReferenceSpace));
                oMeasurementSvc.ReferenceSpace = intMeasRefSpace;
                oMeasurementSvc.CoordSystem    = ((ICoordSystemsMgr)m_Application.DataContext.CoordSystemsMgr).BaseCoordSystem as CoordSystem;
                //Give the measurement service the geometry
                oMeasurementSvc.Geometry = oPolyLineGeometry;
                //Get the length
                dLength = System.Convert.ToInt16(oMeasurementSvc.Length);
                // Measurement service returns length in meters. Convert to feet.
                dLength = Math.Round((dLength / .3048), 0);

                oMeasurementSvc = null;
                returnValue     = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(Application.ApplicationWindow, ex.Message, System.Convert.ToString(modCPTRes.G3E_I_APP_NAME), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                returnValue = false;
            }

            return(returnValue);
        }
        private IGTPolygonGeometry GetPolyGeom(IGTPoint iPt, double xOffset, double yOffset)
        {
            IGTPolylineGeometry oPolyLineGeom = null;
            IGTPolygonGeometry  oGeom         = null;
            IGTPoint            oTmpPt;
            IGTPoint            oStartPt;
            IGTPoint            oMidPT;

            try
            {
                if (iPt == null)
                {
                    return(null);
                }
                oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();
                oGeom         = GTClassFactory.Create <IGTPolygonGeometry>();
                oTmpPt        = GTClassFactory.Create <IGTPoint>();
                oMidPT        = GTClassFactory.Create <IGTPoint>();
                oStartPt      = GTClassFactory.Create <IGTPoint>();;


                oMidPT.X = iPt.X;
                oMidPT.Y = iPt.Y + 10.0;

                oStartPt.X = oMidPT.X + (-14);
                oStartPt.Y = oMidPT.Y;
                oPolyLineGeom.Points.Add(oStartPt);

                oTmpPt.X = oMidPT.X + 14;
                oTmpPt.Y = oMidPT.Y;
                oPolyLineGeom.Points.Add(oTmpPt);

                oTmpPt.X = oTmpPt.X;
                oTmpPt.Y = oTmpPt.Y + 28;
                oPolyLineGeom.Points.Add(oTmpPt);

                oTmpPt.X = oTmpPt.X - 28;
                oTmpPt.Y = oTmpPt.Y;
                oPolyLineGeom.Points.Add(oTmpPt);

                oPolyLineGeom.Points.Add(oStartPt);

                foreach (IGTPoint pt in oPolyLineGeom.Points)
                {
                    oGeom.Points.Add(pt);
                }

                return(oGeom);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(oGeom);
            }

            finally
            {
            }
        }
Exemple #4
0
        private void DoLineGeometryByFID(List <AssetHistory> objHistList, int iFID)
        {
            try
            {
                IGTGeometry[] arrGeoms;
                object[]      arrStyles;
                object[]      arrToolTips;
                string        sDisplayName = string.Empty;

                IGTPolylineGeometry oPolyLine = GTClassFactory.Create <IGTPolylineGeometry>();

                string sFID = iFID.ToString();


                foreach (AssetHistory objToUse in objHistList)
                {
                    IGTPoint apoint = GTClassFactory.Create <IGTPoint>();

                    apoint.X = objToUse.OGG_X1;
                    apoint.Y = objToUse.OGG_Y1;
                    apoint.Z = objToUse.OGG_Z1;

                    oPolyLine.Points.Add(apoint);
                }

                if (oPolyLine.Points.Count > 0)
                {
                    arrGeoms    = new IGTGeometry[1];
                    arrStyles   = new object[1];
                    arrToolTips = new object[1];

                    arrGeoms[0]    = (IGTGeometry)oPolyLine;
                    arrStyles[0]   = this.oGenParams.HistoricalSymbol;
                    arrToolTips[0] = "FID " + sFID;
                    sDisplayName   = "Line FID " + sFID;


                    this.oDisplay.AppendTemporaryGeometries(sDisplayPathName, sDisplayName, arrGeoms, arrStyles, arrToolTips, true, true);
                }

                this.oApp.RefreshWindows();
            }
            catch (Exception ex)
            {
                CommandUtilities.LogException(oDiag, "CCStreetLightTracker.DoLineGeometry", ex);
                throw ex;
            }
        }
Exemple #5
0
        private void CreateLeaderLine(IGTKeyObject p_WPKeyObject, double p_X1, double p_Y2)
        {
            try
            {
                IGTComponent oCUComponent = p_WPKeyObject.Components.GetComponent(42);

                if (oCUComponent != null)
                {
                    if (oCUComponent.Recordset != null)
                    {
                        if (oCUComponent.Recordset.RecordCount == 0)
                        {
                            oCUComponent.Recordset.AddNew();
                            oCUComponent.Recordset.Fields["G3E_FID"].Value = p_WPKeyObject.FID;
                            oCUComponent.Recordset.Fields["G3E_FNO"].Value = 191;
                            oCUComponent.Recordset.Fields["G3E_CNO"].Value = 42;

                            IGTPolylineGeometry gTPolylineGeometry = GTClassFactory.Create <IGTPolylineGeometry>();
                            IGTPoint            gTPoint1           = GTClassFactory.Create <IGTPoint>();
                            IGTPoint            gTPoint2           = GTClassFactory.Create <IGTPoint>();

                            gTPoint1.X = ((IGTOrientedPointGeometry)(p_WPKeyObject.Components.GetComponent(19102).Geometry)).FirstPoint.X;
                            gTPoint1.Y = ((IGTOrientedPointGeometry)(p_WPKeyObject.Components.GetComponent(19102).Geometry)).FirstPoint.Y;

                            gTPoint2.X = p_X1;
                            gTPoint2.Y = p_Y2;

                            gTPolylineGeometry.Points.Add(gTPoint1);
                            gTPolylineGeometry.Points.Add(gTPoint2);

                            oCUComponent.Geometry = gTPolylineGeometry;
                            oCUComponent.Recordset.Update();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private bool StoreLinePoints(IGTPolylineGeometry oPolyLineGeom, int iFNO, int lFID)
        {
            bool bReturnValue = false;

            try
            {
                IGTPoints oPnts = oPolyLineGeom.Points;

                //Get the size of the current array of unsorted points
                int j = m_aSortedPoints.Length - 1;

                //Set the new upper boundary for the array
                int k = j + oPnts.Count;

                //Reallocate memory for the new points
                Array.Resize(ref m_aSortedPoints, k);

                //Store the values in the array
                for (int i = j; i < k; i++)
                {
                    m_aSortedPoints[i].oPnt = oPnts[i - j];
                    m_aSortedPoints[i].iFNO = iFNO;
                    m_aSortedPoints[i].lFID = lFID;

                    //Set the endpoint indicator after loop
                    m_aSortedPoints[i].IsEndPoint = false;
                }
                m_aSortedPoints[j].IsEndPoint     = true;
                m_aSortedPoints[k - 1].IsEndPoint = true;
                oPnts = null;

                bReturnValue = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_PROCESSING_GEOMETRY + ": " + ex.Message, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                bReturnValue = false;
            }

            return(bReturnValue);
        }
        /// <summary>
        /// Method create new polygon
        /// </summary>
        /// <param name="m_TargetPolygon"></param>
        /// <returns></returns>
        private IGTCompositePolygonGeometry CreatePolygon(IGTGeometry m_gTargetPolygon)
        {
            IGTPolylineGeometry         m_gPolylineGeometry         = GTClassFactory.Create <IGTPolylineGeometry>();
            IGTCompositePolygonGeometry m_gCompositePolygonGeometry = GTClassFactory.Create <IGTCompositePolygonGeometry>();
            IGTGeometryCollection       m_gGeometryCollection       = GTClassFactory.Create <IGTGeometryCollection>();

            try
            {
                //Remove duplicate points from New polygon
                for (int i = 0; i < m_gTargetPolygon.KeypointCount; i++)
                {
                    if (i > 0 && i < m_gTargetPolygon.KeypointCount - 1)
                    {
                        if (!m_gTargetPolygon.GetKeypointPosition(i).PointsAreEqual(m_gTargetPolygon.GetKeypointPosition(i + 1)))
                        {
                            m_gPolylineGeometry.Points.Add(m_gTargetPolygon.GetKeypointPosition(i));
                        }
                    }
                    else
                    {
                        m_gPolylineGeometry.Points.Add(m_gTargetPolygon.GetKeypointPosition(i));
                    }
                }

                //Add polylines to the collection
                m_gGeometryCollection.Add(m_gPolylineGeometry);

                //Build composite polygon
                foreach (IGTPolylineGeometry m_gtPolylineGeometry in m_gGeometryCollection)
                {
                    m_gCompositePolygonGeometry.Add(m_gtPolylineGeometry);
                }
                return(m_gCompositePolygonGeometry);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// Custom command mouse move event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void m_oGTCustomCommandHelper_MouseMove(object sender, GTMouseEventArgs e)
        {
            m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpCrossHair;
            if ((m_blFirstPointSelected))
            {
                m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg2);
                m_blSecondPointSelected = true;
                m_blPointSelected       = false;

                m_oEditService.TargetMapWindow = m_oGTApplication.ActiveMapWindow;
                m_oEditService.RemoveAllGeometries();

                //Snap to the Selected Geomentry
                m_secondtPoint = GetSnapPoint(m_gSrcGeometry, e.WorldPoint);

                //Append points to Line geometry
                m_gLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();
                m_gLineGeom.Points.Add(m_firstPoint);
                m_gLineGeom.Points.Add(m_secondtPoint);

                //Add Geometry to edit service
                m_oEditService.AddGeometry(m_gLineGeom, Convert.ToInt32(310000042));

                //Begin move from snap point
                m_oEditService.BeginMove(e.WorldPoint);
            }
            else
            {
                m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg1);
                if (!m_blPointSelected)
                {
                    m_blFirstPointSelected = false;
                    m_blPointSelected      = true;
                }
            }
        }
Exemple #9
0
        private IGTPolygonGeometry GetPolyGeom(IGTPoint iPt, double xOffset, double yOffset, double length = 0)
        {
            try
            {
                if (iPt == null)
                {
                    return(null);
                }
                IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();
                IGTPolygonGeometry  oGeom         = GTClassFactory.Create <IGTPolygonGeometry>();
                IGTPoint            oTmpPt        = GTClassFactory.Create <IGTPoint>();
                IGTPoint            oMidPT        = GTClassFactory.Create <IGTPoint>();
                IGTPoint            oStartPt      = GTClassFactory.Create <IGTPoint>();;

                oMidPT.X = iPt.X;
                oMidPT.Y = iPt.Y;

                if (length > 0)
                {
                    //oStartPt.X = oMidPT.X;
                    //oStartPt.Y = oMidPT.Y - (length/2);
                    //oPolyLineGeom.Points.Add(oStartPt);

                    //oTmpPt.X = oStartPt.X + (length/2);
                    //oTmpPt.Y = oStartPt.Y;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oTmpPt.X = oTmpPt.X;
                    //oTmpPt.Y = oTmpPt.Y + length;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oTmpPt.X = oTmpPt.X - length;
                    //oTmpPt.Y = oTmpPt.Y;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oPolyLineGeom.Points.Add(oStartPt);

                    oStartPt.X = oMidPT.X;
                    oStartPt.Y = oMidPT.Y - 5;
                    oPolyLineGeom.Points.Add(oStartPt);

                    oTmpPt.X = oStartPt.X + 5;
                    oTmpPt.Y = oStartPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y + 10;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X - 10;
                    oTmpPt.Y = oTmpPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y - 10;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oPolyLineGeom.Points.Add(oStartPt);
                }

                else
                {
                    oStartPt.X = oMidPT.X + (-14);
                    oStartPt.Y = oMidPT.Y;
                    oPolyLineGeom.Points.Add(oStartPt);

                    oTmpPt.X = oMidPT.X + 14;
                    oTmpPt.Y = oMidPT.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y + 28;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X - 28;
                    oTmpPt.Y = oTmpPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oPolyLineGeom.Points.Add(oStartPt);
                }
                foreach (IGTPoint pt in oPolyLineGeom.Points)
                {
                    oGeom.Points.Add(pt);
                }

                return(oGeom);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        //public string node1Structure

        public bool ProcessSelectSet()
        {
            bool bReturnValue = false;

            try
            {
                m_aSortedPoints = new CablePullPoint[1];
                m_aSegments     = new CablePullSegment[1];

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                relationshipService.DataContext = m_Application.DataContext;
                int index = 0;
                m_SelectedFID = oGTDCKeys[index].FID;
                m_SelectedFNO = oGTDCKeys[index].FNO;
                relationshipService.ActiveFeature = m_Application.DataContext.OpenFeature(m_SelectedFNO, m_SelectedFID);

                if (relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value != null)
                {
                    m_featureState = relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value.ToString();
                }

                if (relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.RecordCount > 0)
                {
                    relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.MoveFirst();
                    m_CU = relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.Fields["CU_C"].Value.ToString();
                }

                if (CommonDT.AllowCUEdit(relationshipService.ActiveFeature))
                {
                    m_AllowCUEdit = true;
                }
                else
                {
                    m_AllowCUEdit = false;
                }

                int ductBankFID = 0;

                try
                {
                    IGTKeyObjects relatedDuctKOs = relationshipService.GetRelatedFeatures(6);

                    if (relatedDuctKOs.Count > 0)
                    {
                        relationshipService.ActiveFeature = relatedDuctKOs[0];
                        IGTKeyObjects relatedFormationKOs = relationshipService.GetRelatedFeatures(6);
                        if (relatedFormationKOs.Count > 0)
                        {
                            relationshipService.ActiveFeature = relatedFormationKOs[0];
                            IGTKeyObjects relatedDuctBankKOs = relationshipService.GetRelatedFeatures(3);
                            if (relatedDuctBankKOs.Count > 0)
                            {
                                ductBankFID = relatedDuctBankKOs[0].FID;
                                relationshipService.ActiveFeature = relatedDuctBankKOs[0];
                                IGTKeyObjects structure1 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                IGTKeyObjects structure2 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                                if (structure1.Count > 0)
                                {
                                    IGTKeyObject thing = structure1[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node1Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                                if (structure2.Count > 0)
                                {
                                    IGTKeyObject thing = structure2[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node2Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_NO_RELATED_DUCTBANK, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                catch
                {
                }


                // Get the primary geographic and primary detail componentviews from metadata
                // Get the selected object matching the primary geographic or primary detail componentviews in that order
                Recordset metadataRS           = m_Application.DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + ConstantsDT.FNO_DUCTBANK);
                short     primaryGeographicCNO = 0;
                short     primaryDetailCNO     = 0;
                if (metadataRS.RecordCount > 0)
                {
                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value))
                    {
                        primaryGeographicCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value);
                    }

                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value))
                    {
                        primaryDetailCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value);
                    }
                }

                IGTDDCKeyObjects oDuctBankGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oDuctBankGTDCKeys = m_Application.DataContext.GetDDCKeyObjects(ConstantsDT.FNO_DUCTBANK, ductBankFID, GTComponentGeometryConstants.gtddcgAllPrimary);

                metadataRS = m_Application.DataContext.MetadataRecordset("G3E_COMPONENTVIEWS_OPTABLE");
                string filter = "(g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryGeographicCNO + ") or (g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryDetailCNO + ")";
                metadataRS.Filter = filter;
                if (metadataRS.RecordCount > 0)
                {
                    metadataRS.Sort = "g3e_detail";

                    while (!metadataRS.EOF)
                    {
                        if (metadataRS.Fields["G3E_VIEW"].Value.ToString() == oDuctBankGTDCKeys[index].ComponentViewName)
                        {
                            //m_SelectedFID = oGTDCKeys[index].FID;
                            //m_SelectedFNO = oGTDCKeys[index].FNO;
                            break;
                        }
                        metadataRS.MoveNext();
                        index++;
                    }


                    IGTGeometry         oGeometry     = oDuctBankGTDCKeys[index].Geometry;
                    IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();

                    if (oGeometry.Type == GTGeometryTypeConstants.gtgtPolylineGeometry || oGeometry.Type == GTGeometryTypeConstants.gtgtLineGeometry)
                    {
                        // Geometry is okay to use as it is.
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry;
                        bReturnValue  = true;
                    }
                    else if (oGeometry.Type == GTGeometryTypeConstants.gtgtCompositePolylineGeometry)
                    {
                        // Any arcs must be stroked to line segments
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry.Stroke();
                        bReturnValue  = true;
                    }
                    else
                    {
                        // Invalid geometry type.
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_GEOMETRY, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        bReturnValue = false;
                    }

                    if (bReturnValue)
                    {
                        // Store each point of the line in the feature's geometry
                        StoreLinePoints(oPolyLineGeom, m_SelectedFNO, m_SelectedFID);

                        //Compute the included angles for each set of three points in the sorted array
                        ComputeIncludedAngles();

                        //Build the arrays for the segments and bends that will comprise the pull
                        if (!BuildSegmentsAndBends())
                        {
                            bReturnValue = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_COMPONENT_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    bReturnValue = false;
                }
            }
            catch (Exception e)
            {
                m_aSegments     = new CablePullSegment[1];
                m_aBends        = new double[1];
                m_aSortedPoints = new CablePullPoint[1];
            }

            return(bReturnValue);
        }
Exemple #11
0
        /// <summary>
        /// Method to apply offset to removal feature / old feature
        /// </summary>
        /// <param name="sqlString"></param>
        /// <returns></returns>
        private void ApplyOffSetToGraphicComponents(short featureFNO, int featureFID)
        {
            IGTPoint point = null;

            try
            {
                IGTKeyObject  feature       = m_iGtApplication.DataContext.OpenFeature(featureFNO, featureFID);
                IGTComponents allComponents = feature.Components;
                feature.Components.GetComponent(1).Recordset.MoveFirst();
                string sStructureID = Convert.ToString(feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value);

                foreach (IGTComponent component in allComponents)
                {
                    if (!IsGraphicGeoComp(component.CNO))
                    {
                        continue;
                    }

                    if (component.Geometry == null)
                    {
                        continue;
                    }
                    switch (component.Geometry.Type)
                    {
                    case GTGeometryTypeConstants.gtgtOrientedPointGeometry:
                        IGTOrientedPointGeometry orientedPtGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>();
                        point   = GTClassFactory.Create <IGTPoint>();
                        point.X = component.Geometry.FirstPoint.X + m_offSetX;
                        point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                        orientedPtGeometry.Origin      = point;
                        orientedPtGeometry.Orientation = ((IGTOrientedPointGeometry)component.Geometry).Orientation;
                        component.Geometry             = orientedPtGeometry;
                        break;

                    case GTGeometryTypeConstants.gtgtTextPointGeometry:
                        IGTTextPointGeometry textPtGeometry = GTClassFactory.Create <IGTTextPointGeometry>();
                        point   = GTClassFactory.Create <IGTPoint>();
                        point.X = component.Geometry.FirstPoint.X + m_offSetX;
                        point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                        textPtGeometry.Origin = point;
                        textPtGeometry.Normal = ((IGTOrientedPointGeometry)component.Geometry).Orientation;
                        component.Geometry    = textPtGeometry;
                        break;

                    case GTGeometryTypeConstants.gtgtPolylineGeometry:
                        IGTPolylineGeometry newFtPlineGeo = GTClassFactory.Create <IGTPolylineGeometry>();
                        for (int k = 0; k <= component.Geometry.KeypointCount - 1; k++)
                        {
                            point   = GTClassFactory.Create <IGTPoint>();
                            point.X = component.Geometry.GetKeypointPosition(k).X + m_offSetX;
                            point.Y = component.Geometry.GetKeypointPosition(k).Y + m_offSetY;
                            newFtPlineGeo.Points.Add(point);
                        }
                        component.Geometry = newFtPlineGeo;
                        break;

                    case GTGeometryTypeConstants.gtgtCompositePolylineGeometry:
                        IGTCompositePolylineGeometry newFtCpline          = GTClassFactory.Create <IGTCompositePolylineGeometry>();
                        IGTPolylineGeometry          polylineGeometrytemp = GTClassFactory.Create <IGTPolylineGeometry>();
                        foreach (IGTGeometry subgeom in (IGTCompositePolylineGeometry)component.Geometry)
                        {
                            switch (subgeom.Type)
                            {
                            case GTGeometryTypeConstants.gtgtPointGeometry:
                            case GTGeometryTypeConstants.gtgtOrientedPointGeometry:
                                point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                break;

                            case GTGeometryTypeConstants.gtgtLineGeometry:
                                point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                point.X = component.Geometry.LastPoint.X + m_offSetX;
                                point.Y = component.Geometry.LastPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                break;

                            case GTGeometryTypeConstants.gtgtPolylineGeometry:
                                for (int k = 0; k < subgeom.KeypointCount; k++)
                                {
                                    point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                    point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                    polylineGeometrytemp.Points.Add(point);
                                }
                                break;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }

                feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value = sStructureID; //Reset the Structure ID to original value. The update is needed as Set Structure Locaiton FI changed the original Structure ID
                UpdateAssociatedWorkPointsStructureId(feature.FNO, feature.FID, sStructureID);            //Update all the WP associated with the feature
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Command Click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e)
        {
            try
            {
                m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow;
                if (m_blPointSelected)
                {
                    //Snap to the Selected Geomentry
                    m_firstPoint = GetSnapPoint(m_gSrcGeometry, e.WorldPoint);

                    m_blFirstPointSelected  = true;
                    m_blSecondPointSelected = false;
                    m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg1);
                }
                if ((m_blFirstPointSelected) && (m_blSecondPointSelected))
                {
                    try
                    {
                        m_oEditService.EndMove(e.WorldPoint);
                        m_blFirstPointSelected = false;
                        m_oGTTransactionManager.Begin("Divide Landbase Boundries");

                        // Get the Located object and snap the destination to nearest vertex.
                        IGTDDCKeyObjects m_oLocatedObjects = m_oGTApplication.ActiveMapWindow.LocateService.Locate(e.WorldPoint, 3, 1, GTSelectionTypeConstants.gtmwstSelectSingle);
                        m_secondtPoint = GetSnapPoint(m_oLocatedObjects[0].Geometry, e.WorldPoint);

                        //Perform the break Polygon
                        IGTGeometry[] m_gTargetPolygons = m_gSrcGeometry.BreakPolygon(m_gLineGeom);

                        //Intialise two polygons
                        IGTKeyObject m_oFirstPolygon  = m_oGTApplication.DataContext.OpenFeature(m_sourceFNO, m_sourceFID);
                        IGTKeyObject m_oSecondPolygon = m_oGTApplication.DataContext.NewFeature(m_sourceFNO);

                        //Set the geometry with the newly created ones.
                        m_oFirstPolygon.Components.GetComponent(m_primaryGeoCNO).Geometry  = CreatePolygon(m_gTargetPolygons[0]);
                        m_oSecondPolygon.Components.GetComponent(m_primaryGeoCNO).Geometry = CreatePolygon(m_gTargetPolygons[1]);

                        //Fetch the required components
                        Recordset rsFirstFeature  = m_oFirstPolygon.Components.GetComponent(m_landbaseCNO).Recordset;
                        Recordset rsSecondFeature = m_oSecondPolygon.Components.GetComponent(m_landbaseCNO).Recordset;

                        //Assign required field values
                        rsSecondFeature.Fields["SOURCE"].Value       = rsFirstFeature.Fields["SOURCE"].Value;
                        rsSecondFeature.Fields["CREATED_BY"].Value   = m_oGTApplication.DataContext.DatabaseUserName;
                        rsSecondFeature.Fields["CREATED_DATE"].Value = System.DateTime.Today;
                        rsSecondFeature.Fields["STAGE"].Value        = "Accepted";

                        m_oGTTransactionManager.Commit();
                        m_oGTTransactionManager.RefreshDatabaseChanges();

                        m_oGTApplication.RefreshWindows();
                        m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Commit complete");
                        m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow;
                        m_oGTCustomCommandHelper.Complete();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(sStatusBarMsg3, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg3);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                ExitCommand();
            }
            finally
            {
                if (m_blSecondPointSelected)
                {
                    m_gLineGeom    = null;
                    m_gSrcGeometry = null;
                    m_oEditService.RemoveAllGeometries();
                    m_oEditService = null;
                    ExitCommand();
                }
            }
        }