/// <summary> /// Set Right Node Values /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetRightOriginPoint(IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry) { try { IGTPoint m_gtRightOriginPoint = null; //set the node value for Bypass point placed at Right if ((m_rlnode1 != 0) && (m_rlnode1 == m_rpnode2)) { m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = m_rlnode1; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, -xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } return(m_gtRightOriginPoint); } catch { throw; } }
//Dictionary<short, short> m_fnoGraphicCnoPair; //Dictionary<short, short> m_FnoAttributeCnoPair; /// <summary> /// Custom Boundary Query /// </summary> /// <param name="point"></param> /// <param name="boundaryFno"></param> public customBoundaryQuery(IGTPoint point, short boundaryFno) { this.m_iGtpoint = point; this.m_boundaryFno = boundaryFno; this.m_iGtApplication = GTClassFactory.Create <IGTApplication>(); this.m_iGtDataContext = m_iGtApplication.DataContext; }
/// <summary> /// Get Segment And Angle on which point is placed /// </summary> /// <param name="m_gtPolylineGeometry"></param> /// <param name="gtPoint"></param> /// <returns></returns> protected IGTGeometry GetSegmentAndAngle(IGTGeometry m_gtPolylineGeometry, IGTPoint gtPoint) { bool flag = false; IGTGeometry m_gtPolylineGeometrySegment = GTClassFactory.Create <IGTGeometry>(); IGTSegment m_gtSegment = GTClassFactory.Create <IGTSegment>(); IGTPoint m_gtsnapPoint = GetSnapPoint(m_gtPolylineGeometry, gtPoint); try { if (m_gtPolylineGeometry.Type == "CompositePolylineGeometry") { //get the segment for (int i = 0; i < m_gtPolylineGeometry.KeypointCount - 1; i++) { m_gtSegment.Begin = m_gtPolylineGeometry.GetKeypointPosition(i); m_gtSegment.End = m_gtPolylineGeometry.GetKeypointPosition(i + 1); if (m_gtsnapPoint.IsOn(m_gtSegment)) { flag = true; break; } } if (flag) { m_gtPolylineGeometrySegment = m_gtPolylineGeometry.ExtractGeometry(m_gtSegment.Point1, m_gtSegment.Point2, false); } } return(m_gtPolylineGeometrySegment); } catch { throw; } }
/// <summary> /// Get Angle Between Two Points /// </summary> /// <param name="gtStartPoint"></param> /// <param name="gtEndPoint"></param> /// <returns></returns> protected double AngleBetweenTwoPoints(IGTPoint gtStartPoint, IGTPoint gtEndPoint) { double deltaX = gtEndPoint.X - gtStartPoint.X; double deltaY = gtEndPoint.Y - gtStartPoint.Y; return(Math.Atan2(deltaY, deltaX)); }
/// <summary> /// This method is used to get the tool tip of the selected temporary geometry. /// </summary> /// <param name="gTDisplayService"></param> /// <param name="strTempGeoDisplayPath"></param> /// <param name="strTempGeoDisplayName"></param> /// <param name="strTempGeoToolTip"></param> /// <returns></returns> private string GetToolTipOfTemporaryGeometry(IGTDisplayService gTDisplayService, out string strTempGeoDisplayPath, out string strTempGeoDisplayName, string strTempGeoToolTip) { strTempGeoDisplayPath = gTDisplayService.SelectedDisplayControlNode.DisplayPathName; strTempGeoDisplayName = gTDisplayService.SelectedDisplayControlNode.DisplayName; if (!string.IsNullOrEmpty(strTempGeoDisplayPath) && !string.IsNullOrEmpty(strTempGeoDisplayName)) { IGTPoint ptTempGeo = gTDisplayService.GetRange(strTempGeoDisplayPath, strTempGeoDisplayName).BottomLeft; IGTDDCKeyObjects gTDDCTempGeoKeyObjects = assetHistoryModel.m_Application.ActiveMapWindow.LocateService.Locate(ptTempGeo, 5, -1, GTSelectionTypeConstants.gtmwstSelectAll); if (gTDDCTempGeoKeyObjects.Count > 0) { foreach (IGTDDCKeyObject ddcKey in gTDDCTempGeoKeyObjects) { if (ddcKey.FNO == 400) { strTempGeoToolTip = Convert.ToString(gTDDCTempGeoKeyObjects[0].Recordset.Fields["G3E_TOOLTIP"].Value); break; } } } } if (string.IsNullOrEmpty(strTempGeoToolTip)) { strTempGeoToolTip = gTDisplayService.SelectedDisplayControlNode.DisplayName; } return(strTempGeoToolTip); }
/// <summary> /// Support method for Geocode locate. May be removed at a later date. /// </summary> /// <param name="x"></param> /// <param name="y"></param> internal static void geoLocate(double x, double y) { gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; gtGeoEditService.RemoveAllGeometries(); gtApp.ActiveMapWindow.DisplayScale = 250; IGTPoint locationPoint = gCoordinateConvert(x, y, 0); IGTWorldRange gtWorldRange = gtApp.ActiveMapWindow.GetRange(); double xOffset = (gtWorldRange.TopRight.X - gtWorldRange.BottomLeft.X) / 2; double yOffset = (gtWorldRange.TopRight.Y - gtWorldRange.BottomLeft.Y) / 2; IGTPoint tempPt = GTClassFactory.Create <IGTPoint>(); tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X + xOffset; tempPt.Y = locationPoint.Y + yOffset; gtWorldRange.TopRight = tempPt; tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X - xOffset; tempPt.Y = locationPoint.Y - yOffset; gtWorldRange.BottomLeft = tempPt; gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; IGTPointGeometry newSymbol = GTClassFactory.Create <IGTPointGeometry>(); newSymbol.Origin = locationPoint; gtGeoEditService.AddGeometry(newSymbol, Convert.ToInt16(GTStyleIDConstants.gtstyleHandleSquareX)); gtApp.ActiveMapWindow.DisplayScale = 250; gtApp.ActiveMapWindow.ZoomArea(gtWorldRange); gtApp.RefreshWindows(); }
public void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject) { //Reading the arguments IGTPolygonGeometry oCPLGeom = null; double XOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString()); double YOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString()); if (selectedObject.Geometry.Type == "OrientedPointGeometry") { IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry; oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset); RotateGeom(iPointGeom, ref oCPLGeom); } else if (selectedObject.Geometry.Type == "PolygonGeometry") //GTGeometryTypeConstants.gtgtPolygonGeometry { IGTPolygonGeometry iPolygonGeom = (IGTPolygonGeometry)selectedObject.Geometry; // We do not know what is the first placement point. So we will loop through all the points and grab one point from two identical points // because First and Last point would be same // TODO Is there any better way ? To confirm.. var dupPoint = from p in iPolygonGeom.Points group p by p.X into g where g.Count() > 1 select g.ToString(); IGTPoint duplicated = iPolygonGeom.Points.First(p => dupPoint.Contains(p.X.ToString())); oCPLGeom = GetPolyGeom(duplicated, XOffset, YOffset); RotateGeom(iPolygonGeom, ref oCPLGeom); } if (oCPLGeom != null) { m_PTHelper.SetGeometry(oCPLGeom); m_PTHelper.EndPlacement(); this.AssemblyCopyToModel(oCPLGeom); } }
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 { } }
private void ExtendFollowingAutoFitRules(IGTMapWindow window, IGTWorldRange range) { try { double extentX = range.TopRight.X - range.BottomLeft.X; double extentY = range.TopRight.Y - range.BottomLeft.Y; double extendBY; if (extentY < 0 || extentX < 0) { return; } if (extentY < 1 && extentX < 1) { extendBY = AverageSymbolSize * 4; } else { extendBY = Math.Max(extentX, extentY) * (window.SelectBehaviorZoomFactor - 1); } IGTPoint tr = GTClassFactory.Create <IGTPoint>(range.TopRight.X + extendBY, range.TopRight.Y + extendBY, 0); IGTPoint bl = GTClassFactory.Create <IGTPoint>(range.BottomLeft.X - extendBY, range.BottomLeft.Y - extendBY, 0); range.BottomLeft = bl; range.TopRight = tr; } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Left Origin Point /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetLeftOriginPoint(IGTKeyObject m_KeyObject, IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry, IGTKeyObjects m_gtRelativeLines) { try { //Get Left Origin Point IGTPoint m_gtLeftOriginPoint = null; IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); m_gtRelationshipService.DataContext = m_gtApplication.DataContext; if (m_rlnode2 != 0) { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, xOffset, 0); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); //establish the relationship m_gtRelationshipService.ActiveFeature = m_KeyObject; m_gtRelationshipService.SilentEstablish(iRNO, m_gtRelativeLines[0], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, -xOffset, 0); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); } m_gtRelationshipService = null; return(m_gtLeftOriginPoint); } catch { throw; } }
/// <summary> /// Method to create Work Label geometry /// </summary> /// <param name="wpGeometry"> WorkPoint geometry</param> /// <param name="tTVfeature"> Tree trimming feature </param> /// <param name="cid">cid</param> private void CreateWorkLabelGeometry(IGTOrientedPointGeometry wpGeometry, IGTKeyObject tTVfeature, short cid) { try { IGTTextPointGeometry iGtTxtPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint textPoint = GTClassFactory.Create <IGTPoint>(); textPoint.X = wpGeometry.Origin.X + Convert.ToDouble(m_Arguments.GetArgument(0)); textPoint.Y = wpGeometry.Origin.Y + Convert.ToDouble(m_Arguments.GetArgument(1)); textPoint.Z = 0; iGtTxtPointGeometry.Origin = textPoint; IGTComponent igtComponent = tTVfeature.Components.GetComponent(19006); if (igtComponent.Recordset.RecordCount != 0) { igtComponent.Recordset.MoveLast(); } igtComponent.Recordset.AddNew("G3E_FID", tTVfeature.FID); igtComponent.Recordset.Fields["G3E_FNO"].Value = 190; igtComponent.Recordset.Fields["G3E_CNO"].Value = 19006; igtComponent.Recordset.Fields["G3E_CID"].Value = cid; igtComponent.Geometry = iGtTxtPointGeometry; igtComponent.Recordset.Update(System.Type.Missing, System.Type.Missing); } catch (Exception) { throw; } }
//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); }
/// <summary> /// Calculate Centroid for given boundayr Geometry /// </summary> /// <param name="gtGeometry"></param> /// <returns></returns> public IGTPoint CalculateCentroid(IGTGeometry gtGeometry) { IGTPoint gtCenterPt = GTClassFactory.Create <IGTPoint>(); gtCenterPt.X = 0; gtCenterPt.Y = 0; gtCenterPt.Z = 0; if (gtGeometry.KeypointCount > 1) { for (int indx = 0; indx < gtGeometry.KeypointCount - 1; indx++) { gtCenterPt.X += gtGeometry.GetKeypointPosition(indx).X; gtCenterPt.Y += gtGeometry.GetKeypointPosition(indx).Y; gtCenterPt.Z += gtGeometry.GetKeypointPosition(indx).Z; } gtCenterPt.X /= gtGeometry.KeypointCount - 1; gtCenterPt.Y /= gtGeometry.KeypointCount - 1; gtCenterPt.Z /= gtGeometry.KeypointCount - 1; } else { gtCenterPt = gtGeometry.FirstPoint; } return(gtCenterPt); }
/// <summary> /// Method to which convert a point to Paper coordinates /// </summary> /// <param name="p_plotMap">Plot Map</param> /// <param name="p_ptWorld">Point which needs to be convereted to Paper coordinates</param> /// <returns></returns> private IGTPoint WorldToPaper(IGTPlotMap p_plotMap, IGTPoint p_ptWorld) { try { return(p_plotMap.WorldToPaper(p_ptWorld)); } catch { return(null); } }
/// <summary> /// Angle Between Two Points /// </summary> /// <param name="gtStartPoint"></param> /// <param name="gtEndPoint"></param> /// <returns></returns> protected double AngleBetweenTwoPoints(IGTPoint gtStartPoint, IGTPoint gtEndPoint) { double deltaX = gtEndPoint.X - gtStartPoint.X; double deltaY = gtEndPoint.Y - gtStartPoint.Y; //TODO 3D oOffset.Z = oEndPoint.Z - oStartPoint.Z; return(Math.Atan2(deltaY, deltaX)); }
public customBufferQuery(IGTPoint point, double distance, short fno) { this.m_referencePoint = point; this.m_distance = distance; this.m_targetFno = fno; this.m_iGtApplication = GTClassFactory.Create <IGTApplication>(); this.m_iGtDataContext = m_iGtApplication.DataContext; }
public customBufferQuery(IGTPoint point, double distance, short fno) { this.m_referencePoint = point; this.m_distance = distance * 3.28084; // Input is in meters, convert meters to feet -- 1 m = 3.28084 ft this.m_targetFno = fno; this.m_iGtApplication = GTClassFactory.Create <IGTApplication>(); this.m_iGtDataContext = m_iGtApplication.DataContext; }
private double GetAngleByTwoPoints(IGTPoint oP1, IGTPoint oP2) { double returnValue = 0; double dRetVal = 0; double dXVal = oP2.X - oP1.X; double dYVal = oP2.Y - oP1.Y; if ((int)dXVal == 0) { if (dYVal > 0) { dRetVal = 90; } else if (dYVal < 0) { dRetVal = 270; } else if ((int)dYVal == 0) { //Should never happen - points would be coincident. //Default to zero degrees. dRetVal = 0; } } else if (dXVal > 0) { if (dYVal > 0) { //First quadrant dRetVal = System.Math.Atan(System.Convert.ToDouble(dYVal / dXVal)) * (180.0 / Math.PI);// RadiansToDegrees; } else if (dYVal < 0) { //Fourth quadrant dRetVal = System.Math.Atan(System.Convert.ToDouble(dYVal / dXVal)) * (180.0 / Math.PI);// RadiansToDegrees; } else if ((int)dYVal == 0) { dRetVal = 0; } } else if (dXVal < 0) { if ((int)dYVal == 0) { dRetVal = 180; } else { //Second or third quadrant dRetVal = System.Math.Atan(System.Convert.ToDouble(dYVal / dXVal)) * (180.0 / Math.PI);// RadiansToDegrees; dRetVal = dRetVal + 180; } } returnValue = System.Convert.ToDouble(dRetVal); return(returnValue); }
/// <summary> /// customBoundaryQuery /// </summary> /// <param name="Point"></param> /// <param name="PointFno"></param> /// <param name="BoundaryFno"></param> /// <param name="BoundryFid"></param> public customBoundaryQuery(IGTPoint Point, short PointFno, short BoundaryFno, int BoundryFid) { this.m_iGtpoint = Point; this.m_pointFno = PointFno; this.m_boundaryFno = BoundaryFno; this.m_boundaryFid = BoundryFid; this.m_iGtApplication = GTClassFactory.Create <IGTApplication>(); this.m_iGtDataContext = m_iGtApplication.DataContext; }
private void GetAssemblyPointsAndOrientation(IGTPolygonGeometry oGeometry, ref double dOrientation) { double pi = 0.0; double dx = 0.0; double dy = 0.0; string sCoordinates1 = string.Empty; pi = 4 * System.Math.Atan(1); dOrientation = 0; try { IGTPoint oPoint0 = oGeometry.Points[0]; IGTPoint oPoint1 = oGeometry.Points[1]; IGTPolygonGeometry oTemp = (IGTPolygonGeometry)(oGeometry); for (int i = 0; i < oTemp.Points.Count; i++) { sCoordinates1 = string.Join(",", new string[] { sCoordinates1, oTemp.Points[i].X.ToString(), oTemp.Points[i].Y.ToString(), oTemp.Points[i].Z.ToString() }); } sCoordinates1 = sCoordinates1.Remove(0, 1); int rAffected = 0; // Execute .NET stored procedure ADODB.Recordset oRS = m_GTApplication.DataContext.Execute("{call OC_INSERT_TEMP_PLR_COORD('" + sCoordinates1 + "')}", out rAffected, 1, new object[1]); // Calculate orientation dx = oPoint1.X - oPoint0.X; dy = oPoint1.Y - oPoint0.Y; if (dx == 0) { if (dy >= 0) { dOrientation = pi / 2; } else { dOrientation = -(pi / 2); } } else { dOrientation = System.Math.Atan(dy / dx); if (dx < 0) { dOrientation = dOrientation + pi; } } } catch (Exception ex) { throw; } }
private void AssemblyCopyToModel(IGTPolygonGeometry oGeometry) { int ownerID = 0; IGTPoint firstPnt = null; IGTPoint secondPnt = null; IGTPoint thirtPnt = null; int lRecords; double dGeoOrientation = 0.0; try { frmAssmbly = new frmAssembly(); frmAssmbly.Application = m_GTApplication; frmAssmbly.FeatureFNO = m_ActiveGraphicComponent.FNO; frmAssmbly.ShowDialog(); if (frmAssmbly.FeatureIdentifier != 0) { ownerID = GetOwnerIdentifier(); GetAssemblyPointsAndOrientation(oGeometry, ref firstPnt, ref secondPnt, ref thirtPnt, ref dGeoOrientation); //string assemblyQuery = "BEGIN G3E_DeepCopy.CopyChildrenToModel(" + m_ActiveGraphicComponent.FNO.ToString() + " ," + // frmAssmbly.FeatureIdentifier.ToString() + ", " + // m_ActiveGraphicComponent.FNO.ToString() + ", " + // m_ActiveGraphicComponent.CNO.ToString() + ", " + // m_ActiveGraphicComponent.FID.ToString() + ", " + // ownerID.ToString() + ", '" + // firstPnt.X.ToString().Replace(",", ".") + "', '" + // firstPnt.Y.ToString().Replace(",", ".") + "', '" + // secondPnt.X.ToString().Replace(",", ".") + "', '" + // secondPnt.Y.ToString().Replace(",", ".") + "', '" + // thirtPnt.X.ToString().Replace(",", ".") + "', '" + // thirtPnt.Y.ToString().Replace(",", ".") + "', '" + // dGeoOrientation.ToString().Replace(",", ".") + "'," + // "' 0 '," + // "' 0 '," + // "' 0 '," + // "' 0 '," + // "' 0 '," + // "' 0 '," + // "' 0 '," + // "' 0 '" + "); END;"; string assemblyQuery = "BEGIN OC_EXECUTE_DEEPCOPY(" + m_ActiveGraphicComponent.FNO.ToString() + " ," + frmAssmbly.FeatureIdentifier.ToString() + ", " + m_ActiveGraphicComponent.FNO.ToString() + ", " + m_ActiveGraphicComponent.CNO.ToString() + ", " + m_ActiveGraphicComponent.FID.ToString() + ", " + ownerID.ToString() + "); END;"; Recordset oRS = m_GTApplication.DataContext.Execute(assemblyQuery, out lRecords, (int)CommandTypeEnum.adCmdText, new object()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public double AngleBetweenTwoPoints(IGTPoint pntA, IGTPoint pntB) { double DX = 0, DY = 0; double dAngleBetweenTwoPoints; DX = pntA.X - pntB.X; DY = pntA.Y - pntB.Y; dAngleBetweenTwoPoints = Math.Atan2(DY, DX) * (180 / Math.PI); return(dAngleBetweenTwoPoints); }
public GTHistoryGeometry(double _x, double _y, double _z) { _point = GTClassFactory.Create <IGTOrientedPointGeometry>(); IGTPoint apoint = GTClassFactory.Create <IGTPoint>(); apoint.X = _x; apoint.Y = _y; apoint.Z = _z; _point.Origin = apoint; }
public static IGTPoint RetrieveRelativePoint(IGTGraphicComponent relativeComponent) { //initialize IGTGeometry relativeGeometry = relativeComponent.Geometry; IGTPoint relativePoint = GTClassFactory.Create <IGTPoint>(); relativePoint.X = ((IGTOrientedPointGeometry)relativeGeometry).Origin.X; relativePoint.Y = ((IGTOrientedPointGeometry)relativeGeometry).Origin.Y; relativePoint.Z = ((IGTOrientedPointGeometry)relativeGeometry).Origin.Z; return(relativePoint); }
/// <summary> /// Get Left Origin Point /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetLeftOriginPoint(IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry, IGTKeyObjects m_gtRelativeLines) { try { //Get Left Origin Point IGTPoint m_gtLeftOriginPoint = null; IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); if ((m_gtRelativePoint.FNO == transformerUGFNO) || (m_gtRelativePoint.FNO == AutotransfomerFNO)) { //establish the connectivity for Relative point with Linear feature EstablishRelationship(m_gtRelativePoint, m_gtRelativeLines); } else { //set the node value for Bypass point placed at top if (m_KeyObjectCollection[1] != null) { m_gtRelationshipService.DataContext = m_gtApplication.DataContext; m_gtRelationshipService.ActiveFeature = m_KeyObjectCollection[1]; m_gtRelationshipService.SilentDelete(iRNO); IGTComponent m_gtBypassComp = m_KeyObjectCollection[1].Components.GetComponent(ConnectivityCNO); m_gtBypassComp.Recordset.Fields["NODE_1_ID"].Value = 0; m_gtBypassComp.Recordset.Fields["NODE_2_ID"].Value = 0; m_gtBypassComp.Recordset.Update(); } } //set the node value for Bypass point placed at Left if ((m_rlnode2 != 0) && (m_rlnode2 == m_rpnode1)) { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode2; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, -xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = m_rlnode1; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } m_gtRelationshipService = null; return(m_gtLeftOriginPoint); } catch { throw; } }
/// <summary> /// Support method for Geocode locate. May be removed at a later date. /// </summary> /// <param name="dX"></param> /// <param name="dY"></param> /// <param name="dZ"></param> /// <returns></returns> internal static IGTPoint gCoordinateConvert(double dX, double dY, double dZ) { //CoordSystem coordsystem; //IDictionary<string, IAltCoordSystemPath> myAltPathDict; IGTPoint point = GTClassFactory.Create <IGTPoint>(); //ICoordSystemsMgr coordMgr; //IAltCoordSystemPath tmpPath; const double degToRad = Math.PI / 180.0; try { //// convert LAT LONG to State Plane //coordMgr = gtDataContext.CoordSystemsMgr; //System.Diagnostics.Debug.Print("Lon :" + dX.ToString() + " Lat :" + dY.ToString()); ////Convert to radians //dX = dX * degToRad; //dY = dY * degToRad; //coordsystem = coordMgr.BaseCoordSystem as CoordSystem; //myAltPathDict = coordMgr.AltPathDictionary; //myAltPathDict.TryGetValue("{720E36F0-5586-4960-84B1-4544BA6123B3}", out tmpPath); //// Coodinate systems in database. //((ILinkableTransformation)coordsystem).TransformPoint(CSPointConstants.cspLLU, 1, // CSPointConstants.cspENU, 1, //CSPointConstants.cspENO // ref dX, ref dY, ref dZ); //point.X = dX; //point.Y = dY; //point.Z = 0.0; //System.Diagnostics.Debug.Print("X :" + dX.ToString() + " Y :" + dY.ToString()); //coordMgr = null; //coordsystem = null; IGTHelperService helperSrvc = GTClassFactory.Create <IGTHelperService>(); helperSrvc.DataContext = gtDataContext; point.X = dX * degToRad; point.Y = dY * degToRad; point = helperSrvc.GeographicPointToStorage(point); helperSrvc = null; return(point); } catch (Exception ex) { MessageBox.Show(ex.Message, "gCoordinateConvert - Error", MessageBoxButtons.OK); point.X = 0.0; point.Y = 0.0; return(point); } }
private double CalculateDistanceFromReferencePoint(IGTPoint targetPoint) { try { double totalDistance = Math.Sqrt(((targetPoint.X - m_referencePoint.X) * (targetPoint.X - m_referencePoint.X)) + ((targetPoint.Y - m_referencePoint.Y) * (targetPoint.Y - m_referencePoint.Y))); return(totalDistance); } catch (Exception) { throw; } }
/// <summary> /// Method to create work point feature /// </summary> /// <returns>Work point feature IGTKeyObject</returns> public IGTKeyObject CreateWorkPointFeature() { try { IGTKeyObject workPointFeature = m_dataContext.NewFeature(191); IGTComponents workPointComponents = workPointFeature.Components; int wpOffsetX = 0; int wpOffsetY = 0; GetWorkPointOffset(ref wpOffsetX, ref wpOffsetY); foreach (IGTComponent component in workPointComponents) { Recordset tempRs = component.Recordset; if (tempRs != null) { if (tempRs.RecordCount > 0) { if (component.CNO == 19102) // Work point symbol { IGTOrientedPointGeometry orientedPtGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); IGTPoint point = GTClassFactory.Create <IGTPoint>(); point.X = m_locationX - wpOffsetX; point.Y = m_locationY - wpOffsetY; orientedPtGeometry.Origin = point; component.Geometry = orientedPtGeometry; } if (component.CNO == 19103) // Work point Label { IGTTextPointGeometry gTTextPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint gTPoint = GTClassFactory.Create <IGTPoint>(); gTPoint.X = m_locationX - wpOffsetX; gTPoint.Y = m_locationY - wpOffsetY; gTTextPointGeometry.Origin = gTPoint; gTTextPointGeometry.Alignment = GTAlignmentConstants.gtalBottomCenter; component.Geometry = gTTextPointGeometry; component.Recordset.Update(); } } } } // Leader Line should end at a point 70% of the way toward the structure from center of the Work Point. m_locationX = m_locationX - wpOffsetX * .3; m_locationY = m_locationY - wpOffsetY * .3; CreateLeaderLine(workPointFeature, m_locationX, m_locationY); return(workPointFeature); } catch (Exception) { throw; } }
/// <summary> /// Gets the list of member codes /// </summary> /// <returns></returns> private List <string> GetMemberCodes() { try { List <string> codesList = new List <string>(); IGTKeyObject gTKeyObject = DataContext.OpenFeature(110, POLE_FID); Recordset rs = gTKeyObject.Components.GetComponent(1).Recordset; IGTGeometry geometry = gTKeyObject.Components.GetComponent(11002).Geometry; IGTPoint point = GTClassFactory.Create <IGTPoint>(); point.X = geometry.FirstPoint.X; point.Y = geometry.FirstPoint.Y; point.Z = geometry.FirstPoint.Z; customBoundaryQuery boundaryQuery = new customBoundaryQuery(point, 235);// County boundary FNO 235 Recordset resultRs1 = boundaryQuery.PerformPointInPolygon(); if (resultRs1 != null && resultRs1.RecordCount > 0) { IGTKeyObject countyFeature = DataContext.OpenFeature(Convert.ToInt16(resultRs1.Fields["G3E_FNO"].Value), Convert.ToInt32(resultRs1.Fields["G3E_FID"].Value)); Recordset boundaryAttributesRs = countyFeature.Components.GetComponent(23501).Recordset; // // County Boundary Attributes if (boundaryAttributesRs != null && boundaryAttributesRs.RecordCount > 0) { boundaryAttributesRs.MoveFirst(); if (!string.IsNullOrEmpty(Convert.ToString(boundaryAttributesRs.Fields["ID"].Value))) { string countyBoundaryId = Convert.ToString(boundaryAttributesRs.Fields["ID"].Value).Replace("TX", string.Empty).Trim(); Recordset memberCodeRS = GetRecordSet(string.Format(@"SELECT NJUNS_MEMBER FROM NJUNS_MEMBER A , NJUNS_CONTACTS B WHERE A.NJUNS_MEMBER_ID = B.NJUNS_MEMBER_ID AND B.COUNTY_N_ID = {0} ", countyBoundaryId)); if (memberCodeRS != null && memberCodeRS.RecordCount > 0) { memberCodeRS.MoveFirst(); while (!memberCodeRS.EOF) { codesList.Add(Convert.ToString(memberCodeRS.Fields["NJUNS_MEMBER"].Value)); memberCodeRS.MoveNext(); } memberCodeRS.Close(); memberCodeRS = null; } } } } return(codesList); } catch (Exception) { throw; } }
public IGTPoint GetOffsetPoint(IGTPoint inputPt, double offsetX, double offsetY, IGTVector vector) { double angle = Vector2Angle(vector); double rotatedOffsetX = (Math.Cos(angle * Math.PI / 180) * offsetX) - (Math.Sin(angle * Math.PI / 180) * offsetY); double rotatedOffsetY = (Math.Sin(angle * Math.PI / 180) * offsetX) + (Math.Cos(angle * Math.PI / 180) * offsetY); IGTPoint gtPt = GTClassFactory.Create <IGTPoint>(); gtPt.X = inputPt.X + rotatedOffsetX; gtPt.Y = inputPt.Y + rotatedOffsetY; return(gtPt); }