Example #1
0
 private void menuItem72_Click(object sender, EventArgs e)
 {
     frmDrawProfile frmDrawProfile1 = new frmDrawProfile(null) ;
     frmDrawProfile1.Show();
 }
Example #2
0
        //根据多段线和阀门数组创建高程剖面 
        public static void ProfileCreateGraph(MainFrm pMainFrm, IPolyline pPolyline, IArray pSewerElevArray)
        {
            AxMapControl axMap = pMainFrm.getMapControl();
            IZ pPolylineZ = pPolyline as IZ;
            IRasterLayer pRasterLyr = FindRasterLayer("Elevation", pMainFrm);
            //获得表面进行插值
            ISurface pSurface = GetSurface(pRasterLyr);
            //创建Polyline z-ware;
            IZAware pZAwareLineZ = pPolyline as IZAware;
            pZAwareLineZ.ZAware = true;
            //'* work around for InterpolateFromSurface sometimes flipping polyline
            IPoint pPtOrigFrom = pPolyline.FromPoint;
            IPoint pPtOrigTo = pPolyline.ToPoint;
            //添加Z值到多边形上
            pPolylineZ.InterpolateFromSurface(pSurface);
            if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y)
                pPolyline.ReverseOrientation();
            //添加M值到线上
            IMSegmentation pMSegmentation = pPolyline as IMSegmentation;
            IMAware pMAware = pPolyline as IMAware;
            pMAware.MAware = true;
            pMSegmentation.SetMsAsDistance(false);
            //创建表格
            ITable pTable = ProfileCreateTable();
            int i=0;
            if (pTable != null)
            {
                //在图层列表控件中要确保该表格还不存在,如果存在则删除它
                IStandaloneTableCollection pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
                for ( i = 0; i<=pStandAloneTabColl.StandaloneTableCount - 1; i++)
                {
                    if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable")
                        pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i));
                }
                //创建一个新的独立表,并把它添加到地图集合中
                IStandaloneTable pStandAloneTab = new StandaloneTableClass();
                pStandAloneTab.Table = pTable;
                pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
                pStandAloneTabColl.AddStandaloneTable(pStandAloneTab);
                pTable = pStandAloneTab as ITable;
                                //为两个字段设置别名 
                ITableFields pTableFields = pStandAloneTab as ITableFields;
                IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z"));
                pFieldInfo.Alias = "Ground Elevation";
                pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev"));
                pFieldInfo.Alias = "Sewer Line Elevation";
                //为表格获得一个插入光标 
                ICursor pCursor=pTable.Insert(true);
                IRowBuffer pRowBuff;
                //
                IPointCollection pPtCollection = pPolyline as IPointCollection;
                IEnumVertex pEnumVertex = pPtCollection.EnumVertices;
                pEnumVertex.Reset();
                IPoint pPT;
                 int iPartIndex;
                int iVertexIndex;
                  i = 0;
                //添加节点XYZ到新表格中
                pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
                while (pPT != null)
                {
                    pRowBuff = pTable.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);
                    pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i)));
                    pCursor.InsertRow(pRowBuff);
                    pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
                    i = i + 1;
                }
                pCursor.Flush();
                pCursor = null;
                pCursor = pTable.Search(null, false);
                IQueryFilter pQueryFilter = new QueryFilterClass();
                pQueryFilter.WhereClause = "SewerElev <> -99";
                ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false);

                pCursor = null;
                pCursor = pTable.Update(null, false);
                pRowBuff = pCursor.NextRow();
                double m = 0;
                double Mmin=0;
                double Mmax=0;
                double deltaM=0;
                double deltaSewerElev=0;
                double sewerelev=0;
                double newZ=0;
                int j = 0;
                double minSewerElev=0;
                double maxSewerElev=0;
                IRow pRowSewerElev;
                while (pRowBuff != null)
                {
                    if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99)
                    {
                        m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M")));
                        newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev;
                        pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ);
                        pCursor.UpdateRow(pRowBuff as IRow);
                    }
                    else
                    {
                        if (j == 0)
                        {
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            minSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                            Mmin = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                            Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                        }
                        else
                        {
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            if (pRowSewerElev != null)
                            {
                                minSewerElev = maxSewerElev;
                                Mmin = Mmax;
                                maxSewerElev =Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                                Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                            }
                        }
                        deltaSewerElev = maxSewerElev - minSewerElev;
                        deltaM = Mmax - Mmin;
                        sewerelev = minSewerElev;
                        j = j + 1;
                    }
                    pRowBuff = pCursor.NextRow() as IRowBuffer;
                }
                pCursor.Flush();    
                //从表格中创建图形
                m_SewerElevStructArray = new ArrayClass();
               
                pCursor = null;
                pCursor = pTable.Search(null, false);
                pRowSewerElev = null;
                pRowSewerElev = pCursor.NextRow();
                while (pRowSewerElev != null)
                {
                    clsProfileStruct pProfileDataStruct = new clsProfileStruct();
                    pProfileDataStruct.M = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                    pProfileDataStruct.Z = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Z")));
                    pProfileDataStruct.dSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Sewerelev")));
                    m_SewerElevStructArray.Add(pProfileDataStruct);
                    pRowSewerElev = pCursor.NextRow();
                }

                frmDrawProfile frmDrawProfile1 = new frmDrawProfile(m_SewerElevStructArray);
                frmDrawProfile1.Show();
            }
        }