//两点构造线段的Segment private ISegment MadeLineSeg_2Point(IPoint pPoint1, IPoint pPoint2) { ILine pLine = new LineClass(); pLine.PutCoords(pPoint1, pPoint2); return((ISegment)pLine); }
private IGeometryCollection GenerateYardSticks(IGeometryCollection verticesColl) { IPoint startPT = new PointClass(); IPoint endPT = new PointClass(); IGeometryCollection yardstickColl = new GeometryBagClass(); ISegmentCollection yardsegColl = new PolylineClass(); object obj = Type.Missing; for (int i = 0; i < verticesColl.GeometryCount; i++) { if (i < verticesColl.GeometryCount - 1) { ILine pLine = new LineClass(); startPT = verticesColl.get_Geometry(i) as IPoint; endPT = verticesColl.get_Geometry(i + 1) as IPoint; pLine.PutCoords(startPT, endPT); yardsegColl.AddSegment(pLine as ISegment, ref obj, ref obj); } else { MessageBox.Show(i + " yardsticks generated"); } } IPolyline pPolyline = (IPolyline)yardsegColl; yardstickColl.AddGeometry(pPolyline, ref obj, ref obj); return(yardstickColl); }
/// <summary> /// 通过起点和终点创建线段(IPolyline对象) /// </summary> /// <param name="pt1">起点</param> /// <param name="pt2">终点</param> /// <returns></returns> public static IPolyline CreatePolyline(IPoint pt1, IPoint pt2) { //a. 创建Line对象(也可是其他Segment对象), //b. QI到Segment对象 //c. 创建Path对象,通过Path的addSegment,将最初的Line添加进Path中 //d. 创建GeometryCollection对象,通过AddGeometry,将path添加进GeometryCollection中 //e. 将GeometryCollection QI到 IPolyline ILine line = new LineClass(); // 创建一个Line对象 line.PutCoords(pt1, pt2); // 设置LIne对象的起始终止点 ISegment segment = line as ISegment; // QI到ISegment ISegmentCollection path = new PathClass(); // 创建一个Path对象 object o = Type.Missing; path.AddSegment(segment, ref o, ref o);// 通过Isegmentcoletcion接口为Path对象添加Segment对象 // 创建一个Polyline对象 IGeometryCollection polyline = new PolylineClass(); polyline.AddGeometry(path as IGeometry, ref o, ref o); IPolyline resultPolyline = polyline as IPolyline; return(resultPolyline); }
//将收集到的点转换成线 private IPolyline CreatePolyline(IPointCollection pPointcollection) { int PointNumber = int.Parse(pPointcollection.PointCount.ToString()); object o = Type.Missing; //线数组 ISegmentCollection pSegmentCollection = new PolylineClass(); IZAware z = pSegmentCollection as IZAware; IMAware m = pSegmentCollection as IMAware; z.ZAware = true; m.MAware = true; for (int i = 0; i < PointNumber - 1; i++) { ILine pLine = new LineClass(); pLine.PutCoords(pPointcollection.get_Point(i), pPointcollection.get_Point(i + 1)); pSegmentCollection.AddSegment((ISegment)pLine, ref o, ref o); } IPolyline pPolyline = new PolylineClass(); pPolyline = pSegmentCollection as IPolyline; return(pPolyline); }
/// <summary> /// 在三维场景中由两点生成线的绘制 20110609 /// </summary> /// <param name="Point1">前一个点要素</param> /// <param name="Point2">后一点要素</param> /// <param name="r"></param> /// <param name="g"></param> /// <param name="b"></param> /// <param name="Width">线符号宽</param> /// <returns></returns> public static IElement PointToPolyline(IPoint Point1, IPoint Point2, int r, int g, int b, double Width) { ILine line = new LineClass(); line.PutCoords(Point1, Point2); object missing = Type.Missing; ISegmentCollection segColl = new PolylineClass(); segColl.AddSegment(line as ISegment, ref missing, ref missing); IPolyline pPolyline = new PolylineClass(); pPolyline = segColl as IPolyline; IZAware pZAware = new PolylineClass(); pZAware = pPolyline as IZAware; pZAware.ZAware = true; IElement lineElement = new LineElementClass(); ISimpleLine3DSymbol pSimpleLine3DSymbol = new SimpleLine3DSymbolClass(); pSimpleLine3DSymbol.Style = esriSimple3DLineStyle.esriS3DLSWall; pSimpleLine3DSymbol.ResolutionQuality = 1; ILineSymbol pLineSymbol = pSimpleLine3DSymbol as ILineSymbol; pLineSymbol.Color = getRGB(r, g, b); pLineSymbol.Width = Width; lineElement.Geometry = pZAware as IGeometry; ILineElement lineElement2 = lineElement as ILineElement; lineElement2.Symbol = pLineSymbol; return(lineElement); }
/// <summary> /// ���ݵ㼯���������Ҫ�� /// </summary> /// <params name="featureLayer"></params> /// <params name="lstPoint"></params> public void CreateLine(IFeatureLayer featureLayer, List<IPoint> lstPoint, int ID) { //try //{ IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IPointCollection multipoint = new MultipointClass(); if (lstPoint.Count < 2) { MessageBox.Show(@"��ѡ���������������ϵ�����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ISegmentCollection pPath = new PathClass(); ILine pLine; ISegment pSegment; object o = Type.Missing; for (int i = 0; i < lstPoint.Count - 1; i++) { pLine = new LineClass(); pLine.PutCoords(lstPoint[i], lstPoint[i + 1]); pSegment = pLine as ISegment; pPath.AddSegment(pSegment, ref o, ref o); } IGeometryCollection pPolyline = new PolylineClass(); pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); IGeometry geometry = pPolyline as IGeometry; DrawCommon.HandleZMValue(feature, geometry);//����ͼ��Zֵ���� feature.Shape = pPolyline as PolylineClass; int iFieldID = feature.Fields.FindField(GIS_Const.FIELD_BID); feature.Value[iFieldID] = ID.ToString(); feature.Store(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(false); IEnvelope envelop = feature.Shape.Envelope; DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop; DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); } else { MessageBox.Show(@"��ѡ����ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } //} //catch //{ // return; //} }
private static double GetAngleOfSegment(IPoint FromPoint, IPoint ToPoint) { //double testa = DegreeToRadian(Math.Atan((inSegment.ToPoint.Y - inSegment.FromPoint.Y) / (inSegment.ToPoint.X - inSegment.FromPoint.X))); ////degrees(atan((top - bottom)/(right - left))) ILine line = new LineClass(); double outAngle; double pi = 4 * System.Math.Atan(1); line.PutCoords(FromPoint, ToPoint); //if (line.Angle < 0) // outAngle = (180 * line.Angle) / pi; //else // outAngle = (180 - (line.Angle * 180) / 3.14159265358979); outAngle = (180 - (line.Angle * 180) / 3.14159265358979); //double dangle = Math.Abs(line.Angle) * 360 / (2 * pi); //line.FromPoint = inSegment.FromPoint; //line.ToPoint = inSegment.ToPoint; //outAngle = (int)System.Math.Round(((180 * line.Angle) / pi), 0); //outAngle = line.Angle; //outAngle = outAngle + 90; if (outAngle < 0) { outAngle += 360; } if (outAngle > 360) { outAngle -= 360; } return(outAngle); }
//添加SEGMENT private void addSegmentColllectionToolStripMenuItem_Click(object sender, EventArgs e) { ISegment[] segmentArray = new ISegment[10]; IPolyline polyline = new PolylineClass(); ISegmentCollection segmentCollection = new PolylineClass(); for (int i = 0; i < 10; i++) { ILine line = new LineClass(); IPoint fromPoint = new PointClass(); fromPoint.PutCoords(i * 10, i * 10); IPoint toPoint = new PointClass(); toPoint.PutCoords(i * 15, i * 15); line.PutCoords(fromPoint, toPoint); segmentArray[i] = line as ISegment; segmentCollection.AddSegment(line as ISegment, Type.Missing, Type.Missing); } //也可通过IGeometryBridge对象的AddSegments方法进行整个segment数据的添加 //IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); //geometryBridge.AddSegments(segmentCollection, ref segmentArray); polyline = segmentCollection as IPolyline; addFeature("polyline", polyline as IGeometry); this.axMapControl1.Extent = polyline.Envelope; this.axMapControl1.Refresh(); }
/// <summary> /// 两点之间的连线是否与线相交 /// </summary> /// <param name="mFPoint"></param> /// <param name="mLPoint"></param> /// <param name="lineFeature"></param> /// <returns>true:相交;false:不相交</returns> private bool IsIntersect(IPoint mFPoint, IPoint mLPoint, IFeature lineFeature) { //声明线要素 //IPolyline mPLine = new PolylineClass(); //mPLine.FromPoint = mFPoint; //mPLine.ToPoint = mLPoint; //声明点集 //IPointCollection mPointCol = new PolylineClass(); //object obj = System.Reflection.Missing.Value; //mPointCol.AddPoint(mFPoint, ref obj, ref obj); //mPointCol.AddPoint(mLPoint, ref obj, ref obj); //mPLine = mPointCol as IPolyline; ILine pLine = new LineClass(); pLine.PutCoords(mFPoint, mLPoint); ISegmentCollection pSegCol = new PolylineClass(); object obj = Type.Missing; pSegCol.AddSegment(pLine as ISegment, ref obj, ref obj); IRelationalOperator pRelOpera = pSegCol as IRelationalOperator; if (pRelOpera.Disjoint(lineFeature.Shape)) { //不相交 return(false); } else { //相交 return(true); } }
public static double GetAngleRadianByPolyline(IPolyline polyline) { ILine pLine = new LineClass(); pLine.PutCoords(polyline.FromPoint, polyline.ToPoint); return(pLine.Angle); }
public static IGeometryCollection ConstructPolygon(IPoint[] pointArray) { //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象 object o = Type.Missing; ISegmentCollection pSegCollection = new RingClass(); for (int i = 0; i < pointArray.Length - 1; i++) { IPoint from = pointArray[i]; IPoint to = pointArray[i + 1]; ILine pLine = new LineClass(); //设置Line对象的起始终止点 pLine.PutCoords(from, to); //QI到ISegment ISegment pSegment = pLine as ISegment; pSegCollection.AddSegment(pSegment, ref o, ref o); } //QI到IRing接口封闭Ring对象,使其有效 IRing pRing = pSegCollection as IRing; pRing.Close(); //使用Ring对象构建Polygon对象 IGeometryCollection pGeometryColl = new PolygonClass(); pGeometryColl.AddGeometry(pRing, ref o, ref o); //释放AO对象 System.Runtime.InteropServices.Marshal.ReleaseComObject(pRing); return(pGeometryColl); }
public static ILine ConstructLine(IPoint from, IPoint to) { ILine pline = new LineClass(); pline.PutCoords(from, to); return(pline); }
public static IGeometryCollection ConstructPolygon(List <IPoint> pointArray) { //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象 object o = Type.Missing; ISegmentCollection pSegCollection = new RingClass(); for (int i = 0; i < pointArray.Count - 1; i++) { IPoint from = pointArray[i]; IPoint to = pointArray[i + 1]; ILine pLine = new LineClass(); //设置Line对象的起始终止点 pLine.PutCoords(from, to); //QI到ISegment ISegment pSegment = pLine as ISegment; pSegCollection.AddSegment(pSegment, ref o, ref o); } //QI到IRing接口封闭Ring对象,使其有效 IRing pRing = pSegCollection as IRing; pRing.Close(); //使用Ring对象构建Polygon对象 IGeometryCollection pGeometryColl = new PolygonClass(); pGeometryColl.AddGeometry(pRing, ref o, ref o); return(pGeometryColl); }
public static double GetAngle(IPoint from, IPoint to) { ILine pLine = new LineClass(); pLine.PutCoords(from, to); return(pLine.Angle); }
public static double GetAngleDegreeByPolyline(IPolyline polyline) { ILine pLine = new LineClass(); pLine.PutCoords(polyline.FromPoint, polyline.ToPoint); return((180 * pLine.Angle) / Math.PI); }
private void route_Search_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (this.start_time.EditValue == "" || this.end_time.EditValue == "") { MessageBox.Show("请选择起止日期"); return; } SqlHelper help = new SqlHelper(); String sql = "select * from route where tm between '" + this.start_time.EditValue + "' and '" + this.end_time.EditValue + "'"; DataTable dt = help.getMySqlRead(sql); ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IColor color = GisClass.GetRgbColor(0, 255, 0); simpleMarkerSymbol.Color = color; ILineElement lineElement = new LineElementClass(); IElement ele1 = lineElement as IElement; ISegment pSegment; ILine pLine = null; object o = Type.Missing; ISegmentCollection pPath = new PathClass(); for (int i = 0; i < dt.Rows.Count; i++) { IMarkerElement markerEle = new MarkerElementClass(); IElement ele = markerEle as IElement; IPoint point = new PointClass(); markerEle.Symbol = simpleMarkerSymbol; point.PutCoords(Double.Parse(dt.Rows[i]["x"].ToString()), Double.Parse(dt.Rows[i]["y"].ToString())); ele.Geometry = point; pGraphicsContainer.AddElement(ele, 0); //逐段添加线 if (i > 0 && i < dt.Rows.Count) { IPoint point1 = new PointClass(); point1.PutCoords(Double.Parse(dt.Rows[i - 1]["x"].ToString()), Double.Parse(dt.Rows[i - 1]["y"].ToString())); pLine = new LineClass(); pLine.PutCoords(point1, point); pSegment = pLine as ISegment; pPath.AddSegment(pSegment, ref o, ref o); } axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); } IGeometryCollection pPolyline = new PolylineClass(); pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); IPolyline polyline = pPolyline as IPolyline; //获取范围 IEnvelope ev = polyline.Envelope; this.axMapControl1.ActiveView.Extent = ev; ele1.Geometry = pPolyline as IPolyline; pGraphicsContainer.AddElement(ele1, 0); }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); if (m_NewPolygonFeedback == null) { return; } m_NewPolygonFeedback.MoveTo(pt); if (m_ptCollection.PointCount == 0) { return; } double d_Total = 0; double d_segment = 0; double d_Area = 0;//20140219 lyf IPoint lastPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); ILine line = new LineClass(); line.PutCoords(lastPt, pt); //节距离 d_segment = line.Length; m_frmMeasureResult.Segment = d_segment; ///20140219 lyf 当前点和起始点距离,计算周长用 IPoint firstPt = m_ptCollection.get_Point(0); ILine tempLastLine = new LineClass(); tempLastLine.PutCoords(pt, firstPt); try { IPolyline polyline = m_ptCollection as IPolyline; if (polyline.IsEmpty) { d_Total = d_segment; d_Area = 0; } else { d_Total = polyline.Length + d_segment + tempLastLine.Length; d_Area = CaculateArea(pt); } } catch { } //赋值给总长度 m_frmMeasureResult.Total = d_Total; m_frmMeasureResult.Area = d_Area; m_frmMeasureResult.PolygonResultChange(); }
/// <summary> /// Converts the angle of the line to Geographic Rotation. /// </summary> /// <param name="source">The source.</param> /// <returns>Returns a <see cref="double" /> representing the angle.</returns> public static double GetGeographicAngle(this IPolyline source) { if (source == null) { return(0); } ILine line = new LineClass(); line.PutCoords(source.FromPoint, source.ToPoint); return(line.GetGeographicAngle()); }
private ILine CreateLine(double x1, double y1, double x2, double y2) { IPoint pnt1 = new PointClass(); pnt1.PutCoords(x1, y1); IPoint pnt2 = new PointClass(); pnt2.PutCoords(x2, y2); Line ln = new LineClass(); ln.PutCoords(pnt1, pnt2); return(ln); }
private ILine CreateLine(int x1, int y1, int x2, int y2) { IPoint pnt1 = new PointClass(); pnt1.PutCoords(x1, y1); IPoint pnt2 = new PointClass(); pnt2.PutCoords(x2, y2); ILine ln = new LineClass(); ln.PutCoords(pnt1, pnt2); return(ln); }
public static IGeometryCollection ConstructSector(IPoint[] pointArray, double circRadius, double angle) { // 边 ILine pLine = new LineClass(); pLine.PutCoords(pointArray[0], pointArray[1]); // 弧 //ESRI.ArcGIS.Geometry.ICircularArc cir = new CircularArcClass(); //ESRI.ArcGIS.Geometry.IConstructCircularArc con = new CircularArcClass(); //cir = con as ICircularArc; //cir.PutCoordsByAngle(pointArray[0], angle * Math.PI / 180, 40 * Math.PI / 180, circRadius); // 边 ILine pLine1 = new LineClass(); pLine.PutCoords(pointArray[2], pointArray[0]); //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象 object o = Type.Missing; ISegmentCollection pSegCollection = new PathClass(); // 添加进pSegCollection pSegCollection.AddSegment(pLine as ISegment, ref o, ref o); //pSegCollection.AddSegment(cir as ISegment, ref o, ref o); pSegCollection.AddSegment(pLine1 as ISegment, ref o, ref o); // QI到IRing接口封闭Ring对象,使其有效 //IPath pRing = pSegCollection as IPath; //pRing.Close(); // 使用Ring对象构建Polygon对象 IGeometryCollection pGeometryColl = new PolylineClass(); pGeometryColl.AddGeometry(pSegCollection as IGeometry, ref o, ref o); return(pGeometryColl); }
public static IPolyline CreatePolyline(TuLine t) { ISegment pSegment; ILine pLine; object o = Type.Missing; ISegmentCollection pPath = new PathClass(); pLine = new LineClass(); pLine.PutCoords(t.Begin, t.End); pSegment = pLine as ISegment; pPath.AddSegment(pSegment, ref o, ref o); IGeometryCollection pPolyline = new PolylineClass(); pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); return(pPolyline as IPolyline); }
/// <summary> /// Creates the line. /// </summary> /// <returns></returns> private ILine CreateLine() { IPoint fromPoint = new PointClass(); fromPoint.PutCoords(1, 3); IPoint toPoint = new PointClass(); toPoint.PutCoords(3, 1); ILine line = new LineClass(); line.PutCoords(fromPoint, toPoint); return(line); }
private void CreateDongShi(IPoint P0, IPoint P1, IPoint P2, IPoint P3, string hdid, string bid) { ISegmentCollection pPath = new PathClass(); //第一条线段 ILine pLine = new LineClass(); pLine.PutCoords(P0, P1); //QI到ISegment ISegment pSegment = pLine as ISegment; //创建一个Path对象 System.Object o = Type.Missing; //通过ISegmentCollection接口为Path对象添加Segment对象 pPath.AddSegment(pSegment, ref o, ref o); //第二条线段 ILine pLine2 = new LineClass(); pLine2.PutCoords(P1, P2); ISegment pSegment2 = pLine2 as ISegment; //创建一个Path对象 //通过ISegmentCollection接口为Path对象添加Segment对象 pPath.AddSegment(pSegment2, ref o, ref o); //第三条线段 ILine pLine3 = new LineClass(); pLine3.PutCoords(P2, P3); ISegment pSegment3 = pLine3 as ISegment; //创建一个Path对象 //通过ISegmentCollection接口为Path对象添加Segment对象 pPath.AddSegment(pSegment3, ref o, ref o); IGeometryCollection pPolyline = new PolylineClass(); //通过IGeometryCollection为Polyline对象添加Path对象 pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); if (m_pDongshiFeatureLayer != null) { System.Collections.Generic.List <ziduan> list = new System.Collections.Generic.List <ziduan>(); list.Add(new ziduan(GIS_Const.FIELD_HDID, hdid)); list.Add(new ziduan(GIS_Const.FIELD_BID, bid)); DataEditCommon.CreateNewFeature(m_pDongshiFeatureLayer, pPolyline as IGeometry, list); m_hookHelper.ActiveView.Refresh(); } }
static public IPolyline CreatePly(List <IPoint> ptList) { ISegmentCollection sc = new PathClass(); for (int i = 0; i < ptList.Count - 1; i++) { ILine newline = new LineClass(); newline.PutCoords(ptList[i], ptList[i + 1]); sc.AddSegment(newline as ISegment, Type.Missing, Type.Missing); } IPolyline pline = new PolylineClass(); IGeometryCollection gPolyline = pline as IGeometryCollection; gPolyline.AddGeometry(sc as IGeometry, Type.Missing, Type.Missing); pline = gPolyline as IPolyline; return(pline); }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); if (m_NewLineFeedback == null) { return; } m_NewLineFeedback.MoveTo(pt); if (m_ptColl.PointCount == 0) { return; } double d_Total = 0; double d_segment = 0; IPoint lastPt = m_ptColl.get_Point(m_ptColl.PointCount - 1); ILine line = new LineClass(); line.PutCoords(lastPt, pt); //节距离 d_segment = line.Length; _MsgInfo.Segment = d_segment; try { IPolyline polyline = m_ptColl as IPolyline; if (polyline.IsEmpty) { d_Total = d_segment; } else { d_Total = polyline.Length + d_segment; } } catch { } //赋值给总长度 _MsgInfo.Total = d_Total; _MsgInfo.LineResultChange(); }
public void PolylineEqualityComparer_Equals_True() { IPoint fromPoint = new PointClass(); fromPoint.PutCoords(1, 3); IPoint toPoint = new PointClass(); toPoint.PutCoords(3, 1); ILine line = new LineClass(); line.PutCoords(fromPoint, toPoint); PolylineEqualityComparer comparer = new PolylineEqualityComparer(.01); Assert.IsTrue(comparer.Equals(line, line)); }
public void GeometryEqualityComparer_Equals_False() { IPoint fromPoint = new PointClass(); fromPoint.PutCoords(1, 3); IPoint toPoint = new PointClass(); toPoint.PutCoords(3, 1); ILine line = new LineClass(); line.PutCoords(fromPoint, toPoint); GeometryEqualityComparer comparer = new GeometryEqualityComparer(); Assert.IsFalse(comparer.Equals(line, null)); }
//将收集到的点转换成线 private List <IPolyline> CreatePolyline(IPointCollection pPointcollection) { List <IPolyline> lineList = new List <IPolyline>(); int PointNumber = int.Parse(pPointcollection.PointCount.ToString()); object o = Type.Missing; IPolyline pPolyline = new PolylineClass(); for (int i = 0; i < PointNumber - 1; i++) { ILine pLine = new LineClass(); pLine.PutCoords(pPointcollection.get_Point(i), pPointcollection.get_Point(i + 1)); ISegmentCollection pSC = new PolylineClass(); pSC.AddSegment(pLine as ISegment, ref o, ref o); pPolyline = pSC as IPolyline; lineList.Add(pPolyline); } return(lineList); }
/// <summary> /// Creates the polyline. /// </summary> /// <returns></returns> private IPolyline CreatePolyline() { IPoint fromPoint = new PointClass(); fromPoint.PutCoords(1, 3); IPoint toPoint = new PointClass(); toPoint.PutCoords(3, 1); ILine line = new LineClass(); line.PutCoords(fromPoint, toPoint); ISegmentCollection collection = new PolylineClass(); collection.AddSegment((ISegment)line); return((IPolyline)collection); }
/// <summary> /// 通过点集创建线段(IPolyline对象) /// </summary> /// <param name="pts"></param> /// <returns></returns> public static IPolyline CreatePolyline(IPoint[] pts) { var segments = new List <ISegment>();//存放单条线的每一段(Line对象) for (int i = 0; i < pts.Length - 1; i++) { Line line = new LineClass(); line.PutCoords(pts[i], pts[i + 1]); segments.Add((ISegment)line); } ISegment[] segmentArray = segments.ToArray();//存放单条线的每一段(Line对象) ISegmentCollection segmentCollection = new PolylineClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddSegments(segmentCollection, ref segmentArray); IPolyline polyLine = segmentCollection as IPolyline; return(polyLine); }
/// <summary> /// 延长 /// </summary> /// <param name="player">当前操作图层</param> /// <param name="pMap">当前操作地图</param> private void GetIntersectionPoint(ILayer player, IMap pMap) { IEnumFeature pEnumFeature = pMap.FeatureSelection as IEnumFeature; IFeature selectFeature = pEnumFeature.Next(); IPolyline extendline = selectFeature.Shape as IPolyline; IFeature selectFeature2 = pEnumFeature.Next(); IPolyline intersectionline = selectFeature2.Shape as IPolyline; IActiveView maprefr = (IActiveView)pMap; IFeatureLayer pfeaturelayer = (IFeatureLayer)player; IFeatureClass pfeatureclass = pfeaturelayer.FeatureClass; IDataset pDataset = (IDataset)pfeaturelayer.FeatureClass; IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace; IFeature addfeature = pfeatureclass.CreateFeature(); //IPolyline pline = addfeature.Shape as IPolyline; IGeometry pGeometry; IPoint pPointFrom = new PointClass(); IPoint pPointTo = new PointClass(); ILine pLine = new LineClass(); pLine.PutCoords(pPointFrom, pPointTo); //IPolyline pline = new PointClass(); double X1 = extendline.ToPoint.X; double Y1 = extendline.ToPoint.Y; double X2 = extendline.FromPoint.X; double Y2 = extendline.FromPoint.Y; double a1 = Y2 - Y1; double b1 = X1 - X2; double c1 = X1 * Y2 - X2 * Y1; double x1 = intersectionline.ToPoint.X; double y1 = intersectionline.ToPoint.Y; double x2 = intersectionline.FromPoint.X; double y2 = intersectionline.FromPoint.Y; double a2 = y2 - y1; double b2 = x1 - x2; double c2 = x1 * y2 - x2 * y1; double isparallline = a1 * b2 - a2 * b1; double getpx = (c1 * b2 - c2 * b1) / isparallline; double getpy = (a1 * c2 - a2 * c1) / isparallline; pWorkspaceEdit.StartEditOperation(); //pline.ToPoint.X = getpx; //pline.ToPoint.Y = getpy; //pline.FromPoint = extendline.ToPoint; pPointFrom.X = getpx; pPointFrom.Y = getpy; pPointTo = extendline.ToPoint; pLine.PutCoords(pPointFrom, pPointTo); ISegmentCollection psegmentcollection = new PolylineClass(); object oMissing = Type.Missing; psegmentcollection.AddSegment((ISegment)pLine, oMissing, oMissing); //pline = (IGeometry)psegmentcollection; pGeometry = psegmentcollection as IGeometry; addfeature.Shape = pGeometry; addfeature.Store(); pWorkspaceEdit.StopEditOperation(); maprefr.Refresh(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 2) return; IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); IGraphicsContainer graphicContainer = m_hookHelper.ActiveView.GraphicsContainer; IEnvelope pEnvBounds = null; //��ȡ��һ�ι켣�ߵķ�Χ,�Ա�ȷ��ˢ�·�Χ try { if (m_TracePolygon != null) { m_TracePolygon.QueryEnvelope(pEnvBounds); pEnvBounds.Expand(4, 4, true); //���ο�����������4��(����2������),Ŀ����Ϊ�˱�֤�г����ˢ������ } else pEnvBounds = m_hookHelper.ActiveView.Extent; } catch { pEnvBounds = m_hookHelper.ActiveView.Extent; } #region ������� if (m_NewPolygonFeedback == null) { //�Ƴ�element RemoveElements(); //ˢ�� m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); Application.DoEvents(); m_NewPolygonFeedback = new NewPolygonFeedbackClass(); //�����ȵõ�symbol,������symbol ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 2; simpleLineSymbol.Color = TransColorToAEColor(Color.Blue); m_simpleFillSymbol.Outline = simpleLineSymbol; m_NewPolygonFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay; m_NewPolygonFeedback.Start(pt); } else { m_NewPolygonFeedback.AddPoint(pt); } if (m_ptCollection == null) { m_ptCollection = new PolylineClass(); } //��¼�ڵ� object obj = Type.Missing; m_ptCollection.AddPoint(pt, ref obj, ref obj); #endregion #region ���ƽ�� try { IElement vertexElement = createElement_x(pt); // graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer; //g.AddElement(vertexElement, 0); //g.MoveElementToGroup(vertexElement, m_VertexElement); m_VertexElement.AddElement(vertexElement); //ˢ�� m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, vertexElement, pEnvBounds); } catch { } #endregion try { if (m_ptCollection.PointCount >= 2) { IPoint fromPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 2); //�����ڶ����� IPoint toPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); //����һ���� ILine line = new LineClass(); line.PutCoords(fromPt, toPt); #region ���ƹ켣�� try { object missing = Type.Missing; ISegmentCollection segColl = new PolylineClass(); segColl.AddSegment(line as ISegment, ref missing, ref missing); IPolyline polyline = new PolylineClass(); polyline = segColl as IPolyline; IElement traceElement = createElement_x(polyline); //graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer; m_TraceElement.AddElement(traceElement); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, traceElement, pEnvBounds); } catch { } #endregion #region ���㵥�ߵij���,���������ʾ�ڵ����е�ƫ������ //try //{ // double angle = line.Angle; // if ((angle > (Math.PI / 2) && angle < (Math.PI)) || (angle > -Math.PI && angle < -(Math.PI / 2))) // ����90��С�ڵ���180 // angle += Math.PI; // //��ע��Yֵƫ���� // double d_OffsetY = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(9); // //��ע�� // double d_CenterX = (fromPt.X + toPt.X) / 2; // double d_CenterY = (fromPt.Y + toPt.Y) / 2 + d_OffsetY; //����ƫ�� // IPoint labelPt = new PointClass(); // labelPt.PutCoords(d_CenterX, d_CenterY); // ITextElement txtElement = CreateTextElement(line.Length.ToString("0.00")); // IElement labelelement = txtElement as IElement; // labelelement.Geometry = labelPt; // object oElement = (object)labelelement; // //���ݽǶ���ת // TransformByRotate(ref oElement, labelPt, angle); // ////��ӵ�GraphicsContainer // //g.AddElement(labelelement, 0); // ////�Ƶ�m_LabelElement���� // //g.MoveElementToGroup(labelelement, m_LabelElement); // //��ӵ��� // m_LabelElement.AddElement(labelelement); // //ˢ�� // m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, labelelement, pEnvBounds); //} //catch //{ } #endregion } } catch { } m_frmMeasureResult.PolygonResultChange(); }
private IGSLine CreateGSLine(String inCourse, esriDirectionUnits inDirectionUnits, esriDirectionType inDirectionType, ISegment EntryTangent, out ISegment ExitTangent, out ICircularArc outCircularArc) { // string[] sCourse = inCourse.Split(' '); Utilities UTILS = new Utilities(); double dToMeterUnitConversion = UTILS.ToMeterUnitConversion(); // ISegment ExitTangent = null; string item = (string)sCourse.GetValue(0); if (item.ToLower() == "dd") {//Direction distance -- straight line course IGSLine pLine = new GSLineClass(); double dBear = DirectionString_2_NorthAzimuth((string)sCourse.GetValue(1), inDirectionType, inDirectionUnits); pLine.Bearing = dBear; pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion; pLine.FromPoint = m_count; m_count += 1; pLine.ToPoint = m_count; //Now define the tangent exit segment //in case it's needed for the next course (TC tangent curve, or Angle deflection) double dPolar = DirectionString_2_PolarRadians((string)sCourse.GetValue(1), inDirectionType, inDirectionUnits); IPoint pFromPt = new PointClass(); pFromPt.PutCoords(1000, 1000); IConstructPoint2 pToPt = new PointClass(); pToPt.ConstructAngleDistance(pFromPt, dPolar, 100); ILine ExitTangentLine = new LineClass(); ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt); ExitTangent = (ISegment)ExitTangentLine; outCircularArc = null; Marshal.ReleaseComObject(pFromPt); Marshal.ReleaseComObject(pToPt); return pLine; } if (item.ToLower() == "ad") {//Angle deflection distance IGSLine pLine = new GSLineClass(); double dDeflAngle = Angle_2_Radians((string)sCourse.GetValue(1), inDirectionUnits); //now need to take the previous tangent segment, reverse its orientation and //add +ve clockwise to get the bearing ILine calcLine = (ILine)EntryTangent; double dBear = PolarRAD_2_SouthAzimuthRAD(calcLine.Angle) + dDeflAngle; pLine.Bearing = dBear; pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion; pLine.FromPoint = m_count; m_count += 1; pLine.ToPoint = m_count; //Now define the tangent exit segment //in case it's needed for the next course (TC tangent curve, or Angle deflection) IPoint pFromPt = new PointClass(); pFromPt.PutCoords(1000, 1000); IConstructPoint2 pToPt = new PointClass(); double dPolar = NorthAzimuthRAD_2_PolarRAD(dBear); pToPt.ConstructAngleDistance(pFromPt, dPolar, 100); ILine ExitTangentLine = new LineClass(); ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt); ExitTangent = (ISegment)ExitTangentLine; outCircularArc = null; Marshal.ReleaseComObject(pFromPt); Marshal.ReleaseComObject(pToPt); return pLine; } else if ((item.ToLower() == "nc") || (item.ToLower() == "tc")) { double dChordlength; double dChordBearing; ICircularArc pArc = ConstructCurveFromString(inCourse, EntryTangent, inDirectionType, inDirectionUnits, out dChordlength, out dChordBearing); try { IGSLine pLine = new GSLineClass(); pLine.Bearing = PolarRAD_2_NorthAzimuthRAD(dChordBearing); pLine.Radius = pArc.Radius * dToMeterUnitConversion;//convert to meters if (pArc.IsCounterClockwise) { pLine.Radius = pLine.Radius * -1; } pLine.Distance = dChordlength * dToMeterUnitConversion; //convert to meters pLine.FromPoint = m_count; m_count += 1; pLine.ToPoint = m_count; ILine pTangentLine = new LineClass(); pArc.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, 100, pTangentLine); //pass the exit tangent back out for use as next entry tangent ExitTangent = (ISegment)pTangentLine; outCircularArc = pArc; return pLine; } catch { } } outCircularArc = null; ExitTangent = null; return null; }
private ILine ConstructLine(double x1, double y1, double x2, double y2) { IPoint p1 = new PointClass(); p1.PutCoords(x1, y1); p1.Project(SpatialReferenceHelper.BCAlbersSpatialReference); IPoint p2 = new PointClass(); p2.PutCoords(x2, y2); p2.Project(SpatialReferenceHelper.BCAlbersSpatialReference); ILine theReturn = new LineClass(); theReturn.PutCoords(p1, p2); theReturn.Project(SpatialReferenceHelper.BCAlbersSpatialReference); return theReturn; }
public static string AddLaterals(IApplication app, List<AddLateralDetails> addLateralsDetails, IFeature inFeatures, bool logOperation, bool suppressDialog, bool store, bool ForceSourcePointConnection, IFeatureLayer pEditLayer) { string resetFlow = ""; bool useDefaultTemplate; List<IFeature> ComplFeat = new List<IFeature>(); IMap map = null; IEditor editor = null; IMouseCursor appCursor = null; IMxDocument mxdoc = null; IFeatureLayer pointFLayer = null; IFeatureLayer matchLineFLayer = null; IFeatureLayer targetLineFLayer = null; IEditLayers eLayers = null; ISelectionSet2 pointSelSet = null; IFeatureSelection pointFeatureSelection = null; IEditTemplate pLateralLineEditTemp = null; List<pointAlongSettings> pointAlongLayers = null; pointAlongSettings pointAlongLayer = null; ICursor pointCursor = null; IFeature pointFeature = null; //ProgressBar ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = null; ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = null; ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog = null; // Create a CancelTracker ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = null; try { if (Control.ModifierKeys == Keys.Control) { useDefaultTemplate = false; } else { useDefaultTemplate = true; } bool boolSelectedEdges = false; if (Control.ModifierKeys == Keys.Shift) { boolSelectedEdges = true; } else { boolSelectedEdges = false; } //Get edit session bool LatCreated = false; editor = Globals.getEditor(app); if (editor.EditState != esriEditState.esriStateEditing) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("MustBEditg"), _caption); editor = null; return ""; } //Change mouse cursor to wait - automatically changes back (ArcGIS Desktop only) appCursor = new MouseCursorClass(); appCursor.SetCursor(2); mxdoc = (IMxDocument)app.Document; map = editor.Map; for (int k = 0; k < addLateralsDetails.Count; k++) { bool FCorLayerPoint = true; if (pEditLayer != null) { if (pEditLayer.Name == addLateralsDetails[k].Point_LayerName) { pointFLayer = pEditLayer; } else { continue; } } else { pointFLayer = (IFeatureLayer)Globals.FindLayer(map, addLateralsDetails[k].Point_LayerName, ref FCorLayerPoint); } if (inFeatures != null) { if (pointFLayer == null) continue; if (pointFLayer.FeatureClass == null) continue; if (inFeatures.Class.CLSID.ToString() != pointFLayer.FeatureClass.CLSID.ToString()) continue; if (inFeatures.Class.ObjectClassID.ToString() != pointFLayer.FeatureClass.ObjectClassID.ToString()) continue; if (inFeatures.Class.AliasName.ToString() != pointFLayer.FeatureClass.AliasName.ToString()) continue; } //Report any problems before exiting if (pointFLayer == null) { continue; } bool FCorLayerMatch = true; bool FCorLayerTarget = true; matchLineFLayer = (IFeatureLayer)Globals.FindLayer(map, addLateralsDetails[k].MainLine_LayerName, ref FCorLayerMatch); targetLineFLayer = (IFeatureLayer)Globals.FindLayer(map, addLateralsDetails[k].LateralLine_LayerName, ref FCorLayerTarget); // IFeatureLayerDefinition2 pFeatLayerdef = matchLineFLayer as IFeatureLayerDefinition2; if (matchLineFLayer == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_1") + "'" + addLateralsDetails[k].MainLine_LayerName + "'.", _caption); return ""; } if (matchLineFLayer.FeatureClass == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_1") + "'" + addLateralsDetails[k].MainLine_LayerName + "'.", _caption); return ""; } if (matchLineFLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_2") + "'" + addLateralsDetails[k].MainLine_LayerName + "'.", _caption); return ""; } if (targetLineFLayer == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_3") + "'" + addLateralsDetails[k].LateralLine_LayerName + "'.", _caption); return ""; } if (targetLineFLayer.FeatureClass == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_3") + "'" + addLateralsDetails[k].LateralLine_LayerName + "'.", _caption); return ""; } if (targetLineFLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsMess_4") + "'" + addLateralsDetails[k].LateralLine_LayerName + "'.", _caption); return ""; } //Confirm the other layers are the correct shape type if (pointFLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint || matchLineFLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) return ""; //Confirm that target layer is editable and is a line layer eLayers = (IEditLayers)editor; if (!(eLayers.IsEditable(targetLineFLayer)) || (targetLineFLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)) return ""; //Confirm that the two line layers are different Feature classes if ((matchLineFLayer.FeatureClass.CLSID == targetLineFLayer.FeatureClass.CLSID) && (matchLineFLayer.FeatureClass.AliasName == targetLineFLayer.FeatureClass.AliasName)) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_1") , A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_2") ); return ""; } //Verify that some points are selected pointFeatureSelection = (IFeatureSelection)pointFLayer; if (pointFeatureSelection.SelectionSet.Count == 0) continue; pointSelSet = pointFeatureSelection.SelectionSet as ISelectionSet2; if (useDefaultTemplate) { //pLateralLineEditTemp = Globals.PromptAndGetEditTemplate(app, targetLineFLayer, addLateralsDetails[k].LateralLine_EditTemplate); pLateralLineEditTemp = Globals.PromptAndGetEditTemplateGraphic(targetLineFLayer, addLateralsDetails[k].LateralLine_EditTemplate); } else { pLateralLineEditTemp = Globals.PromptAndGetEditTemplateGraphic(targetLineFLayer, ""); //pLateralLineEditTemp = Globals.PromptAndGetEditTemplate(app, targetLineFLayer, ""); } if (addLateralsDetails[k].PointAlong != null) { if (addLateralsDetails[k].PointAlong.Length > 0) { pointAlongLayers = new List<pointAlongSettings>(); // IEditTemplate pPointAlongEditTemp; for (int j = 0; j < addLateralsDetails[k].PointAlong.Length; j++) { pointAlongLayer = new pointAlongSettings(); bool FCorLayerPointsAlong = true; pointAlongLayer.PointAlongLayer = (IFeatureLayer)Globals.FindLayer(map, addLateralsDetails[k].PointAlong[j].LayerName, ref FCorLayerPointsAlong); if (pointAlongLayer == null) { if (MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsAsk_1") , A4LGSharedFunctions.Localizer.GetString("Warning") , MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return ""; } else if (pointAlongLayer.PointAlongLayer == null) { if (MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsAsk_1") , A4LGSharedFunctions.Localizer.GetString("Warning") , MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return ""; } else if (pointAlongLayer.PointAlongLayer.FeatureClass == null) { if (MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsAsk_2") , A4LGSharedFunctions.Localizer.GetString("Warning") , MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return ""; } else if (pointAlongLayer.PointAlongLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPoint) { MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsAsk_3") , A4LGSharedFunctions.Localizer.GetString("Warning") ); return ""; } pointAlongLayer.PolygonIntersectSide = addLateralsDetails[k].PointAlong[j].PolygonOffsetSide; if (pointAlongLayer.PolygonIntersectSide == null) { pointAlongLayer.PolygonIntersectSide = "TO"; } bool FCorLayerTemp = true; pointAlongLayer.PolygonIntersectLayer = (IFeatureLayer)Globals.FindLayer(map, addLateralsDetails[k].PointAlong[j].PolygonOffsetLayerName, ref FCorLayerTemp); pointAlongLayer.FoundAsLayer = FCorLayerTemp; if (pointAlongLayer == null) { if (MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsAsk_1") , A4LGSharedFunctions.Localizer.GetString("Warning") , MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return ""; } else if (pointAlongLayer.PolygonIntersectLayer != null) { if (pointAlongLayer.PolygonIntersectLayer.FeatureClass != null) { //Confirm that target layer is editable and is a line layer if (pointAlongLayer.PolygonIntersectLayer != null) { if (pointAlongLayer.PolygonIntersectLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { MessageBox.Show(addLateralsDetails[k].PointAlong[j].PolygonOffsetLayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_3")); return ""; } } } } //Confirm that target layer is editable and is a line layer if (pointAlongLayer.PointAlongLayer != null) { if (!(eLayers.IsEditable(pointAlongLayer.PointAlongLayer)) || (pointAlongLayer.PointAlongLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)) { MessageBox.Show(addLateralsDetails[k].PointAlong[j].LayerName + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_4")); return ""; } if (useDefaultTemplate) { pointAlongLayer.PointAlongEditTemplate = Globals.PromptAndGetEditTemplateGraphic(pointAlongLayer.PointAlongLayer, addLateralsDetails[k].PointAlong[j].EditTemplate); //pointAlongLayer.PointAlongEditTemplate = Globals.PromptAndGetEditTemplate(app, pointAlongLayer.PointAlongLayer, addLateralsDetails[k].PointAlong[j].EditTemplate); } else { pointAlongLayer.PointAlongEditTemplate = Globals.PromptAndGetEditTemplateGraphic(pointAlongLayer.PointAlongLayer, ""); //pointAlongLayer.PointAlongEditTemplate = Globals.PromptAndGetEditTemplate(app, pointAlongLayer.PointAlongLayer, ""); } } //if (addLateralsDetails[k].PointAlong[j].Distance < 0) // pointAlongLayer.PointAlongDistance = 0; //else pointAlongLayer.PointAlongDistance = (double)addLateralsDetails[k].PointAlong[j].Distance; //if (addLateralsDetails[k].PointAlong[j].DistanceIsPercent != null) pointAlongLayer.DistanceIsPercent = (bool)addLateralsDetails[k].PointAlong[j].DistanceIsPercent; //else // pointAlongLayer.DistanceIsPercent =false; pointAlongLayers.Add(pointAlongLayer); //Verify subtype is valid for target point //if (targetPointFLayer != null) //{ // ISubtypes targetPointSubtypes = targetPointFLayer[j].FeatureClass as ISubtypes; // //string targetPointSubtypeName = targetPointSubtypes.get_SubtypeName(_targetPointSubtype); // if ((targetPointSubtypes == null) || (!targetPointSubtypes.HasSubtype))// || (String.IsNullOrEmpty(targetPointSubtypeName))) // addLateralsDetails[k].PointAlong[j].Subtype = -1; // else // { // try // { // string SubVal = targetPointSubtypes.get_SubtypeName(addLateralsDetails[k].PointAlong[j].Subtype); // // addLateralsDetails[k].PointAlong[j].Subtype = SubVal // //targetPointSubtype[k] = addLateralsDetails[k].PointAlong[j].Subtype; // } // catch // { // addLateralsDetails[k].PointAlong[j].Subtype = targetPointSubtypes.DefaultSubtypeCode; // } // } //} //else //{ // addLateralsDetails[k].PointAlong[j].Subtype = -1; //} //addLateralsDetails[k].PointAlong[j].Distance // addLateralsDetails[k].PointAlong[j].DistanceIsPercent // addLateralsDetails[k].PointAlong[j].FieldToPopulate // addLateralsDetails[k].PointAlong[j].ValueToPopulate } } } //**************************************** int total; total = pointSelSet.Count; int i = 0; // Create a CancelTracker trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass(); // Set the properties of the Step Progressor System.Int32 int32_hWnd = app.hWnd; if (suppressDialog == false) { progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass(); stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd); stepProgressor.MinRange = 0; stepProgressor.MaxRange = total; stepProgressor.StepValue = 1; stepProgressor.Message = _caption; // Create the ProgressDialog. This automatically displays the dialog progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast // Set the properties of the ProgressDialog progressDialog.CancelEnabled = true; progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AddLine") + i.ToString() + A4LGSharedFunctions.Localizer.GetString("Of") + total.ToString() + "."; progressDialog.Title = _caption; progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe; progressDialog.ShowDialog(); } // Create an edit operation enabling undo/redo if (logOperation) { try { editor.StartOperation(); } catch { logOperation = false; } } IPoint fromPoint = null; IPoint selPt1 = null; IPoint selPt2 = null; ILine distanceLine = null; object Missing = null; IEnvelope env = null; IEnumIDs selIds = null; IFeature pointFeature2 = null; List<int> completedOIDArrayList = null; ITopologicalOperator topoOp = null; IPolygon poly = null; ISpatialFilter sFilter = null; IFeatureCursor lineCursor = null; INetworkFeature pNF = null; IFeature testPointFeature = null; int featOID1, featOID2, nearbyCount; try { // ISelectionSet2 sel = pointSelSet as ISelectionSet2; pointSelSet.Update(null, false, out pointCursor); completedOIDArrayList = new List<int>(); while ((pointFeature = (IFeature)pointCursor.NextRow()) != null) { try { //if (inFeatures != null) //{ // if (pointFeature.OID != inFeatures.OID) // { // continue; // } //} i += 1; if (suppressDialog == false) { //Update progress bar progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AddLine") + i.ToString() + A4LGSharedFunctions.Localizer.GetString("Of") + total.ToString() + "." + Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("CurrentOID") + pointFeature.OID; stepProgressor.Step(); } ESRI.ArcGIS.esriSystem.IStatusBar statusBar = app.StatusBar; statusBar.set_Message(0, i.ToString()); //Check if the cancel button was pressed. If so, stop process bool boolean_Continue = trackCancel.Continue(); if (!boolean_Continue) { break; } if (!ComplFeat.Contains(pointFeature)) { //Get the "from" point for new line (start from selected point) fromPoint = pointFeature.ShapeCopy as IPoint; //Create new feature(s) env = new EnvelopeClass(); //Dual Laterals When Two Selected if (total == 2 && addLateralsDetails[k].Dual_When_Two_Selected) { if (suppressDialog == false) { //Update progress bar progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AddLine") + i.ToString() + A4LGSharedFunctions.Localizer.GetString("Of") + total.ToString() + "." + Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("CurrentOID") + pointFeature.OID; stepProgressor.Step(); } //Obtain both starting points selIds = pointSelSet.IDs; selIds.Reset(); featOID1 = selIds.Next(); featOID2 = selIds.Next(); pointFeature2 = pointFLayer.FeatureClass.GetFeature(featOID2); selPt1 = pointFeature.ShapeCopy as IPoint; selPt2 = pointFeature2.ShapeCopy as IPoint; //Measure distance distanceLine = new LineClass(); distanceLine.PutCoords(selPt1, selPt2); if (distanceLine.Length <= addLateralsDetails[k].Dual_Max_Distance_When_Two_Selected) { LatCreated = CreateDual(ref app, ref editor, pointFeature, pointFeature2, distanceLine, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].Dual_Option_Make_Square, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature2); if (LatCreated) ComplFeat.Add(pointFeature); //CreateDualOld(pointFeature, pointFeature2, distanceLine, matchLineFLayer, // lineFeature, targetLineFLayer, targetPointFLayer, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].Dual_Option_Make_Square, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); //_targetPointDistance, _targetPointDistanceIsPercent, _targetPointSubtype, _targetPointValue, _targetPointFieldName); break; } //Create two single laterals if the duals are not created else { LatCreated = CreateSingle(ref app, ref editor, pointFeature, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature); LatCreated = CreateSingle(ref app, ref editor, pointFeature2, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature2); //CreateSingleOld(pointFeature, matchLineFLayer, lineFeature, targetLineFLayer, targetPointFLayer, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); //CreateSingleOld(pointFeature2, matchLineFLayer, lineFeature, targetLineFLayer, targetPointFLayer, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); break; } } //Dual Laterals when Nearby else if ((total != 1) & addLateralsDetails[k].Dual_When_Nearby) { //Check that this feature has not already been completed if (completedOIDArrayList.Contains(pointFeature.OID)) continue; selPt1 = pointFeature.ShapeCopy as IPoint; nearbyCount = 0; pointFeature2 = null; //Determine if extactly one other point is within the specified max distance topoOp = selPt1 as ITopologicalOperator; poly = topoOp.Buffer(addLateralsDetails[k].Dual_Max_Distance_When_Nearby / 2) as IPolygon; sFilter = new SpatialFilterClass(); sFilter.Geometry = poly; sFilter.GeometryField = pointFLayer.FeatureClass.ShapeFieldName; sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; if (addLateralsDetails[k].SearchOnLayer) lineCursor = pointFLayer.Search(sFilter, false); else lineCursor = pointFLayer.FeatureClass.Search(sFilter, false); while ((testPointFeature = lineCursor.NextFeature()) != null) { if (testPointFeature.OID != pointFeature.OID) { //Check that this nearby feature has not already been completed if (!completedOIDArrayList.Contains(pointFeature.OID)) { pointFeature2 = testPointFeature; nearbyCount += 1; } } if (nearbyCount > 1) break; } if (nearbyCount == 1) { selPt2 = pointFeature2.ShapeCopy as IPoint; //Measure distance distanceLine = new LineClass(); distanceLine.PutCoords(selPt1, selPt2); LatCreated = CreateDual(ref app, ref editor, pointFeature, pointFeature2, distanceLine, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].Dual_Option_Make_Square, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature2); if (LatCreated) ComplFeat.Add(pointFeature); //CreateDualOld(pointFeature, pointFeature2, distanceLine, matchLineFLayer, // lineFeature, targetLineFLayer, targetPointFLayer, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].Dual_Option_Make_Square, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); //Add 2nd OID to completed list completedOIDArrayList.Add(pointFeature2.OID); } //Create a single lateral if 1 nearby not found else { LatCreated = CreateSingle(ref app, ref editor, pointFeature, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature); //CreateSingleOld(pointFeature, matchLineFLayer, lineFeature, targetLineFLayer, targetPointFLayer, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); } } //Single Laterals else { LatCreated = CreateSingle(ref app, ref editor, pointFeature, matchLineFLayer, targetLineFLayer, pLateralLineEditTemp, pointAlongLayers, addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, addLateralsDetails[k].FromToFields, addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].Hook_DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, store, addLateralsDetails[k].SearchOnLayer, addLateralsDetails[k].SearchDistance, addLateralsDetails[k].Hook_Angle, boolSelectedEdges); if (LatCreated) ComplFeat.Add(pointFeature); //CreateSingleOld(pointFeature, matchLineFLayer, lineFeature, targetLineFLayer, targetPointFLayer, // addLateralsDetails[k].LateralLine_StartAtMain, addLateralsDetails[k].DeleteExistingLines, // addLateralsDetails[k].Point_FieldToCalcFromMain, addLateralsDetails[k].Main_FieldToCalcForPoint, // addLateralsDetails[k].Point_PrefixForMainValue, addLateralsDetails[k].LateralLine_ValueToPopulate, // addLateralsDetails[k].LateralLine_FieldToPopulate, targetLineSubValue, // addLateralsDetails[k].Hook_DoglegDistance, addLateralsDetails[k].DistanceIsPercent, addLateralsDetails[k].TolerenceForDelete, // addLateralsDetails[k].PointAlong); } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsLbl_2") + "\n" + ex.Message, ex.Source); } finally { } // addLateralsDetails[k].InitDefaults(); if (addLateralsDetails[k].Reset_Flow != null) { resetFlow = addLateralsDetails[k].Reset_Flow; if (resetFlow.ToUpper() == "DIGITIZED") { Globals.GetCommand("A4WaterUtilities_EstablishFlowDigitized", app).Execute(); } else if (resetFlow.ToUpper() == "ROLE") { Globals.GetCommand("A4WaterUtilities_EstablishFlowAncillary", app).Execute(); } else if (resetFlow.ToUpper() == "Ancillary".ToUpper()) { Globals.GetCommand("A4WaterUtilities_EstablishFlowAncillary", app).Execute(); } else { } } } if (ForceSourcePointConnection) { foreach (IFeature sourcePnt in ComplFeat) { if (sourcePnt != null) { if (sourcePnt.Shape.IsEmpty != true) { if (sourcePnt is INetworkFeature) { pNF = (INetworkFeature)sourcePnt; try { pNF.Connect(); } catch { } } } } } } } catch (Exception ex) { editor.AbortOperation(); MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsLbl_2") + "\n" + ex.Message, ex.Source); } finally { // Cleanup if (progressDialog != null) progressDialog.HideDialog(); if (lineCursor != null) Marshal.ReleaseComObject(lineCursor); pNF = null; fromPoint = null; selPt1 = null; selPt2 = null; distanceLine = null; Missing = null; env = null; selIds = null; pointFeature2 = null; completedOIDArrayList = null; topoOp = null; poly = null; sFilter = null; lineCursor = null; testPointFeature = null; } if (logOperation) { try { // Stop the edit operation editor.StopOperation(_caption); } catch { logOperation = false; } } //88 } return resetFlow; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsLbl_2") + "\n" + ex.Message, ex.Source); return ""; } finally { ComplFeat.Clear(); if (map != null) { (map as IActiveView).Refresh(); } if (progressDialog != null) progressDialog.HideDialog(); ComplFeat = null; map = null; editor = null; appCursor = null; mxdoc = null; pointFLayer = null; matchLineFLayer = null; targetLineFLayer = null; eLayers = null; pointSelSet = null; pointFeatureSelection = null; pLateralLineEditTemp = null; pointAlongLayers = null; pointAlongLayer = null; pointCursor = null; pointFeature = null; //ProgressBar progressDialogFactory = null; stepProgressor = null; progressDialog = null; // Create a CancelTracker trackCancel = null; } }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); if (m_NewLineFeedback == null) return; m_NewLineFeedback.MoveTo(pt); if (m_ptColl.PointCount == 0) return; double d_Total = 0; double d_segment = 0; IPoint lastPt = m_ptColl.get_Point(m_ptColl.PointCount - 1); ILine line = new LineClass(); line.PutCoords(lastPt, pt); //�ھ��� d_segment = line.Length; _MsgInfo.Segment = d_segment; try { IPolyline polyline = m_ptColl as IPolyline; if (polyline.IsEmpty) { d_Total = d_segment; } else { d_Total = polyline.Length + d_segment; } } catch { } //��ֵ���ܳ��� _MsgInfo.Total = d_Total; _MsgInfo.LineResultChange(); }
///方法1:根据点要素直接生产线要素,《参考绘制巷道》 /// <summary> /// 根据点集坐标绘制线要素 /// </summary> /// <params name="featureLayer"></params> /// <params name="lstPoint"></params> public static void CreateLine(IFeatureLayer featureLayer, List<IPoint> lstPoint, string ID) { try { IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IPointCollection multipoint = new MultipointClass(); if (lstPoint.Count < 2) { MessageBox.Show(@"请选择两个及两个以上点数。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ISegmentCollection pPath = new PathClass(); ILine pLine; ISegment pSegment; object o = Type.Missing; for (int i = 0; i < lstPoint.Count - 1; i++) { pLine = new LineClass(); pLine.PutCoords(lstPoint[i], lstPoint[i + 1]); pSegment = pLine as ISegment; pPath.AddSegment(pSegment, ref o, ref o); } IGeometryCollection pPolyline = new PolylineClass(); pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); IGeometry geometry = pPolyline as IGeometry; DrawCommon.HandleZMValue(feature, geometry);//几何图形Z值处理 feature.Shape = pPolyline as PolylineClass; int iFieldID = feature.Fields.FindField("BID"); feature.Value[iFieldID] = ID.ToString(); feature.Store(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); IEnvelope envelop = feature.Shape.Envelope; DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop; GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(1.5, 1.5, true); GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, feature); GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); //DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); } else { MessageBox.Show(@"请选择线图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { return; } }
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { IActiveView pActiveView = axMapControl1.ActiveView.FocusMap as IActiveView; IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); object Missing = Type.Missing; switch (m_BasicOperationTool) { case "isMeasure": if (!m_bInUse) break; bool bFirstTime = false; if (m_pLineSymbol == null) bFirstTime = true; pActiveView.ScreenDisplay.StartDrawing(pActiveView.ScreenDisplay.hDC, -1); if (bFirstTime == true) { IRgbColor pRgbColor = new RgbColorClass(); m_pLineSymbol = new SimpleLineSymbolClass(); m_pLineSymbol.Width = 2; pRgbColor.Red = 223; pRgbColor.Green = 223; pRgbColor.Blue = 223; m_pLineSymbol.Color = pRgbColor; ISymbol pSymbol = m_pLineSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen; //�����ı����� m_pTextSymbol = new TextSymbolClass(); m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; m_pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; m_pTextSymbol.Size = 16; pSymbol = m_pTextSymbol as ISymbol; stdole.IFontDisp fnt = (stdole.IFontDisp)new stdole.StdFontClass(); fnt.Name = "Arial"; fnt.Size = Convert.ToDecimal(20); m_pTextSymbol.Font = fnt; pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen; //�������Ի��ı� m_pTextPoint = new PointClass(); } else { pActiveView.ScreenDisplay.SetSymbol(m_pTextSymbol as ISymbol); pActiveView.ScreenDisplay.DrawText(m_pTextPoint, m_pTextSymbol.Text); pActiveView.ScreenDisplay.SetSymbol(m_pLineSymbol as ISymbol); if (m_pLinePolyline.Length > 0) pActiveView.ScreenDisplay.DrawPolyline(m_pLinePolyline); } //����㵽�յ�֮������߲������ı��ĽǶ� ILine pLine = new LineClass(); pLine.PutCoords(m_pStartPoint, pPoint); double angle = pLine.Angle; angle = angle * (180 / 3.1415926); if ((angle > 90) || (angle < 180)) angle = angle + 180; if ((angle < 0) || (angle > -90)) angle = angle - 180; if ((angle < -90) || (angle > -180)) angle = angle - 180; if (angle > 180) angle = angle - 180; //Ϊ�˻����ı�������ı��ľ��룬�ǶȺ͵� double deltaX = pPoint.X - m_pStartPoint.X; double deltaY = pPoint.Y - m_pStartPoint.Y; m_pTextPoint.X = m_pStartPoint.X + deltaX / 2; m_pTextPoint.Y = m_pStartPoint.Y + deltaY / 2; m_pTextSymbol.Angle = angle; int distance = Convert.ToInt32(Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY))); m_pTextSymbol.Text = "[" + distance.ToString() + "]"; //�����ı� pActiveView.ScreenDisplay.SetSymbol(m_pTextSymbol as ISymbol); pActiveView.ScreenDisplay.DrawText(m_pTextPoint, m_pTextSymbol.Text); //��ö���� IPolyline pPolyline = new PolylineClass(); ISegmentCollection pSegColl = pPolyline as ISegmentCollection; pSegColl.AddSegment(pLine as ISegment, ref Missing, ref Missing); m_pLinePolyline = GetSmashedLine(pActiveView.ScreenDisplay, m_pTextSymbol as ISymbol, m_pTextPoint, pPolyline); //���ƶ���� pActiveView.ScreenDisplay.SetSymbol(m_pLineSymbol as ISymbol); if (m_pLinePolyline.Length > 0) { pActiveView.ScreenDisplay.DrawPolyline(m_pLinePolyline); } pActiveView.ScreenDisplay.FinishDrawing(); break; } }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); if (m_NewPolygonFeedback == null) return; m_NewPolygonFeedback.MoveTo(pt); if (m_ptCollection.PointCount == 0) return; double d_Total = 0; double d_segment = 0; double d_Area = 0;//20140219 lyf IPoint lastPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); ILine line = new LineClass(); line.PutCoords(lastPt, pt); //�ھ��� d_segment = line.Length; m_frmMeasureResult.Segment = d_segment; ///20140219 lyf ��ǰ�����ʼ����룬�����ܳ��� IPoint firstPt = m_ptCollection.get_Point(0); ILine tempLastLine = new LineClass(); tempLastLine.PutCoords(pt, firstPt); try { IPolyline polyline = m_ptCollection as IPolyline; if (polyline.IsEmpty) { d_Total = d_segment; d_Area = 0; } else { d_Total = polyline.Length + d_segment+tempLastLine.Length; d_Area = CaculateArea(pt); } } catch { } //��ֵ���ܳ��� m_frmMeasureResult.Total = d_Total; m_frmMeasureResult.Area = d_Area; m_frmMeasureResult.PolygonResultChange(); }
private double calcDistanceMeters(ESRI.ArcGIS.ADF.Web.Geometry.Point toPoint, ESRI.ArcGIS.ADF.Web.Geometry.Point fromPoint) { ILine2 line; double distance = 0; ESRI.ArcGIS.Geometry.Point p1, p2; p1 = new PointClass(); p2 = new PointClass(); p1.PutCoords(toPoint.X, toPoint.Y); p2.PutCoords(fromPoint.X, fromPoint.Y); ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); ISpatialReference spatialReference = spatialReferenceFactory.CreateSpatialReference((int) esriSRProjCSType.esriSRProjCS_World_Mercator); ISpatialReference spatialReferenceOrig = spatialReferenceFactory.CreateSpatialReference((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); line = new LineClass(); line.SpatialReference = spatialReferenceOrig; line.PutCoords(p1, p2); line.Project(spatialReference); distance = line.Length; return distance; }
private void DrawFanShaped(double x, double y, IActiveView pActiveView) { double radius = this.radius; double small_radius = this.small_radius; double start_angle = this.start_angle; double central_angle = this.central_angle; if (pActiveView != null) { IGraphicsContainer graphicsContainer = pActiveView as IGraphicsContainer; //画大圆 IPoint pCenterPoint = new PointClass(); pCenterPoint.PutCoords(x, y); ICircularArc pCircularArc = new CircularArcClass(); pCircularArc.PutCoordsByAngle(pCenterPoint, start_angle * Math.PI / 180.0, central_angle * Math.PI / 180.0, radius); IPoint pStartPoint = pCircularArc.FromPoint; IPoint pEndPoint = pCircularArc.ToPoint; ILine pLine1 = new LineClass(); pLine1.PutCoords(pCenterPoint, pStartPoint); ILine pLine2 = new LineClass(); pLine2.PutCoords(pEndPoint, pCenterPoint); ISegmentCollection pRing1 = new PolygonClass(); ISegment pSegment1 = pLine1 as ISegment; pRing1.AddSegment(pSegment1); ISegment pSegment2 = pCircularArc as ISegment; pRing1.AddSegment(pSegment2); ISegment pSegment3 = pLine2 as ISegment; pRing1.AddSegment(pSegment3); //小圆 ICircularArc pCircularArc1 = new CircularArcClass(); pCircularArc1.PutCoordsByAngle(pCenterPoint, start_angle * Math.PI / 180.0, central_angle * Math.PI / 180.0, small_radius); IPoint pStartPoint1 = pCircularArc1.FromPoint; IPoint pEndPoint1 = pCircularArc1.ToPoint; ILine pLine3 = new LineClass(); pLine3.PutCoords(pCenterPoint, pStartPoint1); ILine pLine4 = new LineClass(); pLine4.PutCoords(pEndPoint1, pCenterPoint); ISegmentCollection pRing2 = new PolygonClass(); ISegment pSegment4 = pLine3 as ISegment; pRing2.AddSegment(pSegment4); ISegment pSegment5 = pCircularArc1 as ISegment; pRing2.AddSegment(pSegment5); ISegment pSegment6 = pLine4 as ISegment; pRing2.AddSegment(pSegment6); //简化 ITopologicalOperator pTopoLogical1 = pRing1 as ITopologicalOperator; pTopoLogical1.Simplify(); ITopologicalOperator pTopoLogical2 = pRing2 as ITopologicalOperator; pTopoLogical2.Simplify(); IGeometry geometry = pTopoLogical1.Difference(pTopoLogical2 as IGeometry); //产生一个SimpleFillSymbol符号 IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Width = 1; ISimpleFillSymbol simpleFillSymbol; simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; //设置颜色 IRgbColor rgbcolor = new RgbColorClass(); rgbcolor.Red = 0; rgbcolor.Green = 0; rgbcolor.Blue = 255; simpleFillSymbol.Color = rgbcolor as IColor; simpleFillSymbol.Outline = simpleLineSymbol; IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; IElement pElement = fillShapeElement as IElement; pElement.Geometry = geometry; graphicsContainer.AddElement(pElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
public int GetSelectSegment(IFeature pFeature, IPoint pPoint, ref ISegment pSegment) { int index = -1; pSegment = null; if (pFeature == null || pPoint == null) return index; ISegmentCollection pSegCol = pFeature.ShapeCopy as ISegmentCollection; ISegment pSeg; double dDistance = 0; double dTempDist = 0; IPoint pPt1; IPoint pPt2; ILine tmpLine = null; IPoint pProjectPt; for (int i = 0; i < pSegCol.SegmentCount; i++) { pSeg = pSegCol.Segment[i]; if (pSeg.GeometryType == esriGeometryType.esriGeometryLine) { if (dDistance == 0 && pSegment == null) { tmpLine = new LineClass(); tmpLine.PutCoords(pSeg.FromPoint, pSeg.ToPoint); //�㵽ֱ�ߵľ��� dDistance = Math.Abs(GetPointToLineDistance(pPoint, tmpLine)); pSegment = pSeg; index = i; } else { tmpLine.PutCoords(pSeg.FromPoint, pSeg.ToPoint); if (pSeg.FromPoint.X < pSeg.ToPoint.X) { pPt1 = pSeg.FromPoint; pPt2 = pSeg.ToPoint; } else { pPt2 = pSeg.FromPoint; pPt1 = pSeg.ToPoint; } //���ͶӰ�㲻��ֱ���ϣ��մ���ֱ�߲��ܹ��������� pProjectPt = GetProjectionPoint(pPoint, tmpLine); dTempDist = Math.Abs(GetPointToLineDistance(pPoint, tmpLine)); if (dDistance > dTempDist) { dDistance = dTempDist; pSegment = pSeg; index = i; } } } else if (pSeg.GeometryType == esriGeometryType.esriGeometryCircularArc) { ICircularArc tmpArc = pSeg as ICircularArc; if (dDistance == 0 && pSegment == null) { dDistance = Math.Abs(Math.Sqrt(Math.Pow(pPoint.X - tmpArc.CenterPoint.X, 2) + Math.Pow(pPoint.Y - tmpArc.CenterPoint.Y, 2))); pSegment = pSeg; index = i; } else { dTempDist = Math.Abs(Math.Sqrt(Math.Pow(pPoint.X - tmpArc.CenterPoint.X, 2) + Math.Pow(pPoint.Y - tmpArc.CenterPoint.Y, 2))); if (dDistance > dTempDist) { pSegment = pSeg; index = i; } } } } return index; }
private void CreateDongShi(IPoint P0, IPoint P1, IPoint P2, IPoint P3, string hdid, string bid) { ISegmentCollection pPath = new PathClass(); //��һ���߶� ILine pLine = new LineClass(); pLine.PutCoords(P0, P1); //QI��ISegment ISegment pSegment = pLine as ISegment; //����һ��Path���� System.Object o = Type.Missing; //ͨ��ISegmentCollection�ӿ�ΪPath�������Segment���� pPath.AddSegment(pSegment, ref o, ref o); //�ڶ����߶� ILine pLine2 = new LineClass(); pLine2.PutCoords(P1, P2); ISegment pSegment2 = pLine2 as ISegment; //����һ��Path���� //ͨ��ISegmentCollection�ӿ�ΪPath�������Segment���� pPath.AddSegment(pSegment2, ref o, ref o); //�������߶� ILine pLine3 = new LineClass(); pLine3.PutCoords(P2, P3); ISegment pSegment3 = pLine3 as ISegment; //����һ��Path���� //ͨ��ISegmentCollection�ӿ�ΪPath�������Segment���� pPath.AddSegment(pSegment3, ref o, ref o); IGeometryCollection pPolyline = new PolylineClass(); //ͨ��IGeometryCollectionΪPolyline�������Path���� pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o); if (m_pDongshiFeatureLayer != null) { System.Collections.Generic.List<ziduan> list = new System.Collections.Generic.List<ziduan>(); list.Add(new ziduan(GIS_Const.FIELD_HDID, hdid)); list.Add(new ziduan(GIS_Const.FIELD_BID, bid)); DataEditCommon.CreateNewFeature(m_pDongshiFeatureLayer, pPolyline as IGeometry,list); m_hookHelper.ActiveView.Refresh(); } }
public void points() { string strs = "Marker"; switch (strs) { case "Marker": IMarkerElement pMarkerElement;//对于点,线,面的element定义这里都不一样,他是可实例化的类,而IElement是实例化的类,必须通过 IMarkerElement 初始化负值给 IElement 。 IElement pMElement; IPoint pPoint=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE pMarkerElement = new MarkerElementClass(); pMElement = pMarkerElement as IElement; RubberPointClass pRubberBand = new RubberPointClass();//你的RUBBERBAND随着你的图形耳边 //pPoint = pRubberBand.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPoint; ////pPoint = pRubberBand.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPoint; //pPoint.X = 101; //pPoint.Y = 37; // pPoint.PutCoords(Convert.ToDouble(101), Convert.ToDouble(37)); //pPoint = axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(200, 200); // pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text)); // pPoint = axMapControl.ToMapPoint(334, 344); //pPoint.X = pPoint.X; //pPoint.Y = pPoint.Y; /*00000000000000000000000000000000000经纬度转换坐标*/ //IGlobeDisplay m_globeDisplay = axGlobeControl1.GlobeDisplay; //// IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay; ////axGlobeControl1.GlobeDisplay.ActiveViewer; //ISceneViewer sceneViewer = m_globeDisplay.ActiveViewer; //IGlobeViewUtil globeViewUtil = (IGlobeViewUtil)sceneViewer.Camera; //int winX, winY; ////globeViewUtil.GeographicToWindow(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text), 0, out winX, out winY); ////pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));//x,y地理坐标 //pPoint=axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(0, 0);//x,y为屏幕坐标 ////pPoint.X = Convert.ToDouble(textBox1.Text); ////pPoint.Y = Convert.ToDouble(textBox2.Text); //pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));//x,y地理坐标 //axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(pPoint, out winX, out winY); // int mx = winX; //int my = winY; //pPoint=axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(200, 400);//x,y为屏幕坐标 //调用GetProject2方法经纬度转换成米 pPoint = GetProject2(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text)); //pPoint.PutCoords(Convert.ToDouble(textBox3.Text), Convert.ToDouble(textBox4.Text)); /*00000000000000000000000000000000000*/ // pPoint = axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(mx, my); //pPoint.PutCoords(mx, my); //pPoint.X = mx; //pPoint.Y = my; //ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass(); //pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(2414); //pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954)); pMElement.Geometry = pPoint;//把你在屏幕中画好的图形付给 IElement 储存 IGraphicsContainer pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器 // axMapControl.get_Layer(0) // ILayer pLayer = this.axMapControl.get_Layer(1);//所要加的层 pGraphicsContainer.AddElement(pMElement, 0);//显示储存在 IElement 中图形,这样就持久化了。 axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //axMapControl.Refresh(); break; case "Line": //ILineElement pLineElement; //IElement pLElement; //IPolyline pLine; // IGraphicsContainer pGraphicsContainerl = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器 //pLineElement = new LineElementClass(); //pLElement = pLineElement as IElement; //RubberLineClass pRubberBandd = new RubberLineClass(); //pLine = pRubberBandd.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPolyline; //pLElement.Geometry = pLine; //pGraphicsContainerl = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器 //pGraphicsContainerl.AddElement(pLElement, 0);//把刚刚的element转到容器上 //axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //00000000000 //调用GetProject2方法经纬度转换成米 IPoint pPointl=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE pPointl = GetProject2(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text)); IPoint pPointl2=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE pPointl2 = GetProject2(-120, 40); //创建一个Line对象 ILine pLine2 = new LineClass(); //Polyline pLine2 = new PolylineClass(); //设置Line对象的起始终止点 pLine2.PutCoords(pPointl, pPointl2); //IPointCollection pMultipoint = new MultipointClass(); //object o=Type.Missing; //pMultipoint.AddPoint(pPointl, ref o, ref o); //pMultipoint.AddPoint(pPointl2, ref o, ref o); axMapControl.ActiveView.Refresh();//刷新当前视图 break; case "Fill": IFillShapeElement pFillShapeElement; IElement pgonElemnt; IPolygon pPolygon; pFillShapeElement = new PolygonElementClass(); pgonElemnt = pFillShapeElement as IElement;//Element RubberPolygonClass pRubberBand3 = new RubberPolygonClass();//在屏幕上画个多边形 pPolygon = pRubberBand3.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPolygon; pgonElemnt.Geometry = pPolygon;//把这个多边形转成Element pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器 //pGraphicsContainer.DeleteAllElements (); pGraphicsContainer.AddElement(pgonElemnt, 0);//把刚刚的element转到容器上 axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); break; } }
private double EvalAngle(ILine line1, ILine line2) { if (line1 == null || line2 == null) return double.NaN; // Create two alternate polygons and find the one with the minimum perimeter // First, assume that everybody's nose-to-tail ILine theJoinLine = new LineClass(); theJoinLine.PutCoords(line1.ToPoint, line2.FromPoint); ISegmentCollection theSegColl = new PolygonClass(); theSegColl.AddSegment((ISegment)line1, ref this._missing, ref this._missing); theSegColl.AddSegment((ISegment)theJoinLine, ref this._missing, ref this._missing); theSegColl.AddSegment((ISegment)line2, ref this._missing, ref this._missing); IPolygon thePolygon1 = (IPolygon)theSegColl; thePolygon1.Close(); // Now flip the second line create the second polygon ILine theFlipped = new LineClass(); theFlipped.PutCoords(line2.ToPoint, line2.FromPoint); theJoinLine = new LineClass(); theJoinLine.PutCoords(line1.ToPoint, theFlipped.FromPoint); theSegColl = new PolygonClass(); theSegColl.AddSegment((ISegment)line1, ref this._missing, ref this._missing); theSegColl.AddSegment((ISegment)theJoinLine, ref this._missing, ref this._missing); theSegColl.AddSegment((ISegment)theFlipped, ref this._missing, ref this._missing); IPolygon thePolygon2 = (IPolygon)theSegColl; thePolygon2.Close(); // The polygon with the minimum perimeter (length) is the one we want IPolygon theMinPerimeter; ILine theRealLine2; if (thePolygon1.Length < thePolygon2.Length) { theMinPerimeter = thePolygon1; theRealLine2 = line2; } else { theMinPerimeter = thePolygon2; theRealLine2 = theFlipped; } // Work out the angles from 1 to join to 2 double[] angles = new double[2]; IConstructAngle theConstAngle = (IConstructAngle) new GeometryEnvironmentClass(); angles[0] = Math.Abs(theConstAngle.ConstructThreePoint(line1.FromPoint, line1.ToPoint, theRealLine2.FromPoint)); if (this.IsConcave(line1.FromPoint, line1.ToPoint, theRealLine2.FromPoint, theMinPerimeter)) angles[0] = 2 * Math.PI - angles[0]; angles[1] = Math.Abs(theConstAngle.ConstructThreePoint(line1.ToPoint, theRealLine2.FromPoint, theRealLine2.ToPoint)); if (this.IsConcave(line1.ToPoint, theRealLine2.FromPoint, theRealLine2.ToPoint, theMinPerimeter)) angles[1] = 2 * Math.PI - angles[1]; // Figure out which side of the iBeam makes a theoretical triangle with angles A, B, and C double angleResult = Math.Abs(Math.PI - (angles[0] + angles[1])); //this.DebugPrint(line1, theJoinLine, theRealLine2, angles, angleResult); return angleResult; }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { if (m_circleFeedBack != null) { IMxDocument mxDoc = m_application.Document as IMxDocument; //Get and cache last location just in case color change is requested in keydown to //refresh the feedback IScreenDisplay disp = ((IMxApplication)m_application).Display; m_lastPoint = disp.DisplayTransformation.ToMapPoint(X, Y); //Move feedback m_circleFeedBack.MoveTo(m_lastPoint); //Calculate angle to determine cursor IConstructAngle constructAngle = (IConstructAngle)m_geomEnv; ILine angleLine = new LineClass(); angleLine.PutCoords(m_centerPoint, m_lastPoint); double angle = constructAngle.ConstructLine(angleLine); SetCursor(angle); } }
public bool HasTangentCurveMatchFeatures(IFeatureClass FeatureClass, IPolycurve inPolycurve, string WhereClause, double AngleToleranceTangentCompareInDegrees, double StraightLinesBreakLessThanInDegrees, double MaximumDeltaInDegrees, double ExcludeTangentsShorterThan, out int outFoundTangentCurvesCount, ref List<string> CurveInfoFromNeighbours) { outFoundTangentCurvesCount = 0; ILine pOriginalChord = new Line(); pOriginalChord.PutCoords(inPolycurve.FromPoint, inPolycurve.ToPoint); IVector3D vecOriginalSelected = new Vector3DClass(); vecOriginalSelected.PolarSet(pOriginalChord.Angle, 0, 1); int idxRadius = FeatureClass.FindField("RADIUS"); if (idxRadius == -1) return false; int idxCenterPointID = FeatureClass.FindField("CENTERPOINTID"); if (idxCenterPointID == -1) return false; object val = null; IGeometryBag pGeomBag = new GeometryBagClass(); IGeometryCollection pGeomColl = (IGeometryCollection)pGeomBag; IGeometry MultiPartPolyLine = new PolylineClass(); //qi IGeoDataset pGeoDS = (IGeoDataset)FeatureClass; ISpatialReference spatialRef = pGeoDS.SpatialReference; MultiPartPolyLine.SpatialReference = spatialRef; IGeometryCollection geometryCollection2 = MultiPartPolyLine as IGeometryCollection; ILine pTangentLineAtEnd = new Line(); //new ILine pTangentLineAtStart = new Line(); //new object objMissing = Type.Missing; for (int i = 0; i < 2; i++) { ILine pThisLine = null; if (i == 0) { inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtTo, 1.0, true, 0.2, pTangentLineAtEnd); pThisLine = new Line(); pThisLine.PutCoords(pTangentLineAtEnd.FromPoint, pTangentLineAtEnd.ToPoint); pGeomColl.AddGeometry(pThisLine); } else { inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0.0, true, 0.2, pTangentLineAtStart); pThisLine = new Line(); pThisLine.PutCoords(pTangentLineAtStart.FromPoint, pTangentLineAtStart.ToPoint); pGeomColl.AddGeometry(pThisLine); } //Create a new path for each line. ISegmentCollection newPath = new PathClass(); newPath.AddSegment((ISegment)pThisLine, ref objMissing, ref objMissing); //The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments. geometryCollection2.AddGeometry(newPath as IGeometry, ref objMissing, ref objMissing); } //now buffer the lines IGeometryCollection outBufferedGeometryCol = new GeometryBagClass(); for (int jj = 0; jj < geometryCollection2.GeometryCount; jj++) { IPath pPath = geometryCollection2.get_Geometry(jj) as IPath; IGeometryCollection pPolyL = new PolylineClass(); pPolyL.AddGeometry((IGeometry)pPath); ITopologicalOperator topologicalOperator = (ITopologicalOperator)pPolyL; IPolygon pBuffer = topologicalOperator.Buffer(0.1) as IPolygon; outBufferedGeometryCol.AddGeometry(pBuffer, ref objMissing, ref objMissing); } ITopologicalOperator pUnionedBuffers = null; pUnionedBuffers = new PolygonClass() as ITopologicalOperator; pUnionedBuffers.ConstructUnion((IEnumGeometry)outBufferedGeometryCol); ISpatialFilter pSpatFilt = new SpatialFilter(); pSpatFilt.WhereClause = WhereClause; pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial; pSpatFilt.Geometry = (IGeometry)pUnionedBuffers; IFeatureCursor pFeatCursLines = null; try { pFeatCursLines = FeatureClass.Search(pSpatFilt, false); } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } IVector3D vecFoundGeom = new Vector3DClass(); IFeature pFeat = pFeatCursLines.NextFeature(); bool bHasTangentStraightLineAtJunction = false; List<int> lstLargeBreak = new List<int>(); while (pFeat != null) { IGeometry pFoundLineGeom = pFeat.ShapeCopy; IPolycurve pFoundLineAsPolyCurve = pFoundLineGeom as IPolycurve; int iRelativeOrientation = GetRelativeOrientation(pFoundLineAsPolyCurve, inPolycurve); //iRelativeOrientation == 1 --> closest points are original TO and found TO //iRelativeOrientation == 2 --> closest points are original TO and found FROM //iRelativeOrientation == 3 --> closest points are original FROM and found TO //iRelativeOrientation == 4 --> closest points are original FROM and found FROM //if the feature has no radius attribute, skip. double dRadius = 0; int iCtrPoint = -1; val = pFeat.get_Value(idxRadius); if (val == DBNull.Value) dRadius = 0; else dRadius = (double)val; val = pFeat.get_Value(idxCenterPointID); IPolycurve pPolyCurve = pFoundLineGeom as IPolycurve; ILine pFoundChordCandidate = new LineClass(); pFoundChordCandidate.PutCoords(pPolyCurve.FromPoint, pPolyCurve.ToPoint); //first check for liklihood that subject line is supposed to stay straight, by //geometry chord bearing angle break test vecFoundGeom.PolarSet(pFoundChordCandidate.Angle, 0, 1); double dDotProd = vecFoundGeom.DotProduct(vecOriginalSelected); double dAngleCheck = Math.Acos(dDotProd) * 180 / Math.PI; //in degrees dAngleCheck = Math.Abs(dAngleCheck); double dLargeAngleBreakInDegrees = 3; if (dAngleCheck > dLargeAngleBreakInDegrees && dAngleCheck < (180 - dLargeAngleBreakInDegrees)) //large angle break non-tangent, greater than 3 degrees { if (!lstLargeBreak.Contains(iRelativeOrientation)) lstLargeBreak.Add(iRelativeOrientation); } if ((dAngleCheck <= StraightLinesBreakLessThanInDegrees || (180 - dAngleCheck) < StraightLinesBreakLessThanInDegrees) && val == DBNull.Value && dRadius == 0 && !(pPolyCurve.Length< ExcludeTangentsShorterThan)) { if (lstLargeBreak.Contains(iRelativeOrientation)) bHasTangentStraightLineAtJunction = true; } if (val == DBNull.Value || dRadius == 0 || pPolyCurve.Length< ExcludeTangentsShorterThan) {//if the feature has a null centrpointID then skip. Marshal.ReleaseComObject(pFeat); pFeat = pFeatCursLines.NextFeature(); continue; } if (Math.Abs(inPolycurve.Length / dRadius * 180 / Math.PI) > MaximumDeltaInDegrees) { //if the resulting curve would have a central angle more than MaximumDeltaInDegrees degrees then skip Marshal.ReleaseComObject(pFeat); pFeat = pFeatCursLines.NextFeature(); continue; } iCtrPoint = (int)val; //if geometry of curve neighbour curves have been cracked then there can be more than one segment //however since all segments would be circular arcs, just need to test the first segment ISegmentCollection pFoundLineGeomSegs = pFoundLineGeom as ISegmentCollection; ISegment pSeg = pFoundLineGeomSegs.get_Segment(0); if (!(pSeg is ICircularArc)) { Marshal.ReleaseComObject(pFeat); pFeat = pFeatCursLines.NextFeature(); continue; } dRadius = (double)pFeat.get_Value(idxRadius); IVector3D vect1 = new Vector3DClass(); IVector3D vect2 = new Vector3DClass(); ILine tang = new Line(); double dUnitSignChange = 1; if (iRelativeOrientation == 1) //closest points are original TO and found TO { dUnitSignChange = -1; vect1.PolarSet(pTangentLineAtEnd.Angle, 0, 1); pFoundLineAsPolyCurve.QueryTangent(esriSegmentExtension.esriExtendAtTo, 1.0, true, 1, tang); vect2.PolarSet(tang.Angle, 0, 1); } else if (iRelativeOrientation == 2)//closest points are original TO and found FROM { vect1.PolarSet(pTangentLineAtEnd.Angle, 0, 1); pFoundLineAsPolyCurve.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0.0, true, 1, tang); vect2.PolarSet(tang.Angle, 0, 1); } else if (iRelativeOrientation == 3)//closest points are original FROM and found TO { vect1.PolarSet(pTangentLineAtStart.Angle, 0, 1); pFoundLineAsPolyCurve.QueryTangent(esriSegmentExtension.esriExtendAtTo, 1.0, true, 1, tang); vect2.PolarSet(tang.Angle, 0, 1); } else if (iRelativeOrientation == 4)//closest points are original FROM and found FROM { dUnitSignChange = -1; vect1.PolarSet(pTangentLineAtStart.Angle, 0, 1); pFoundLineAsPolyCurve.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0.0, true, 1, tang); vect2.PolarSet(tang.Angle, 0, 1); } dDotProd = vect1.DotProduct(vect2); dAngleCheck = Math.Acos(dDotProd) * 180 / Math.PI; //in degrees dAngleCheck = Math.Abs(dAngleCheck); if (dAngleCheck < AngleToleranceTangentCompareInDegrees || (180 - dAngleCheck) < AngleToleranceTangentCompareInDegrees) { double dDerivedRadius = dRadius * dUnitSignChange; string sHarvestedCurveInfo = pFeat.OID.ToString() + "," + dDerivedRadius.ToString("#.000") + "," + iCtrPoint.ToString() + "," + "t"; CurveInfoFromNeighbours.Add(sHarvestedCurveInfo); outFoundTangentCurvesCount++; } Marshal.ReleaseComObject(pFeat); pFeat = pFeatCursLines.NextFeature(); } Marshal.FinalReleaseComObject(pFeatCursLines); if (bHasTangentStraightLineAtJunction) return false; //open to logic change to be less conservative bool bHasParallelCurveFeaturesNearby = (outFoundTangentCurvesCount > 0); return bHasParallelCurveFeaturesNearby; }
private static void ProfileCreateGraph(IApplication app, List<ProfileGraphDetails> ProfileGraph, IPolyline pPolyline, List<mainDetails> SewerColMains, List<manholeDetails> SewerColManholes, List<tapDetails> SewerColTap, int CurrentDetail) { // profile the sewer line and the surface elevation data // pPolyLine is a line composed from the edge results of the network trace IWorkspace pWS = null; ICursor pCursor = null; IMxDocument pMxDoc = null; IMap pMap = null; IZ pPolyLineZ = null; IZAware pZAwareLineZ = null; ISurface pSurface = null; IRasterLayer pRasterLayer = null; //get the elevation layer ILayer pRasLay = null; IPoint pPtOrigFrom = null; IPoint pPtOrigTo = null; IStandaloneTableCollection pStandAloneTabColl = null; IStandaloneTable pStandAloneTabMainLabel = null; ITable pTapTable = null; ITable pMainTable = null; ITable pManholeTable = null; ITable pSurfaceTable = null; ITable pMainLabelTable = null; ITableFields pTableFieldsMainLabel = null; IStandaloneTable pStandAloneTabMain = null; ITableFields pTableFieldsMain = null; IStandaloneTable pStandAloneTabManhole = null; ITableFields pTableFieldsManhole = null; IStandaloneTable pStandAloneTabSurface = null; ITableFields pTableFieldsSurface = null; IStandaloneTable pStandAloneTabTap = null; ITableFields pTableFieldsTap = null; IRowBuffer pRowBuff = null; ICursor pLabelCursor = null; ICursor pTapCursor = null; ISegment pSegment = null; ILine pLine = null; IPoint pFromPnt = null; IPoint pToPnt = null; IPoint pMidPnt = null; IDataGraphBase pDataGraphBase = null; IDataGraphT pDataGraphT = null; IPointCollection pPtCollection = null; IEnumVertex pEnumVertex = null; IPoint pPt = null; ISeriesProperties pAreaSeriesProps = null; IColor pColor = null; String strXDataFldName = null; String strYDataFldName = null; IDataSortSeriesProperties pSortFlds = null; IPointSeriesProperties pScatterSeriesProps2 = null; ISeriesProperties pScatterSeriesProps = null; IBarSeriesProperties pManHoleSeries = null; ILineSeriesProperties pLineSeriesProps2 = null; ISeriesProperties pLineSeriesProps = null; ITrackCancel pCancelTracker = null; IDataGraphWindow2 pDataGraphWin = null; IDataGraphCollection pDataGraphs = null; try { pMxDoc = (IMxDocument)app.Document; pMap = pMxDoc.FocusMap; // Open the Workspace pWS = Globals.CreateInMemoryWorkspace(); //get the elevation layer bool FCorLayerRas = true; pRasLay = Globals.FindLayer(pMap, ProfileGraph[CurrentDetail].Elevation_LayerName, ref FCorLayerRas); if (pRasLay != null) { pRasterLayer = pRasLay as IRasterLayer; // get the surface to interpolate from pSurface = Globals.GetSurface(pRasterLayer); // make the polyline z-aware pZAwareLineZ = (IZAware)pPolyline; pZAwareLineZ.ZAware = true; // work around for InterpolateFromSurface sometimes flipping polyline pPtOrigFrom = pPolyline.FromPoint; pPtOrigTo = pPolyline.ToPoint; pPolyline.Project((pRasterLayer as IGeoDataset).SpatialReference); // add z values to the polyline pPolyLineZ = (IZ)pPolyline; pPolyLineZ.InterpolateFromSurface(pSurface); pPolyline.ReverseOrientation(); } int i; pStandAloneTabColl = (IStandaloneTableCollection)pMap; for (i = pStandAloneTabColl.StandaloneTableCount - 1; i > 0; i--) { if (pStandAloneTabColl.StandaloneTable[i].Name == "Point Table") { pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.StandaloneTable[i]); continue; } else if (pStandAloneTabColl.StandaloneTable[i].Name == "Surface Table") { pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.StandaloneTable[i]); continue; } else if (pStandAloneTabColl.StandaloneTable[i].Name == "Line Table") { pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.StandaloneTable[i]); continue; } else if (pStandAloneTabColl.StandaloneTable[i].Name == "Line Label Table") { pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.StandaloneTable[i]); continue; } else if (pStandAloneTabColl.StandaloneTable[i].Name == "Points Along Table") { pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.StandaloneTable[i]); continue; } } pMainTable = Globals.createTableInMemory("Line Table", createLineFields(), pWS); if (pMainTable == null) return; pManholeTable = Globals.createTableInMemory("Point Table", createPointFields(), pWS); if (pManholeTable == null) return; if (pRasterLayer != null) { pSurfaceTable = Globals.createTableInMemory("Surface Table", createSurfaceFields(), pWS); if (pSurfaceTable == null) return; } pMainLabelTable = Globals.createTableInMemory("Line Label Table", createLineLabelFields(), pWS); if (pMainLabelTable == null) return; pTapTable = Globals.createTableInMemory("Points Along Table", createLineLabelFields(), pWS); if (pTapTable == null) return; // add the table to the map so it can be edited // Create a new standalone table and add it to the collection of the focus map pStandAloneTabMainLabel = new StandaloneTableClass(); pStandAloneTabMainLabel.Table = pMainLabelTable; pStandAloneTabColl.AddStandaloneTable(pStandAloneTabMainLabel); pMainLabelTable = (ITable)pStandAloneTabMainLabel;// QI, used in data graph pTableFieldsMainLabel = (ITableFields)pStandAloneTabMainLabel; pStandAloneTabMain = new StandaloneTableClass(); pStandAloneTabMain.Table = pMainTable; pStandAloneTabColl.AddStandaloneTable(pStandAloneTabMain); pMainTable = (ITable)pStandAloneTabMain;// QI, used in data graph pTableFieldsMain = (ITableFields)pStandAloneTabMain; pStandAloneTabManhole = new StandaloneTableClass(); pStandAloneTabManhole.Table = pManholeTable; pStandAloneTabColl.AddStandaloneTable(pStandAloneTabManhole); pManholeTable = (ITable)pStandAloneTabManhole;// QI, used in data graph pTableFieldsManhole = (ITableFields)pStandAloneTabManhole; if (pSurfaceTable != null) { pStandAloneTabSurface = new StandaloneTableClass(); pStandAloneTabSurface.Table = pSurfaceTable; pStandAloneTabColl.AddStandaloneTable(pStandAloneTabSurface); pSurfaceTable = (ITable)pStandAloneTabSurface;// QI, used in data graph pTableFieldsSurface = (ITableFields)pStandAloneTabSurface; } if (pTapTable != null) { pStandAloneTabTap = new StandaloneTableClass(); pStandAloneTabTap.Table = pTapTable; pStandAloneTabColl.AddStandaloneTable(pStandAloneTabTap); pTapTable = (ITable)pStandAloneTabTap;// QI, used in data graph pTableFieldsTap = (ITableFields)pStandAloneTabTap; } // Refresh the TOC pMxDoc.UpdateContents(); // get an insert cursor for the table pCursor = pManholeTable.Insert(true); double minChartVal = 0.0; double maxChartVal = 0.0; int id = 0; foreach (manholeDetails manholeDetail in SewerColManholes) { //SewerElevCollManholesDetails.Add(new object[] { pPt.M, manRim, manInvElev, manInv, manID }); pRowBuff = pManholeTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), manholeDetail.M);//0 pRowBuff.set_Value(pRowBuff.Fields.FindField("TOPELEV"), manholeDetail.Top);//1 pRowBuff.set_Value(pRowBuff.Fields.FindField("BOTELEV"), manholeDetail.Bottom);//2 //pRowBuff.set_Value(pRowBuff.Fields.FindField("INVERT"), manholeDetail.Invert);//3 pRowBuff.set_Value(pRowBuff.Fields.FindField("ID"), manholeDetail.ManholeID);//4 if (id == 0) { minChartVal = (double)manholeDetail.Bottom; maxChartVal = (double)manholeDetail.Top; id++; } else { if (minChartVal > (double)manholeDetail.Bottom) minChartVal = (double)manholeDetail.Bottom; if (maxChartVal < (double)manholeDetail.Top) maxChartVal = (double)manholeDetail.Top; } pCursor.InsertRow(pRowBuff); } // flush any writes pCursor.Flush(); Marshal.ReleaseComObject(pCursor); pCursor = pMainTable.Insert(true); pLabelCursor = pMainLabelTable.Insert(true); pTapCursor = pTapTable.Insert(true); foreach (mainDetails mainDetail in SewerColMains) { //SewerElevCollManholesDetails.Add(new object[] { pPt.M, manRim, manInvElev, manInv, manID }); //pRowBuff.set_Value(pRowBuff.Fields.FindField("FROMM"), mainDetail.UpM);//0 //pRowBuff.set_Value(pRowBuff.Fields.FindField("TOM"), mainDetail.DownM);//1 //pRowBuff.set_Value(pRowBuff.Fields.FindField("FROMELEV"), mainDetail.UpElev);//2 //pRowBuff.set_Value(pRowBuff.Fields.FindField("TOELEV"), mainDetail.DownElev);//3 pRowBuff = pMainTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("ELEVATION"), mainDetail.UpElev);//2 pRowBuff.set_Value(pRowBuff.Fields.FindField("MEASURE"), mainDetail.UpM);//3 pRowBuff.set_Value(pRowBuff.Fields.FindField("FACILITYID"), mainDetail.MainID);//4 pCursor.InsertRow(pRowBuff); pRowBuff = pMainTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("ELEVATION"), mainDetail.DownElev);//2 pRowBuff.set_Value(pRowBuff.Fields.FindField("MEASURE"), mainDetail.DownM);//3 pRowBuff.set_Value(pRowBuff.Fields.FindField("FACILITYID"), mainDetail.MainID);//4 pCursor.InsertRow(pRowBuff); pLine = new LineClass(); pFromPnt = new PointClass(); pToPnt = new PointClass(); pMidPnt = new PointClass(); pFromPnt.Y = mainDetail.UpElev; pFromPnt.X = mainDetail.UpM; pToPnt.Y = mainDetail.DownElev; pToPnt.X = mainDetail.DownM; pLine.PutCoords(pFromPnt, pToPnt); pSegment = pLine as ISegment; pSegment.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, pMidPnt); // pSegM = (ISegmentM)pSegment; // pSegM.SetMs( pRowBuff = pMainLabelTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("ELEVATION"), pMidPnt.Y);//2 pRowBuff.set_Value(pRowBuff.Fields.FindField("MEASURE"), pMidPnt.X);//3 pRowBuff.set_Value(pRowBuff.Fields.FindField("FACILITYID"), mainDetail.MainID);//4 pRowBuff.set_Value(pRowBuff.Fields.FindField("LABEL"), mainDetail.Label);//4 pLabelCursor.InsertRow(pRowBuff); double slope = (pToPnt.Y - pFromPnt.Y) / (pToPnt.X - pFromPnt.X); foreach (tapDetails tpDet in SewerColTap) { double distDown; if (tpDet.Added == true) continue; if (pFromPnt.X < pToPnt.X) { if (tpDet.M > pFromPnt.X && tpDet.M < pToPnt.X) { distDown = tpDet.M - pFromPnt.X; } else continue; } else { if (tpDet.M > pToPnt.X && tpDet.M < pFromPnt.X) { distDown = tpDet.M - pToPnt.X; } else continue; } { pSegment.QueryPoint(esriSegmentExtension.esriNoExtension, distDown, false, pMidPnt); //if (pMidPnt.X == tpDet.M) //{ pRowBuff = pTapTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("ELEVATION"), pMidPnt.Y);//2 pRowBuff.set_Value(pRowBuff.Fields.FindField("MEASURE"), tpDet.M);//3 pRowBuff.set_Value(pRowBuff.Fields.FindField("FACILITYID"), tpDet.tapID);//4 pRowBuff.set_Value(pRowBuff.Fields.FindField("LABEL"), tpDet.tapLabel);//4 //pRowBuff.set_Value(pRowBuff.Fields.FindField("LABEL"), mainDetail.Label);//4 pTapCursor.InsertRow(pRowBuff); tpDet.Added = true; //SewerColTap.Remove(tpDet); // } } } //if (minChartVal > (double)manholeDetail.InvertElev) // minChartVal = (double)manholeDetail.InvertElev; //if (maxChartVal < (double)manholeDetail.Rim) // maxChartVal = (double)manholeDetail.Rim; } // flush any writes pCursor.Flush(); Marshal.ReleaseComObject(pCursor); pLabelCursor.Flush(); Marshal.ReleaseComObject(pLabelCursor); pTapCursor.Flush(); Marshal.ReleaseComObject(pTapCursor); if (pSurfaceTable != null) { pPtCollection = (IPointCollection)pPolyLineZ; pEnumVertex = pPtCollection.EnumVertices; pEnumVertex.Reset(); int lPartIndex; int lVertexIndex; pEnumVertex.Next(out pPt, out lPartIndex, out lVertexIndex); pCursor = pSurfaceTable.Insert(true); while (pPt != null) { pRowBuff = pSurfaceTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), pPt.M);//2 pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"), pPt.Z);//3 pCursor.InsertRow(pRowBuff); pEnumVertex.Next(out pPt, out lPartIndex, out lVertexIndex); } } //============================================================================= // create the graph from the table // create graph pDataGraphBase = new DataGraphTClass(); pDataGraphT = (IDataGraphT)pDataGraphBase; // graph, axis and legend titles. Substitute them for different input layer pDataGraphT.GeneralProperties.Title = ProfileGraph[CurrentDetail].GraphTitle_Name; // "Sewer Main Profile"; pDataGraphT.LegendProperties.Title = ProfileGraph[CurrentDetail].Legend_Name; //"Profile Legend"; // IDataGraphTAxisProperties pHort = pDataGraphT.AxisProperties[0]; pDataGraphT.AxisProperties[0].Title = ProfileGraph[CurrentDetail].LeftAxis_Name; pDataGraphT.AxisProperties[0].AutomaticMaximum = true; pDataGraphT.AxisProperties[0].AutomaticMinimum = true; pDataGraphT.AxisProperties[0].Minimum = minChartVal - 5; pDataGraphT.AxisProperties[0].Maximum = maxChartVal + 5; pDataGraphT.AxisProperties[0].InitDefaults(); //pDataGraphT.AxisProperties[1].AutomaticMaximum = true; //pDataGraphT.AxisProperties[1].AutomaticMinimum = false; //pDataGraphT.AxisProperties[1].Minimum = minChartVal - 5; ////pDataGraphT.AxisProperties[1].Title = "Manholes"; //pDataGraphT.AxisProperties[1].Visible = true; pDataGraphT.AxisProperties[3].Visible = true; pDataGraphT.AxisProperties[3].Title = ProfileGraph[CurrentDetail].TopAxis_Name; pDataGraphT.AxisProperties[2].Title = ProfileGraph[CurrentDetail].BottomAxis_Name; // "Date"; pDataGraphT.AxisProperties[2].ValueFormat = "0"; pDataGraphT.AxisProperties[2].Minimum = 0; pDataGraphT.AxisProperties[2].AutomaticMinimum = false; pDataGraphT.AxisProperties[2].ValueFormat = "#,##0.###"; pDataGraphBase.Name = ProfileGraph[CurrentDetail].Graph_Name; ; // & strTableName layerName; //IDataGraphTGeneralProperties pGenProp = pDataGraphT.GeneralProperties; //pGenProp.Show3D = true; // put the legend below the graph //pDataGraphT.LegendProperties.Alignment = esriDataGraphTLegendBottom // use only for series-specific properties //IPointSeriesProperties pPtSeries; //IAreaSeriesProperties pAreaSeries; //ILineSeriesProperties pLineSeries; //------------------------------------------------------------------------------- // area series - ground elevation int idx = 0; if (pSurfaceTable != null) { // create the area graph for the ground elevation pAreaSeriesProps = pDataGraphT.AddSeries("area:vertical"); //("scatter_plot") '("line:vertical") pAreaSeriesProps.SourceData = pSurfaceTable;// pLayer pAreaSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; pColor = Globals.GetColor(137, 112, 68); pAreaSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB // get the fields to graph - ground elevation strXDataFldName = "X"; //pTable.Fields.Field(i).Name ' "Dist_to_Rds" strYDataFldName = "Y"; // pTable.Fields.Field(i).Name ' "Dist_to_Rds" // pSeriesProps.whereClause = whereClause pAreaSeriesProps.InLegend = true; //show legend ' false = don't show legend pAreaSeriesProps.Name = ProfileGraph[CurrentDetail].Elevation_LayerName;//A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAlias_1"); //pSeriesProps.LabelField = "OBJECTID"; pAreaSeriesProps.ValueFormat = "0 "; pAreaSeriesProps.SetField(0, strXDataFldName); // timefldName pAreaSeriesProps.SetField(1, strYDataFldName); // sort on the X value pSortFlds = (IDataSortSeriesProperties)pAreaSeriesProps; pSortFlds.AddSortingField(strXDataFldName, true, ref idx); } //------------------------------------------------------------------------------- //------Manhole Locations // create the area graph for the ground elevation pAreaSeriesProps = pDataGraphT.AddSeries("bar:minmax"); //("scatter_plot") '("line:vertical") pManHoleSeries = (IBarSeriesProperties)pAreaSeriesProps; pManHoleSeries.BarStyle = esriBarStyle.esriCylinderBar; pManHoleSeries.BarSize = 5; pAreaSeriesProps.SourceData = pManholeTable;// pLayer pAreaSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; pColor = Globals.GetColor(255, 255, 68); pAreaSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB pAreaSeriesProps.InLegend = true; //show legend ' false = don't show legend pAreaSeriesProps.Name = ProfileGraph[CurrentDetail].Point_LayerName;//"Point Locations"; pAreaSeriesProps.HorizontalAxis = 3; pAreaSeriesProps.LabelField = "ID"; pAreaSeriesProps.SetField(0, "X"); pAreaSeriesProps.SetField(1, "BOTELEV"); pAreaSeriesProps.SetField(2, "TOPELEV"); // sort on the X value //pSortFlds = (IDataSortSeriesProperties)pAreaSeriesProps; //idx = 0; //pSortFlds.AddSortingField("X", true, ref idx); //---- // line series - sewer line pColor = Globals.GetColor(76, 230, 0);// green pLineSeriesProps = pDataGraphT.AddSeries("line:vertical"); //("area:vertical") '("scatter_plot") '("line:vertical") pLineSeriesProps.SourceData = pMainTable; // pLayer pLineSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; pLineSeriesProps.PenProperties.Width = 3; pLineSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB // don't have any symbols on the line, just solid pLineSeriesProps2 = (ILineSeriesProperties)pLineSeriesProps;// 'QI pLineSeriesProps2.SymbolProperties.Style = esriDataGraphTSymbolType.esriDataGraphTSymbolNothing; // get the fields to graph strXDataFldName = "MEASURE"; strYDataFldName = "ELEVATION"; pLineSeriesProps.InLegend = true; // show legend ' false = don't show legend pLineSeriesProps.Name = ProfileGraph[CurrentDetail].Line_LayerName;//"Line Profile";// pMainTable.Fields.get_Field(pMainTable.Fields.FindField("ELEVATION")).AliasName; //pSeriesProps.LabelField = "OBJECTID" pLineSeriesProps.ValueFormat = "0 "; pLineSeriesProps.SetField(0, strXDataFldName);// timefldName pLineSeriesProps.SetField(1, strYDataFldName); // sort on the X value pSortFlds = (IDataSortSeriesProperties)pLineSeriesProps; pSortFlds.AddSortingField(strXDataFldName, true, ref idx); //---------- end line series pScatterSeriesProps = pDataGraphT.AddSeries("scatter_plot"); //("area:vertical") '("scatter_plot") '("line:vertical") pScatterSeriesProps.SourceData = pMainLabelTable; // pLayer pScatterSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; pScatterSeriesProps.PenProperties.Width = 3; pScatterSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB // don't have any symbols on the line, just solid pScatterSeriesProps2 = (IPointSeriesProperties)pScatterSeriesProps;// 'QI pScatterSeriesProps2.SymbolProperties.Style = esriDataGraphTSymbolType.esriDataGraphTSymbolCircle; pScatterSeriesProps2.SymbolProperties.Visible = false; pScatterSeriesProps2.SymbolProperties.Color = pColor.RGB; pScatterSeriesProps2.SymbolProperties.BorderProperties.Color = pColor.RGB; pScatterSeriesProps2.SymbolProperties.BorderProperties.Style = esriDataGraphTPenType.esriDataGraphTPenClear; // get the fields to graph strXDataFldName = "MEASURE"; strYDataFldName = "ELEVATION"; pScatterSeriesProps.InLegend = false; // show legend ' false = don't show legend pScatterSeriesProps.Name = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAlias_14"); //pSeriesProps.LabelField = "OBJECTID" pScatterSeriesProps.ValueFormat = " "; pScatterSeriesProps.HorizontalAxis = 3; pScatterSeriesProps.LabelField = "LABEL"; pScatterSeriesProps.Marks = true; pScatterSeriesProps.SetField(0, strXDataFldName);// timefldName pScatterSeriesProps.SetField(1, strYDataFldName); //pScatterSeriesProps.SetField(2, "LABEL"); // sort on the X value // pSortFlds = (IDataSortSeriesProperties)pScatterSeriesProps; // pSortFlds.AddSortingField(strXDataFldName, true, ref idx); //ISeriesProperties pScatterSeriesProps; pScatterSeriesProps = pDataGraphT.AddSeries("scatter_plot"); //("area:vertical") '("scatter_plot") '("line:vertical") pScatterSeriesProps.SourceData = pTapTable; // pLayer // get the fields to graph strXDataFldName = "MEASURE"; strYDataFldName = "ELEVATION"; pScatterSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; pScatterSeriesProps.PenProperties.Width = 3; pScatterSeriesProps.HorizontalAxis = 5; pScatterSeriesProps.LabelField = "LABEL"; if (ProfileGraph[CurrentDetail].PointAlong_ShowLabels.ToUpper() == "TRUE" && ProfileGraph[CurrentDetail].PointAlong_Labels.Length > 0) { pScatterSeriesProps.Marks = true; } pScatterSeriesProps.InLegend = true; // show legend ' false = don't show legend pScatterSeriesProps.Name = ProfileGraph[CurrentDetail].PointAlong_LayerName;//"Points Along"; //pSeriesProps.LabelField = "OBJECTID" pScatterSeriesProps.ValueFormat = " "; pScatterSeriesProps.SetField(0, strXDataFldName);// timefldName pScatterSeriesProps.SetField(1, strYDataFldName); pColor = Globals.GetColor(255, 0, 0);// green pScatterSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB // don't have any symbols on the line, just solid //IPointSeriesProperties pScatterSeriesProps2; pScatterSeriesProps2 = (IPointSeriesProperties)pScatterSeriesProps;// 'QI pScatterSeriesProps2.SymbolProperties.Style = esriDataGraphTSymbolType.esriDataGraphTSymbolStar; pScatterSeriesProps2.SymbolProperties.Visible = true; pScatterSeriesProps2.SymbolProperties.Color = pColor.RGB; pScatterSeriesProps2.SymbolProperties.BorderProperties.Color = pColor.RGB; pScatterSeriesProps2.SymbolProperties.BorderProperties.Style = esriDataGraphTPenType.esriDataGraphTPenSolid; pDataGraphBase.UseSelectedSet = false; pCancelTracker = new CancelTrackerClass(); pDataGraphT.Update(pCancelTracker); // create data graph window pDataGraphWin = new DataGraphWindowClass(); pDataGraphWin.DataGraphBase = pDataGraphBase; pDataGraphWin.Application = app; // size and position the window pDataGraphWin.PutPosition(0, 0, 900, 250); // add the graph to the project pDataGraphs = (IDataGraphCollection)pMxDoc; //QI pDataGraphs.AddDataGraph(pDataGraphBase); //IDataGraphT ptmp = (IDataGraphT)pDataGraphs.DataGraph[1]; //string fld = ptmp.SeriesProperties[5].GetField(0); //fld = ptmp.SeriesProperties[5].GetField(1); //fld = ptmp.SeriesProperties[5].GetField(2); //fld = ptmp.SeriesProperties[5].LabelField; //fld = ptmp.SeriesProperties[5].Marks.ToString(); // fld = ptmp.SeriesProperties[5].HorizontalAxis; pDataGraphT.AxisProperties[0].AutomaticMaximum = true; pDataGraphT.AxisProperties[0].AutomaticMinimum = true; // pDataGraphT.AxisProperties[0].Minimum = minChartVal - 5; //pDataGraphT.AxisProperties[0].Maximum = maxChartVal + 5; pDataGraphT.AxisProperties[0].InitDefaults(); // show the graph pDataGraphWin.Show(true); //// get an insert cursor for the table //pCursor = null; //pRowBuff = null; //pCursor = pProfTable.Insert(true); //// populate the table //IPoint pPt; //int lPartIndex; //int lVertexIndex; //IEnumVertex pEnumVertex; //pPtCollection = (IPointCollection)pPolyline; //pEnumVertex = pPtCollection.EnumVertices; //pEnumVertex.Reset(); //// add the vertex xyz to the new table //i = 0; //pEnumVertex.Next(out pPt, out lPartIndex, out lVertexIndex); //while (pPt != null) //{ // pRowBuff = pProfTable.CreateRowBuffer(); // pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), pPt.X); // pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"), pPt.Y); // pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"), pPt.Z); // pRowBuff.set_Value(pRowBuff.Fields.FindField("M"), pPt.M); // // keep -99999 as a flag, data will be calculated later, // // right now a graph can't ignore null values // if (SewerElevCollFroms[i] == null || SewerElevCollFroms[i].ToString() == "") // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("UPELEV"), -99999); // if (MessageBox.Show("There is a null value in the Upstream Elevations, Continue?", "Missing Data", MessageBoxButtons.YesNo) == DialogResult.No) // { // return; // } // } // else // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("UPELEV"), SewerElevCollFroms[i]); // } // if (SewerElevCollTos[i] == null || SewerElevCollTos[i].ToString() == "") // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("DOWNELEV"), -99999); // if (MessageBox.Show("There is a null value in the Downstream Elevations, Continue?", "Missing Data", MessageBoxButtons.YesNo) == DialogResult.No) // { // return; // } // } // else // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("DOWNELEV"), SewerElevCollTos[i]); // } // if (SewerElevCollRim[i] == null || SewerElevCollRim[i].ToString() == "") // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("RIMELEV"), -99999); // if (MessageBox.Show("There is a null value in the Rim Elevation, Continue?", "Missing Data", MessageBoxButtons.YesNo) == DialogResult.No) // { // return; // } // } // else // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("RIMELEV"), SewerElevCollRim[i]); // } // if (SewerElevCollInvertElev[i] == null || SewerElevCollInvertElev[i].ToString() == "") // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("INVERTELEV"), -99999); // if (MessageBox.Show("There is a null value in the Invert Elevation, Continue?", "Missing Data", MessageBoxButtons.YesNo) == DialogResult.No) // { // return; // } // } // else // { // pRowBuff.set_Value(pRowBuff.Fields.FindField("INVERTELEV"), SewerElevCollInvertElev[i]); // } // // pRowBuff.set_Value(pRowBuff.Fields.FindField("UPELEV"), SewerElevCollFroms[i]); // //pRowBuff.set_Value(pRowBuff.Fields.FindField("DOWNELEV"), SewerElevCollTos[i]); // // pRowBuff.set_Value(pRowBuff.Fields.FindField("RIMELEV"), SewerElevCollRim[i]); // // pRowBuff.set_Value(pRowBuff.Fields.FindField("INVERTELEV"), SewerElevCollInvertElev[i]); // /** use this code if graph can ignore null data // ' ' skip records with -99999 as sewer elev // ' If SewerElevColl(i) <> -99999 Then // ' pRowBuff.Value(pRowBuff.Fields.FindField("SewerElev")) = SewerElevColl(i) // ' Else // ' pRowBuff.Value(pRowBuff.Fields.FindField("SewerElev")) = Null // ' End If*/ // pCursor.InsertRow(pRowBuff); // pEnumVertex.Next(out pPt, out lPartIndex, out lVertexIndex); // i++; //} //// flush any writes //pCursor.Flush(); //Marshal.ReleaseComObject(pCursor); ///* // ' Calculate a value for an intermediate point between 2 manholes // ' needed because graph requires a value for every record or it gives it a zero. // ' Sewer lines have values at each manhole but a sewerline is composed of many // ' lines - where the laterals break it. // ' ** this may change if they modify the software to ignore null values in a graph // */ //// make a cursor of just the records that have a valid sewer elev //// needed to get the deltaSewerElev of the sewer elev data ////********* //string currentField = "UPELEV"; //for (int k = 0; k < 4; k++) //{ // switch (k) // { // case 0: // currentField = "UPELEV"; // break; // case 1: // currentField = "DOWNELEV"; // break; // case 2: // currentField = "RIMELEV"; // break; // case 3: // currentField = "INVERTELEV"; // break; // } // double Mmin = 0.0; // double Mmax = 0.0; // double minSewerElev = 0.0; // double maxSewerElev = 0.0; // double deltaSewerElev = 0.0; // double deltaM = 0.0; // double newZ = 0.0; // double m = 0.0; // double sewerelev = 0.0; // int j; // IRow pRowSewerElev; // ICursor pCursorSewerElev; // IQueryFilter pQueryFilter; // pQueryFilter = new QueryFilterClass(); // pQueryFilter.WhereClause = currentField + " <> -99999"; // pCursorSewerElev = pProfTable.Search(pQueryFilter, false); // // recreate the cursor as an update cursor // pCursor = null; // pCursor = pProfTable.Update(null, false); // pRowBuff = pCursor.NextRow(); // j = 0; // deltaM = 0; // while (pRowBuff != null) // { // // for the intermediate records, SewerElev will have a value of -99999, // // update them with a calculated value // if ((double)(pRowBuff.get_Value(pRowBuff.Fields.FindField(currentField))) == -99999) // { // m = (double)pRowBuff.get_Value(pRowBuff.Fields.FindField("M")); // newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev; // pRowBuff.set_Value(pRowBuff.Fields.FindField(currentField), newZ); // pCursor.UpdateRow(pRowBuff as IRow); // } // else // { // //valid sewer elev record // // calculate the delta sewer elev // if (j == 0) // { // // get the min and max sewer elev values // // get the man and max M value, this is used in the ratio calculation, // // I can't use the whole line length as the M because the slope of the // // sewer pipe can change at each manhole so the calculation has to be // // from manhole to manhole, not the whole line // try // { // pRowSewerElev = pCursorSewerElev.NextRow(); // minSewerElev = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField(currentField)); // //string tmp = pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")).ToString(); // //if (tmp == "") // // Mmin = 0.0; // //else // // Mmin = Convert.ToDouble(tmp); // Mmin = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")); // pRowSewerElev = pCursorSewerElev.NextRow(); // maxSewerElev = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField(currentField)); // Mmax = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")); // } // catch (Exception Ex) // { // MessageBox.Show(Ex.Message); // } // } // else // { // pRowSewerElev = pCursorSewerElev.NextRow(); // if (pRowSewerElev == null) // { // break; // } // minSewerElev = maxSewerElev; // Mmin = Mmax; // maxSewerElev = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField(currentField)); // Mmax = (double)pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")); // } // deltaSewerElev = maxSewerElev - minSewerElev; // deltaM = Mmax - Mmin; // // this value is the base value that the calc'd values need as a base // sewerelev = minSewerElev;//pRowBuff.Value(pRowBuff.Fields.FindField("SewerElev")) // j++; // } // pRowBuff = (IRowBuffer)pCursor.NextRow(); // } // pCursor.Flush(); // Marshal.ReleaseComObject(pCursor); // Marshal.ReleaseComObject(pCursorSewerElev); //} ////============================================================================= //// create the graph from the table //IDataGraphBase pDataGraphBase; //IDataGraphT pDataGraphT; //// create graph //pDataGraphBase = new DataGraphTClass(); //pDataGraphT = (IDataGraphT)pDataGraphBase; //// graph, axis and legend titles. Substitute them for different input layer //pDataGraphT.GeneralProperties.Title = "Sewer Main Profile"; //pDataGraphT.LegendProperties.Title = "Profile Legend"; //// IDataGraphTAxisProperties pHort = pDataGraphT.AxisProperties[0]; //pDataGraphT.AxisProperties[0].Title = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAlias_13"); //pDataGraphT.AxisProperties[0].AutomaticMaximum = true; //pDataGraphT.AxisProperties[0].AutomaticMinimum = true; ////pDataGraphT.AxisProperties[0].Minimum = minChartVal - 5; ////pDataGraphT.AxisProperties[0].Maximum= maxChartVal + 5; ////pDataGraphT.AxisProperties[1].AutomaticMaximum = true; ////pDataGraphT.AxisProperties[1].AutomaticMinimum = false; ////pDataGraphT.AxisProperties[1].Minimum = minChartVal - 5; //////pDataGraphT.AxisProperties[1].Title = "Manholes"; ////pDataGraphT.AxisProperties[1].Visible = true; //pDataGraphT.AxisProperties[3].Visible = true; //pDataGraphT.AxisProperties[3].Title = "Manholes"; //pDataGraphT.AxisProperties[2].Title = "Length (feet)"; // "Date"; //pDataGraphT.AxisProperties[2].ValueFormat = "0"; //pDataGraphT.AxisProperties[2].Minimum = 0; //pDataGraphT.AxisProperties[2].AutomaticMinimum = false; //pDataGraphT.AxisProperties[2].ValueFormat = "#,##0.###"; //pDataGraphBase.Name = "Sewer Main Profile Graph"; // & strTableName layerName; ////IDataGraphTGeneralProperties pGenProp = pDataGraphT.GeneralProperties; ////pGenProp.Show3D = true; //// put the legend below the graph ////pDataGraphT.LegendProperties.Alignment = esriDataGraphTLegendBottom //// use only for series-specific properties ////IPointSeriesProperties pPtSeries; ////IAreaSeriesProperties pAreaSeries; ////ILineSeriesProperties pLineSeries; ////------------------------------------------------------------------------------- //// area series - ground elevation //ISeriesProperties pAreaSeriesProps; //IColor pColor; //// create the area graph for the ground elevation //pAreaSeriesProps = pDataGraphT.AddSeries("area:vertical"); //("scatter_plot") '("line:vertical") //pAreaSeriesProps.SourceData = pProfTable;// pLayer //pAreaSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; //pColor = Globals.GetColor(137, 112, 68); //pAreaSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB //String strXDataFldName; //String strYDataFldName; //// get the fields to graph - ground elevation //strXDataFldName = "M"; //pTable.Fields.Field(i).Name ' "Dist_to_Rds" //strYDataFldName = "Z"; // pTable.Fields.Field(i).Name ' "Dist_to_Rds" ////timefldName = "TSDateTime" ' substitute data/time field name for different dataset ////gageIDFldName = "Name" ' substitute gage ID field name for different dataset //// pSeriesProps.whereClause = whereClause //pAreaSeriesProps.InLegend = true; //show legend ' false = don't show legend //pAreaSeriesProps.Name = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAlias_1"); ////pSeriesProps.LabelField = "OBJECTID"; //pAreaSeriesProps.ValueFormat = "0 "; //pAreaSeriesProps.SetField(0, strXDataFldName); // timefldName //pAreaSeriesProps.SetField(1, strYDataFldName); //// sort on the X value //IDataSortSeriesProperties pSortFlds; //pSortFlds = (IDataSortSeriesProperties)pAreaSeriesProps; //int idx = 0; //pSortFlds.AddSortingField(strXDataFldName, true, ref idx); ////------------------------------------------------------------------------------- ////------Manhole Locations //IBarSeriesProperties pManHoleSeries; //// create the area graph for the ground elevation //pAreaSeriesProps = pDataGraphT.AddSeries("bar:minmax"); //("scatter_plot") '("line:vertical") //pManHoleSeries = (IBarSeriesProperties)pAreaSeriesProps; //pManHoleSeries.BarStyle = esriBarStyle.esriCylinderBar; //pManHoleSeries.BarSize = 5; //pAreaSeriesProps.SourceData = pManTable;// pLayer //pAreaSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; //pColor = Globals.GetColor(255, 255, 68); //pAreaSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB //pAreaSeriesProps.InLegend = true; //show legend ' false = don't show legend //pAreaSeriesProps.Name = "Manhole Locations"; //pAreaSeriesProps.HorizontalAxis = 3; //pAreaSeriesProps.LabelField = "ID"; //pAreaSeriesProps.SetField(0, "X"); //pAreaSeriesProps.SetField(1, "INVERTELEV"); //pAreaSeriesProps.SetField(2, "RIMELEV"); //// sort on the X value ////pSortFlds = (IDataSortSeriesProperties)pAreaSeriesProps; ////idx = 0; ////pSortFlds.AddSortingField("X", true, ref idx); ////---- //// line series - sewer line //currentField = "UPELEV"; //int currentFieldWidth = 1; //for (int k = 3; k >= 0; k--) //{ // switch (k) // { // case 0: // currentField = "UPELEV"; // pColor = Globals.GetColor(76, 230, 0);// green // currentFieldWidth = 3; // break; // case 1: // currentField = "DOWNELEV"; // pColor = Globals.GetColor(76, 0, 255); // currentFieldWidth = 3; // break; // case 2: // currentField = "RIMELEV"; // pColor = Globals.GetColor(76, 230, 255); // currentFieldWidth = 3; // continue; // //break; // case 3: // currentField = "INVERTELEV"; // pColor = Globals.GetColor(255, 230, 0); // currentFieldWidth = 3; // break; // } // ISeriesProperties pLineSeriesProps; // pLineSeriesProps = pDataGraphT.AddSeries("line:vertical"); //("area:vertical") '("scatter_plot") '("line:vertical") // pLineSeriesProps.SourceData = pProfTable; // pLayer // pLineSeriesProps.ColorType = esriGraphColorType.esriGraphColorCustomAll; // pLineSeriesProps.PenProperties.Width = currentFieldWidth; // pLineSeriesProps.CustomColor = pColor.RGB; // pSymbol.Color.RGB // // don't have any symbols on the line, just solid // ILineSeriesProperties pLineSeriesProps2; // pLineSeriesProps2 = (ILineSeriesProperties)pLineSeriesProps;// 'QI // pLineSeriesProps2.SymbolProperties.Style = esriDataGraphTSymbolType.esriDataGraphTSymbolNothing; // // get the fields to graph // strXDataFldName = "M"; // strYDataFldName = currentField; // pLineSeriesProps.InLegend = true; // show legend ' false = don't show legend // pLineSeriesProps.Name = pProfTable.Fields.get_Field(pProfTable.Fields.FindField(currentField)).AliasName; // //pSeriesProps.LabelField = "OBJECTID" // pLineSeriesProps.ValueFormat = "0 "; // pLineSeriesProps.SetField(0, strXDataFldName);// timefldName // pLineSeriesProps.SetField(1, strYDataFldName); // // sort on the X value // pSortFlds = (IDataSortSeriesProperties)pLineSeriesProps; // pSortFlds.AddSortingField(strXDataFldName, true, ref idx); // //---------- end line series //} //pDataGraphBase.UseSelectedSet = false; //ITrackCancel pCancelTracker; //pCancelTracker = new CancelTrackerClass(); //pDataGraphT.Update(pCancelTracker); ////pDataGraphT.get_AxisProperties(0).AutomaticMaximum = true; ////pDataGraphT.get_AxisProperties(0).AutomaticMinimum= true; ////pDataGraphT.get_AxisProperties(1).AutomaticMaximum = true; ////pDataGraphT.get_AxisProperties(1).AutomaticMinimum = true; ////pDataGraphT.get_AxisProperties(2).AutomaticMaximum = true; ////pDataGraphT.get_AxisProperties(2).AutomaticMinimum = true; ////pDataGraphT.get_AxisProperties(3).AutomaticMaximum = true; ////pDataGraphT.get_AxisProperties(3).AutomaticMinimum = true; //// create data graph window //IDataGraphWindow2 pDataGraphWin; //pDataGraphWin = new DataGraphWindowClass(); //pDataGraphWin.DataGraphBase = pDataGraphBase; //pDataGraphWin.Application = app; //// size and position the window //pDataGraphWin.PutPosition(0, 0, 900, 250); //// add the graph to the project //IDataGraphCollection pDataGraphs; //pDataGraphs = (IDataGraphCollection)pMxDoc; //QI //pDataGraphs.AddDataGraph(pDataGraphBase); ////IDataGraphT ptmp = (IDataGraphT)pDataGraphs.DataGraph[1]; ////string fld = ptmp.SeriesProperties[5].GetField(0); ////fld = ptmp.SeriesProperties[5].GetField(1); ////fld = ptmp.SeriesProperties[5].GetField(2); ////fld = ptmp.SeriesProperties[5].LabelField; ////fld = ptmp.SeriesProperties[5].Marks.ToString(); //// fld = ptmp.SeriesProperties[5].HorizontalAxis; //// show the graph //pDataGraphWin.Show(true); } catch (Exception Ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "ProfileCreateGraph " + Ex.Message); } finally { pWS = null; pCursor = null; pMxDoc = null; pMap = null; pPolyLineZ = null; pZAwareLineZ = null; pSurface = null; pRasterLayer = null; pRasLay = null; pPtOrigFrom = null; pPtOrigTo = null; pStandAloneTabColl = null; pStandAloneTabMainLabel = null; pTapTable = null; pMainTable = null; pManholeTable = null; pSurfaceTable = null; pMainLabelTable = null; pTableFieldsMainLabel = null; pStandAloneTabMain = null; pTableFieldsMain = null; pStandAloneTabManhole = null; pTableFieldsManhole = null; pStandAloneTabSurface = null; pTableFieldsSurface = null; pStandAloneTabTap = null; pTableFieldsTap = null; pRowBuff = null; pLabelCursor = null; pTapCursor = null; pSegment = null; pLine = null; pFromPnt = null; pToPnt = null; pMidPnt = null; pDataGraphBase = null; pDataGraphT = null; pPtCollection = null; pEnumVertex = null; pPt = null; pAreaSeriesProps = null; pColor = null; pSortFlds = null; pScatterSeriesProps2 = null; pScatterSeriesProps = null; pManHoleSeries = null; pLineSeriesProps2 = null; pLineSeriesProps = null; pCancelTracker = null; pDataGraphWin = null; pDataGraphs = null; } }
private void createpolygon(IPointCollection ippoints) { ISegmentCollection ppath = new PathClass(); IGeometryCollection ppolyline = new PolylineClass(); if (ippoints.PointCount >= 3) { int i; object o = Type.Missing; if (ippoints.PointCount >= 4) { ippoints.RemovePoints(ippoints.PointCount - 2, 1); } ippoints.AddPoint(ippoints.get_Point(0)); for (i = 0; i < ippoints.PointCount - 1; i++) { ILine pline = new LineClass(); pline.PutCoords(ippoints.get_Point(i), ippoints.get_Point(i + 1)); ISegment psegment = pline as ISegment; ppath.AddSegment(psegment, ref o, ref o); ppolyline.AddGeometry(ppath as IGeometry, ref o, ref o); } ipPolyResult = ppolyline as IPolyline; ISegmentCollection pRing = new RingClass(); IGeometryCollection pGeometryColl = new PolygonClass(); for (int j = 0; j < ppolyline.GeometryCount; j++) { pRing.AddSegmentCollection(ppolyline.get_Geometry(j) as ISegmentCollection); pGeometryColl.AddGeometry(pRing as IGeometry, ref o, ref o); } ipolygon = pGeometryColl as IPolygon; } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 2) return; INewLineFeedback pLineFeed; if (m_pPoint1 == null) { m_pPoint1 = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_pPoint1 = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pPoint1); m_pFeedback = new NewLineFeedbackClass(); pLineFeed = (INewLineFeedback)m_pFeedback; pLineFeed.Start(m_pPoint1); if (m_pFeedback != null) m_pFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay; } else if (m_pPoint2 == null) { ///20140216 lyf ICursor pCursor = null; m_selectionSet.Search(null, false, out pCursor); IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor; IFeature m_pFeature = pFeatureCursor.NextFeature(); if (pCursor != null) { pCursor = null; ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pCursor); } if (m_pFeature == null) { MessageBox.Show(@"��ѡҪ��Ϊ�գ�������ѡ��Ҫ�ء�", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } m_pPoint2 = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_pPoint2 = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pPoint2); //�ߺ�Ҫ�ض���ȫ�ˣ���ʼ���� //IFeatureLayer pFeatureLayer = m_pCurrentLayer as IFeatureLayer; IFeatureClass pFeatureClass = m_featureLayer.FeatureClass; ILine nLine = new LineClass();//�������� nLine.PutCoords(m_pPoint1, m_pPoint2); ITransformation nTransformation = new AffineTransformation2DClass(); IAffineTransformation2D nAffineTransformation2D = nTransformation as IAffineTransformation2D; nAffineTransformation2D.DefineReflection(nLine); //����༭ IWorkspaceEdit pWorkspaceEdit = DataEditCommon.g_CurWorkspaceEdit;// GetWorkspaceEdit(); ITransform2D nTransform2D = m_pFeature.Shape as ITransform2D;//����Ŀ�� nTransform2D.Transform(esriTransformDirection.esriTransformForward, nTransformation); if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry0Dimension) { pWorkspaceEdit.StartEditOperation(); IFeature pNewFeature = pFeatureClass.CreateFeature(); IPoint pNewPoint = nTransform2D as IPoint; pNewFeature.Shape = pNewPoint; pNewFeature.Store(); pWorkspaceEdit.StopEditOperation(); DataEditCommon.g_pMyMapCtrl.Map.ClearSelection(); DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature); } else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry1Dimension) { pWorkspaceEdit.StartEditOperation(); IFeature pNewFeature = pFeatureClass.CreateFeature(); IPolyline pNewPolyline = nTransform2D as IPolyline;//�������� pNewFeature.Shape = pNewPolyline; pNewFeature.Store(); pWorkspaceEdit.StopEditOperation(); DataEditCommon.g_pMyMapCtrl.Map.ClearSelection(); DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature); } else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry2Dimension) { pWorkspaceEdit.StartEditOperation(); IFeature pNewFeature = pFeatureClass.CreateFeature(); IPolygon pNewPolygon = nTransform2D as IPolygon;//�������� pNewFeature.Shape = pNewPolygon; pNewFeature.Store(); pWorkspaceEdit.StopEditOperation(); DataEditCommon.g_pMyMapCtrl.Map.ClearSelection(); DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature); } else { } pLineFeed = (INewLineFeedback)m_pFeedback; pLineFeed.AddPoint(m_pPoint2); pLineFeed.Stop();//��קֹͣ m_pFeature = null; m_pPoint1 = null; m_pPoint2 = null; } m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void createpolyline(IPointCollection ippoints) { ISegmentCollection ppath = new PathClass(); IGeometryCollection ppolyline = new PolylineClass(); if (ippoints.PointCount >= 2) { int i; for (i = 0; i < ippoints.PointCount - 1; i++) { ILine pline = new LineClass(); pline.PutCoords(ippoints.get_Point(i), ippoints.get_Point(i + 1)); ISegment psegment = pline as ISegment; object o = Type.Missing; ppath.AddSegment(psegment, ref o, ref o); ppolyline.AddGeometry(ppath as IGeometry, ref o, ref o); } ipPolyResult = ppolyline as IPolyline; } }
/// <summary> /// 绘制揭露断层图元 /// </summary> /// <params name="faultage"></params> private void DrawJldc(Faultage faultage) { ////1.获得当前编辑图层 //DrawSpecialCommon drawspecial = new DrawSpecialCommon(); //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_EXPOSE_FAULTAGE;//“揭露断层”图层 //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName); //if (featureLayer == null) //{ // MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制揭露断层图元。"); // return; //} ////2.生成要素(要根据中心点获取起止点) ////中心点 //double centrePtX = Convert.ToDouble(this.txtCoordinateX.Text.ToString()); //double centrePtY = Convert.ToDouble(this.txtCoordinateY.Text.ToString()); //IPoint centrePt = new PointClass(); //centrePt.X = centrePtX; //centrePt.Y = centrePtY; //// 图形坐标Z //zwy 20140526 add //double dCoordinateZ = 0; //if (!double.TryParse(this.txtCoordinateZ.Text.Trim(), out dCoordinateZ)) //{ // MessageBox.Show("输入的Z坐标不是有效数值,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //centrePt.Z = dCoordinateZ; //double angle = Convert.ToDouble(this.txtAngle.Text.ToString());//倾角 //double length = 10;//默认长度为20,左右各10 ////计算起止点 //IPoint fromPt = new PointClass(); //IPoint toPt = new PointClass(); //CalculateEndpoints(centrePt, angle, length, ref fromPt, ref toPt); //DataEditCommon.g_CurWorkspaceEdit.StartEditing(false); //DataEditCommon.g_CurWorkspaceEdit.StartEditOperation(); //IFeature pFeature = featureLayer.FeatureClass.CreateFeature(); //ILine line = new LineClass(); //line.PutCoords(fromPt, toPt); //object Missing = Type.Missing; //ISegment segment = line as ISegment; //ISegmentCollection newLine = new PolylineClass(); //newLine.AddSegment(segment, ref Missing, ref Missing); //IPolyline polyline = newLine as IPolyline; //DataEditCommon.ZMValue(pFeature, polyline); //zwy 20140526 add //pFeature.Shape = polyline; ////2.1断层标注(DCBZ) //string strMC = this.txtFaultageName.Text;//断层名称 //string strLC = this.txtGap.Text;//落差 //string strQJ = this.txtAngle.Text;//倾角 //string strDCBZ = strMC + " " + "H=" + strLC + "m" + " " + "<" + strQJ + "°"; ////断层标注字段赋值(该字段值保持在图层属性中) //int index = featureLayer.FeatureClass.Fields.FindField("FAULTAGE_NAME"); //pFeature.set_Value(index, strDCBZ); ////要素ID字段赋值(对应属性表中BindingID) //int iFieldID = pFeature.Fields.FindField(GIS_Const.FIELD_BID); //pFeature.Value[iFieldID] = faultage.bid.ToString(); //pFeature.Store(); //DataEditCommon.g_CurWorkspaceEdit.StopEditOperation(); //DataEditCommon.g_CurWorkspaceEdit.StopEditing(true); ////2.2给生成的断层赋符号 //int ID = pFeature.OID; //string path = Application.StartupPath + @"\symbol.ServerStyle";//【这里用到了自己定义的符号库】 ////默认为正断层(符号) //string sGalleryClassName = "123"; //string symbolName = "123"; ; //if (this.rbtnFrontFaultage.Checked)//正断层 //{ // sGalleryClassName = "123"; // symbolName = "123"; //} //else if (this.rbtnOppositeFaultage.Checked)//逆断层 //{ // sGalleryClassName = "1234"; // symbolName = "1234"; //} //ILineSymbol lineSymbol = GetSymbol(path, sGalleryClassName, symbolName); //ILayer layer = featureLayer as ILayer; //SpecialLineRenderer(layer, ID, lineSymbol); //AddAnnotate(layer, GIS_Const.FILE_DCBZ); ////缩放到新增的线要素,并高亮该要素 //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = pFeature.Shape.Envelope; //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(1.5, 1.5, true); //GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, pFeature); //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_EXPOSE_FAULTAGE); var featureLayer = (IFeatureLayer)pLayer; if (pLayer == null) { MessageBox.Show(@"未找到揭露断层图层,无法绘制揭露断层图元。"); return; } //2.生成要素(要根据中心点获取起止点) //中心点 IPoint centrePt = new PointClass(); centrePt.X = faultage.coordinate_x; centrePt.Y = faultage.coordinate_y; centrePt.Z = faultage.coordinate_z; var trend = faultage.trend; //走向 var length = faultage.length / 2; //默认长度为20,左右各10 //计算起止点 IPoint fromPt = new PointClass(); IPoint toPt = new PointClass(); CalculateEndpoints(centrePt, trend, length, ref fromPt, ref toPt); ILine line = new LineClass(); line.PutCoords(fromPt, toPt); var missing = Type.Missing; var segment = (ISegment)line; ISegmentCollection newLine = new PolylineClass(); newLine.AddSegment(segment, ref missing, ref missing); var polyline = (IPolyline)newLine; var list = new List<ziduan> { new ziduan("bid", faultage.bid), new ziduan("FAULTAGE_NAME", faultage.name), new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture)), new ziduan("GAP", faultage.gap), new ziduan("ANGLE", faultage.angle.ToString(CultureInfo.InvariantCulture)), new ziduan("TREND", faultage.trend.ToString(CultureInfo.InvariantCulture)), new ziduan("SEPARATION", faultage.separation), new ziduan("type", faultage.type) }; var pfeature = DataEditCommon.CreateNewFeature(featureLayer, polyline, list); if (pfeature == null) return; MyMapHelp.Jump(polyline); DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh( (esriViewDrawPhase)34, null, null); }
private void theForm_BoxChange(object sender, EventArgs e) { bool bNeedRefresh = false; ISDUTExtension theExt = this.Extension; IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theExt.FocusMap); ui.CreateWellsiteBoxForm theForm = (ui.CreateWellsiteBoxForm)sender; IPolygon theBox = null; if (double.IsNaN(theForm.Orientation) == false && double.IsNaN(theForm.BoxSize) == false) { theBox = this.CreateBox(this._Wellsite, theForm.Orientation, theForm.BoxSize, theForm.SizeUnits); theBox.Project(theExt.FocusMap.SpatialReference); } // Clear existing feedback if (this._Feedback != null) { theGCont.DeleteElement(this._Feedback); this._Feedback = null; bNeedRefresh = true; } // Create new graphic if (theBox != null) { object theMissing = Type.Missing; IElement theBoxE = new PolygonElementClass(); theBoxE.Geometry = theBox; ((IFillShapeElement)theBoxE).Symbol = util.GraphicsHelper.get_SimplePolygonSymbol( util.GraphicsHelper.get_RgbColor(0, 0, 0), esriSimpleFillStyle.esriSFSHollow, util.GraphicsHelper.get_SimpleLineSymbol( util.GraphicsHelper.get_RgbColor(0, 0, 0), 2.0, esriSimpleLineStyle.esriSLSSolid)); ILine theLine = new LineClass(); theLine.PutCoords(this._Wellsite, theBox.FromPoint); ISegmentCollection theSegColl = new PolylineClass(); theSegColl.AddSegment((ISegment)theLine, ref theMissing, ref theMissing); IElement theLineE = new LineElementClass(); theLineE.Geometry = (IGeometry)theSegColl; IGroupElement theGroupE = new GroupElementClass(); theGroupE.AddElement(theBoxE); theGroupE.AddElement(theLineE); this._Feedback = (IElement)theGroupE; theGCont.AddElement(this._Feedback, 0); bNeedRefresh = true; } // Refresh the graphics in the map if (bNeedRefresh) { IActiveView theAV = (IActiveView)theExt.FocusMap; theAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, theAV.Extent); } }
private static double GetAngleOfSegment(IPoint FromPoint, IPoint ToPoint) { //double testa = DegreeToRadian(Math.Atan((inSegment.ToPoint.Y - inSegment.FromPoint.Y) / (inSegment.ToPoint.X - inSegment.FromPoint.X))); ////degrees(atan((top - bottom)/(right - left))) ILine line = new LineClass(); double outAngle; double pi = 4 * System.Math.Atan(1); line.PutCoords(FromPoint, ToPoint); //if (line.Angle < 0) // outAngle = (180 * line.Angle) / pi; //else // outAngle = (180 - (line.Angle * 180) / 3.14159265358979); outAngle = (180 - (line.Angle * 180) / 3.14159265358979); //double dangle = Math.Abs(line.Angle) * 360 / (2 * pi); //line.FromPoint = inSegment.FromPoint; //line.ToPoint = inSegment.ToPoint; //outAngle = (int)System.Math.Round(((180 * line.Angle) / pi), 0); //outAngle = line.Angle; //outAngle = outAngle + 90; if (outAngle < 0) { outAngle += 360; } if (outAngle > 360) { outAngle -= 360; } return outAngle; }
private ICircularArc ConstructCurveFromString(string inString, ISegment ExitTangentFromPreviousCourse, esriDirectionType inDirectionType, esriDirectionUnits inDirectionUnits, out double outChordLength, out double outChordBearing) { // IConstructCircularArc pConstArc = new CircularArcClass(); ICircularArc pArc = (ICircularArc)pConstArc; IPoint pPt = new PointClass(); pPt.PutCoords(1000, 1000); //initialize the curve params bool bHasRadius = false; double dRadius = -1; bool bHasChord = false; double dChord = -1; bool bHasArc = false; double dArcLength = -1; bool bHasDelta = false; double dDelta = -1; bool bCCW = false; //assume curve to right unless proven otherwise //now initialize bearing types for non-tangent curves bool bHasRadialBearing = false; double dRadialBearing = -1; bool bHasChordBearing = false; double dChordBearing = -1; bool bHasTangentBearing = false; double dTangentBearing = -1; ISegment EntryTangentSegment = null; int iItemPosition = 0; string[] sCourse = inString.Split(' '); int UpperBound = sCourse.GetUpperBound(0); bool bIsTangentCurve = (((string)sCourse.GetValue(0)).ToLower() == "tc"); foreach (string item in sCourse) { if (item == null) break; if ((item.ToLower() == "r") && (!bHasRadius) && (iItemPosition <= 3)) {// this r is for radius dRadius = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1)); bHasRadius = true; //found a radius } if ((item.ToLower()) == "c" && (!bHasChord) && (iItemPosition <= 3)) {// this c is for chord length dChord = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1)); bHasChord = true; //found a chord length } if ((item.ToLower()) == "a" && (!bHasArc) && (iItemPosition <= 3)) {// this a is for arc length dArcLength = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1)); bHasArc = true; //found an arc length } if ((item.ToLower()) == "d" && (!bHasDelta) && (iItemPosition <= 3)) {// this d is for delta or central angle dDelta = Angle_2_Radians((string)sCourse.GetValue(iItemPosition + 1), inDirectionUnits); bHasDelta = true; //found a central angle } if ((item.ToLower()) == "r" && (!bHasRadialBearing) && (iItemPosition > 3) && (UpperBound > 5)) {// this r is for radial bearing try { dRadialBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits); if (!(dRadialBearing == -999)) { bHasRadialBearing = true; } //found a radial bearing } catch { }//this will catch case of final R meaning a curve right and not radial bearing } if ((item.ToLower()) == "c" && (!bHasChordBearing) && (iItemPosition > 3)) {// this c is for chord bearing dChordBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits); bHasChordBearing = true; //found a chord bearing } if ((item.ToLower()) == "t" && (!bHasTangentBearing) && (iItemPosition > 3)) {// this t is for tangent bearing dTangentBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits); bHasTangentBearing = true; //found a tangent bearing IConstructPoint2 pToPt = new PointClass(); pToPt.ConstructAngleDistance(pPt, dTangentBearing, 100); ILine EntryTangentLine = new LineClass(); EntryTangentLine.PutCoords(pPt, (IPoint)pToPt); EntryTangentSegment = (ISegment)EntryTangentLine; } if ((item.ToLower()) == "l") // this l is for defining a curve to the left bCCW = true; iItemPosition += 1; } if (!(bIsTangentCurve)) //non-tangent curve {//chord bearing if (bHasRadius && bHasChord && bHasChordBearing) { try { pConstArc.ConstructBearingRadiusChord(pPt, dChordBearing, bCCW, dRadius, dChord, true); } catch { }; } if (bHasRadius && bHasArc && bHasChordBearing) { try { pConstArc.ConstructBearingRadiusArc(pPt, dChordBearing, bCCW, dRadius, dArcLength); } catch { }; } if (bHasRadius && bHasDelta && bHasChordBearing) { try { pConstArc.ConstructBearingRadiusAngle(pPt, dChordBearing, bCCW, dRadius, dDelta); } catch { }; } if (bHasChord && bHasDelta && bHasChordBearing) { try { pConstArc.ConstructBearingAngleChord(pPt, dChordBearing, bCCW, dDelta, dChord); } catch { }; } if (bHasChord && bHasArc && bHasChordBearing) { try { pConstArc.ConstructBearingChordArc(pPt, dChordBearing, bCCW, dChord, dArcLength); } catch { }; } //tangent bearing if (bHasRadius && bHasChord && bHasTangentBearing) { try { pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord); } catch { }; } if (bHasRadius && bHasArc && bHasTangentBearing) { try { pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength); } catch { }; } if (bHasRadius && bHasDelta && bHasTangentBearing) { try { pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta); } catch { }; } if (bHasChord && bHasDelta && bHasTangentBearing) { try { pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord); } catch { }; } if (bHasChord && bHasArc && bHasTangentBearing) { try { pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength); } catch { }; } //radial bearing if (bHasRadialBearing) { //need to convert radial bearing to tangent bearing by adding/subtracting 90 degrees double dTanBear = 0; if (bCCW) dTanBear = dRadialBearing - (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees)); else dTanBear = dRadialBearing + (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees)); IConstructPoint2 pToPt = new PointClass(); pToPt.ConstructAngleDistance(pPt, dTanBear, 100); ILine EntryTangentLine = new LineClass(); EntryTangentLine.PutCoords(pPt, (IPoint)pToPt); EntryTangentSegment = (ISegment)EntryTangentLine; } if (bHasRadius && bHasChord && bHasRadialBearing) { try { pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord); } catch { }; } if (bHasRadius && bHasArc && bHasRadialBearing) { try { pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength); } catch { }; } if (bHasRadius && bHasDelta && bHasRadialBearing) { try { pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta); } catch { }; } if (bHasChord && bHasDelta && bHasRadialBearing) { try { pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord); } catch { }; } if (bHasChord && bHasArc && bHasRadialBearing) { try { pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength); } catch { }; } } else { //tangent curve if (bHasRadius && bHasChord) { try { pConstArc.ConstructTangentRadiusChord(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dChord); } catch { }; } if (bHasRadius && bHasArc) { try { pConstArc.ConstructTangentRadiusArc(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dArcLength); } catch { }; } if (bHasRadius && bHasDelta) { try { pConstArc.ConstructTangentRadiusAngle(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dDelta); } catch { }; } if (bHasChord && bHasDelta) { try { pConstArc.ConstructTangentAngleChord(ExitTangentFromPreviousCourse, false, bCCW, dDelta, dChord); } catch { }; } if (bHasChord && bHasArc) { try { pConstArc.ConstructTangentChordArc(ExitTangentFromPreviousCourse, false, bCCW, dChord, dArcLength); } catch { }; } } ILine pLine = new LineClass(); try { pLine.PutCoords(pArc.FromPoint, pArc.ToPoint); } catch { outChordLength = -1; outChordBearing = -1; return null; } outChordLength = pLine.Length; outChordBearing = pLine.Angle; return pArc; }